Jump to content

Timer for an individual player


Cassandra

Recommended Posts

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
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

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

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
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
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
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

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
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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...