Jump to content

  •  

tampicos

Member Since 28 Aug 2016
Offline Last Active Sep 23 2016 04:17 PM
-----

Topics I've Started

Donation Counter

11 September 2016 - 07:59 AM

Hi All!!,

 

There is some great information here and I have to thank GM Ocean for their awesome beginner guides. Alas, I am stuck. I've been working on a script based on rachel sanc + some of the newbie trade guides to collect a set amount of coins, save the number, and once the number is reached, it'll increase the rates of the server. If I reset the npc, it'll work just fine but when I reset the server, it'll remember the last number saved but won't continue to update.

 

// Script is supposed to take an instance item from player.
// Once a set number of that instance item is accumulated
// Rates will increase temporarily 
//
//= - Variable in use: have_donated_g (0 no/1 yes)
//= - Variable in use: $rate_donate (max 10000)
	
prontera,160,180,4	script	Coin	4_M_LAZY,{

.@npc_name$ = "[^FF0000 Lazy Leveler ^000000]";

if (have_donated_g == 0) {
	mes .@npc_name$;
	mes "Give me";
	while ( .@i < getarraysize(.required_items)) {
	mes ""+ .required_amount[.@i] +"x "+ getitemname(.required_items[.@i]) +"";
		++.@i;
	}
	next;	
	switch(select("Yes", "No WAY!!"))	{
	case 1:
			callsub G_Donate, 1, getitemname(.required_items[.@i]) +" x"+ .required_amount[.@i];
			break;
	case 2:
			mes "Stingy!";
			break;
	}
close2;
end;
}
else	{
	mes .@npc_name$;
	mes "Welcome back " + strcharinfo(PC_NAME) + "!";
	mes "Any more coins?";
		switch(select("Yes", "No WAY!!"))	{
			case 1:
					callsub G_Donate,1, getitemname(.required_items[.@i]) +" x"+ .required_amount[.@i];
					break;
			case 2:
					mes "Stingy!";
					break;
			}
			close2;
			end;
	}
G_Donate:
	mes .@npc_name$;
	mes "So, " + strcharinfo(PC_NAME) + "...";
	mes "I just want to make sure,";
	mes "You want to donate "+getarg(1); //.required_amount[.@i] +"x "+ getitemname(.required_items[.@i]) +"?";
	next;
	if (select("No", "Yes") == 1) {
		mes .@npc_name$;
		mes "Oh, I see.";
		close2;
		end;
		
	}
	if ((countitem(.required_items[0]) >= .required_amount[0])) {
		
		$rate_donate +=getarg(0);
		while (.@j < getarraysize(.required_items)) {
		delitem .required_items[.@j], .required_amount[.@j];
		++.@j;
		have_donated_g = 1;
		next;
		}
				
		if ($rate_donate > 9999) {
			mes .@npc_name$;
			mes "Thanks so much for";
			mes "your donation!";
			return;
		}
		else {
			.@remaining = 10000-$rate_donate;
			mes .@npc_name$;
			mes "Thank you so much!";
			mes "we need "+.@remaining+" more donations!";
			next;
			mes .@npc_name$;
			mes "Come back and donate more!";
			return;
		}
	}
	else {
		mes .@npc_name$;
		mes "You don't have all the required items.";
		return;
	}
close2;
end;

OnInit:
	setarray .required_items[0], Ancient_Gold_Coin;
	setarray .required_amount[0], 1;
	end;
}

Any help is appreciated

 

p.s. I already have the rate increase coded but I want to get the counter working before putting them together.

 

 

**edit**

 

Turns out it works, I was just not shutting down the server correctly so nothing was saving /swt