tosfera Posted August 13, 2013 Share Posted August 13, 2013 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
bandi94 Posted August 13, 2013 Share Posted August 13, 2013 (edited) 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 August 13, 2013 by Guest Link to comment
tosfera Posted August 13, 2013 Author Share Posted August 13, 2013 The dxDraw is already client sided, but I'm not sure why I made it server sided. Does these functions even work on client side? Not sure because of the sync; setElementHealth think it does, I'll give it a shot. Link to comment
tosfera Posted August 13, 2013 Author Share Posted August 13, 2013 Got it working on client sided, that was easier then I thought. Copied my code into client sided, changed source to localPlayer and BAM, worked. thanks! Link to comment
bandi94 Posted August 13, 2013 Share Posted August 13, 2013 Well both of them will work , now it's up to you if you wanna only draw it by text,number or you wanna show it to, with a progressbar. Also you can use: onClientElementDataChange 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