Jump to content
  • 0
Sign in to follow this  
Guest

Charity NPC - Help pls

Question

Guest

Hello everyone, I'm trying to make a Charity NPC. I'm beginner in scripting and Im using guides and forums just to see how it works.
It working without any errors, i just want to add an activation event and deactivation event. Thank you


The way i want it to work is like :

  • Players can choose how much they would donate in ZENY. (5m, 10m, 15m or 25m)
  • If player, donated a money to the NPC it will do an announcement.
  • If the npc collects 75m it will activate/show the NPC Quests (quest npcs are hidden) for 2 days.
  • After 2 days, it will hide the quest npcs. So players need to donate 75m in total to activate again.

Heres the script i made.

//Charity NPC//
//Ryonin//

izlude,124,139,6	script	Lucy	101,{

		// Variables
		set .@n$, "[Lucy]";
		set ##donate5m, 5000000;
		set ##donate10m, 10000000;
		set ##donate15m, 15000000;
		set ##donate25m, 25000000;
		
		// Zeny Detector
		if (Zeny < ##donate5m)
			{
			mes .@n$;
			mes "Sorry, you dont have enough money to talk to me.";
			mes "You need to have atleast ^FF00005,000,000z^000000.";
			mes "The total amount I collected is : ^0000CD["+##totaldonate+"]^000000 zeny.";
			close;
			end;}		
		
		// Start
		mes .@n$;
		mes "Hello, Citizen of Ragnarok Offline.";
		mes "Can I help you with something?";
		next;
		switch(select("Yes, I would like to donate:No, Thank you")) {
		
		case 1:
			mes .@n$;
			mes "I was assigned by the ^DAA520 GM Team^000000 to collect the donation money.";
			mes "The total amount I collected is : ^0000CD["+##totaldonate+"]^000000 zeny.";
			next;
			mes .@n$;
			mes "You can only donate 1,000,000z or 5,000,000z.";
			next;
			mes .@n$;
			mes "If I collected a total amount of ^FF000075,000,000^000000z.";
			mes "I can activate this event:";
			mes "Event: ^8B008BComodo Hat Festival Quest^000000.";
			mes "Event Duration: ^006400[2 DAYS]^000000.";
			next;
			mes .@n$;
			mes "How much money you want to donate?";
			mes "Once you donate, I can't your money back.";
			next;
			switch(select("5,000,000z:10,000,000z:15,000,000z:25,000,000z")) {
				case 1:
					mes .@n$;
					set zeny, zeny - ##donate5m;
					goto Donate5M;
					close;
					
				case 2:
					mes	.@n$;
					set zeny, zeny - ##donate10m;
					goto Donate10M;
					close;
				
				case 3:
					mes .@n$;
					set zeny, zeny - ##donate15m;
					goto Donate15M;
					close;
				
				case 4:
					mes	.@n$;
					set zeny, zeny - ##donate25m;
					goto Donate25M;
					close;
					
				}
			close;
			end;
		case 2:
			mes .@n$;
			mes	"Okay then. See you later.";
			close;
			end;
		}
// Zeny Donation Selection

	Donate5M:
				set ##totaldonate, ##totaldonate + 5000000;
				mes "Thank you for donating 5,000,000z!";
				mes "We appreciate your generosity.";
				announce "[Charity Lucy: "+strcharinfo(0)+"] has donated [5,000,000z] to Charity! We appreciate your generosity.",0;
				next;
				mes .@n$;
				mes "The total amount I collected is : ^0000CD["+##totaldonate+"]^000000 zeny.";
				close;
				
	Donate10M:
				set ##totaldonate, ##totaldonate + 10000000;
				mes "Thank you for donating 10,000,000z!";
				mes "We appreciate your generosity.";
				announce "[Charity Lucy: "+strcharinfo(0)+"] has donated [10,000,000z] to Charity! We appreciate your generosity.",0;
				next;
				mes .@n$;
				mes "The total amount I collected is : ^0000CD["+##totaldonate+"]^000000 zeny.";
				close;
				
	Donate15M:
				set ##totaldonate, ##totaldonate + 15000000;
				mes "Thank you for donating 15,000,000z!";
				mes "We appreciate your generosity.";
				announce "Charity Lucy: ["+strcharinfo(0)+"] has donated [15,000,000z] to Charity! We appreciate your generosity.",0;
				next;
				mes .@n$;
				mes "The total amount I collected is : ^0000CD["+##totaldonate+"]^000000 zeny.";
				close;
				
	Donate25M:
				set ##totaldonate, ##totaldonate + 25000000;
				mes "Thank you for donating 25,000,000z!";
				mes "We appreciate your generosity.";
				announce "Charity Lucy: ["+strcharinfo(0)+"] has donated [25,000,000z] to Charity! We appreciate your generosity.",0;
				next;
				mes .@n$;
				mes "The total amount I collected is : ^0000CD["+##totaldonate+"]^000000 zeny.";
				close;
				
	Reset:
				set ##totaldonate, 0;
				announce "Charity Lucy: Charity Event for 2 Days has ended. Don't forget to donate to activate.",0;
				sleep 10000;
				announce "Charity Lucy: Thank you for your generosity.",0;
				close;
}
Edited by Guest

Share this post


Link to post
Share on other sites

2 answers to this question

Recommended Posts

  • 0

Select Code
//Charity NPC//
//Ryonin//

izlude,124,139,6	script	Lucy	101,{

// Variables
	.@n$ = "[Lucy]";
//	$donate5m = 5000000; // you used global account variables, but you need global variable here ($)
//	$donate10m = 10000000; // if you do it like this, those variables will be set each time someone talks to the npc.
//	$donate15m = 15000000;
//	$donate25m = 25000000; // i kept em but they're totally not needed

/*// Zeny Detector  // this would prevent anyone to do anything
	if (Zeny < $donate5m) {
		mes .@n$;
		mes "Sorry, you dont have enough money to talk to me.";
		mes "You need to have atleast ^FF00005,000,000z^000000.";
		mes "The total amount I collected is : ^0000CD["+$totaldonate+"]^000000 zeny.";
		close;
		end;
	}
*/
// Start
	mes .@n$;
	mes "Hello, Citizen of Ragnarok Offline.";
	mes "Can I help you with something?";
	next;
	if (select("Yes, I would like to donate", "No, Thank you") ==2) { // removed the switch here, instead, if you select the 2nd answer the npc will directly end.
		mes .@n$;										// Also you had close; end; in your script, which is not needed.
		mes "Okay then. See you later.";
		close;
	}
	mes .@n$;
	mes "I was assigned by the ^DAA520 GM Team^000000 to collect the donation money.";
	mes "The total amount I collected is : ^0000CD["+$totaldonate+"]^000000 zeny.";
	next;
	mes .@n$;
	mes "You can only donate 1,000,000z or 5,000,000z.";
	next;
	mes .@n$;
	mes "If I collected a total amount of ^FF000075,000,000^000000z.";
	mes "I can activate this event:";
	mes "Event: ^8B008BComodo Hat Festival Quest^000000.";
	mes "Event Duration: ^006400[2 DAYS]^000000.";
	next;
	mes .@n$;
	mes "How much money you want to donate?";
	mes "Once you donate, I can't your money back.";
	next;
	.@menu = select("5,000,000z", "10,000,000z", "15,000,000z", "25,000,000z"); // removing the switch, instead we store selection in a variable (1-4 depending on selection)
	setarray(.@costs[0] = 5000000, 10000000, 15000000, 25000000); // setting a temporary array with the costs)
	switch (.@menu) { //switching the variable we set before
	case 1:
	case 2:
	case 3:
	case 4:
		mes .@n$;						// same message, regardless how much you donated
		if (Zeny < .@costs[.@menu-1]) {	// you forgot a Zeny check so I added one
			mes .@n$;
			mes "You don't have enough Zeny?";
                        close;
		}
		Zeny -= .@costs[.@menu-1];				// zeny -= the costs you selected (arrays start at 0, so its your selection -1)
		close;

		$totaldonate += .@costs[.@menu-1]; // variable += the donated amount
		mes "Thank you for donating "+.@costs[.@menu-1]+"!"; //
		mes "We appreciate your generosity.";
		announce "[Charity Lucy: "+strcharinfo(0)+"] has donated ["+.@costs[.@menu-1]+"] to Charity! We appreciate your generosity.", 0;
		next;
		mes .@n$;
		mes "The total amount I collected is : ^0000CD["+$totaldonate+"]^000000 zeny.";
		close;
	} // closing the switch
	end;
} // closing npc

 

i did some comments inside - everything is untested

 

to enable npcs depending on donated amount you can either use a fake_npc and check for $totaldonate > 25m or whatever, or you do like in rachel quest

 

//== Donation Lottery Quest/High Priest Quest :: rachel_oz & rachel_ma1 =
ra_temple,119,180,0	script	Temple Entrance#ra_tem	WARPNPC,1,1,{
OnTouch:
	if ($rachel_donate >= 10000) {
		if (MISC_QUEST & 8192) { warp "ra_temin",169,23; end; }

		if (ra_tem_q < 10) {
			mes "^3355FFThe temple's";
			mes "entrance is locked.^000000";
			next;
			select("Kick Door.", "Smash Door with Weapon.");
			emotion e_omg,0,"Nemma#ra_temple";
			mes "[Priestess Nemma]";
			mes "Please don't do that!";
			close;
		}
	}
	warp "ra_temin",169,23;
	end;
}

Share this post


Link to post
Share on other sites
  • 0
Guest

 

Select Code
//Charity NPC//
//Ryonin//

izlude,124,139,6	script	Lucy	101,{

// Variables
	.@n$ = "[Lucy]";
//	$donate5m = 5000000; // you used global account variables, but you need global variable here ($)
//	$donate10m = 10000000; // if you do it like this, those variables will be set each time someone talks to the npc.
//	$donate15m = 15000000;
//	$donate25m = 25000000; // i kept em but they're totally not needed

/*// Zeny Detector  // this would prevent anyone to do anything
	if (Zeny < $donate5m) {
		mes .@n$;
		mes "Sorry, you dont have enough money to talk to me.";
		mes "You need to have atleast ^FF00005,000,000z^000000.";
		mes "The total amount I collected is : ^0000CD["+$totaldonate+"]^000000 zeny.";
		close;
		end;
	}
*/
// Start
	mes .@n$;
	mes "Hello, Citizen of Ragnarok Offline.";
	mes "Can I help you with something?";
	next;
	if (select("Yes, I would like to donate", "No, Thank you") ==2) { // removed the switch here, instead, if you select the 2nd answer the npc will directly end.
		mes .@n$;										// Also you had close; end; in your script, which is not needed.
		mes "Okay then. See you later.";
		close;
	}
	mes .@n$;
	mes "I was assigned by the ^DAA520 GM Team^000000 to collect the donation money.";
	mes "The total amount I collected is : ^0000CD["+$totaldonate+"]^000000 zeny.";
	next;
	mes .@n$;
	mes "You can only donate 1,000,000z or 5,000,000z.";
	next;
	mes .@n$;
	mes "If I collected a total amount of ^FF000075,000,000^000000z.";
	mes "I can activate this event:";
	mes "Event: ^8B008BComodo Hat Festival Quest^000000.";
	mes "Event Duration: ^006400[2 DAYS]^000000.";
	next;
	mes .@n$;
	mes "How much money you want to donate?";
	mes "Once you donate, I can't your money back.";
	next;
	.@menu = select("5,000,000z", "10,000,000z", "15,000,000z", "25,000,000z"); // removing the switch, instead we store selection in a variable (1-4 depending on selection)
	setarray(.@costs[0] = 5000000, 10000000, 15000000, 25000000); // setting a temporary array with the costs)
	switch (.@menu) { //switching the variable we set before
	case 1:
	case 2:
	case 3:
	case 4:
		mes .@n$;						// same message, regardless how much you donated
		if (Zeny < .@costs[.@menu-1]) {	// you forgot a Zeny check so I added one
			mes .@n$;
			mes "You don't have enough Zeny?";
                        close;
		}
		Zeny -= .@costs[.@menu-1];				// zeny -= the costs you selected (arrays start at 0, so its your selection -1)
		close;

		$totaldonate += .@costs[.@menu-1]; // variable += the donated amount
		mes "Thank you for donating "+.@costs[.@menu-1]+"!"; //
		mes "We appreciate your generosity.";
		announce "[Charity Lucy: "+strcharinfo(0)+"] has donated ["+.@costs[.@menu-1]+"] to Charity! We appreciate your generosity.", 0;
		next;
		mes .@n$;
		mes "The total amount I collected is : ^0000CD["+$totaldonate+"]^000000 zeny.";
		close;
	} // closing the switch
	end;
} // closing npc

 

i did some comments inside - everything is untested

 

to enable npcs depending on donated amount you can either use a fake_npc and check for $totaldonate > 25m or whatever, or you do like in rachel quest

 

//== Donation Lottery Quest/High Priest Quest :: rachel_oz & rachel_ma1 =
ra_temple,119,180,0	script	Temple Entrance#ra_tem	WARPNPC,1,1,{
OnTouch:
	if ($rachel_donate >= 10000) {
		if (MISC_QUEST & 8192) { warp "ra_temin",169,23; end; }

		if (ra_tem_q < 10) {
			mes "^3355FFThe temple's";
			mes "entrance is locked.^000000";
			next;
			select("Kick Door.", "Smash Door with Weapon.");
			emotion e_omg,0,"Nemma#ra_temple";
			mes "[Priestess Nemma]";
			mes "Please don't do that!";
			close;
		}
	}
	warp "ra_temin",169,23;
	end;
}

Thank you so much. I really appreciate your comments and suggestions. 

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...
Sign in to follow this  

×
×
  • Create New...

Important Information

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