RegisterNetEvent("robbery")
AddEventHandler("robbery", function()
TriggerClientEvent("chatMessage", -1, "ROBBERY", {255,255,255}, "Paleto Bank is being robbed!")
TriggerClientEvent("robberyMoney")
end)
Client
RegisterNetEvent("robberyMoney")
AddEventHandler("robberyMoney", function()
TriggerEvent("chatMessage", "ROBBERY", {255, 255, 255}, "You will recieve your money in 30 seconds.")
Citizen.Wait(3000)
cash = cash + 300
end)
The message for TriggerClientEvent("chatMessage", -1, "ROBBERY", {255,255,255}, "Paleto Bank is being robbed!") works but the client event “robberyMoney” is not being triggered. I am not sure why.
Thank you, also do you know if there is a way to stop someone from spamming my code:
(There is a blip [thanks @xander1998] and when you go over it if you press E it makes a server message saying there is a bank robbery.) Is there a way to stop someone from spamming it?
Citizen.CreateThread(function()
while true do
Citizen.Wait(0)
for k in pairs(table) do
local plyCoords = GetEntityCoords(GetPlayerPed(-1), false)
local dist = Vdist(plyCoords.x, plyCoords.y, plyCoords.z, table[k].x, table[k].y, table[k].z)
if dist <= 1.2 then
DrawText3("Press E To Start A Bank Robbery")
if IsControlJustPressed(1,51) then
TriggerServerEvent("robbery")
TriggerEvent("robberyMoney")
end
end
end
end
end)
Have a variable on the serverside that is like… local isRobberyActive = false. Then when the event is triggered, check if it is true or false, if it is false, run the event and set it to true.
Or you can use this if they press it too many times