Jump to content
  • 0
Eross

Donation Floating rate npc problem

Question

Hi! recently I asked for a help from a rathena dev to make an NPC that will require players donation to activate ,,, Its working on Hercules ,however, when the event is running ,after the server restart the rates of server is returning to its original rate and the announcement on login turns into 'Base exp: 0x Job exp: 0x' 

 

heres my script .. Thanks !

 

Quote

//============================================================
//= Donation Floating Server Rates
//============================================================

prontera,123,209,6	script	Rates Broker#FloatingRates	4_M_KHKYEL,{

		//set $floating_rates_hours_left,0;
		//set $fr_delay,0;
	if ($fr_delay > gettimetick(2) && .fr_delay) {
			mes .npc$;
			mes "I'm afraid you'll have to wait " + Time2Str($fr_delay) + " before you can donate again.";
			close;
	}
	if ($floating_rates_hours_left > 0) {
		.@seconds_left = 3600 - (gettime(2) * 60 + gettime(1));
		.@hours_left = ($floating_rates_hours_left - 1) * 3600;
		.@time_left = .@seconds_left + .@hours_left;
		
		.@dun_d = .@time_left / 86400;
		.@dun_h = (.@time_left / 3600) % 24;
		.@dun_m = (.@time_left / 60) % 60;
		.@dun_s = .@time_left % 60;
		
		if (.@dun_d > 0) {
			.@remaining$ = .@dun_d + " day" + (.@dun_d > 1 ? "s" : "") + " and ";
		}
		
		.@remaining$ = .@remaining$ + (.@dun_h < 10 ? "0" : "")+.@dun_h+":"+(.@dun_m < 10 ? "0" : "")+.@dun_m+":"+(.@dun_s < 10 ? "0" : "")+.@dun_s;
		
		mes .npc$;
		mes "Floating Rate event will end in";
		mes "^0000ff"+.@remaining$+"^000000";
		mes "^666666Use^000000 ^0000ff@rates^000000 ^666666to see current rates^000000.";
		//mes "Current rates are:";
		//mes "Base Exp: ^0000ff"+($@brate/100)+"."+($@brate-$@brateminus)+"^000000x Job Exp: ^0000ff"+($@jrate/100)+"."+($@jrate-$@jrateminus)+"^000000x";
		close;
	}
	
	mes .npc$;
	mes "Server's current total funds are:";
	mes "~ [^0000ff" + callfunc("F_InsertComma",$fr_zeny) + "^000000] Zeny";
	mes ""+callfunc("F_InsertComma",$fr_diff)+" more Zeny to reach target funds."; 
	//mes "Target funds to initiate: ^ff0000*" + callfunc("F_InsertComma",.fr_td) + " Zeny*^000000";
	mes "Exp Rates: ^0000ffRandom (5.00x ~ 8.00x)";
	mes "^ff0000NOTE:^000000 After reaching our"; 
	mes "target funds, the floating rate";
	mes "event will start right away";
	mes "and will change rates every ^0000ff[Clock 00]^000000."; 
	mes "^66666601:00, 02:00, 03:00, 04:00^000000 so on for the next 48 hours.";
	next;
	mes .npc$;
	mes "^ff0000WARNING!:^000000 Minutes that has passed before the event starts will not be counted on event timer.";
	mes "For example, the event started at";
	mes "04:35, the minutes from 04:00-04:35 will set to ^666666'NULL'^000000 on our timer.";
	mes "Therefore, instead of having 48hours event, you'll only get 47hours & 25minutes";
	mes "(Less the minutes passed). That's why we highly suggest to reach target funds within first";
	mes "one to ten minute of an hour. ^ff0000Always check server time before trying to initiate the event.^000000";
	next;
	mes .npc$;
	mes "Would you like to donate?";
	next;
	
	switch(select("Yes:No")) {
		case 1:
Change_Amount:			
			mes .npc$;
			mes "Please input desired amount.";
			next;
			input .@fr_zeny;
			
			if (.@fr_zeny < 1) {
				mes .npc$;
				mes "Input number greater than 0.";
				end;		
			}
			mes .npc$;
			mes "Please confirm Zeny transfer.";
			next;
			
			switch(select("Cancel:Change Amount:Confirm")) {
				case 1:
					close;
				case 2:
					.@fr_zeny = 0;
					next;
					goto Change_Amount;
					close;
				case 3:
					if (Zeny < .@fr_zeny) {
						mes .npc$;
						mes "Sorry, but you don't have enough";
						mes "zeny to donate.";
						close;
					}	
					if (.@fr_zeny > $fr_diff) {
						mes .npc$;
						mes "The amount you entered will exceed on remaining balance.";
						mes "Remaining Balance: "+callfunc("F_InsertComma",$fr_diff)+" Zeny";
						mes "^ff0000*Please input exact amount next time*.";
						close;
					}
					if (.@fr_zeny == $fr_diff && (gettime(2) > 10)) {
						mes .npc$;
						mes "^ff0000Warning:Minutes that has passed will not be counted on 48hour duration of this event.";
						mes "It'll be best if you start this event on the first 1 to 10 minutes to maximize event time period.^000000";
						next;
							switch (select("Okay, Ill be back later.:I don't care! Bring it on!")) {
								case 1:
									close;
								case 2:
									goto Initiate_FR;
							}
					}	
					Initiate_FR:	
					mes .npc$;
					mes "Zeny has succesfully transfered.";
					Zeny -= .@fr_zeny;
					$fr_zeny += .@fr_zeny;
					$fr_diff -= .@fr_zeny;
					
					if ($fr_zeny >= .fr_td) {
						$fr_zeny = 0;	
						announce ""+.npc$+": We reached our target funds! Activating Floating Rates Event...",bc_all,0xFF6060;					
						// Up to you whether you want to add an extra hour or not, as otherwise the event will be below 48 hours.
						$floating_rates_hours_left = 48;
						donpcevent strnpcinfo(0) + "::OnMinute00";
					}
					
					close;
			}
			
			break;
		case 2:
			close;
			break;
	}
	
	end;
OnInit:
//Script Settings
	.fr_delay = 120;            // Quest delay, in hours (0 to disable).
	.fr_td = 5000000; 						//Target donation amount
	$fr_diff = .fr_td - $fr_zeny; 			//Difference between target funds and balance
	.npc$ = "[Rates Broker]"; 				//NPC Name
	if ($floating_rates_hours_left > 0) { end; }
OnMinute00:
	if (gettime(2) == 0) {
		$floating_rates_hours_left--;
	}
	
	if ($floating_rates_hours_left < 0) {
		end;
	}
	else if ($floating_rates_hours_left == 0) {
		$floating_rates_hours_left = -1;
		.@default_brate = 500;
		.@default_jrate = 500;
		
		if (getbattleflag("base_exp_rate") != .@default_brate) {
			setbattleflag("base_exp_rate", .@default_brate);
		}
		
		if (getbattleflag("job_exp_rate") != .@default_jrate) {
			setbattleflag("job_exp_rate", .@default_jrate);
		}
		$fr_delay = gettimetick(2) + (.fr_delay * 3600);
		announce ""+.npc$+": Event is over, rates were changed back to: Base Exp ~ "+(.@default_brate/100)+"x Job Exp ~ "+(.@default_jrate/100)+"x ",bc_all,0xFF6060;
		end;
	}
	
	$@brate = rand(600,800);
	$@jrate = rand(600,800);
	//$@drate = rand(100,150);
	//Base exp
	setbattleflag("base_exp_rate",$@brate);
	//Job exp
	setbattleflag("job_exp_rate",$@jrate);
	$@brateminus = ($@brate/100) * 100;
	$@jrateminus = ($@jrate/100) * 100;
	announce ""+.npc$+": Current rates are: Base Exp ~ "+($@brate/100)+"."+($@brate-$@brateminus)+"x Job Exp ~ "+($@jrate/100)+"."+($@jrate-$@jrateminus)+"x ",bc_all,0xFF6060;
	
	if ($floating_rates_hours_left == 1) {
		announce ""+.npc$+": There is one hour left before the event will end.",bc_all,0xFF6060;
	}
	
	end;
	
OnPCLoginEvent:
	if ($floating_rates_hours_left > 0) {
		dispbottom "Current server rates are: Base Exp ~ "+($@brate/100)+"."+($@brate-$@brateminus)+"x Job Exp ~ "+($@jrate/100)+"."+($@jrate-$@jrateminus)+"x [Floating Rates Event: Enabled]",0xFF6060;
		end;
	}
	if ($floating_rates_hours_left == 0) {
		dispbottom "Current server rates are: Base Exp ~ "+(.@default_brate/100)+"x Job Exp ~ "+(.@default_jrate/100)+"x [Floating Rates Event: Disabled]",0xFF6060;		
		end;
	}
}

 

 

Edited by erjsanmiguel

Share this post


Link to post
Share on other sites

0 answers to this question

Recommended Posts

  • 0
5 hours ago, Origami said:

Hi! recently I asked for a help from a rathena dev to make an NPC that will require players donation to activate ,,, Its working on Hercules ,however, when the event is running ,after the server restart the rates of server is returning to its original rate and the announcement on login turns into 'Base exp: 0x Job exp: 0x' 

 

heres my script .. Thanks !

 

 

It's because any temporary variables are removed from the npc once the server restarts or once the npc been reloaded. Your rates will be 0 because any 0 value divided by any amount (100) will always return 0.

 

It's better to use OnTimer<tick>. See documentation for more info.

Edited by cjvirus09

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.