Furious^ONE! Posted July 2, 2020 Share Posted July 2, 2020 Hi, I tried to put timer after taping command but, don't work https://cdn.discordapp.com/attachments/704011430097322024/728353446456983693/unknown.png -- command, id of car, txt of car, replace texture local cmdTime = 10000 local skins = { {"test", 411, "bopp", "test.png"}, } local cmdTime = setTimer(function() for i = 1, #skins do addCommandHandler(skins[i][1], function(plr) if getPedOccupiedVehicle(plr) and getElementModel(getPedOccupiedVehicle(plr)) == skins[i][2] then triggerClientEvent(root, "onNalozPJ", root, getPedOccupiedVehicle(plr), skins[i][2], skins[i][3], "txt/"..skins[i][4]) end end, cmdTime, 1) end Link to comment
N3xT Posted July 2, 2020 Share Posted July 2, 2020 what are you trying to achieve exactly? a command with a cooldown? Link to comment
#Mr.Pop Posted July 3, 2020 Share Posted July 3, 2020 (edited) -- command, id of car, txt of car, replace texture local cmdTime = 10000 local skins = { {"test", 411, "bopp", "test.png"}, } local cmdTime = setTimer(function() for i = 1, #skins do addCommandHandler(skins[i][1], function(plr) if getPedOccupiedVehicle(plr) and getElementModel(getPedOccupiedVehicle(plr)) == skins[i][2] then triggerClientEvent(root, "onNalozPJ", root, getPedOccupiedVehicle(plr), skins[i][2], skins[i][3], "txt/"..skins[i][4]) end end) end end, cmdTime, 1) Edited July 3, 2020 by #Mr.Pop Link to comment
nxFairlywell Posted July 3, 2020 Share Posted July 3, 2020 (edited) "Put a timer after tapping a command" -- command, id of car, txt of car, replace texture local cmdTime = 10000 local skins = { {"test", 411, "bopp", "test.png"}, } local PlayerTappedCommand = {}; function getSkinByCMD(cmd) if cmd and type(cmd)=="string" then local skin = {}; for i = 1, #skins do if skins[i][1]==cmd then skin[1]=cmd;skin[2]=skins[2];skin[3]=skins[3];skin[4]=skins[4]; return skin; end end return {}; end return false; end function DoSomething(plr, skin) if getPedOccupiedVehicle(plr) and getElementModel(getPedOccupiedVehicle(plr)) == skin[2] then triggerClientEvent(root, "onNalozPJ", root, getPedOccupiedVehicle(plr), skin[2], skin[3], "txt/"..skin[4]) PlayerTappedCommand[plr] = false; end end function CommandFunc(player,cmd) if PlayerTappedCommand[player] then outputChatBox("you used the command before!",player) return false; end local skin = getSkinByCMD(cmd); if skin and type(skin)=="table" and #skin>0 then PlayerTappedCommand[player] = true; local Timer = setTimer(DoSomething, cmdTime, 1, player, skin); end outputConsole ("Wrong command or skin = {empty}",player); return false; end for i = 1, #skins do addCommandHandler(skins[i][1],CommandFunc) end Edited July 3, 2020 by VenomNX Link to comment
Furious^ONE! Posted July 3, 2020 Author Share Posted July 3, 2020 15 hours ago, #Mr.Pop said: -- command, id of car, txt of car, replace texture local cmdTime = 10000 local skins = { {"test", 411, "bopp", "test.png"}, } local cmdTime = setTimer(function() for i = 1, #skins do addCommandHandler(skins[i][1], function(plr) if getPedOccupiedVehicle(plr) and getElementModel(getPedOccupiedVehicle(plr)) == skins[i][2] then triggerClientEvent(root, "onNalozPJ", root, getPedOccupiedVehicle(plr), skins[i][2], skins[i][3], "txt/"..skins[i][4]) end end) end end, cmdTime, 1) I tried this code, but it's same the old code I don't know why, no error in debugscript Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now