Hello,
I’m working on a laundry script for dirty monney. However, I’m facing an issue with client and server relation.
Here are the scripts I have:
Client:
Citizen.CreateThread(function(user)
while true do
Citizen.Wait(0)
DrawMarker(1, -146.98616027832, -1108.23010253906, 42.1392707824707, 0, 0, 0, 0, 0, 0, 2.001, 2.0001, 0.5001, 0, 155, 255, 200, 0, 0, 0, 0)
-- Affiche Marqueur pour faire spawn
if GetDistanceBetweenCoords(-146.98616027832, -1108.23010253906, 42.1392707824707, GetEntityCoords(LocalPed())) < 1 then
drawTxt("Appuyer sur ~g~H~s~ afin de pouvoir ~b~blanchir~s~ votre argent", 2, 1, 0.5, 0.8, 0.6, 255, 255, 255, 255)
if IsControlJustPressed(1, Keys["H"]) then
Citizen.Wait(0)
drawNotification("Tu veux donc blanchir de l'argent!")
Citizen.Wait(500)
drawNotification("Montre moi combien tu as ...")
Citizen.Wait(1000)
TriggerServerEvent('laundry:money', user)
end
end
Menu.renderGUI()
end
end)
RegisterNetEvent('laundry:checkdown')
AddEventHandler('laundry:checkdown', function()
drawNotification("Il faut au moins 100K petit")
end)
RegisterNetEvent('laundry:checkup')
AddEventHandler('laundry:checkup', function()
drawNotification("On peut discuter comme des adultes!")
end)
Server:
function drawNotification(text)
SetNotificationTextEntry("STRING")
AddTextComponentString(text)
DrawNotification(false, false)
end
function bankBalanceDirty(player)
local executed_query = MySQL:executeQuery("SELECT * FROM users WHERE identifier = '@name'", {['@name'] = player})
local result = MySQL:getResults(executed_query, {'dirty_money'}, "identifier")
return tonumber(result[1].dirty_money)
end
RegisterServerEvent('laundry:money')
AddEventHandler('laundry:money', function(user)
drawNotification("COUCOU je suis dans le fichier server muthafucker") -- To try if I managed to have a server reaction
local player = user.identifier
local dirty = bankBalanceDirty(player)
if (dirty < 100000) then
TriggerClientEvent('laundry:checkdown')
drawNotification("Il faut au moins 100K petit caca")
else
TriggerClientEvent('laundry:checkup')
end
end)
Have you any lead?
Cheers