Castillo Posted July 6, 2010 Posted July 6, 2010 hi guys, i have a problem with some timers i need for my script to work like i want, the problem is that all works fine but the timers isnt setting for who uses /kill is setting it for all players not just client, here is my code. local locktime = 0 local times = {} function suicide ( player, commandName ) if ( player ) and locktime == 0 then killPed ( player ) times[player] = setTimer(Lock,50,1) times[player] = setTimer(UnLock,5000,1) elseif locktime == 1 then outputChatBox("ERROR: You can suicide once every 1 minute.",player,255,0,0) end end addCommandHandler ( "kill", suicide ) function Lock() locktime = 1 end function UnLock() locktime = 0 end San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
[DMC] Posted July 6, 2010 Posted July 6, 2010 hi guys, i have a problem with some timers i need for my script to work like i want, the problem is that all works fine but the timers isnt setting for who uses /kill is setting it for all players not just client, here is my code. local locktime = 0 local times = {} function suicide ( player, commandName ) if ( player ) and locktime == 0 then killPed ( player ) times[player] = setTimer(Lock,50,1) times[player] = setTimer(UnLock,5000,1) elseif locktime == 1 then outputChatBox("ERROR: You can suicide once every 1 minute.",player,255,0,0) end end addCommandHandler ( "kill", suicide ) function Lock() locktime = 1 end function UnLock() locktime = 0 end make the commandhandler clientsidded maybe
50p Posted July 6, 2010 Posted July 6, 2010 ...make the commandhandler clientsidded maybe This way he will not be able to kill the player. He'll have to triggerServerEvent which is pointless because the command can be server-side without any problems. SolidSnake14, you have a global variable locktime which is set by any player and because it's just simple variable you check if it's already set to 1 (by other player). Solution: Make a table which will hold value for each player separately or use set/getElementData to determine if player used the command within the last minute. You have to remember, setTimer lets you pass additional arguments to the functions it will call, so you can pass player element to a function which would "unlock" the command for him. NOTE: You didn't need timer to set locktime to 1. You could set it inside the if clause. You also don't need to hold timers in a table because you don't even use them anywhere, killing them, etc. - MTA Script Editor - Ask your scripting questions properly, please. - 50p's public resources - Meta.xml - what is it for? How is it possible LOL
dzek (varez) Posted July 6, 2010 Posted July 6, 2010 it's extremely popular problem - blocking/enabling something for specified time for each player by a command - and using only one variable as a "lock".. isnt it logical? Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online! programista php rzeszów Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting. Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!
Castillo Posted July 6, 2010 Author Posted July 6, 2010 it's extremely popular problem - blocking/enabling something for specified time for each player by a command - and using only one variable as a "lock".. isnt it logical? I fixed it already, can close topic. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
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