• 0
Sign in to follow this  
IsabelaFernandez

delay script

Question

13 answers to this question

Recommended Posts

  • 0
18 minutes ago, IsabelaFernandez said:

 

Hello, as the title already informs, I would if possible to add 2 seconds of delay to be able to use this script again. Thank you so much to who you can help me.

https://pastebin.com/S6hEFRmf

Here you go check OnInit part:

 

-	script	paytowinbuffs	-1,{
	end;

OnBuffs:
	if(!isequipped(4263)) {
		message strcharinfo(0),"Does not work equipped with Incarnated Samurai Card.";
		end;
	}
	if(getgroupid() <= 4) {
		message strcharinfo(0),"You don't have any Authorization for this command.";
		end;
	}
	.@timer = delay_buffer - gettimetick(2);	
	if (.@timer > 0) {
		dispbottom( "You have to wait "+ .@timer +" second"+ ( .@timer > 1 ? "s" : "" ) +" to use the command again.", 0xFF0000 );
		end;
	}	
	.@size = getarraysize(.buffs$);
	for( .@i = 0; .@i < .@size; .@i++ ) {
		.@menu$ = .@menu$ + ""+.buffs$[.@i]+"" + ":";
	}
	.@i = select(.@menu$) -1;
	sc_start .elements[.@i],180000,5;
	delay_buffer = gettimetick(2) + .delay;
	end;

OnInit:
	.delay  = 3 * 2; // 5 = 5 seconds *60 = 360 seconds
	setarray .buffs$, "^800080Envenenar Arma^000000", "^40E0D0Aspersio^000000", "^000000Sombrio^000000", "^FFD700Encantar com Ventania^000000", "^0000FFEncantar com Geada^000000", "^FF0000Encantar com Chama^000000", "^B8860BEncantar com Terremoto^000000";
	setarray .elements, 26, 37, "144", "98", "97", "96", "99";
	bindatcmd "encantar","paytowinbuffs::OnBuffs",0,99;
	end;
}

 

 

 

Edited by Royr

Share this post


Link to post
Share on other sites
  • 0
3 minutes ago, Royr said:

Here you go check OnInit part:

 

-	script	paytowinbuffs	-1,{
	end;

OnBuffs:
	if(getgroupid() <= 4) {
		message strcharinfo(0),"Falha, você não possui VIP.";
		end;
	}
	if(isequipped(4263)) {
		message strcharinfo(0),"Não funciona equipado com Samurai Encarnado.";
		end;
	}
	
	.@timer = delay_buffer - gettimetick(2);	
	if (.@timer > 0) {
		dispbottom( "You have to wait "+ .@timer +" second"+ ( .@timer > 1 ? "s" : "" ) +" to use the command again.", 0xFF0000 );
		end;
	}	
	
	.@size = getarraysize(.buffs$);
	for( .@i = 0; .@i < .@size; .@i++){
		.@menu$ = .@menu$ + ""+.buffs$[.@i]+"" + ":";
	}
	.@i = select(.@menu$) -1;
	sc_start .elements[.@i],180000,5;
	//atcommand "@refresh "+strcharinfo(0);
	delay_buffer = gettimetick(2) + .delay;
	end;

OnInit:
	.delay  = 3 * 2; // 5 = 5 seconds *60 = 360 seconds
	setarray .buffs$, "^800080Envenenar Arma^000000", "^40E0D0Aspersio^000000", "^000000Sombrio^000000", "^FFD700Encantar com Ventania^000000", "^0000FFEncantar com Geada^000000", "^FF0000Encantar com Chama^000000", "^B8860BEncantar com Terremoto^000000";
	setarray .elements, 26, 37, "144", "98", "97", "96", "99";
	bindatcmd "encantar","paytowinbuffs::OnBuffs",0,99;
	end;
}

  

 

 

 

thanks but I have a problem that players are able to circumvent the restriction of the item using the command fast 2 times in a row .... any idea how to solve this?

Share this post


Link to post
Share on other sites
  • 0

You could add a variable when the player is using it.

-	script	paytowinbuffs	-1,{
	end;

OnBuffs:
	if(getgroupid() <= 4) {
		message strcharinfo(0),"Falha, você não possui VIP.";
		end;
	}
	if(isequipped(4263)) {
		message strcharinfo(0),"Não funciona equipado com Samurai Encarnado.";
		end;
	}
	if(@buffs_inuse) {
		end;
	}

	if (gettimetick(2) < delay_buffer) {
		dispbottom( "You have to wait "+Time2Str(delay_bufer)+" to use the command again.", 0xFF0000 );
		end;
	}

	@buffs_inuse = true;

	[email protected]$ = implode(.buffs$,":");
	[email protected] = prompt([email protected]$) -1;
	if([email protected] < 255) {
		sc_start .elements[[email protected]],180000,5;
		//atcommand "@refresh "+strcharinfo(0);
		delay_buffer = gettimetick(2) + .delay;
	}

	@buffs_inuse = false;
	end;

OnInit:
	.delay  = 3 * 2; // 5 = 5 seconds *60 = 360 seconds
	setarray .buffs$, "^800080Envenenar Arma^000000", "^40E0D0Aspersio^000000", "^000000Sombrio^000000", "^FFD700Encantar com Ventania^000000", "^0000FFEncantar com Geada^000000", "^FF0000Encantar com Chama^000000", "^B8860BEncantar com Terremoto^000000";
	setarray .elements, 26, 37, 144, 98, 97, 96, 99;
	bindatcmd "encantar","paytowinbuffs::OnBuffs",0,99;
	end;
}

 

  • Upvote 1

Share this post


Link to post
Share on other sites
  • 0

If you compute the delay before the buffing then the „lock“ is not needed, since the delay is handling that. The problem is that current implementation is calculating the delay after buffing, which I think results in running the script twice before the delay does what it should do. 

  • Upvote 1

Share this post


Link to post
Share on other sites
  • 0
47 minutes ago, n0tttt said:

You could add a variable when the player is using it.

-	script	paytowinbuffs	-1,{
	end;

OnBuffs:
	if(getgroupid() <= 4) {
		message strcharinfo(0),"Falha, você não possui VIP.";
		end;
	}
	if(isequipped(4263)) {
		message strcharinfo(0),"Não funciona equipado com Samurai Encarnado.";
		end;
	}
	if(@buffs_inuse) {
		end;
	}

	if (gettimetick(2) < delay_buffer) {
		dispbottom( "You have to wait "+Time2Str(delay_bufer)+" to use the command again.", 0xFF0000 );
		end;
	}

	@buffs_inuse = true;

	[email protected]$ = implode(.buffs$,":");
	[email protected] = prompt([email protected]$) -1;
	if([email protected] < 255) {
		sc_start .elements[[email protected]],180000,5;
		//atcommand "@refresh "+strcharinfo(0);
		delay_buffer = gettimetick(2) + .delay;
	}

	@buffs_inuse = false;
	end;

OnInit:
	.delay  = 3 * 2; // 5 = 5 seconds *60 = 360 seconds
	setarray .buffs$, "^800080Envenenar Arma^000000", "^40E0D0Aspersio^000000", "^000000Sombrio^000000", "^FFD700Encantar com Ventania^000000", "^0000FFEncantar com Geada^000000", "^FF0000Encantar com Chama^000000", "^B8860BEncantar com Terremoto^000000";
	setarray .elements, 26, 37, 144, 98, 97, 96, 99;
	bindatcmd "encantar","paytowinbuffs::OnBuffs",0,99;
	end;
}

 

 

thanks, but unfortunately it is still possible to cheat spamming the command =(

36 minutes ago, Normynator said:

If you compute the delay before the buffing then the „lock“ is not needed, since the delay is handling that. The problem is that current implementation is calculating the delay after buffing, which I think results in running the script twice before the delay does what it should do. 

 

could you give an example of how it would look?

Share this post


Link to post
Share on other sites
  • 0

Try

-	script	paytowinbuffs	-1,{
	end;

OnBuffs:
	if(getgroupid() <= 4) {
		message strcharinfo(0),"Falha, você não possui VIP.";
		end;
	}
	if(isequipped(4263)) {
		message strcharinfo(0),"Não funciona equipado com Samurai Encarnado.";
		end;
	}
	if(@buffs_inuse == 1) {
		end;
	}

	if (gettimetick(2) < delay_buffer) {
		dispbottom( "You have to wait "+Time2Str(delay_bufer)+" to use the command again.", 0xFF0000 );
		end;
	}

	@buffs_inuse = 1;

	[email protected]$ = implode(.buffs$,":");
	[email protected] = prompt([email protected]$) -1;
	if([email protected] < 255) {
		sc_start .elements[[email protected]],180000,5;
		//atcommand "@refresh "+strcharinfo(0);
		delay_buffer = gettimetick(2) + .delay;
	}

	@buffs_inuse = 0;
	end;

OnInit:
	.delay  = 3 * 2; // 5 = 5 seconds *60 = 360 seconds
	setarray .buffs$, "^800080Envenenar Arma^000000", "^40E0D0Aspersio^000000", "^000000Sombrio^000000", "^FFD700Encantar com Ventania^000000", "^0000FFEncantar com Geada^000000", "^FF0000Encantar com Chama^000000", "^B8860BEncantar com Terremoto^000000";
	setarray .elements, 26, 37, 144, 98, 97, 96, 99;
	bindatcmd "encantar","paytowinbuffs::OnBuffs",0,99;
	end;
}

 

  • Upvote 1

Share this post


Link to post
Share on other sites
  • 0
Just now, Hijirikawa said:

Try

-	script	paytowinbuffs	-1,{
	end;

OnBuffs:
	if(getgroupid() <= 4) {
		message strcharinfo(0),"Falha, você não possui VIP.";
		end;
	}
	if(isequipped(4263)) {
		message strcharinfo(0),"Não funciona equipado com Samurai Encarnado.";
		end;
	}
	if(@buffs_inuse == 1) {
		end;
	}

	if (gettimetick(2) < delay_buffer) {
		dispbottom( "You have to wait "+Time2Str(delay_bufer)+" to use the command again.", 0xFF0000 );
		end;
	}

	@buffs_inuse = 1;

	.@menu$ = implode(.buffs$,":");
	.@i = prompt(.@menu$) -1;
	if(.@i < 255) {
		sc_start .elements[.@i],180000,5;
		//atcommand "@refresh "+strcharinfo(0);
		delay_buffer = gettimetick(2) + .delay;
	}

	@buffs_inuse = 0;
	end;

OnInit:
	.delay  = 3 * 2; // 5 = 5 seconds *60 = 360 seconds
	setarray .buffs$, "^800080Envenenar Arma^000000", "^40E0D0Aspersio^000000", "^000000Sombrio^000000", "^FFD700Encantar com Ventania^000000", "^0000FFEncantar com Geada^000000", "^FF0000Encantar com Chama^000000", "^B8860BEncantar com Terremoto^000000";
	setarray .elements, 26, 37, 144, 98, 97, 96, 99;
	bindatcmd "encantar","paytowinbuffs::OnBuffs",0,99;
	end;
}

 

it is still possible to activate the command spamming the command. any idea how to block the command's spam usage? 

Share this post


Link to post
Share on other sites
  • 0
6 minutes ago, IsabelaFernandez said:
it is still possible to activate the command spamming the command. any idea how to block the command's spam usage? 
-	script	paytowinbuffs	-1,{
	end;
OnBuffs:
	if(gettimetick(2) < use_delay){
		message strcharinfo(0),"Nope";
		end;
	}
	if(getgroupid() <= 4) {
		message strcharinfo(0),"Falha, você não possui VIP.";
		end;
	}
	if(isequipped(4263)) {
		message strcharinfo(0),"Não funciona equipado com Samurai Encarnado.";
		end;
	}
	if (gettimetick(2) < delay_buffer) {
		dispbottom( "You have to wait "+Time2Str(delay_bufer)+" to use the command again.", 0xFF0000 );
		end;
	}
	use_delay = gettimetick(2) + .use_delay;
	[email protected]$ = implode(.buffs$,":");
	[email protected] = prompt([email protected]$) -1;
	if([email protected] < 255) {
		sc_start .elements[[email protected]],180000,5;
		//atcommand "@refresh "+strcharinfo(0);
		delay_buffer = gettimetick(2) + .delay;
	}
	end;
OnInit:
	.use_delay = 5; // 5 second use delay
	.delay  = 3 * 2; // 5 = 5 seconds *60 = 360 seconds
	setarray .buffs$, "^800080Envenenar Arma^000000", "^40E0D0Aspersio^000000", "^000000Sombrio^000000", "^FFD700Encantar com Ventania^000000", "^0000FFEncantar com Geada^000000", "^FF0000Encantar com Chama^000000", "^B8860BEncantar com Terremoto^000000";
	setarray .elements, 26, 37, 144, 98, 97, 96, 99;
	bindatcmd "encantar","paytowinbuffs::OnBuffs",0,99;
	end;
}

 

Share this post


Link to post
Share on other sites
  • 0
1 minute ago, Hijirikawa said:
-	script	paytowinbuffs	-1,{
	end;
OnBuffs:
	if(gettimetick(2) < use_delay){
		message strcharinfo(0),"Nope";
		end;
	}
	if(getgroupid() <= 4) {
		message strcharinfo(0),"Falha, você não possui VIP.";
		end;
	}
	if(isequipped(4263)) {
		message strcharinfo(0),"Não funciona equipado com Samurai Encarnado.";
		end;
	}
	if (gettimetick(2) < delay_buffer) {
		dispbottom( "You have to wait "+Time2Str(delay_bufer)+" to use the command again.", 0xFF0000 );
		end;
	}
	use_delay = gettimetick(2) + .use_delay;
	[email protected]$ = implode(.buffs$,":");
	[email protected] = prompt([email protected]$) -1;
	if([email protected] < 255) {
		sc_start .elements[[email protected]],180000,5;
		//atcommand "@refresh "+strcharinfo(0);
		delay_buffer = gettimetick(2) + .delay;
	}
	end;
OnInit:
	.use_delay = 5; // 5 second use delay
	.delay  = 3 * 2; // 5 = 5 seconds *60 = 360 seconds
	setarray .buffs$, "^800080Envenenar Arma^000000", "^40E0D0Aspersio^000000", "^000000Sombrio^000000", "^FFD700Encantar com Ventania^000000", "^0000FFEncantar com Geada^000000", "^FF0000Encantar com Chama^000000", "^B8860BEncantar com Terremoto^000000";
	setarray .elements, 26, 37, 144, 98, 97, 96, 99;
	bindatcmd "encantar","paytowinbuffs::OnBuffs",0,99;
	end;
}

 

I still can use ... I realized that before when spamming and could charm, sometimes I was in Stone Curse mode ...
 is it possible to add so that they stay in Stone Curse if they can enchant with the restriction of item 4263?

Share this post


Link to post
Share on other sites
  • 0

Simple way

 

if(@usingBuff) end;

@usingBuff = 1;

your Buffs  logic Here;

sleep2 2000;

@usingBuff = 0;

end;

 

Share this post


Link to post
Share on other sites
  • 0
2 hours ago, Zell said:

Simple way

 

if(@usingBuff) end;

@usingBuff = 1;

your Buffs  logic Here;

sleep2 2000;

@usingBuff = 0;

end;

 

 

Do I add this to the script or create another one? Sorry, I do not have script knowledge. /sob

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this