SphereCommunity
24h hour online when server crash timer dissapear... - Printable Version

+- SphereCommunity (https://forum.spherecommunity.net)
+-- Forum: Sphere 0.56d (/Forum-Sphere-0-56d)
+--- Forum: General Help (/Forum-General-Help)
+--- Thread: 24h hour online when server crash timer dissapear... (/Thread-24h-hour-online-when-server-crash-timer-dissapear)

Pages: 1 2


24h hour online when server crash timer dissapear... - Alias - 09-13-2012 04:55 AM

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


RE: 24h hour online when server crash timer dissapear... - Shaklaban - 09-13-2012 06:09 AM

maybe you need to solve crash problem first Big Grin

anyway you can use Mordaunt's idea or timerf:

http://forum.spherecommunity.net/showthread.php?tid=1767&pid=5535#pid5535


RE: 24h hour online when server crash timer dissapear... - Gil Amarth - 09-13-2012 06:47 AM

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.


RE: 24h hour online when server crash timer dissapear... - Shaklaban - 09-13-2012 07:05 AM

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


RE: 24h hour online when server crash timer dissapear... - Gil Amarth - 09-13-2012 07:20 AM

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=


RE: 24h hour online when server crash timer dissapear... - Mordaunt - 09-13-2012 08:52 AM

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.


RE: 24h hour online when server crash timer dissapear... - Skul - 09-13-2012 10:39 AM

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



RE: 24h hour online when server crash timer dissapear... - Alias - 09-13-2012 01:46 PM

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


RE: 24h hour online when server crash timer dissapear... - Gil Amarth - 09-13-2012 09:18 PM

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


RE: 24h hour online when server crash timer dissapear... - Mordaunt - 09-13-2012 10:04 PM

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