Hey, I want to add a cooldown to my /motor command, but I just don’t know how to. Could anyone help me, I want to add if you send the command after each other under a minute you get a message saying you still have to wait the amount of seconds to wait. Here’s the code of the client.lua file:
-- Shows a notification on the player's screen
function ShowNotification( text )
SetNotificationTextEntry("STRING")
AddTextComponentSubstringPlayerName(text)
DrawNotification(false, false)
end
RegisterCommand('motor', function(source, args, rawCommand)
local x,y,z = table.unpack(GetOffsetFromEntityInWorldCoords(PlayerPedId()))
local veh = "Faggio2"
local playerPed = PlayerPedId()
vehiclehash = GetHashKey(veh)
RequestModel(vehiclehash)
Citizen.CreateThread(function()
local waiting = 0
while not HasModelLoaded(vehiclehash) do
waiting = waiting + 100
Citizen.Wait(100)
if waiting > 5000 then
ShowNotification("~r~Daddy chill zometeen crashed je computah")
break
end
end
local vehicle = CreateVehicle(vehiclehash, x, y, z, GetEntityHeading(PlayerPedId())+90, 1, 0)
SetPedIntoVehicle(playerPed, vehicle, -1)
end)
end)