Jump to content
  • 0
ItsFree

R> a NPC with progressbar & those with % to get one of a list of items [Solved]

Question

Hi, rAthena Community i wanna request a NPC with this... i guess is possible because i saw a similar time ago (was a fishing npc as i remember...)
The NPC Requested:

1.- the NPC will give you 1 item at random of a list of X amount of items (i dont know could get a jellopy or a fluff or a poring coing, etc).

2.- before the NPC give you that random item, first the npc will ask you to give 1 of the next 4 items: Bronze Coin(673), Silver Coin (675), Gold Coin (671) & Platinum Coin (677).

3.- if you give bronze coin, a progressbar will show with a duration of 10 seconds, if you give silver again a progressbar with 8 seconds... gold -> 5 seconds, platinum - 2 seconds.

The percent (%) of the items i want they be editable (i mean i can select if 10% which item, or 1%, etc).

After the progressbar start... the npc will deleted your item (coin).

Extra: if could add something like an announce when the player get a "very rare item" would be nice.

 

Thx... as i said i saw a similar NPC like this some years ago was a fishing script or something like that, that fishing npc tell you that you need a fishing bait, and stuff like that as i remember... that npc had the progress bar also the announce, the 1 item of a list and the % of the items, the only thing that didnt have was that option of "if you give this item the wait will be less"

 

i gonna try find that script to have a better idea... and adding that script here if helps :P thx... if dont understand something... just tell me to explain it better

 

Edit:

 

these are the scripts i found and were "similar" that i want:

 

prontera,160,172,0	script	Fishing Hole	844,{
	
//Fishing rod
set [email protected],2764;
//Fishing Lure
set [email protected],2775;
//Auto-Fish
set [email protected],1;
//Auto-Fish on Fail
set [email protected],1;
Fish:
	if (isequipped([email protected])) && (isequipped([email protected])){
		specialeffect EF_BUBBLE,"Fishing Hole";
		soundeffect "fishingrod.wav",0;
		dispbottom "[Fishing] Casting...";
		set [email protected],15;
			if (isequipped(2550)) { //Fisher's Muffler
				set [email protected],[email protected] - 2;
			}
			if (isequipped(2443)) { //Fisher's Boots
				set [email protected],[email protected] - 2;
			}
			if (isequipped(2764)) { //Fishing Pole
				set [email protected],[email protected] - 3;
			}
			if (isequipped(2775)) { //Fishing Lure
				set [email protected],[email protected] - 1;
			}
		progressbar "ffffff",[email protected];
		if (rand(1,20) == 2){
		getitem 6096,1; //Fish with Blue Back
		specialeffect2 EF_TEMP_OK;
		soundeffectall "success.wav",0,strcharinfo(3);
		mapannounce strcharinfo(3),strcharinfo(0)+" has caught a Blue Fish!",bc_map,"0xff77ff";
		if([email protected]==1){
		goto Fish;}else{
		end;}
		}
			if (rand(1,6) == 1) ||(rand(1,6) == 3) || (rand(1,6) == 6){
			setarray [email protected][0],579,908,909,963,956,6049,918,960,910,938,624;// List of Junk/Other
			set [email protected],[email protected][rand(getarraysize([email protected]))];
			getitem [email protected],1;
			}
			else {
			dispbottom "[Fishing] Nothing was caught...";
			if([email protected] == 1){
			goto Fish;} else{
			end;}
			}
		if (rand(1,100) == 3){
		setarray [email protected][0],644,603,617;
		set [email protected], [email protected][rand(getarraysize([email protected]))];
		getitem [email protected],1; //Reward
		mapannounce strcharinfo(3),strcharinfo(0)+" has caught a "+getitemname([email protected])+"!",bc_map,"0x33CC00";
		}
		if([email protected] == 1){
		goto Fish;} else{
		end;}
		}
	else {
	dispbottom "[Fishing] You need a Rod and Lure.";
	end;
	}
}

also this
 

comodo,196,112,6 script School of Fish 723,{
if(countitem(632) < 1) goto L_Exit;
L_Exit:
mes "You do not have Fatty Chubby.";
close;
delitem 632,1;
if (isequipped(2764)) && (isequipped(2775)){
specialeffect2 EF_BUBBLE;
set [email protected],15;
if (isequipped(2550)) set [email protected],[email protected]; //Fisher's Muffler.
}
if (isequipped(2443)) set [email protected],[email protected]; //Fish_Shoes
}
if (isequipped(5380)) set [email protected],[email protected]; //Fish_Shoes
}
progressbar "ffffff",[email protected];
if (rand(1,20) == 2) {
getitem 6096,5; //Big Fish
specialeffect EF_BUBBLE;
mapannounce "comodo","" + strcharinfo(0) + " has caught a 5 Tuna!!!",bc_map,"0xff77ff";
end;
}
set [email protected]_ran,rand(1,70);
if ([email protected]_ran < 20) {
specialeffect2 610;
getitem 29183,1; //Anchovy

}
else if ([email protected]_ran == 20) {
specialeffect2 610;
getitem 29184,1; //Bass

}
else if ([email protected]_ran == 21) {
specialeffect2 610;
getitem 29185,1; //Crab

}
else if ([email protected]_ran == 22) {
specialeffect2 610;
getitem 29186,1; //Eel

}
else if ([email protected]_ran == 23) {
specialeffect2 610;
getitem 29187,1; //Jelly Fish

}
else if ([email protected]_ran == 24) {
specialeffect2 610;
getitem 29188,1; //Lobster

}
else if ([email protected]_ran == 25) {
specialeffect2 610;
getitem 29189,1; //Perch

}
else if ([email protected]_ran == 26) {
specialeffect2 610;
getitem 29190,1; //Pike

}
else if ([email protected]_ran == 27) {
specialeffect2 610;
getitem 29191,1; //Puffer

}
else if ([email protected]_ran == 28) {
specialeffect2 610;
getitem 9192,1; //Salmon
}
else if (([email protected]_ran > 28) && ([email protected]_ran < 40)) {
specialeffect2 610;
getitem 632,1; //Fatty Chubby Earthworm

}
else {
mes "Nothing was caught.";
specialeffect2 611;
close;
}
if (rand(1,200) == 3) {
getitem 6096,20; //Gift_Box
mapannounce "comodo","" + strcharinfo(0) + " has caught a 20 Tuna Fish!!",bc_map,"0x0000ff";
}
if (rand(1,500) == 3) {
getitem 6096,30; //Old_Blue_Box
mapannounce "comodo","" + strcharinfo(0) + " has caught an 30 Tuna Fish!",bc_map,"0x00ffff";
}
if (rand(1,3000) == 3) {
getitem 6096,50; //Old_Violet_Box
mapannounce "comodo","" + strcharinfo(0) + " has caught an 50 Tuna Fish!!",bc_map,"0x44ff44";
}
end;
}
else {
mes "Fish are swimming in the water.";
close;
}
}

comodo.gat,189,108,4 duplicate(School of Fish) School of Fish#1 1158
comodo.gat,183,111,4 duplicate(School of Fish) Tilapya#20 2082
comodo.gat,218,108,4 duplicate(School of Fish) School of Fish#21 1069
comodo.gat,228,108,3 duplicate(School of Fish) School of Fish#22 1158
comodo.gat,214,112,4 duplicate(School of Fish) School of Fish#23 723
comodo.gat,189,122,4 duplicate(School of Fish) Mr Crab#23 1073
comodo.gat,192,106,4 duplicate(School of Fish) Octopus#23 1144
//Shop
comodo,205,112,4 shop Bulantiro 1543,2764:50000000,2775:50000000,2550:100000000,2443:200000000

those scripts its to have a more clear idea

Edited by ItsFree
Link to comment
Share on other sites

9 answers to this question

Recommended Posts

  • 2
prontera,158,173,4	script	CoinExchanger	88,{

	mes("Welcome");
	mes("Please give me your coins...");

	// Check Inventory for Coins
	getinventorylist;

	freeloop(true);
	[email protected] = 0;
	for([email protected]_index = 0; [email protected]_index < getarraysize(.exchange_ids); [email protected]_index++) {
		for([email protected] = 0; [email protected] < @inventorylist_count; [email protected]++) {

			if (@inventorylist_id[.[email protected]] == .exchange_ids[[email protected]_index]) {
				if (@inventorylist_amount[[email protected]] >= .exchange_amount[[email protected]_index]) {
					set([email protected]_coin_index[[email protected]], [email protected]_index);
					set([email protected]$, [email protected]$ + ( [email protected]$ == "" ? "" : ":" ) + getitemname(.exchange_ids[[email protected]_index]) + "(" + @inventorylist_amount[[email protected]] + ")");
					[email protected]++;
				}
			}
		}
	}
	freeloop(false);

	if ([email protected]$ == "") {
		next;
		mes("You do not have any coins!");
		close;
	}

	// Display Option to Show them choices and how many coins they have...
	set [email protected], select([email protected]$) - 1; // Subtract 1 to get Array Index
	set [email protected], [email protected]_coin_index[[email protected]];

	// dispbottom("You have chosen to use " + getitemname(.exchange_ids[[email protected]]) );
	// dispbottom("Progress bar Duration is: " + .exchange_duration[[email protected]] + " seconds.");

	mes("Goodluck");
	close2;

	progressbar("00FF00", .exchange_duration[[email protected]]); // Start the Progressbar

	// On Progress Bar Completion... let's see what we do here...
	delitem(.exchange_ids[[email protected]], .exchange_amount[[email protected]]);
	freeloop(true);
	for([email protected] = 0; [email protected] < getarraysize(.available_items); [email protected]++) {
		[email protected] = rand(1, 100);
		if ([email protected] <= .available_chance[[email protected]]) { // GET THE ITEM
			mes "Here you go";
			getitem(.available_items[[email protected]], .available_amount[[email protected]]);
			if (.available_chance[[email protected]] <= .announce_level_chance) {
				announce(strcharinfo(0) + " just scored " + getitemname(.available_items[[email protected]]), bc_all, C_YELLOW);
			}
			close;
		}
	}
	freeloop(false);

	mes("You got the default prize...");
	getitem(.default_item, .default_amount);
	close;

	OnInit:
		setarray(.exchange_ids, 673, 675, 671, 677);
		setarray(.exchange_amount, 1, 1, 1, 1);
		setarray(.exchange_duration, 10, 8, 5, 2); // # of seconds to progressbar...

		setarray(.available_items, 501, 502, 503, 504);
		setarray(.available_amount, 1, 1, 1, 1);
		setarray(.available_chance, 50, 40, 30, 10); // % of 100

		set(.announce_level_chance, 10); // Will only display announce if they get item 504... since it's the only one with 10 chance or lower

		set(.default_item, 501);
		set(.default_amount, 1);
		end;

}

This should work

Link to comment
Share on other sites

  • 0

Crude and Highly Untested

prontera,158,173,4	script	CoinExchanger	88,{

	mes("Welcome");
	mes("Please give me your coins...");
	
	// Check Inventory for Coins
	getinventorylist;

	freeloop(true);
	for([email protected]_index = 0; [email protected]_index < getarraysize(.exchange_ids); [email protected]_index++) {
		for([email protected] = 0; [email protected] < @inventorylist_count, [email protected]++) {
			if (@inventorylist_id[[email protected]] == .exchange_ids[[email protected]_index]) {
				if (@inventorylist_amount[[email protected]] >= .exchange_amount[[email protected]_index]) {
					set([email protected]_coin_index[getarraysize([email protected]_coin_index)], [email protected]_index);
					set([email protected]$, ( [email protected]$ = "" ? "" : ":" ) + getitemname(.exchange_ids[[email protected]_index]) + "(" + @inventorylist_amount[[email protected]] + ")");
				}
			}
		}
	}
	freeloop(false);

	// Display Option to Show them choices and how many coins they have...
	set [email protected], select([email protected]$) - 1; // Subtract 1 to get Array Index
	set [email protected], [email protected]_coin_index[[email protected]];

	dispbottom("You have chosen to use " + getitemname(.exchange_ids[[email protected]]) );

	progressbar("00FF00", .exchange_duration[[email protected]]); // Start the Progressbar 

	// On Progress Bar Completion... let's see what we do here...
	delitem(.exchange_ids[[email protected]], .exchange_amount[[email protected]];
	freeloop(true);
	for([email protected] = 0; [email protected] < getarraysize(.available_items); [email protected]++) {
		[email protected] = rand(1, 100); 
		if ([email protected] <= .available_chance[[email protected]]) { // GET THE ITEM
			mes "Here you go";
			getitem(.available_items[[email protected]], .available_amount[[email protected]]);
			if (.available_chance[[email protected]] <= .announce_level_chance) {
				announce(strcharinfo(0) + " just scored " + getitemname(.exchange_ids[[email protected]]), bc_all, C_YELLOW);
			}
			close;
		} 
	}
	freeloop(false);

	mes("You got the default prize...");
	getitem(.default_item, .default_amount);
	close;	
 
	OnInit:
		setarray(.exchange_ids, 673, 675, 671, 677);
		setarray(.exchange_amount, 1, 1, 1, 1);
		setarray(.exchange_duration, 10, 8, 5, 2); // # of seconds to progressbar...

		setarray(.available_items, 501, 502, 503, 504);
		setarray(.available_amount, 1, 1, 1, 1);
		setarray(.available_chance, 50, 40, 30, 10); // % of 100 

		set(.announce_level_chance, 10); // Will only display announce if they get item 504... since it's the only one with 10 chance or lower
		
		set(.default_item, 501);
		set(.default_amount, 1);
		end;

}

 

Edited by Z3R0
Modfiied for >= for Count ID to allowed count
  • Upvote 1
Link to comment
Share on other sites

  • 0

Thx i'll test it, some mistakes with ) ; i've fixed those mistakes only 2 "problems"

1.- you can check it on the image below (this problem happen just sometimes, most offen with 675 - silver coin)

2.- all the progress bar have the same duration. they had all the same but no, actually the one slower was the one with the error the silver coin (675) is the slowest, and the others 3, have a similar speed:

if i only have a coin of the same type all the progress are 10 seconds and when i've the 4, each one have the speed they should have, but after use gold or platinum bronze and silver change to 10 seconds (with bronze its ok, but with silver not).

Script fixed with the problems with ")" and ";".
 

prontera,158,173,4	script	CoinExchanger	88,{

	mes("Welcome");
	mes("Please give me your coins...");
	
	// Check Inventory for Coins
	getinventorylist;

	freeloop(true);
	for([email protected]_index = 0; [email protected]_index < getarraysize(.exchange_ids); [email protected]_index++) {
		for([email protected] = 0; [email protected] < @inventorylist_count; [email protected]++) {
			if (@inventorylist_id[[email protected]] == .exchange_ids[[email protected]_index]) {
				if (@inventorylist_amount[[email protected]] >= .exchange_amount[[email protected]_index]) {
					set([email protected]_coin_index[getarraysize([email protected]_coin_index)], [email protected]_index);
					set([email protected]$, ( [email protected]$ = "" ? "" : ":" ) + getitemname(.exchange_ids[[email protected]_index]) + "(" + @inventorylist_amount[[email protected]] + ")");
				}
			}
		}
	}
	freeloop(false);

	// Display Option to Show them choices and how many coins they have...
	set [email protected], select([email protected]$) - 1; // Subtract 1 to get Array Index
	set [email protected], [email protected]_coin_index[[email protected]];

	dispbottom("You have chosen to use " + getitemname(.exchange_ids[[email protected]]) );

	progressbar("00FF00", .exchange_duration[[email protected]]); // Start the Progressbar 

	// On Progress Bar Completion... let's see what we do here...
	delitem(.exchange_ids[[email protected]], .exchange_amount[[email protected]]);
	freeloop(true);
	for([email protected] = 0; [email protected] < getarraysize(.available_items); [email protected]++) {
		[email protected] = rand(1, 100); 
		if ([email protected] <= .available_chance[[email protected]]) { // GET THE ITEM
			mes "Here you go";
			getitem(.available_items[[email protected]], .available_amount[[email protected]]);
			if (.available_chance[[email protected]] <= .announce_level_chance) {
				announce(strcharinfo(0) + " just scored " + getitemname(.exchange_ids[[email protected]]), bc_all, C_YELLOW);
			}
			close;
		} 
	}
	freeloop(false);

	mes("You got the default prize...");
	getitem(.default_item, .default_amount);
	close;	
 
	OnInit:
		setarray(.exchange_ids, 673, 675, 671, 677);
		setarray(.exchange_amount, 1, 1, 1, 1);
		setarray(.exchange_duration, 10, 8, 5, 2); // # of seconds to progressbar...

		setarray(.available_items, 501, 502, 503, 504);
		setarray(.available_amount, 1, 1, 1, 1);
		setarray(.available_chance, 50, 40, 30, 10); // % of 100 

		set(.announce_level_chance, 10); // Will only display announce if they get item 504... since it's the only one with 10 chance or lower
		
		set(.default_item, 501);
		set(.default_amount, 1);
		end;

}

 

2dabfbf41a6238e7c860d6228c0224da.png

Also... if i click somewhere else the progress bar cancel and i stuck (im agree with the cancel, but no with the stuck ><).

Edited by ItsFree
Link to comment
Share on other sites

  • 0

Ok, I can look into it tonight, sorry, I am at work, just thought I would whip something up, I can test it out tonight late though if you don't have anyone to debunk it by then...

 

Sorry for it not working right off the bat :D

Link to comment
Share on other sites

  • 0

@Z3R0 you can simplify this part

	// Check Inventory for Coins
	getinventorylist;

	freeloop(true);
	for([email protected]_index = 0; [email protected]_index < getarraysize(.exchange_ids); [email protected]_index++) {
		for([email protected] = 0; [email protected] < @inventorylist_count, [email protected]++) {
			if (@inventorylist_id[[email protected]] == .exchange_ids[[email protected]_index]) {
				if (@inventorylist_amount[[email protected]] >= .exchange_amount[[email protected]_index]) {
					set([email protected]_coin_index[getarraysize([email protected]_coin_index)], [email protected]_index);
					set([email protected]$, ( [email protected]$ = "" ? "" : ":" ) + getitemname(.exchange_ids[[email protected]_index]) + "(" + @inventorylist_amount[[email protected]] + ")");
				}
			}
		}
	}
	freeloop(false);
	// Display Option to Show them choices and how many coins they have...
	set [email protected], select([email protected]$) - 1; // Subtract 1 to get Array Index
	set [email protected], [email protected]_coin_index[[email protected]];

into this, using the countitem() to check if player has the item with them or not.

	[email protected]_ids_size = getarraysize(.exchange_ids);
	for ([email protected] = 0; [email protected] < [email protected]_ids_size; [email protected]++) {
		if (countitem(.exchange_ids[[email protected]]) >= .exchange_amount[[email protected]]) {
			[email protected]$ = [email protected]$ + getitemname(.exchange_ids[[email protected]]);
		}
		[email protected]$ = [email protected]$ + ":";
	}
	[email protected] = select([email protected]$) - 1;
	dispbottom("You have chosen to use " + getitemname(.exchange_ids[[email protected]]) );

/lv

Link to comment
Share on other sites

  • 0
On 8/2/2017 at 11:04 PM, Z3R0 said:

Crude and Highly Untested

prontera,158,173,4	script	CoinExchanger	88,{

	mes("Welcome");
	mes("Please give me your coins...");
	
	// Check Inventory for Coins
	getinventorylist;

	freeloop(true);
	for([email protected]_index = 0; [email protected]_index < getarraysize(.exchange_ids); [email protected]_index++) {
		for([email protected] = 0; [email protected] < @inventorylist_count, [email protected]++) {
			if (@inventorylist_id[[email protected]] == .exchange_ids[[email protected]_index]) {
				if (@inventorylist_amount[[email protected]] >= .exchange_amount[[email protected]_index]) {
					set([email protected]_coin_index[getarraysize([email protected]_coin_index)], [email protected]_index);
					set([email protected]$, ( [email protected]$ = "" ? "" : ":" ) + getitemname(.exchange_ids[[email protected]_index]) + "(" + @inventorylist_amount[[email protected]] + ")");
				}
			}
		}
	}
	freeloop(false);

	// Display Option to Show them choices and how many coins they have...
	set [email protected], select([email protected]$) - 1; // Subtract 1 to get Array Index
	set [email protected], [email protected]_coin_index[[email protected]];

	dispbottom("You have chosen to use " + getitemname(.exchange_ids[[email protected]]) );

	progressbar("00FF00", .exchange_duration[[email protected]]); // Start the Progressbar 

	// On Progress Bar Completion... let's see what we do here...
	delitem(.exchange_ids[[email protected]], .exchange_amount[[email protected]];
	freeloop(true);
	for([email protected] = 0; [email protected] < getarraysize(.available_items); [email protected]++) {
		[email protected] = rand(1, 100); 
		if ([email protected] <= .available_chance[[email protected]]) { // GET THE ITEM
			mes "Here you go";
			getitem(.available_items[[email protected]], .available_amount[[email protected]]);
			if (.available_chance[[email protected]] <= .announce_level_chance) {
				announce(strcharinfo(0) + " just scored " + getitemname(.exchange_ids[[email protected]]), bc_all, C_YELLOW);
			}
			close;
		} 
	}
	freeloop(false);

	mes("You got the default prize...");
	getitem(.default_item, .default_amount);
	close;	
 
	OnInit:
		setarray(.exchange_ids, 673, 675, 671, 677);
		setarray(.exchange_amount, 1, 1, 1, 1);
		setarray(.exchange_duration, 10, 8, 5, 2); // # of seconds to progressbar...

		setarray(.available_items, 501, 502, 503, 504);
		setarray(.available_amount, 1, 1, 1, 1);
		setarray(.available_chance, 50, 40, 30, 10); // % of 100 

		set(.announce_level_chance, 10); // Will only display announce if they get item 504... since it's the only one with 10 chance or lower
		
		set(.default_item, 501);
		set(.default_amount, 1);
		end;

}

 

@Z3R0 may i ask a question.

what is the "?" all about on this code

set([email protected]$, ( [email protected]$ = "" ? "" : ":" ) + getitemname(.exchange_ids[[email protected]_index]) + "(" + @inventorylist_amount[[email protected]] + ")");

Link to comment
Share on other sites

  • 0
On 11/3/2017 at 8:48 PM, Nerks said:

what is the "?" all about on this code

set([email protected]$, ( [email protected]$ = "" ? "" : ":" ) + getitemname(.exchange_ids[[email protected]_index]) + "(" + @inventorylist_amount[[email protected]] + ")");

 

(a > b) ? a : b;

this an expression which returns one of two values, a or b. 
The condition, (a > b), is tested. 
If it is true the first value, a, is returned. 
If it is false, the second value, b, is returned.

Whichever value is returned is dependent on the conditional test, a > b. 

Link to comment
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.



×
×
  • Create New...

Important Information

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