badneko Posted November 28, 2015 Group: Members Topic Count: 17 Topics Per Day: 0.00 Content Count: 37 Reputation: 1 Joined: 06/09/14 Last Seen: February 10, 2019 Share Posted November 28, 2015 Something like start time, then stop it and show the time has passed. Quote Link to comment Share on other sites More sharing options...
0 Skorm Posted December 4, 2015 Group: Forum Moderator Topic Count: 33 Topics Per Day: 0.01 Content Count: 1282 Reputation: 393 Joined: 02/03/12 Last Seen: April 11 Share Posted December 4, 2015 Something like start time, then stop it and show the time has passed. All the types of timers have different unique advantages but the best in terms of utility and performance is the built in timer... If that's even what you're asking... If you just want to show the amount of time that's passed between a distinct time-frame variables are the best way of doing that. startnpctimer; //Starting the timer attached to the npc. .start = gettimetick(2); //Saving the start time to my npc variable. end; OnTimer10000: //Calling the label when 10 seconds have passed. stopnpctimer; //Destroying the timer. .end = gettimetick(2); //Saving my ending time. .difference = .end - .start; //Calculating the time that has passed. dispbottom .difference + " seconds have passed."; //Spilling the output. Quote Link to comment Share on other sites More sharing options...
0 Emistry Posted December 4, 2015 Group: Forum Moderator Topic Count: 93 Topics Per Day: 0.02 Content Count: 10018 Reputation: 2369 Joined: 10/28/11 Last Seen: 10 hours ago Share Posted December 4, 2015 @Skorm i believe your method is redundant. why not just pick initnpctimer + stopnpctimer + getnpctimer or start gettimetick - end gettimetick Quote Link to comment Share on other sites More sharing options...
0 badneko Posted December 4, 2015 Group: Members Topic Count: 17 Topics Per Day: 0.00 Content Count: 37 Reputation: 1 Joined: 06/09/14 Last Seen: February 10, 2019 Author Share Posted December 4, 2015 Thanks guys!. And now how i can avoid the "there is no player attached error"? Quote Link to comment Share on other sites More sharing options...
0 AnnieRuru Posted December 4, 2015 Group: Members Topic Count: 18 Topics Per Day: 0.00 Content Count: 2044 Reputation: 682 Joined: 10/09/12 Last Seen: December 20, 2020 Share Posted December 4, 2015 if you are writing something like algorithm script, you can just use gettimetick(0) .@start = gettimetick(0); callfunc "F_SomeAlgorithm"; dispbottom "time used -> "+( gettimetick(0) - .@start ) +" mili-seconds"; you can find various algorithm like sorting algorithm in this topic http://herc.ws/board/topic/4321-help-me-improve-this-merge-sort-algorithm/ or shuffle algorithm in this topic https://github.com/HerculesWS/Hercules/pull/872 but if you are just to check how much time it click on the npc, gettimetick(0) cannot be use here because it will go negative at 24th day has to use npctimer *check and see properly did I use rathena test server ? OK* I think there is a bug, yes, both hercules and rathena, I tested both prontera,158,185,5 script dfgdgdfg 1_F_MARIA,{ attachnpctimer; // comment this line, it shows the timer initnpctimer; sleep2 1000; stopnpctimer; dispbottom getnpctimer(0); end; } if the attachnpctimer is leave on, the timer always show 0, but when I remove it, which makes it attach to npc, the timer will start showing ... for the time being, stick to gettimetick(0) ... 1 Quote Link to comment Share on other sites More sharing options...
0 Skorm Posted December 4, 2015 Group: Forum Moderator Topic Count: 33 Topics Per Day: 0.01 Content Count: 1282 Reputation: 393 Joined: 02/03/12 Last Seen: April 11 Share Posted December 4, 2015 @Skorm i believe your method is redundant. why not just pick initnpctimer + stopnpctimer + getnpctimer or start gettimetick - end gettimetick Please use your head. You say my method is redundant and then tell him to use commands that function in the exact same way. For clarity, yes he is starting it with a different command and checking it in a different way but they both work on the same timer system within the source. What I was trying to explain is to use NPC TIMERS... Instead of sleep or loops. x_x And to save timestamps to variables! But yeah thanks for insulting staff. You're a fantastic Global Moderator (Keeping the peace). (If you reply to this message, Emistry, I will not answer. I'm not trying to start a war I'm just pointing out the obvious.) if you are writing something like algorithm script, you can just use gettimetick(0) .@start = gettimetick(0); callfunc "F_SomeAlgorithm"; dispbottom "time used -> "+( gettimetick(0) - .@start ) +" mili-seconds"; you can find various algorithm like sorting algorithm in this topic http://herc.ws/board/topic/4321-help-me-improve-this-merge-sort-algorithm/ or shuffle algorithm in this topic https://github.com/HerculesWS/Hercules/pull/872 but if you are just to check how much time it click on the npc, gettimetick(0) cannot be use here because it will go negative at 24th day has to use npctimer *check and see properly did I use rathena test server ? OK* I think there is a bug, yes, both hercules and rathena, I tested both prontera,158,185,5 script dfgdgdfg 1_F_MARIA,{ attachnpctimer; // comment this line, it shows the timer initnpctimer; sleep2 1000; stopnpctimer; dispbottom getnpctimer(0); end; } if the attachnpctimer is leave on, the timer always show 0, but when I remove it, which makes it attach to npc, the timer will start showing ... for the time being, stick to gettimetick(0) ... Thank you Annie for offering depth into your answer, and avoiding any kind of arbitrary arguments. Also thank you for finding a bug in Emistry's "Superior" method. You really are the best. Quote Link to comment Share on other sites More sharing options...
0 Emistry Posted December 4, 2015 Group: Forum Moderator Topic Count: 93 Topics Per Day: 0.02 Content Count: 10018 Reputation: 2369 Joined: 10/28/11 Last Seen: 10 hours ago Share Posted December 4, 2015 @Skorm hmm, I am not exactly sure when did I insult you ? your method, OnTimer10000 has clearly told the script it's already 10 seconds passed. why you still need to store the start and end time ? and recalculate the difference, which is also 10 seconds . it's unnecessary and redundant method in scripts. well, everyone have their own style, I am not saying that my method are so-called "Superior" here, but i defnitely believe it's could be enhanced. Quote Link to comment Share on other sites More sharing options...
0 AnnieRuru Posted December 4, 2015 Group: Members Topic Count: 18 Topics Per Day: 0.00 Content Count: 2044 Reputation: 682 Joined: 10/09/12 Last Seen: December 20, 2020 Share Posted December 4, 2015 (edited) ok both of you please stop ... if I actually see this in hercules, I'll invisible the post, and send a group PM to both of you to settle this issue privately ... both of you are respectable scripters in rathena, along with Capuche, Euphy , Brian ... and some others despite the difference in emulator we are using, there is no need to create whatever drama that can raise the tension between all of us anyway .. I just found this in the source code ... its a TODO https://github.com/rathena/rathena/blob/master/src/map/npc.c#L780 try report this issue to get this fix EDIT: and this is gettimetick(0) method, which will go negative on 24th day and may create bug prontera,158,185,5 script kjhfksdjf 100,{ if ( @timeon ) { dispbottom "time used -> "+( gettimetick(0) - @start ) +" mili-seconds"; @start = 0; // clear the var } else @start = gettimetick(0); @timeon ^= 1; end; } Edited December 4, 2015 by AnnieRuru 1 Quote Link to comment Share on other sites More sharing options...
Question
badneko
Something like start time, then stop it and show the time has passed.
Link to comment
Share on other sites
7 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.