Hello there! I’ve been working on a RP server for a while and I have some problems. If anyone can help me, it would be awesome!
The server is basically ESX scripts - https://i.imgur.com/BohzLCk.png - and Im using MySQL database to save players information.
Today I was looking to get something to convert black money to clean money and I found this script. I dont have experience in .lua and for me looks like the code is correct.
local PlayersWashing = {}
local function WashMoney(source)
SetTimeout(10000, function()
if PlayersWashing[source] == true then
TriggerEvent('esx:getPlayerFromId', source, function(xPlayer)
local blackMoney = xPlayer:getAccount('black_money').money
if blackMoney < Config.Slice then
TriggerClientEvent('esx_moneywash:showNotification', source, 'You dont have the minimun money to start, minimum : $' .. Config.Slice)
else
local washedMoney = math.floor(Config.Slice / 100 * Config.Percentage)
xPlayer:removeAccountMoney('black_money', Config.Slice)
xPlayer:addMoney(washedMoney)
WashMoney(source)
end
end)
end
end)
end
RegisterServerEvent('esx_moneywash:startWash')
AddEventHandler('esx_moneywash:startWash', function()
PlayersWashing[source] = true
TriggerClientEvent('esx_moneywash:showNotification', source, 'Starting...')
WashMoney(source)
end)
RegisterServerEvent('esx_moneywash:stopWash')
AddEventHandler('esx_moneywash:stopWash', function()
PlayersWashing[source] = false
end)
Basically when I do the esx_moneywash:startWash its says the notification “Starting…” and nothing happen.
If anyone can help with this and If someone need aditional information, just say. Thanks!
local PID = 0
local GUI = {}
GUI.ControlsShowed = false
GUI.Time = 0
local hasAlreadyEnteredMarker = false;
local lastZone = nil;
function Notification(message)
SetNotificationTextEntry("STRING")
AddTextComponentString(message)
DrawNotification(0,1)
end
RegisterNetEvent('esx_moneywash:showNotification')
AddEventHandler('esx_moneywash:showNotification', function(notify)
Notification(notify)
end)
AddEventHandler('playerSpawned', function(spawn)
PID = GetPlayerServerId(PlayerId())
end)
AddEventHandler('esx_moneywash:hasEnteredMarker', function(zone)
GUI.ControlsShowed = true
SendNUIMessage({
showControls = true,
message = 'Blanchir argent'
})
end)
AddEventHandler('esx_moneywash:hasExitedMarker', function(zone)
GUI.ControlsShowed = false
SendNUIMessage({
showControls = false
})
TriggerServerEvent('esx_moneywash:stopWash')
end)
-- Render markers
Citizen.CreateThread(function()
while true do
Wait(0)
local coords = GetEntityCoords(GetPlayerPed(-1))
for k,v in pairs(Config.Zones) do
if(GetDistanceBetweenCoords(coords, v.x, v.y, v.z, true) < Config.DrawDistance) then
DrawMarker(Config.MarkerType, v.x, v.y, v.z, 0.0, 0.0, 0.0, 0, 0.0, 0.0, Config.MarkerSize.x, Config.MarkerSize.y, Config.MarkerSize.z, Config.MarkerColor.r, Config.MarkerColor.g, Config.MarkerColor.b, 100, false, true, 2, false, false, false, false)
end
end
end
end)
-- Activate menu when player is inside marker
Citizen.CreateThread(function()
while true do
Wait(0)
local coords = GetEntityCoords(GetPlayerPed(-1))
local isInMarker = false
local currentZone = nil
for k,v in pairs(Config.Zones) do
if(GetDistanceBetweenCoords(coords, v.x, v.y, v.z, true) < Config.MarkerSize.x / 2) then
isInMarker = true
currentZone = k
end
end
if isInMarker and not hasAlreadyEnteredMarker then
hasAlreadyEnteredMarker = true
lastZone = currentZone
TriggerEvent('esx_moneywash:hasEnteredMarker', currentZone)
end
if not isInMarker and hasAlreadyEnteredMarker then
hasAlreadyEnteredMarker = false
TriggerEvent('esx_moneywash:hasExitedMarker', lastZone)
end
end
end)
-- Menu interactions
Citizen.CreateThread(function()
while true do
Wait(0)
if GUI.ControlsShowed and IsControlPressed(0, Keys['ENTER']) and (GetGameTimer() - GUI.Time) > 1000 then
SendNUIMessage({
showControls = false
})
GUI.ControlsShowed = false
GUI.Time = GetGameTimer()
TriggerServerEvent('esx_moneywash:startWash')
end
end
end)
in your first message , in this code you using a tab called PlayerWashing , you using it into your function, but you never fill it , i don’t see in your code any part who fill this tab with something
is it you who made that code or someone else and you trying to change it ?