timera = 0
function SetTimera(a)
timera = GetGameTimer() - a
end
function GetTimera()
return GetGameTimer() - timera
end
edit:
Would use it the following way:
Citizen.CreateThread(function()
Citizen.Wait(0)
SetTimera(0)
local triggered = false
while not triggered do
if GetTimera() > 5000 then TriggerEvent("hood") triggered = true end
end
end)
The timer itself works, but I’m trying to set it so the timer is activated so when a user does /hood it makes them wait 5 seconds, I’m trying to figure out how to add the timer to the chat message /hood
Citizen.CreateThread(function(timer)
local time = 5
while (time ~= 0) do
Wait( 1000 )
time = time - 1
end
AddEventHandler( 'chatMessage', function( source, n, message )
if ( message == "/hood" ) then
CancelEvent()
TriggerClientEvent( 'hood', source, timer )
end
end )
local timer = 0
Citizen.CreateThread(function(timer)
while timer > 0 do
Wait(1000)
timer = timer - 1
end
end)
AddEventHandler( 'chatMessage', function(source, n, message)
if (message == "/hood" ) then
if timer > 0 then
CancelEvent()
else
TriggerClientEvent('hood', source, timer)
end
end
end)
AddEventHandler( 'chatMessage', function(source, n, message)
if (message == "/hood" ) then
Citizen.Wait(5000)
TriggerClientEvent('hood', source)
end
end)
RegisterNetEvent( 'drawNotification' )
AddEventHandler( 'drawNotification', function()
drawNotification("~g~Your vehicle is being repaired by the mechanic. Please wait 15 seconds.")end)
end)
SERVER:
AddEventHandler( 'chatMessage', function(source, n, message)
if (message == "/trunk" ) then
TriggerClientEvent('drawNotification', source)
Citizen.Wait(15000)
TriggerClientEvent('fixVehicle ', source)
end
end)