SphereCommunity

Full Version: 24h hour online when server crash timer dissapear...
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Hi i have create a 24 hour online reward system it mean's if player stay online for 24h he get reward, but the problem is when server crash all player timer go to 0 so they can take reward how to repair this thing ?
I am using this for login and logout

ON=@LOGIN
findid(i_reward_timer).timer = <findid(i_reward_timer).tag0.timer>
findid(i_reward_timer).tag0.timer = 0

ON=@LOGOUT
findid(i_reward_timer).timer = <findid(i_reward_timer).tag0.timer>
findid(i_reward_timer).tag0.timer = -1

but when server crash timer go to 0 Confused

Thanks, and sorry for bad english
maybe you need to solve crash problem first Big Grin

anyway you can use Mordaunt's idea or timerf:

http://forum.spherecommunity.net/showthr...35#pid5535
Only put that:

ON=@LOGOUT
findid(i_reward_timer).timer = 86400 // 24 hours in seconds

If the server crashes, there is no LOGOUT fired and no Timer reset to original position.
When the players logins again, the timer is in the position of the last save.

But anytime the player logout normally, his timer will set to a full 24 hour timer.
he says server is crashed so logout will not fire, maybe he can reset all timers f_on_server_start or on=@login timer=86400
I doubt he wants all the timer reseted when the server is crashed, don´t have much sense. It´s not the players fault.
But if he wants that, on=@login timer=86400 is the better way.

ON=@LOGOUT
findid(i_reward_timer).timer = 86400 // 24 hours in seconds
tag.safe_logout=1

ON=@LOGIN
if !(<tag0.safe_logout>) // logout with crash
findid(i_reward_timer).timer = 86400
else // logout without crash
// put here anything you want
endif
tag.safe_logout=
Well... how about updating their play time in a tag and using f_onserver_timer as a mechanism to update it.
That way you could update the tag periodically and should the server crash the player would only be down by whatever the interval your using is.
Use timerf as mentioned above or fire the timer every second and add the tag, then compare the tag to see if you have X amount of seconds, a little example:
Code:
on=@login
findid.i_reward_timer.timer=1

[itemdef i_reward_timer]
defname=i_reward_timer
name=Reward Timer
id=i_memory

on=@create
attr=attr_move_never|attr_invis

on=@timer
tag0.timer += 1 //add 1 second
if (<dtag0.timer> >= 86400) //1 day?
  //give reward
  tag.timer=0 //reset timer
endif
timer=1
return 1
My server is not crashing but the problem is when any of my familly can turn off pc and it the same as crash, i will try your suggestion when i will be at home, tyvm for helping Smile
(09-13-2012 10:39 AM)Skul Wrote: [ -> ]Use timerf as mentioned above or fire the timer every second and add the tag, then compare the tag to see if you have X amount of seconds, a little example:
Code:
on=@login
findid.i_reward_timer.timer=1

[itemdef i_reward_timer]
defname=i_reward_timer
name=Reward Timer
id=i_memory

on=@create
attr=attr_move_never|attr_invis

on=@timer
tag0.timer += 1 //add 1 second
if (<dtag0.timer> >= 86400) //1 day?
  //give reward
  tag.timer=0 //reset timer
endif
timer=1
return 1

A timer which fires every second to every player?
It´s very expensive in resources, in my opinion.
I would run it at the most frewunt of once per minute... you could get away with once every 15 or so. I use, or have used, the method with the server timer to regulate multiple scripts. That way you're not creating lots of memory items running timers
Pages: 1 2
Reference URL's