I want to make a command @bghappy 20 <- 20% bonus

eKoh

New member
Messages
75
Points
0
I want to make a command like that, but I am not sure if it can be done by scripting or by sourcing.

Usage:

@bghappy 20

Set Battlegrounds happy hour for a 20% bonus.

@bghappy 0

Ends the Battleground happy hour.


This is the script command that is being used for the current Battleground Happy hour script:

Code:
	set .bonus,120; // +20%	set .showbonus,.bonus - 100;			 setbattleflag "bg_reward_rates",.bonus; // +20% Reward Rates			setbattleflag "bg_ranked_mode",1; // Sets ranked mode //This is the one that stops it:			 setbattleflag "bg_reward_rates",100; // Normal Rates			setbattleflag "bg_ranked_mode",0;
 
Code:
-       script  bghappy_1   -1,{              OnInit:bindatcmd "bghappy",strnpcinfo(3)+"::OnBghappy", 40,99; end; OnBghappy:if (@bghappy) {set @bghappy, 0;setbattleflag "bg_reward_rates",100; // Normal Ratessetbattleflag "bg_ranked_mode",0; dispbottom "Battlegrounds +20% mode is OFF.";end;} else {set @bghappy, 1;setbattleflag "bg_reward_rates",120; // +20% Reward Ratessetbattleflag "bg_ranked_mode",1;dispbottom "Battlegrounds +20% mode is ON.";end;}}
 
- script bghappy_1 -1,{ OnInit:bindatcmd "bghappy",strnpcinfo(3)+"::OnBghappy", 40,99; end; OnBghappy:if (@bghappy) {set @bghappy, 0;setbattleflag "bg_reward_rates",100; // Normal Ratessetbattleflag "bg_ranked_mode",0; dispbottom "Battlegrounds +20% mode is OFF.";end;} else {set @bghappy, 1;setbattleflag "bg_reward_rates",120; // +20% Reward Ratessetbattleflag "bg_ranked_mode",1;dispbottom "Battlegrounds +20% mode is ON.";end;}}
I think holding the state if happy hour is enabled or not shouldn't be handled by a temporary character variable.

I would go for a on and off command build instead of a toggle.

But it doesn't really do what was requested anyway.

Code:
-	script	bghappy_1	-1,{	OnInit:		bindatcmd "bghappy", strnpcinfo( 3 ) + "::OnBGHappyhour", 40, 99;	end;	 	OnBGHappyhour:		.@rate = atoi( .@atcmd_parameters$[ 0 ] );				setbattleflag "bg_reward_rates", 100 + .@rate;				if( .@rate ) {			.@ranked = 1;			dispbottom "Battlegrounds Happyhour +" + .@rate + "% mode is ON.";		} else {			.@ranked = 0;			dispbottom "Battlegrounds Happyhour mode is OFF.";		}				setbattleflag "bg_ranked_mode", .@ranked;	end;}
 
Thank you a lot guys! Specially Winterfox. I could understand how the bindatcommand script command works and I managed to add a new usage:

@bghappy &lt;Bonus in %&gt; &lt;Minutes till bonus end&gt;

Btw, how can I make a codebox with "Select Code" option?

- script bghappy_1 -1,{
OnInit:
bindatcmd "bghappy", strnpcinfo( 3 ) + "::OnBGHappyhour", 40, 99;
end;

OnBGHappyhour:

// ---[ Bonus Rates ]-----------
.@rate = atoi( .@atcmd_parameters$[ 0 ] );
.minutes = atoi( .@atcmd_parameters$[ 1 ] );
setbattleflag "bg_reward_rates", 100 + .@rate;

if( .@rate ) {
.@ranked = 1;
dispbottom "Battlegrounds Happyhour +" + .@rate + "% mode is ON for " + .minutes +" minutes.";
} else {
.@ranked = 0;
dispbottom "Battlegrounds Happyhour mode is OFF.";
}

setbattleflag "bg_ranked_mode", .@ranked;
 
// ---[ Bonus Minutes ]-----------
if ( .minutes )
{
initnpctimer "" + strnpcinfo(0) + "";
}
end;

OnTimer60000:
.minutes = .minutes - 1;
if ( .minutes == 0 )
{
.@ranked = 0;
announce "Battlegrounds Happyhour mode is OFF.",0,0x00FF00;
setbattleflag "bg_reward_rates", 100;
setbattleflag "bg_ranked_mode", 0;
stopnpctimer;
end;
}
announce "" + .minutes + " minutes left to end Battlegrounds Happyhour.",0x00FF00;
stopnpctimer;
initnpctimer;
end;
}
 
Or http://pastebin.com/eiEau6nm
 
Last edited by a moderator:
Back
Top