Cassandra Posted March 14, 2013 Share Posted March 14, 2013 Is there a way to create a timer for an individual player or is it always global? For example, something like this: sometimer = {} sometimer.player = player sometimer.player["timer"] = setTimer(somefunc, someinterval, 0, player) Link to comment
Booo Posted March 14, 2013 Share Posted March 14, 2013 Is there a way to create a timer for an individual player or is it always global?For example, something like this: sometimer = {} sometimer.player = player sometimer.player["timer"] = setTimer(somefunc, someinterval, 0, player) sometimer = {} sometimer[player] = setTimer(somefunc, someinterval, 0, player) example time = { } function FF() time[source] = setTimer(outputChatBox,5000,1,"ola bro",source,255,255,255) end addEventHandler ( "onPlayerJoin", getRootElement(), FF ) Link to comment
Cassandra Posted March 14, 2013 Author Share Posted March 14, 2013 Is there a way to create a timer for an individual player or is it always global?For example, something like this: sometimer = {} sometimer.player = player sometimer.player["timer"] = setTimer(somefunc, someinterval, 0, player) sometimer = {} sometimer[player] = setTimer(somefunc, someinterval, 0, player) example time = { } function FF() time[source] = setTimer(outputChatBox,5000,1,"ola bro",source,255,255,255) end addEventHandler ( "onPlayerJoin", getRootElement(), FF ) Aaah thanks, i will try it. Edit: It worked thanks! Link to comment
Booo Posted March 14, 2013 Share Posted March 14, 2013 Aaah thanks, i will try it. Edit: It worked thanks! function SS ( TT ) if TT = "Quit" and isTimer(time[source]) then killTimer(time[source]) end outputChatBox ("U Are Welcome ") end addEventHandler ( "onPlayerQuit", getRootElement(), SS ) Link to comment
Anderl Posted March 14, 2013 Share Posted March 14, 2013 None of the codes above create a local timer. They're still global. @Booo, your last code is wrong. Link to comment
Renkon Posted March 14, 2013 Share Posted March 14, 2013 If you want to create for individual player go clientside. If you want to create for everybody go serverside liek boo's example Link to comment
50p Posted March 14, 2013 Share Posted March 14, 2013 Timers trigger functions. If you want the function to be called for specific player then use player element as argument for the function (server-side). Just like in the first Booo's example with outputChatBox func. Link to comment
Cassandra Posted March 14, 2013 Author Share Posted March 14, 2013 Timers trigger functions. If you want the function to be called for specific player then use player element as argument for the function (server-side). Just like in the first Booo's example with outputChatBox func. I did it but then if the timer get's killed, it get's killed for each players on the world. Link to comment
50p Posted March 14, 2013 Share Posted March 14, 2013 Timers trigger functions. If you want the function to be called for specific player then use player element as argument for the function (server-side). Just like in the first Booo's example with outputChatBox func. I did it but then if the timer get's killed, it get's killed for each players on the world. When you kill a timer you kill the specific timer (if it was for 1 player it will be killed for that player). Show us what you're having problem with and we'll explain. Do it in the client side. Do client-side scripting as little as possible (mainly GUI). If you can do something server-side then do it server-side. Link to comment
Cassandra Posted March 14, 2013 Author Share Posted March 14, 2013 Timers trigger functions. If you want the function to be called for specific player then use player element as argument for the function (server-side). Just like in the first Booo's example with outputChatBox func. I did it but then if the timer get's killed, it get's killed for each players on the world. When you kill a timer you kill the specific timer (if it was for 1 player it will be killed for that player). Show us what you're having problem with and we'll explain. Well I'm not having problem but the solution you gave them earlier will cause problems as you have created only 1 instance of global timer and doesn't matter what you put as the parameters it will be killed for every player because all of that player is using only that 1 instance of timer. I hope you get what I mean't. Link to comment
50p Posted March 14, 2013 Share Posted March 14, 2013 If you store the timer in a table for each player then it won't kill all the timers. local timers = { }; timers[ player ] = setTimer( outputChatBox, 1000, 1, "hello world", player ); -- it will create 1 timer for 1 player killTimer( timers[ player ] ); -- it will kill the timer previously created for that specific player NOT all the timers Show the code you're having problem with and we'll solve your "global" timer problem or do it yourself once you understand the idea. Remember, you need to create a timer for each player separately. Link to comment
Cassandra Posted March 14, 2013 Author Share Posted March 14, 2013 If you store the timer in a table for each player then it won't kill all the timers. local timers = { }; timers[ player ] = setTimer( outputChatBox, 1000, 1, "hello world", player ); -- it will create 1 timer for 1 player killTimer( timers[ player ] ); -- it will kill the timer previously created for that specific player NOT all the timers Show the code you're having problem with and we'll solve your "global" timer problem or do it yourself once you understand the idea. Remember, you need to create a timer for each player separately. Nvm I misunderstood you. Sorry. 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