Jump to content

Timers


tosfera

Recommended Posts

Hey guys,

I'm creating a hunger system and this is how I'm working on it right now. The player logs in, and receives a hunger data, a timer will be created and he will lose hunger depending on his walking speed. My question is;

I created the timer server sided, when a player logs or disconnects the timer gets destroyed. I've tested it with 1 other guy in my server. My timer goes forward but will this also continue if there are more then 2 players?

this is the timer part;

... 
hungerTimer = setTimer(startHunger, 1000, 1, source); 
... 
  
addEventHandler("onPlayerQuit", root, 
    function () 
        killTimer ( hungerTimer ); 
    end 
); 

Link to comment

Well the best option for server side would be , to create a table with 2 value's.

table.name = getPlayerName(LogedPlayer)

table.timer = setTimmer(.......)

then on playerQuit , you can get his name =>> find him in the table =>> killTimer=>> table.remove

But why not make it client side then you can use dxDraw/Gui ?

Or make only a timmer , and loop trought all player's. Then you don't need to kill it.

Edited by Guest
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...