Jump to content
  • 0
Sign in to follow this  
schan

[HELP] npctimer

Question

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 by schan

Share this post


Link to post
Share on other sites

4 answers to this question

Recommended Posts

  • 0

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.

Share this post


Link to post
Share on other sites
  • 0

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 by AnnieRuru

Share this post


Link to post
Share on other sites
  • 0

 

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. 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.