Jump to content
  • 0
Sign in to follow this  
Yrok

Race to 99 Per Class

Question

Can someone give a script about this Race to max level  reward giver.. When player reaches his max level. he will talk to this npc then. give him reward. 1 Reward Only Per Job. 

Jobs:

Knight
Wizard
Hunter
Blacksmith
Assassin
Priest

Crusader

Sage

Bard

Dancer

Alchemist

Rouge

Monk

and please Broadcast it. thank you

Edited by Yrok
  • Upvote 1

Share this post


Link to post
Share on other sites

17 answers to this question

Recommended Posts

  • 2

I'm sorry, I made a mistake. Here you go, please upvote my post.

///////////////////////////////////////////////////////
//  ___________               _____.__                
//  \__    ___/__.__.________/ ____\__| ____    ____  
//    |    | <   |  |\_  __ \   __\|  |/    \  / ___\ 
//    |    |  \___  | |  | \/|  |  |  |   |  \/ /_/  >
//    |____|  / ____| |__|   |__|  |__|___|  /\___  / 
//            \/       Scripts             \//_____/  
//
//=====================================================
// Name: Race to Max Level
//
// Description:
// This NPC allows for Game Masters to set a reward to
// be given to the first player of each 2nd class that
// reaches maximum level (base and class).
//=====================================================
///////////////////////////////////////////////////////
prontera,147,180,5	script	Race to Max Level	58,{
	set .@gm_level, 99; // GM level required to set the reward
	set .@maxbase, 99;
	set .@maxjob, 50;
	set .@defaultreward, 510;
	setarray .@rewardablejobs[0], Job_Knight, Job_Alchemist, Job_Assassin, Job_Bard, Job_Blacksmith, Job_Crusader, Job_Dancer, Job_Hunter, Job_Monk, Job_Priest, Job_Rogue, Job_Sage, Job_Wizard;
	
	Begin:
	clear;
	mes "[ ^0099ccRace to Max Level^000000 ]";
	mes "Hello, " + ((getgmlevel() >= .@gm_level) ? "master! What do you want to do today?" : "are you here for your reward?");
	switch(select(((getgmlevel() >= .@gm_level) ? "Set Reward:Restart Race" : ":") + ":YES!:...Reward?:Who was rewarded?:Cancel")) {
		case 1:
			goto SetReward;
		case 2:
			goto RestartRace;
		case 3:
			goto GetReward;
		case 4:
			goto ExplainRace;
		case 5:
			goto ShowRewarded;
		default:
			end;
	}
	
	SetReward:
		clear;
		mes "[ ^0099ccRace to Max Level^000000 ]";
		if ($reward == 0)
			set $reward, .@defaultreward;
		mes "The reward is " + getitemname($reward) + " (ID: " + $reward + ").";
		mes "Do you want to change it?";
		if (select("Yes:No") == 1) {
			clear;
			mes "[ ^0099ccRace to Max Level^000000 ]";
			mes "Please enter the new reward item ID.";
			input .@rewardid;			
			clear;
			mes "[ ^0099ccRace to Max Level^000000 ]";
			mes "Set " + getitemname(.@rewardid) + " as the reward?";
			if(select("Yes:No") == 1) {
				set $reward, .@rewardid;
			}
		}
		goto Begin;
	
	RestartRace:
		clear;
		mes "[ ^0099ccRace to Max Level^000000 ]";
		mes "Are you sure you want to restart the race?";
		if (select("Yes:No") == 1) {
			for (.@i = 0; .@i < getarraysize(.@rewardablejobs); .@i++) {
				set $rewarded$[.@rewardablejobs[.@i]], "";
			}
			announce "The Race to Max Level has begun! Claim a reward once you reach " + .@maxbase + " base and " + .@maxjob + " class!", bc_all;
		}
		goto Begin;
	
	GetReward:
		mes "Let's see... " + strcharinfo(0) + ", huh?";
		
		set .@competitioner, 0;
		for (.@i = 0; .@i < getarraysize(.@rewardablejobs); .@i++) {
			if (Class == .@rewardablejobs[.@i]) {
				set .@competitioner, 1;
				if (BaseLevel < .@maxbase || JobLevel < .@maxjob) {
					mes "I'm sorry, but you still need to level a bit more.";
				} else if ($rewarded$[Class] == strcharinfo(0)) {
					mes "You have already claimed your reward.";
				} else if ($rewarded$[Class] != "") {
					mes "Too late!";
					mes "The reward for " + jobname(Class) + " was already claimed by " + $rewarded$[Class] + ".";
				} else goto GiveReward;
			}
		}
		if (.@competitioner == 0)
			mes "You need to change your job.";
		close;
	
	GiveReward:
		set $rewarded$[Class], strcharinfo(0);
		clear;
		mes "[ ^0099ccRace to Max Level^000000 ]";
		mes "Congratulations! You were the first " + jobname(Class) + " to reach " + .@maxbase + " base and " + .@maxjob + " class!";
		getitem $reward, 1;
		announce strcharinfo(0) + " (" + jobname(Class) + ") reached Max. Level and received " + getitemname($reward) + "!", bc_all;
		close;
	
	ExplainRace:
		clear;
		mes "[ ^0099ccRace to Max Level^000000 ]";
		mes "Yes! When you reach the maximum level for your class, talk to me and you'll be rewarded with a special item.";
		next;
		goto Begin;
		
	ShowRewarded:
		clear;
		mes "[ ^0099ccRace to Max Level^000000 ]";
		for (.@i = 0; .@i < getarraysize(.@rewardablejobs); .@i++) {
			mes jobname(.@rewardablejobs[.@i]) + ": " + (($rewarded$[.@rewardablejobs[.@i]] != "") ? $rewarded$[.@rewardablejobs[.@i]] : "^ff0000Nobody^000000");
		}
		next;
		goto Begin;
}

You can change the maxbase and maxjob variables to match your server configuration, as well as define the minimum GM level to set the rewards on the NPC by changing gm_level variable.

Edited by Tyrfing
  • Upvote 1
  • Love 1

Share this post


Link to post
Share on other sites
  • 1
19 hours ago, Tyrfing said:

Here you go, please upvote my post.

mine -> https://rathena.org/board/topic/75015-asking-for-a-prize-npc/
pajodex -> https://rathena.org/board/topic/115293-race-to-99-rewards/#comment-344269

the similarity is there is always a permanent global variable, and your script is missing this thing

heh ... you got potential ... so I refrain from doing this one 😛

  • Love 1

Share this post


Link to post
Share on other sites
  • 1
1 hour ago, Yrok said:

Still error 😞Untitled.png.52a0bb71f47fbec5f3cd1bfb933dc249.png

look goto line 69 or look for this :

for ([email protected] = 0, [email protected] < getarraysize([email protected]); [email protected]++) {
	set $rewarded$[[email protected][[email protected]]], "";
}

and change to :

for ([email protected] = 0; [email protected] < getarraysize([email protected]); [email protected]++) {
	set $rewarded$[[email protected][[email protected]]], "";
}

Typo error only.. just changed the comma "," to semi colon ";"

Edited by pajodex
  • Upvote 1
  • Love 1

Share this post


Link to post
Share on other sites
  • 0
28 minutes ago, AnnieRuru said:

mine -> https://rathena.org/board/topic/75015-asking-for-a-prize-npc/
pajodex -> https://rathena.org/board/topic/115293-race-to-99-rewards/#comment-344269

the similarity is there is always a permanent global variable, and your script is missing this thing

heh ... you got potential ... so I refrain from doing this one 😛

I use a permanent variable attached to the character (maxlvlreward) to store whether he already received the reward, and an NPC variable to store the rewards set by the GM.

I could change this NPC variable to a permanent global variable in order to keep the rewards set by the GM across server restarts and NPC reloads. I suppose that is what you're talking about.

I see that in your script and on pajodex's you use a permanent global variable to hold the amount of players that have reached the maximum level.

Edited by Tyrfing

Share this post


Link to post
Share on other sites
  • 0

nono ... the permanent server variable $var has to be use here to prevent other players from claiming the prize

your script, you should try with multi-client
Player A reach the max level in the server, then Player B can again claim the prize again, Player C again can claim the prize

if done it with permanent server variable then only Player A can claim the prize

the variable maxlvlreward is on the wrong scope
should use $maxlvlreward[BaseJob] something like this

Share this post


Link to post
Share on other sites
  • 0

Ah, yes. I had misunderstood some of the formal requisites. I have just totally rewritten the code. 😉 Check it out on my first reply to this topic.

Edited by Tyrfing
  • Love 2

Share this post


Link to post
Share on other sites
  • 0

Error. Thank you btw 🙂

Untitled.png

Edited by Yrok

Share this post


Link to post
Share on other sites
  • 0

Use this.

* Removed because there was a bug in this version of the script. Please refer to this post for the bug-free version. *

Edited by Tyrfing

Share this post


Link to post
Share on other sites
  • 0

Still error 😞Untitled.png.52a0bb71f47fbec5f3cd1bfb933dc249.png

Share this post


Link to post
Share on other sites
  • 0

My bad. Thanks for the fix, pajodex.

Edited by Tyrfing

Share this post


Link to post
Share on other sites
  • 0
On 5/28/2018 at 10:29 PM, Tyrfing said:

My bad. Thanks for the fix, pajodex.

///////////////////////////////////////////////////////
//  ___________               _____.__                
//  \__    ___/__.__.________/ ____\__| ____    ____  
//    |    | <   |  |\_  __ \   __\|  |/    \  / ___\ 
//    |    |  \___  | |  | \/|  |  |  |   |  \/ /_/  >
//    |____|  / ____| |__|   |__|  |__|___|  /\___  / 
//            \/       Scripts             \//_____/  
//
//=====================================================
// Name: Race to Max Level
//
// Description:
// This NPC allows for Game Masters to set a reward to
// be given to the first player of each 2nd class that
// reaches maximum level (base and class).
//=====================================================
///////////////////////////////////////////////////////
prontera,147,180,5	script	Race to Max Level	58,{
	set .@gm_level, 99; // GM level required to set the reward
	set .@maxbase, 99;
	set .@maxjob, 50;
	set .@defaultreward, 510;
	setarray .@rewardablejobs[0], Job_Knight, Job_Alchemist, Job_Assassin, Job_Bard, Job_Blacksmith, Job_Crusader, Job_Dancer, Job_Hunter, Job_Monk, Job_Priest, Job_Rogue, Job_Sage, Job_Wizard;
	
	Begin:
	mes "[ ^0099ccRace to Max Level^000000 ]";
	mes "Hello, " + ((getgmlevel() >= .@gm_level) ? "master! What do you want to do today?" : "are you here for your reward?");
	next;
	switch(select(((getgmlevel() >= .@gm_level) ? "Set Reward:Restart Race" : ":") + ":YES!:...Reward?:Who was rewarded?:Cancel")) {
		case 1:
			goto SetReward;
		case 2:
			goto RestartRace;
		case 3:
			goto GetReward;
		case 4:
			goto ExplainRace;
		case 5:
			goto ShowRewarded;
		default:
			end;
	}
	
	SetReward:
		mes "[ ^0099ccRace to Max Level^000000 ]";
		if ($reward == 0)
			set $reward, .@defaultreward;
		mes "The reward is " + getitemname($reward) + " (ID: " + $reward + ").";
		mes "Do you want to change it?";
		next;
		if (select("Yes:No") == 1) {
			mes "[ ^0099ccRace to Max Level^000000 ]";
			mes "Please enter the new reward item ID.";
			input .@rewardid;			
			next;
			mes "[ ^0099ccRace to Max Level^000000 ]";
			mes "Set " + getitemname(.@rewardid) + " as the reward?";
			if(select("Yes:No") == 1) {
				set $reward, .@rewardid;
			}
		}
		goto Begin;
	
	RestartRace:
		mes "[ ^0099ccRace to Max Level^000000 ]";
		mes "Are you sure you want to restart the race?";
		next;
		if (select("Yes:No") == 1) {
			for (.@i = 0; .@i < getarraysize(.@rewardablejobs); .@i++) {
				set $rewarded$[.@rewardablejobs[.@i]], "";
			}
			announce "The Race to Max Level has begun! Claim a reward once you reach " + .@maxbase + " base and " + .@maxjob + " class!", bc_all;
		}
		goto Begin;
	
	GetReward:
		mes "Let's see... " + strcharinfo(0) + ", huh?";
		
		set .@competitioner, 0;
		for (.@i = 0; .@i < getarraysize(.@rewardablejobs); .@i++) {
			if (Class == .@rewardablejobs[.@i]) {
				set .@competitioner, 1;
				if (BaseLevel < .@maxbase || JobLevel < .@maxjob) {
					mes "I'm sorry, but you still need to level a bit more.";
				} else if ($rewarded$[Class] == strcharinfo(0)) {
					mes "You have already claimed your reward.";
				} else if ($rewarded$[Class] != "") {
					mes "Too late!";
					mes "The reward for " + jobname(Class) + " was already claimed by " + $rewarded$[Class] + ".";
				} else goto GiveReward;
			}
		}
		if (.@competitioner == 0)
			mes "You need to change your job.";
		close;
	
	GiveReward:
		set $rewarded$[Class], strcharinfo(0);
		next;
		mes "[ ^0099ccRace to Max Level^000000 ]";
		mes "Congratulations! You were the first " + jobname(Class) + " to reach " + .@maxbase + " base and " + .@maxjob + " class!";
		getitem $reward, 1;
		announce strcharinfo(0) + " (" + jobname(Class) + ") reached Max. Level and received " + getitemname($reward) + "!", bc_all;
		close;
	
	ExplainRace:
		mes "[ ^0099ccRace to Max Level^000000 ]";
		mes "Yes! When you reach the maximum level for your class, talk to me and you'll be rewarded with a special item.";
		next;
		goto Begin;
		
	ShowRewarded:
		mes "[ ^0099ccRace to Max Level^000000 ]";
		for (.@i = 0; .@i < getarraysize(.@rewardablejobs); .@i++) {
			mes jobname(.@rewardablejobs[.@i]) + ": " + (($rewarded$[.@rewardablejobs[.@i]] != "") ? $rewarded$[.@rewardablejobs[.@i]] : "^ff0000Nobody^000000");
		}
		next;
		goto Begin;
}

 

is this char base or account base only?

Share this post


Link to post
Share on other sites
  • 0
1 hour ago, skymia said:

is this char base or account base only?

Char-based

Share this post


Link to post
Share on other sites
  • 0

Thanks a lot its working now 🙂

Share this post


Link to post
Share on other sites
  • 0

Hello, sorry for necro but can someone change this into Trans job?

Share this post


Link to post
Share on other sites
  • 0
On 5/22/2018 at 8:13 AM, Tyrfing said:

I'm sorry, I made a mistake. Here you go, please upvote my post.

///////////////////////////////////////////////////////
//  ___________               _____.__                
//  \__    ___/__.__.________/ ____\__| ____    ____  
//    |    | <   |  |\_  __ \   __\|  |/    \  / ___\ 
//    |    |  \___  | |  | \/|  |  |  |   |  \/ /_/  >
//    |____|  / ____| |__|   |__|  |__|___|  /\___  / 
//            \/       Scripts             \//_____/  
//
//=====================================================
// Name: Race to Max Level
//
// Description:
// This NPC allows for Game Masters to set a reward to
// be given to the first player of each 2nd class that
// reaches maximum level (base and class).
//=====================================================
///////////////////////////////////////////////////////
prontera,147,180,5	script	Race to Max Level	58,{
	set .@gm_level, 99; // GM level required to set the reward
	set .@maxbase, 99;
	set .@maxjob, 50;
	set .@defaultreward, 510;
	setarray .@rewardablejobs[0], Job_Knight, Job_Alchemist, Job_Assassin, Job_Bard, Job_Blacksmith, Job_Crusader, Job_Dancer, Job_Hunter, Job_Monk, Job_Priest, Job_Rogue, Job_Sage, Job_Wizard;
	
	Begin:
	clear;
	mes "[ ^0099ccRace to Max Level^000000 ]";
	mes "Hello, " + ((getgmlevel() >= .@gm_level) ? "master! What do you want to do today?" : "are you here for your reward?");
	switch(select(((getgmlevel() >= .@gm_level) ? "Set Reward:Restart Race" : ":") + ":YES!:...Reward?:Who was rewarded?:Cancel")) {
		case 1:
			goto SetReward;
		case 2:
			goto RestartRace;
		case 3:
			goto GetReward;
		case 4:
			goto ExplainRace;
		case 5:
			goto ShowRewarded;
		default:
			end;
	}
	
	SetReward:
		clear;
		mes "[ ^0099ccRace to Max Level^000000 ]";
		if ($reward == 0)
			set $reward, .@defaultreward;
		mes "The reward is " + getitemname($reward) + " (ID: " + $reward + ").";
		mes "Do you want to change it?";
		if (select("Yes:No") == 1) {
			clear;
			mes "[ ^0099ccRace to Max Level^000000 ]";
			mes "Please enter the new reward item ID.";
			input .@rewardid;			
			clear;
			mes "[ ^0099ccRace to Max Level^000000 ]";
			mes "Set " + getitemname(.@rewardid) + " as the reward?";
			if(select("Yes:No") == 1) {
				set $reward, .@rewardid;
			}
		}
		goto Begin;
	
	RestartRace:
		clear;
		mes "[ ^0099ccRace to Max Level^000000 ]";
		mes "Are you sure you want to restart the race?";
		if (select("Yes:No") == 1) {
			for (.@i = 0; .@i < getarraysize(.@rewardablejobs); .@i++) {
				set $rewarded$[.@rewardablejobs[.@i]], "";
			}
			announce "The Race to Max Level has begun! Claim a reward once you reach " + .@maxbase + " base and " + .@maxjob + " class!", bc_all;
		}
		goto Begin;
	
	GetReward:
		mes "Let's see... " + strcharinfo(0) + ", huh?";
		
		set .@competitioner, 0;
		for (.@i = 0; .@i < getarraysize(.@rewardablejobs); .@i++) {
			if (Class == .@rewardablejobs[.@i]) {
				set .@competitioner, 1;
				if (BaseLevel < .@maxbase || JobLevel < .@maxjob) {
					mes "I'm sorry, but you still need to level a bit more.";
				} else if ($rewarded$[Class] == strcharinfo(0)) {
					mes "You have already claimed your reward.";
				} else if ($rewarded$[Class] != "") {
					mes "Too late!";
					mes "The reward for " + jobname(Class) + " was already claimed by " + $rewarded$[Class] + ".";
				} else goto GiveReward;
			}
		}
		if (.@competitioner == 0)
			mes "You need to change your job.";
		close;
	
	GiveReward:
		set $rewarded$[Class], strcharinfo(0);
		clear;
		mes "[ ^0099ccRace to Max Level^000000 ]";
		mes "Congratulations! You were the first " + jobname(Class) + " to reach " + .@maxbase + " base and " + .@maxjob + " class!";
		getitem $reward, 1;
		announce strcharinfo(0) + " (" + jobname(Class) + ") reached Max. Level and received " + getitemname($reward) + "!", bc_all;
		close;
	
	ExplainRace:
		clear;
		mes "[ ^0099ccRace to Max Level^000000 ]";
		mes "Yes! When you reach the maximum level for your class, talk to me and you'll be rewarded with a special item.";
		next;
		goto Begin;
		
	ShowRewarded:
		clear;
		mes "[ ^0099ccRace to Max Level^000000 ]";
		for (.@i = 0; .@i < getarraysize(.@rewardablejobs); .@i++) {
			mes jobname(.@rewardablejobs[.@i]) + ": " + (($rewarded$[.@rewardablejobs[.@i]] != "") ? $rewarded$[.@rewardablejobs[.@i]] : "^ff0000Nobody^000000");
		}
		next;
		goto Begin;
}

You can change the maxbase and maxjob variables to match your server configuration, as well as define the minimum GM level to set the rewards on the NPC by changing gm_level variable.

How to set the reward with random item?

Rare item: costume 1,costume 2,costume 3, etc.... with a 30% chance

Normal item: costume 1,costume 2,costume 3, etc.... with a 70% chance

Share this post


Link to post
Share on other sites
  • 0
Posted (edited)
On 5/14/2020 at 12:33 AM, skymia said:

How to set the reward with random item?

Rare item: costume 1,costume 2,costume 3, etc.... with a 30% chance

Normal item: costume 1,costume 2,costume 3, etc.... with a 70% chance

Been very busy and I'm not really very active in rAthena (or any other RO community) anylonger, but I had some spare time so here you go.

///////////////////////////////////////////////////////
//  ___________               _____.__
//  \__    ___/__.__.________/ ____\__| ____    ____
//    |    | <   |  |\_  __ \   __\|  |/    \  / ___\
//    |    |  \___  | |  | \/|  |  |  |   |  \/ /_/  >
//    |____|  / ____| |__|   |__|  |__|___|  /\___  /
//            \/       Scripts             \//_____/
//
//=====================================================
// Name: Race to Max Level (v2)
//
// Description:
// This NPC allows for Game Masters to set rewards to
// be given to the first player of each 2nd class that
// reaches the maximum level (base and class).
//
// Changes relative to v1:
// - Support for multiple rewards in two categories
// (rare and common).
// - Support for setting rewards by name in-game
// (requires SQL item_db). Otherwise, specify item ID.
// - Support for setting the rare rates in-game.
//
// Additional info:
// - Remember to change [email protected]_item_db to 1 if you use
// a SQL item_db.
//=====================================================
///////////////////////////////////////////////////////
prontera,147,180,5	script	Race to Max Level	58,{
	// GM level required to change the reward
	set .@gm_level, 99;

	// Set this to 1 if you are using SQL item_db.
	set .@sql_item_db, 0;

	// The item_db SQL table name.
	set .@item_db_table$, "item_db_re";

	// Base and job levels required
	set .@maxbase, 99;
	set .@maxjob, 50;

	// The default/initial percentage for rare items.
  set .@rare_chance, 30;

  // Rewards. Remember, you can change these in-game too!
  setarray .@default_rare_rewards[0], 510, 511, 512, 513, 514;
  setarray .@default_common_rewards[0], 510, 511, 512, 513, 514;

	if ($r99_rare_chance == 0)
		$r99_rare_chance = .@rare_chance;
	if (getarraysize($rare_rewards) == 0)
		copyarray $rare_rewards[0], .@default_rare_rewards[0], getarraysize(.@default_rare_rewards);

	if (getarraysize($common_rewards) == 0)
		copyarray $common_rewards[0], .@default_common_rewards[0], getarraysize(.@default_common_rewards);

	setarray .@rewardablejobs[0], Job_Knight, Job_Alchemist, Job_Assassin, Job_Bard, Job_Blacksmith, Job_Crusader, Job_Dancer, Job_Hunter, Job_Monk, Job_Priest, Job_Rogue, Job_Sage, Job_Wizard;

	function SelectFromArray;
	function ListRewards;

	Begin:
		clear;
		mes "[ ^0099ccRace to Max Level^000000 ]";
		mes "Hello, " + ((getgmlevel() >= .@gm_level) ? "master! What do you want to do today?" : "are you here for your reward?");
		if (getgmlevel() >= .@gm_level) {
			.@select$ = "Change rare item chance:Update rewards:Restart race:Test reward:View explanation:Show rewarded players:Cancel";
			switch(select(.@select$)) {
				case 1:
					goto ChangeRate;
				case 2:
					goto UpdateRewards;
				case 3:
					goto RestartRace;
				case 4:
					goto GetReward;
				case 5:
					goto ExplainRace;
				case 6:
					goto ShowRewarded;
				default:
					end;
			}
		} else {
			.@select$ = "YES!:...What reward?:Who was rewarded?:Cancel";
			switch(select(.@select$)) {
				case 1:
					goto GetReward;
				case 2:
					goto ExplainRace;
				case 3:
					goto ShowRewarded;
				default:
					end;
			}
		}

	ChangeRate:
		clear;
		mes "[ ^0099ccRace to Max Level^000000 ]";
		mes "The rare item rate is currently set to ^0099cc" + $r99_rare_chance + "%^000000.";
		mes "What do you want to change it to?";
		input .@new_rate;
		set $r99_rare_chance, .@new_rate;
		mes "Done!";
		next;
		goto Begin;

  // TODO: Provide a means to update the rewards arrays
	UpdateRewards:
		clear;
		mes "[ ^0099ccRace to Max Level^000000 ]";
		mes "Choose which rewards you want to review or update.";
		switch (select("Rare rewards:Common rewards:Cancel")) {
			case 1:
				goto UpdateRareRewards;
			case 2:
				goto UpdateCommonRewards;
			default:
				end;
		}
		// mes "The reward is " + getitemname($reward) + " (ID: " + $reward + ").";
		// mes "Do you want to change it?";
		// if (select("Yes:No") == 1) {
		// 	clear;
		// 	mes "[ ^0099ccRace to Max Level^000000 ]";
		// 	mes "Please enter the new reward item ID.";
		// 	input [email protected];
		// 	clear;
		// 	mes "[ ^0099ccRace to Max Level^000000 ]";
		// 	mes "Set " + getitemname([email protected]) + " as the reward?";
		// 	if(select("Yes:No") == 1) {
		// 		set $reward, [email protected];
		// 	}
		// }
		goto Begin;

	UpdateRareRewards:
		clear;
		mes "[ ^0099ccRace to Max Level^000000 ]";
		mes "These are the rare rewards:";
		ListRewards($rare_rewards);
		if (select("Change reward:Cancel") == 1) {
			clear;
			mes "[ ^0099ccRace to Max Level^000000 ]";
			mes "Which reward do you want to change?";
			.@selected_reward = SelectFromArray($rare_rewards);
			clear;
			mes "[ ^0099ccRace to Max Level^000000 ]";
			mes "Ah, the ^0099cc" + getitemname($rare_rewards[.@selected_reward - 1]) + "^000000.";
			if (.@sql_item_db == 1) {
				mes "What do you want to change it to? (Item name)";
				input .@new_reward$;
				.@sql$ = "SELECT id from `"+ .@item_db_table$ +"` WHERE name_japanese LIKE '%"+ escape_sql(.@new_reward$) +"%'";
				query_sql(.@sql$, .@sql_results);
				.@selected = SelectFromArray(.@sql_results);
				.@selected = .@sql_results[.@selected - 1];
			} else {
				mes "What do you want to change it to? (Item ID)";
				input .@selected;
			}
			clear;
			mes "[ ^0099ccRace to Max Level^000000 ]";
			mes "Update to ^0099cc" + getitemname(.@selected) + "^000000?";
			if (select("Yes:No") == 1) {
				clear;
				mes "[ ^0099ccRace to Max Level^000000 ]";
				mes "Item updated.";
				$rare_rewards[.@selected_reward - 1] = .@selected;
				next;
			}
		}
		goto Begin;

	UpdateCommonRewards:
		clear;
		mes "[ ^0099ccRace to Max Level^000000 ]";
		mes "These are the common rewards:";
		ListRewards($common_rewards);
		if (select("Change reward:Cancel") == 1) {
			clear;
			mes "[ ^0099ccRace to Max Level^000000 ]";
			mes "Which reward do you want to change?";
			.@selected_reward = SelectFromArray($common_rewards);
			clear;
			mes "[ ^0099ccRace to Max Level^000000 ]";
			mes "Ah, the ^0099cc" + getitemname($common_rewards[.@selected_reward - 1]) + "^000000.";
			if (.@sql_item_db == 1) {
				mes "What do you want to change it to? (Item name)";
				input .@new_reward$;
				.@sql$ = "SELECT id from `"+ .@item_db_table$ +"` WHERE name_japanese LIKE '%"+ escape_sql(.@new_reward$) +"%'";
				query_sql(.@sql$, .@sql_results);
				.@selected = SelectFromArray(.@sql_results);
				.@selected = .@sql_results[.@selected - 1];
			} else {
				mes "What do you want to change it to? (Item ID)";
				input .@selected;
			}
			clear;
			mes "[ ^0099ccRace to Max Level^000000 ]";
			mes "Update to ^0099cc" + getitemname(.@selected) + "^000000?";
			if (select("Yes:No") == 1) {
				clear;
				mes "[ ^0099ccRace to Max Level^000000 ]";
				mes "Item updated.";
				$common_rewards[.@selected_reward - 1] = .@selected;
				next;
			}
		}
		goto Begin;

	RestartRace:
		clear;
		mes "[ ^0099ccRace to Max Level^000000 ]";
		mes "Are you sure you want to restart the race?";
		if (select("Yes:No") == 1) {
			for (.@i = 0; .@i < getarraysize(.@rewardablejobs); .@i++) {
				set $rewarded$[.@rewardablejobs[.@i]], "";
			}
			announce "The Race to Max Level has begun! Claim a reward once you reach " + .@maxbase + " base and " + .@maxjob + " class!", bc_all;
		}
		goto Begin;

	GetReward:
		mes "Let's see... " + strcharinfo(0) + ", huh?";

		set .@competitioner, 0;
		for (.@i = 0; .@i < getarraysize(.@rewardablejobs); .@i++) {
			if (Class == .@rewardablejobs[.@i]) {
				set .@competitioner, 1;
				if (BaseLevel < .@maxbase || JobLevel < .@maxjob) {
					mes "I'm sorry, but you still need to level a bit more.";
				} else if ($rewarded$[Class] == strcharinfo(0)) {
					mes "You have already claimed your reward.";
				} else if ($rewarded$[Class] != "") {
					mes "Too late!";
					mes "The reward for " + jobname(Class) + " was already claimed by " + $rewarded$[Class] + ".";
				} else goto GiveReward;
			}
		}
		if (.@competitioner == 0)
			mes "You need to change your job.";
		close;

	GiveReward:
		set $rewarded$[Class], strcharinfo(0);
		clear;
		mes "[ ^0099ccRace to Max Level^000000 ]";
		mes "Congratulations! You were the first " + jobname(Class) + " to reach " + .@maxbase + " base and " + .@maxjob + " class!";

		// Choose item category based on probability
    set .@itemCategory, 0;
    set .@chance, rand(100);
    if (.@chance < $r99_rare_chance) {
      set .@itemCategory, 1;
    }

    if (.@itemCategory == 0) {
      set .@reward, $common_rewards[rand(getarraysize($common_rewards))];
			.@type$ = "Common";
    } else {
      set .@reward, $rare_rewards[rand(getarraysize($rare_rewards))];
			.@type$ = "Rare";
    }

		getitem .@reward, 1;
		announce strcharinfo(0) + " (" + jobname(Class) + ") reached Max. Level and received " + getitemname(.@reward) + " ("+ .@type$ +") !", bc_all;
		close;

	ExplainRace:
		clear;
		mes "[ ^0099ccRace to Max Level^000000 ]";
		mes "Yes! When you reach the maximum level for your class, talk to me and you'll be rewarded with a special item.";
    if ($r99_rare_chance > 0) {
      mes "There is ^0099cc" + $r99_rare_chance + "%^000000 of chance that you'll get a rare item!";
      mes "Possible rare items:";
			set .@length, getarraysize($rare_rewards);
      for (.@i = 0; .@i < .@length; .@i++) {
        set .@item, $rare_rewards[.@i];
        mes " - " + getitemname(.@item);
      }
    }
		mes "Possible common items:";
		set .@length, getarraysize($common_rewards);
		for (.@i = 0; .@i < .@length; .@i++) {
			set .@item, $common_rewards[.@i];
			mes " - " + getitemname(.@item);
		}
		next;
		goto Begin;

	ShowRewarded:
		clear;
		mes "[ ^0099ccRace to Max Level^000000 ]";
		for (.@i = 0; .@i < getarraysize(.@rewardablejobs); .@i++) {
			mes jobname(.@rewardablejobs[.@i]) + ": " + (($rewarded$[.@rewardablejobs[.@i]] != "") ? "^0055ff" + $rewarded$[.@rewardablejobs[.@i]] + "^000000" : "^999999Nobody^000000");
		}
		next;
		goto Begin;

	function SelectFromArray {
		.@size = getarraysize(getarg(0));
		.@rewards_s$ = "";
		for (.@i = 0; .@i < .@size; .@i++) {
			.@rewards_s$ = .@rewards_s$ + getitemname(getelementofarray(getarg(0), .@i )) + ":";
		}
		return select(.@rewards_s$);
	}

	function ListRewards {
		.@rewards = getarg(0);
		.@size = getarraysize(getarg(0));
		for (.@i = 0; .@i < .@size; .@i++) {
			mes .@i + 1 + ". " + getitemname(getelementofarray(getarg(0), .@i));
		}
	}
}

It would probably take me longer to make a version that supports transcendental classes, which I can't really afford to do now.

Edited by Tyrfing

Share this post


Link to post
Share on other sites
  • 0
7 hours ago, Tyrfing said:

Been very busy and I'm not really very active in rAthena (or any other RO community) anylonger, but I had some spare time so here you go.

///////////////////////////////////////////////////////
//  ___________               _____.__
//  \__    ___/__.__.________/ ____\__| ____    ____
//    |    | <   |  |\_  __ \   __\|  |/    \  / ___\
//    |    |  \___  | |  | \/|  |  |  |   |  \/ /_/  >
//    |____|  / ____| |__|   |__|  |__|___|  /\___  /
//            \/       Scripts             \//_____/
//
//=====================================================
// Name: Race to Max Level (v2)
//
// Description:
// This NPC allows for Game Masters to set rewards to
// be given to the first player of each 2nd class that
// reaches the maximum level (base and class).
//
// Changes relative to v1:
// - Support for multiple rewards in two categories
// (rare and common).
// - Support for setting rewards by name in-game
// (requires SQL item_db). Otherwise, specify item ID.
// - Support for setting the rare rates in-game.
//
// Additional info:
// - Remember to change [email protected]_item_db to 1 if you use
// a SQL item_db.
//=====================================================
///////////////////////////////////////////////////////
prontera,147,180,5	script	Race to Max Level	58,{
	// GM level required to change the reward
	set .@gm_level, 99;

	// Set this to 1 if you are using SQL item_db.
	set .@sql_item_db, 0;

	// The item_db SQL table name.
	set .@item_db_table$, "item_db_re";

	// Base and job levels required
	set .@maxbase, 99;
	set .@maxjob, 50;

	// The default/initial percentage for rare items.
  set .@rare_chance, 30;

  // Rewards. Remember, you can change these in-game too!
  setarray .@default_rare_rewards[0], 510, 511, 512, 513, 514;
  setarray .@default_common_rewards[0], 510, 511, 512, 513, 514;

	if ($r99_rare_chance == 0)
		$r99_rare_chance = .@rare_chance;
	if (getarraysize($rare_rewards) == 0)
		copyarray $rare_rewards[0], .@default_rare_rewards[0], getarraysize(.@default_rare_rewards);

	if (getarraysize($common_rewards) == 0)
		copyarray $common_rewards[0], .@default_common_rewards[0], getarraysize(.@default_common_rewards);

	setarray .@rewardablejobs[0], Job_Knight, Job_Alchemist, Job_Assassin, Job_Bard, Job_Blacksmith, Job_Crusader, Job_Dancer, Job_Hunter, Job_Monk, Job_Priest, Job_Rogue, Job_Sage, Job_Wizard;

	function SelectFromArray;
	function ListRewards;

	Begin:
		clear;
		mes "[ ^0099ccRace to Max Level^000000 ]";
		mes "Hello, " + ((getgmlevel() >= .@gm_level) ? "master! What do you want to do today?" : "are you here for your reward?");
		if (getgmlevel() >= .@gm_level) {
			.@select$ = "Change rare item chance:Update rewards:Restart race:Test reward:View explanation:Show rewarded players:Cancel";
			switch(select(.@select$)) {
				case 1:
					goto ChangeRate;
				case 2:
					goto UpdateRewards;
				case 3:
					goto RestartRace;
				case 4:
					goto GetReward;
				case 5:
					goto ExplainRace;
				case 6:
					goto ShowRewarded;
				default:
					end;
			}
		} else {
			.@select$ = "YES!:...What reward?:Who was rewarded?:Cancel";
			switch(select(.@select$)) {
				case 1:
					goto GetReward;
				case 2:
					goto ExplainRace;
				case 3:
					goto ShowRewarded;
				default:
					end;
			}
		}

	ChangeRate:
		clear;
		mes "[ ^0099ccRace to Max Level^000000 ]";
		mes "The rare item rate is currently set to ^0099cc" + $r99_rare_chance + "%^000000.";
		mes "What do you want to change it to?";
		input .@new_rate;
		set $r99_rare_chance, .@new_rate;
		mes "Done!";
		next;
		goto Begin;

  // TODO: Provide a means to update the rewards arrays
	UpdateRewards:
		clear;
		mes "[ ^0099ccRace to Max Level^000000 ]";
		mes "Choose which rewards you want to review or update.";
		switch (select("Rare rewards:Common rewards:Cancel")) {
			case 1:
				goto UpdateRareRewards;
			case 2:
				goto UpdateCommonRewards;
			default:
				end;
		}
		// mes "The reward is " + getitemname($reward) + " (ID: " + $reward + ").";
		// mes "Do you want to change it?";
		// if (select("Yes:No") == 1) {
		// 	clear;
		// 	mes "[ ^0099ccRace to Max Level^000000 ]";
		// 	mes "Please enter the new reward item ID.";
		// 	input [email protected];
		// 	clear;
		// 	mes "[ ^0099ccRace to Max Level^000000 ]";
		// 	mes "Set " + getitemname([email protected]) + " as the reward?";
		// 	if(select("Yes:No") == 1) {
		// 		set $reward, [email protected];
		// 	}
		// }
		goto Begin;

	UpdateRareRewards:
		clear;
		mes "[ ^0099ccRace to Max Level^000000 ]";
		mes "These are the rare rewards:";
		ListRewards($rare_rewards);
		if (select("Change reward:Cancel") == 1) {
			clear;
			mes "[ ^0099ccRace to Max Level^000000 ]";
			mes "Which reward do you want to change?";
			.@selected_reward = SelectFromArray($rare_rewards);
			clear;
			mes "[ ^0099ccRace to Max Level^000000 ]";
			mes "Ah, the ^0099cc" + getitemname($rare_rewards[.@selected_reward - 1]) + "^000000.";
			if (.@sql_item_db == 1) {
				mes "What do you want to change it to? (Item name)";
				input .@new_reward$;
				.@sql$ = "SELECT id from `"+ .@item_db_table$ +"` WHERE name_japanese LIKE '%"+ escape_sql(.@new_reward$) +"%'";
				query_sql(.@sql$, .@sql_results);
				.@selected = SelectFromArray(.@sql_results);
				.@selected = .@sql_results[.@selected - 1];
			} else {
				mes "What do you want to change it to? (Item ID)";
				input .@selected;
			}
			clear;
			mes "[ ^0099ccRace to Max Level^000000 ]";
			mes "Update to ^0099cc" + getitemname(.@selected) + "^000000?";
			if (select("Yes:No") == 1) {
				clear;
				mes "[ ^0099ccRace to Max Level^000000 ]";
				mes "Item updated.";
				$rare_rewards[.@selected_reward - 1] = .@selected;
				next;
			}
		}
		goto Begin;

	UpdateCommonRewards:
		clear;
		mes "[ ^0099ccRace to Max Level^000000 ]";
		mes "These are the common rewards:";
		ListRewards($common_rewards);
		if (select("Change reward:Cancel") == 1) {
			clear;
			mes "[ ^0099ccRace to Max Level^000000 ]";
			mes "Which reward do you want to change?";
			.@selected_reward = SelectFromArray($common_rewards);
			clear;
			mes "[ ^0099ccRace to Max Level^000000 ]";
			mes "Ah, the ^0099cc" + getitemname($common_rewards[.@selected_reward - 1]) + "^000000.";
			if (.@sql_item_db == 1) {
				mes "What do you want to change it to? (Item name)";
				input .@new_reward$;
				.@sql$ = "SELECT id from `"+ .@item_db_table$ +"` WHERE name_japanese LIKE '%"+ escape_sql(.@new_reward$) +"%'";
				query_sql(.@sql$, .@sql_results);
				.@selected = SelectFromArray(.@sql_results);
				.@selected = .@sql_results[.@selected - 1];
			} else {
				mes "What do you want to change it to? (Item ID)";
				input .@selected;
			}
			clear;
			mes "[ ^0099ccRace to Max Level^000000 ]";
			mes "Update to ^0099cc" + getitemname(.@selected) + "^000000?";
			if (select("Yes:No") == 1) {
				clear;
				mes "[ ^0099ccRace to Max Level^000000 ]";
				mes "Item updated.";
				$common_rewards[.@selected_reward - 1] = .@selected;
				next;
			}
		}
		goto Begin;

	RestartRace:
		clear;
		mes "[ ^0099ccRace to Max Level^000000 ]";
		mes "Are you sure you want to restart the race?";
		if (select("Yes:No") == 1) {
			for (.@i = 0; .@i < getarraysize(.@rewardablejobs); .@i++) {
				set $rewarded$[.@rewardablejobs[.@i]], "";
			}
			announce "The Race to Max Level has begun! Claim a reward once you reach " + .@maxbase + " base and " + .@maxjob + " class!", bc_all;
		}
		goto Begin;

	GetReward:
		mes "Let's see... " + strcharinfo(0) + ", huh?";

		set .@competitioner, 0;
		for (.@i = 0; .@i < getarraysize(.@rewardablejobs); .@i++) {
			if (Class == .@rewardablejobs[.@i]) {
				set .@competitioner, 1;
				if (BaseLevel < .@maxbase || JobLevel < .@maxjob) {
					mes "I'm sorry, but you still need to level a bit more.";
				} else if ($rewarded$[Class] == strcharinfo(0)) {
					mes "You have already claimed your reward.";
				} else if ($rewarded$[Class] != "") {
					mes "Too late!";
					mes "The reward for " + jobname(Class) + " was already claimed by " + $rewarded$[Class] + ".";
				} else goto GiveReward;
			}
		}
		if (.@competitioner == 0)
			mes "You need to change your job.";
		close;

	GiveReward:
		set $rewarded$[Class], strcharinfo(0);
		clear;
		mes "[ ^0099ccRace to Max Level^000000 ]";
		mes "Congratulations! You were the first " + jobname(Class) + " to reach " + .@maxbase + " base and " + .@maxjob + " class!";

		// Choose item category based on probability
    set .@itemCategory, 0;
    set .@chance, rand(100);
    if (.@chance < $r99_rare_chance) {
      set .@itemCategory, 1;
    }

    if (.@itemCategory == 0) {
      set .@reward, $common_rewards[rand(getarraysize($common_rewards))];
			.@type$ = "Common";
    } else {
      set .@reward, $rare_rewards[rand(getarraysize($rare_rewards))];
			.@type$ = "Rare";
    }

		getitem .@reward, 1;
		announce strcharinfo(0) + " (" + jobname(Class) + ") reached Max. Level and received " + getitemname(.@reward) + " ("+ .@type$ +") !", bc_all;
		close;

	ExplainRace:
		clear;
		mes "[ ^0099ccRace to Max Level^000000 ]";
		mes "Yes! When you reach the maximum level for your class, talk to me and you'll be rewarded with a special item.";
    if ($r99_rare_chance > 0) {
      mes "There is ^0099cc" + $r99_rare_chance + "%^000000 of chance that you'll get a rare item!";
      mes "Possible rare items:";
			set .@length, getarraysize($rare_rewards);
      for (.@i = 0; .@i < .@length; .@i++) {
        set .@item, $rare_rewards[.@i];
        mes " - " + getitemname(.@item);
      }
    }
		mes "Possible common items:";
		set .@length, getarraysize($common_rewards);
		for (.@i = 0; .@i < .@length; .@i++) {
			set .@item, $common_rewards[.@i];
			mes " - " + getitemname(.@item);
		}
		next;
		goto Begin;

	ShowRewarded:
		clear;
		mes "[ ^0099ccRace to Max Level^000000 ]";
		for (.@i = 0; .@i < getarraysize(.@rewardablejobs); .@i++) {
			mes jobname(.@rewardablejobs[.@i]) + ": " + (($rewarded$[.@rewardablejobs[.@i]] != "") ? "^0055ff" + $rewarded$[.@rewardablejobs[.@i]] + "^000000" : "^999999Nobody^000000");
		}
		next;
		goto Begin;

	function SelectFromArray {
		.@size = getarraysize(getarg(0));
		.@rewards_s$ = "";
		for (.@i = 0; .@i < .@size; .@i++) {
			.@rewards_s$ = .@rewards_s$ + getitemname(getelementofarray(getarg(0), .@i )) + ":";
		}
		return select(.@rewards_s$);
	}

	function ListRewards {
		.@rewards = getarg(0);
		.@size = getarraysize(getarg(0));
		for (.@i = 0; .@i < .@size; .@i++) {
			mes .@i + 1 + ". " + getitemname(getelementofarray(getarg(0), .@i));
		}
	}
}

It would probably take me longer to make a version that supports transcendental classes, which I can't really afford to do now.

i will try this later thanks sir

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.   Paste as plain text instead

  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.

Sign in to follow this  

×
×
  • Create New...

Important Information

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