schan 8 Posted February 7, 2014 (edited) Hi, I need help with this. I want the npc to start a counter on server start up and attach to players who activated it. The counter will continue even if the player logged out of the game. OnTimer60000: //1 minute set minute, minute + 1; stopnpctimer; initnpctimer; end;OnPCLoginEvent: attachnpctimer strcharinfo(0); initnpctimer; end;OnInit: attachnpctimer strcharinfo(0); initnpctimer; end; My script works fine but the counter stops when player logs out of the game and gives me this error on server start up: script_rid2sd: fatal error! player not attached! Edited February 7, 2014 by schan Quote Share this post Link to post Share on other sites
0 AnnieRuru 957 Posted February 7, 2014 (edited) I have never write a script that needs the timer to attach to the player and yet continue after logout what kind of script are you writing ? although this is do-able prontera,155,186,5 script kjfhksdjf 100,{ dispbottom "current timer is "+( gettimetick(2) - .timer[ getcharid(0) ] )+" seconds"; end;OnPCLoginEvent: .@cid = getcharid(0); if ( .timer[.@cid] ) { dispbottom "continue the timer from "+( gettimetick(2) - .timer[.@cid] ); end; } .timer[.@cid] = gettimetick(2); end;}honestly ... tell me what you are writing ... Edited February 7, 2014 by AnnieRuru Quote Share this post Link to post Share on other sites
0 schan 8 Posted February 7, 2014 I have never write a script that needs the timer to attach to the player and yet continue after logout what kind of script are you writing ? although this is do-able prontera,155,186,5 script kjfhksdjf 100,{ dispbottom "current timer is "+( gettimetick(2) - .timer[ getcharid(0) ] )+" seconds"; end;OnPCLoginEvent: .@cid = getcharid(0); if ( .timer[.@cid] ) { dispbottom "continue the timer from "+( gettimetick(2) - .timer[.@cid] ); end; } .timer[.@cid] = gettimetick(2); end;}honestly ... tell me what you are writing ... Hi Annie, I'm trying to make a script that would give experience to players every minute/hour continuously even if they log out of the game. Quote Share this post Link to post Share on other sites
0 jaBote 438 Posted February 7, 2014 I think it's easier for your server's processing capabilities just calculating the time difference from when the user logged out by using the OnPCLogoutEvent to when he logs in back when he uses OnPCLoginEvent. You can use gettimetick(2) for this. Once you know the time the user went out and the time it's logged back in, and since gettimetick(2) is a measure of seconds from January 1 1970, you'll only need to subtract the logout time to the login time (now you have the difference) and then give according exp. This will reduce your processing time burden, because it's way too heavy for a processor to host, say, 5000 timers at once*? *one per character be it online or not, based on a small-sized server of mine that was run alive for some more than a year. Quote Share this post Link to post Share on other sites
0 schan 8 Posted February 7, 2014 Thank you AnnieRuru and jaBote! Quote Share this post Link to post Share on other sites
Hi,
I need help with this. I want the npc to start a counter on server start up and attach to players who activated it.
The counter will continue even if the player logged out of the game.
My script works fine but the counter stops when player logs out of the game and gives me this error on server start up:
Edited by schanShare this post
Link to post
Share on other sites