novo Posted October 3, 2011 Posted October 3, 2011 Hi all. I want to add to a command, restriction with time. Like if you do idk... push, you can't use it again within 60 seconds. I need help with that. Bye and ty.
TAPL Posted October 3, 2011 Posted October 3, 2011 you want make it can't use it again before 60 sec for only who using the command or for all players?
novo Posted October 4, 2011 Author Posted October 4, 2011 The people who are in a ACL group, i made a post for it, can't spam with the command, like if i write now /push, i still wait 60 seconds for use it again. I wanna it. Ty.
BriGhtx3 Posted October 4, 2011 Posted October 4, 2011 if not getElementData ( player, "commandTimer" ) then setElementData ( player, "commandTimer", true ) setTimer ( setElementData, 60000, 1, player, "commandTimer", false ) else outputChatBox ( "You need to wait 60 seconds until executing the command again!", 125, 0, 0 ) end
Phat Looser Posted October 4, 2011 Posted October 4, 2011 iTime = 0 function onceEachMinute() if iTime + 60000 < getTickCount() then [...] iTime = getTickCount() end end
novo Posted October 4, 2011 Author Posted October 4, 2011 I want add the timer to those commands; -------------------------- -- PUSH CMD start -- -------------------------- function pushHisFreakingAss (playerSource, command, arg1) local account = getPlayerAccount( playerSource ) if isObjectInACLGroup("user." ..getAccountName(account), aclGetGroup("VIP")) == false then outputChatBox ("You aren't VIP. You can't use that command.", playerSource, 255, 12, 15, false) else if (arg1 == nil ) or ( arg1 == false ) then outputChatBox ("You must to insert a valid player name.", playerSource, 255, 12, 15, false) else if isObjectInACLGroup("user." ..getAccountName(account), aclGetGroup("VIP")) == true then local playerElement = getPlayerFromName(arg1) if playerElement then local name = getPlayerName(playerElement) local sourceName = getPlayerName(playerElement) local theVehicle = getPedOccupiedVehicle(playerElement) local hisCar = getPedOccupiedVehicle(playerElement) local x, y, z = getElementVelocity ( hisCar ) setElementVelocity ( hisCar, x , y, z + 0.3 ) outputChatBox ("#0082D8" .. getPlayerName(playerElement) .." pushes "..getPlayerName(playerSource).."!", getRootElement(), 255, 255, 255, true) end end end end end addCommandHandler("push", pushHisFreakingAss) -------------------------- -- PUSH CMD end -- -------------------------- -------------------------- -- FIX CMD start -- -------------------------- function fixx ( playerSource, command ) local account = getPlayerAccount( playerSource ) if isObjectInACLGroup("user." ..getAccountName(account), aclGetGroup("VIP")) == false then outputChatBox ("You aren't VIP. You can't use that command.", playerSource, 255, 12, 15, false) else if isObjectInACLGroup("user." ..getAccountName(account), aclGetGroup("VIP")) == true then outputChatBox ("#0082D8" .. getPlayerName(playerSource) .." fixes his self !", getRootElement(), 255, 255, 255, true) if isPedInVehicle(playerSource) then local vehicle = getPedOccupiedVehicle(playerSource) fixVehicle(vehicle) end end end end addCommandHandler ( "fix", fixx ) -------------------------- -- FIX CMD end -- -------------------------- -------------------------- -- NOS CMD start -- -------------------------- function nitro1 ( playerSource, command ) local account = getPlayerAccount( playerSource ) if isObjectInACLGroup("user." ..getAccountName(account), aclGetGroup("VIP")) == false then outputChatBox ("You aren't VIP. You can't use that command.", playerSource, 255, 12, 15, false) else if isObjectInACLGroup("user." ..getAccountName(account), aclGetGroup("VIP")) == true then outputChatBox ("#0082D8" .. getPlayerName(playerSource) .." gives nos to his self !", getRootElement(), 255, 255, 255, true) if isPedInVehicle(playerSource) then local vehicle = getPedOccupiedVehicle(playerSource) addVehicleUpgrade(vehicle,1010) end end end end addCommandHandler ( "nos", nitro1 ) -------------------------- -- NOS CMD end -- -------------------------- -------------------------- -- FLIP CMD start -- -------------------------- function flip () end -------------------------- -- FLIP CMD end -- -------------------------- Where to add it ?
BriGhtx3 Posted October 4, 2011 Posted October 4, 2011 How about thinking a bit on your own? In the functions, and the text has to be between the if not.. and else
novo Posted October 4, 2011 Author Posted October 4, 2011 What text? All the command code ? Please explain me, i'm noob yea.
BriGhtx3 Posted October 4, 2011 Posted October 4, 2011 function pushHisFreakingAss (playerSource, command, arg1) local account = getPlayerAccount( playerSource ) if isObjectInACLGroup("user." ..getAccountName(account), aclGetGroup("VIP")) == false then outputChatBox ("You aren't VIP. You can't use that command.", playerSource, 255, 12, 15, false) else if (arg1 == nil ) or ( arg1 == false ) then outputChatBox ("You must to insert a valid player name.", playerSource, 255, 12, 15, false) else if not getElementData ( player, "commandTimer" ) then if isObjectInACLGroup("user." ..getAccountName(account), aclGetGroup("VIP")) == true then local playerElement = getPlayerFromName(arg1) if playerElement then local name = getPlayerName(playerElement) local sourceName = getPlayerName(playerElement) local theVehicle = getPedOccupiedVehicle(playerElement) local hisCar = getPedOccupiedVehicle(playerElement) local x, y, z = getElementVelocity ( hisCar ) setElementVelocity ( hisCar, x , y, z + 0.3 ) outputChatBox ("#0082D8" .. getPlayerName(playerElement) .." pushes "..getPlayerName(playerSource).."!", getRootElement(), 255, 255, 255, true) end end setElementData ( player, "commandTimer", true ) setTimer ( setElementData, 60000, 1, player, "commandTimer", false ) else outputChatBox ( "You need to wait 60 seconds until executing the command again!", 125, 0, 0 ) end end end end addCommandHandler("push", pushHisFreakingAss) This should be the first function. Now understand this and put it in your codes
novo Posted October 4, 2011 Author Posted October 4, 2011 WARNING: Bad argument @ 'setElementData' [Expected element at argument 1, got nill]
BriGhtx3 Posted October 4, 2011 Posted October 4, 2011 How about changing player to playerElement? That is your script you should adapt it.
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