Jump to content
  • 0
Eross

@request with cooldown timer

Question

Hi ! Im trying to make a bindatcmd script for @refresh but has a 5minutes cooldown ... I just wondering why is it always @refresh failed ???? here is my script 

 

//===================================
//
// @refresh (Remove Stuck Players)
//
//===================================
-	script	refresh	-1,{
	OnInit:
	set .Minutes,5;
	bindatcmd "refresh",strnpcinfo(0)+"::OnAtcommand";
	end;
	OnAtcommand:
	if( .DelayTime <= gettimetick(2)) {
		mes "[@refresh]";
		mes "Stuck on NPC or unable to move?";
		mes "This command has 5 minute cooldown";
		next;
		mes "[@refresh]";		
		mes "Use @refresh?";
		switch(select("No.:Yes.")) {
			case 1:
				close;
			case 2:
				atcommand "@refresh";
				set .DelayTime,gettimetick(2) + ( .Minutes * 60 );
				close;
			}	
	} else if( .DelayTime > gettimetick(2) ){
        set .last,.DelayTime - gettimetick(2);
        set .@min,  .last % (24*60*60) % (60*60) / (60);
        set .@sec,  .last % (24*60*60) % (60*60) % (60);

		message strcharinfo(0), "Wait for "+.@min+" minutes "+.@sec+" seconds before you can use @refresh again.";
		end;
	
		}
	}

 

Share this post


Link to post
Share on other sites

0 answers to this question

Recommended Posts

  • 0
On 5/22/2021 at 11:40 AM, Origami said:

Hi ! Im trying to make a bindatcmd script for @refresh but has a 5minutes cooldown ... I just wondering why is it always @refresh failed ???? here is my script 

 

//=================================== // // @refresh (Remove Stuck Players) // //=================================== - script refresh -1,{ OnInit: set .Minutes,5; bindatcmd "refresh",strnpcinfo(0)+"::OnAtcommand"; end; OnAtcommand: if( .DelayTime <= gettimetick(2)) { mes "[@refresh]"; mes "Stuck on NPC or unable to move?"; mes "This command has 5 minute cooldown"; next; mes "[@refresh]"; mes "Use @refresh?"; switch(select("No.:Yes.")) { case 1: close; case 2: atcommand "@refresh"; set .DelayTime,gettimetick(2) + ( .Minutes * 60 ); close; } } else if( .DelayTime > gettimetick(2) ){ set .last,.DelayTime - gettimetick(2); set .@min, .last % (24*60*60) % (60*60) / (60); set .@sec, .last % (24*60*60) % (60*60) % (60); message strcharinfo(0), "Wait for "+.@min+" minutes "+.@sec+" seconds before you can use @refresh again."; end; } }


//===================================
//
// @refresh (Remove Stuck Players)
//
//===================================
-	script	refresh	-1,{
	OnInit:
	set .Minutes,5;
	bindatcmd "refresh",strnpcinfo(0)+"::OnAtcommand";
	end;
	OnAtcommand:
	if( .DelayTime <= gettimetick(2)) {
		mes "[@refresh]";
		mes "Stuck on NPC or unable to move?";
		mes "This command has 5 minute cooldown";
		next;
		mes "[@refresh]";		
		mes "Use @refresh?";
		switch(select("No.:Yes.")) {
			case 1:
				close;
			case 2:
				atcommand "@refresh";
				set .DelayTime,gettimetick(2) + ( .Minutes * 60 );
				close;
			}	
	} else if( .DelayTime > gettimetick(2) ){
        set .last,.DelayTime - gettimetick(2);
        set .@min,  .last % (24*60*60) % (60*60) / (60);
        set .@sec,  .last % (24*60*60) % (60*60) % (60);

		message strcharinfo(0), "Wait for "+.@min+" minutes "+.@sec+" seconds before you can use @refresh again.";
		end;
	
		}
	}

 

 

Try to change .DelayTime to DelayTime

. = npc variable
without . = playervariable

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

×
×
  • Create New...

Important Information

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