Jump to content
  • 0

NPC that buys/trades costume?


sotf

Question


  • Group:  Members
  • Topic Count:  43
  • Topics Per Day:  0.01
  • Content Count:  173
  • Reputation:   9
  • Joined:  11/14/12
  • Last Seen:  

Good Day rAthena! I know I have requested this a while back (http://rathena.org/board/topic/79595-costumeheadgear-gacha-npc/)
But since I've been adding quite a few hundreds of costumes, it's been really a pain to add them manually. Can someone help me modify this script for it to buy Costume Equips in General and not just a few specific IDs?

Here's the script from the thread above:

 

-	shop	costume_shop	-1,501:-1

prontera,150,180,5	script	bghjkl	58,{

	mes "Hi Good Day! Do you have spare costumes !";
	mes "that you wanna get rid of?";
	next;

	set .@s, select( "No ! Goood bye.", "Trade", "More informations" );
	if( .@s == 1 )
		mes "Okay have a nice day.";
	else if( .@s == 3 ) {
		mes "blabla more informations.";
	}

	getinventorylist;
	for( set .@i, 0; .@i < @inventorylist_count; set .@i, .@i + 1 )
		if( !@inventorylist_expire[.@i] ) {
			while( getd( ".costume_id"+ .@k +"[0]" ) ) {
				while( .@j < getd( ".size_costume"+ .@k ) && @inventorylist_id[.@i] != getd( ".costume_id"+ .@k +"["+ .@j +"]" ) ) set .@j, .@j + 1;
				if( .@j != getd( ".size_costume"+ .@k ) ) {
					for( set .@h, 0; .@h < @inventorylist_amount[.@i]; set .@h, .@h + 1 ) {
						set .@list_id[ .@size_shop ], @inventorylist_id[.@i];
						set .@size_shop, .@size_shop + 1;
					}
					break;
				}
				set .@j, 0;
				set .@k, .@k + 1;
			}
			set .@k, 0;
			
		}

	if( !.@size_shop )
		mes "Hmm I don't see any costumes on your inventory. Please check your inventory.";
	else {
		mes "Okay, here's a list of the costumes in your inventory.";
		next;
		npcshopitem "costume_shop",501,-1;
		for( set .@i, 0; .@i < .@size_shop; set .@i, .@i + 1 )
			npcshopadditem "costume_shop",.@list_id[.@i],0;
		npcshopdelitem "costume_shop",501;
		callshop "costume_shop", 1;
		npcshopattach "costume_shop";
	}
	close;
	
OnBuyItem:
	// if( !checkweight2( .item_exchangeID,.item_count ) ) {
		// message strcharinfo(0),"You need additional weight capacity to complete this trade.";
		// close;
	// }
	set .@count, getarraysize( @bought_nameid );
	for( set .@i, 0; .@i < .size_count; set .@i, .@i + 1 ) {
		set .@check, .item_count[.@i] * .@count;
		if( .@check > 30000) {
			message strcharinfo(0),"You can't purchase that many "+ getitemname( .item_exchangeID[.@i] ) +".";
			end;
		}
		set .@gain$, .@gain$ + ( getstrlen( .@gain$ ) ? ", " : "" ) + .@check +" "+ getitemname( .item_exchangeID[.@i] );
	}
	mes "Sell the costume for "+ .@gain$ +"?";
	next;
	if( select( "Yes, I sell", "No" ) -1 ) close;
	for( set .@i, 0; .@i < .@count; set .@i, .@i + 1 )
		delitem @bought_nameid[.@i], @bought_quantity[.@i];
	for( set .@i, 0; .@i < .size_count; set .@i, .@i + 1 )
		getitem .item_exchangeID[.@i], .item_count[.@i] * .@count;
	mes "good bye.";
	close;
OnInit:
// Item gained
// -----------
	setarray .item_exchangeID, 7539; // item ID gained - you can add more ID <item ID>, <item ID>,...
	setarray .item_count, 10; // item count gained - ( count of the item /element of array of .item_exchangeID )
	set .size_count, getarraysize( .item_count );

// Costume trade ID
// size array must be < 128
// use the synthaxe .costume_idX for adding news array
// ------------------------------------------------
	setarray .costume_id0, 20000, 20001;
	setarray .costume_id1, 20002, 20003;
	
    while( getd( ".costume_id"+ .@i +"[0]" ) ) {
        setd ".size_costume"+ .@i, getarraysize( getd( ".costume_id"+ .@i ) );
        set .@i, .@i +1;
    }
	end;
}

 

 

Thank you for those who are going to help :D

Link to comment
Share on other sites

6 answers to this question

Recommended Posts


  • Group:  Developer
  • Topic Count:  10
  • Topics Per Day:  0.00
  • Content Count:  2407
  • Reputation:   613
  • Joined:  07/05/12
  • Last Seen:  


- shop costume_shop -1,501:-1

prontera,150,180,5 script bghjkl 58,{

mes "Hi Good Day! Do you have spare costumes !";

mes "that you wanna get rid of?";

next;

set .@s, select( "No ! Goood bye.", "Trade", "More informations" );

if( .@s == 1 )

mes "Okay have a nice day.";

else if( .@s == 3 ) {

mes "blabla more informations.";

}

getinventorylist;

.@calc = 1024|2048|4096|8192;// to lazy to calculate

for( set .@i, 0; .@i < @inventorylist_count; set .@i, .@i + 1 )

if( !@inventorylist_expire[.@i] ) {

if ( getiteminfo( @inventorylist_id[.@i],5 ) & .@calc ) {

for( set .@j, 0; .@j < @inventorylist_amount[.@i]; set .@j, .@j + 1 ) {

set .@list_id[ .@size_shop ], @inventorylist_id[.@i];

set .@size_shop, .@size_shop + 1;

}

}

}

if( !.@size_shop )

mes "Hmm I don't see any costumes on your inventory. Please check your inventory.";

else {

mes "Okay, here's a list of the costumes in your inventory.";

next;

npcshopitem "costume_shop",501,-1;

for( set .@i, 0; .@i < .@size_shop; set .@i, .@i + 1 )

npcshopadditem "costume_shop",.@list_id[.@i],0;

npcshopdelitem "costume_shop",501;

callshop "costume_shop", 1;

npcshopattach "costume_shop";

}

end;

OnBuyItem:

// if( !checkweight2( .reward_ID,.reward_amount ) ) {

// message strcharinfo(0),"You need additional weight capacity to complete this trade.";

// close;

// }

set .@count, getarraysize( @bought_nameid );

for( set .@i, 0; .@i < .size_count; set .@i, .@i + 1 ) {// don't check the weight..

set .@check, .reward_amount[.@i] * .@count;

if( .@check > 30000 ) {

message strcharinfo(0),"You can't purchase that many "+ getitemname( .reward_ID[.@i] ) +".";

end;

}

set .@gain$, .@gain$ + ( getstrlen( .@gain$ ) ? ", " : "" ) + .@check +" "+ getitemname( .reward_ID[.@i] );

}

mes "Sell the costume for "+ .@gain$ +"?";

next;

if( select( "Yes, I sell", "No" ) -1 ) end;

for( set .@i, 0; .@i < .@count; set .@i, .@i + 1 )

if ( countitem( @bought_nameid[.@i] ) < @bought_quantity[.@i] ) {

mes "Have you lost one item?";

close;

}

for( set .@i, 0; .@i < .@count; set .@i, .@i + 1 )

delitem @bought_nameid[.@i], @bought_quantity[.@i];

for( set .@i, 0; .@i < .size_count; set .@i, .@i + 1 )

getitem .reward_ID[.@i], .reward_amount[.@i] * .@count;

mes "Good bye.";

close;

OnInit:

setarray .reward_ID, 7539; // item ID gained - you can add more ID <item ID>, <item ID>,...

setarray .reward_amount, 10; // item count gained - ( count of the item /element of array of .reward_ID )

set .size_count, getarraysize( .reward_amount );

end;

}

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  43
  • Topics Per Day:  0.01
  • Content Count:  173
  • Reputation:   9
  • Joined:  11/14/12
  • Last Seen:  

Thank you so much, you helped me once again. :D
I'll try it as soon as I can.



-	shop	costume_shop	-1,501:-1

prontera,150,180,5	script	bghjkl	58,{

	mes "Hi Good Day! Do you have spare costumes !";
	mes "that you wanna get rid of?";
	next;
	set .@s, select( "No ! Goood bye.", "Trade", "More informations" );
	if( .@s == 1 )
		mes "Okay have a nice day.";
	else if( .@s == 3 ) {
		mes "blabla more informations.";
	}

	getinventorylist;
	.@calc = 1024|2048|4096|8192;// to lazy to calculate
	for( set .@i, 0; .@i < @inventorylist_count; set .@i, .@i + 1 )
		if( !@inventorylist_expire[.@i] ) {
			if ( getiteminfo( @inventorylist_id[.@i],5 ) & .@calc ) {
				for( set .@j, 0; .@j < @inventorylist_amount[.@i]; set .@j, .@j + 1 ) {
					set .@list_id[ .@size_shop ], @inventorylist_id[.@i];
					set .@size_shop, .@size_shop + 1;
				}
			}
		}

	if( !.@size_shop )
		mes "Hmm I don't see any costumes on your inventory. Please check your inventory.";
	else {
		mes "Okay, here's a list of the costumes in your inventory.";
		next;
		npcshopitem "costume_shop",501,-1;
		for( set .@i, 0; .@i < .@size_shop; set .@i, .@i + 1 )
			npcshopadditem "costume_shop",.@list_id[.@i],0;
		npcshopdelitem "costume_shop",501;
		callshop "costume_shop", 1;
		npcshopattach "costume_shop";
	}
	end;
	
OnBuyItem:
	// if( !checkweight2( .reward_ID,.reward_amount ) ) {
		// message strcharinfo(0),"You need additional weight capacity to complete this trade.";
		// close;
	// }
	set .@count, getarraysize( @bought_nameid );
	for( set .@i, 0; .@i < .size_count; set .@i, .@i + 1 ) {// don't check the weight..
		set .@check, .reward_amount[.@i] * .@count;
		if( .@check > 30000 ) {
			message strcharinfo(0),"You can't purchase that many "+ getitemname( .reward_ID[.@i] ) +".";
			end;
		}
		set .@gain$, .@gain$ + ( getstrlen( .@gain$ ) ? ", " : "" ) + .@check +" "+ getitemname( .reward_ID[.@i] );
	}
	mes "Sell the costume for "+ .@gain$ +"?";
	next;
	if( select( "Yes, I sell", "No" ) -1 ) end;
	
	for( set .@i, 0; .@i < .@count; set .@i, .@i + 1 )
		if ( countitem( @bought_nameid[.@i] ) < @bought_quantity[.@i] ) {
			mes "Have you lost one item?";
			close;
		}
	for( set .@i, 0; .@i < .@count; set .@i, .@i + 1 )
		delitem @bought_nameid[.@i], @bought_quantity[.@i];
	for( set .@i, 0; .@i < .size_count; set .@i, .@i + 1 )
		getitem .reward_ID[.@i], .reward_amount[.@i] * .@count;
	mes "Good bye.";
	close;

OnInit:
	setarray .reward_ID, 7539; // item ID gained - you can add more ID <item ID>, <item ID>,...
	setarray .reward_amount, 10; // item count gained - ( count of the item /element of array of .reward_ID )
	set .size_count, getarraysize( .reward_amount );
	end;
}

 

I modified the script a bit, into this:

 

-	shop	costume_shop	-1,501:-1

alb2trea,56,41,5	script	Capt. Krauser	561,{
	
	mes "^0000ff[Capt. Krauser]^000000";
	mes "Ahoy mate! Do ye have spare costumes";
	mes "that ye wanna get rid 'o?";
	next;
	set .@s, select( "No! Goood bye.", "Trade-in Costumes", "More information" );
	if( .@s == 1 )
		mes "^0000ff[Capt. Krauser]^000000";
		mes "Okay 'ave a nice day.";
	else if( .@s == 3 ) {
		mes "^0000ff[Capt. Krauser]^000000";
		mes "I needs more clothes fer me mates fer our adventures in th' sea, so I be buyin' some fer these ^00ff00Pirate Doubloons^000000 that we 'ave!";
		next;
		mes "^0000ff[Capt. Krauser]^000000";
		mes "These loots might come in handy fer ye someday too mate!";
	}

	getinventorylist;
	.@calc = 1024|2048|4096|8192;// to lazy to calculate
	for( set .@i, 0; .@i < @inventorylist_count; set .@i, .@i + 1 )
		if( !@inventorylist_expire[.@i] ) {
			if ( getiteminfo( @inventorylist_id[.@i],5 ) & .@calc ) {
				for( set .@j, 0; .@j < @inventorylist_amount[.@i]; set .@j, .@j + 1 ) {
					set .@list_id[ .@size_shop ], @inventorylist_id[.@i];
					set .@size_shop, .@size_shop + 1;
				}
			}
		}

	if( !.@size_shop )
		mes "^0000ff[Capt. Krauser]^000000";
		mes "Shiver me timbers!  I don't see any costumes on yer booty mate!";
	else {
		mes "^0000ff[Capt. Krauser]^000000";
		mes "Okay, here's a list o' th' costumes in yer loot.";
		next;
		npcshopitem "costume_shop",501,-1;
		for( set .@i, 0; .@i < .@size_shop; set .@i, .@i + 1 )
			npcshopadditem "costume_shop",.@list_id[.@i],0;
		npcshopdelitem "costume_shop",501;
		callshop "costume_shop", 1;
		npcshopattach "costume_shop";
	}
	end;
	
OnBuyItem:
	// if( !checkweight2( .reward_ID,.reward_amount ) ) {
		// message strcharinfo(0),"You need additional weight capacity to complete this trade.";
		// close;
	// }
	set .@count, getarraysize( @bought_nameid );
	for( set .@i, 0; .@i < .size_count; set .@i, .@i + 1 ) {// don't check the weight..
		set .@check, .reward_amount[.@i] * .@count;
		if( .@check > 30000 ) {
			message strcharinfo(0),"You can't purchase that many "+ getitemname( .reward_ID[.@i] ) +".";
			end;
		}
		set .@gain$, .@gain$ + ( getstrlen( .@gain$ ) ? ", " : "" ) + .@check +" "+ getitemname( .reward_ID[.@i] );
	}
	mes "Sell the costume for "+ .@gain$ +"?";
	next;
	if( select( "Yes, I sell", "No" ) -1 ) end;
	
	for( set .@i, 0; .@i < .@count; set .@i, .@i + 1 )
		if ( countitem( @bought_nameid[.@i] ) < @bought_quantity[.@i] ) {
			mes "Have you lost one item?";
			close;
		}
	for( set .@i, 0; .@i < .@count; set .@i, .@i + 1 )
		delitem @bought_nameid[.@i], @bought_quantity[.@i];
	for( set .@i, 0; .@i < .size_count; set .@i, .@i + 1 )
		getitem .reward_ID[.@i], .reward_amount[.@i] * .@count;
	mes "Nice doin' business wit' ye!";
	close;

OnInit:
	setarray .reward_ID, 7875; // item ID gained - you can add more ID <item ID>, <item ID>,...
	setarray .reward_amount, 1; // item count gained - ( count of the item /element of array of .reward_ID )
	set .size_count, getarraysize( .reward_amount );
	end;
}

 

and I get this error:

 

16ay6ut.jpg

 

What should I do? :/

 

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  50
  • Topics Per Day:  0.01
  • Content Count:  1702
  • Reputation:   238
  • Joined:  09/05/12
  • Last Seen:  

Thank you so much, you helped me once again. :D

I'll try it as soon as I can.

 

-	shop	costume_shop	-1,501:-1

prontera,150,180,5	script	bghjkl	58,{

	mes "Hi Good Day! Do you have spare costumes !";
	mes "that you wanna get rid of?";
	next;
	set .@s, select( "No ! Goood bye.", "Trade", "More informations" );
	if( .@s == 1 )
		mes "Okay have a nice day.";
	else if( .@s == 3 ) {
		mes "blabla more informations.";
	}

	getinventorylist;
	.@calc = 1024|2048|4096|8192;// to lazy to calculate
	for( set .@i, 0; .@i < @inventorylist_count; set .@i, .@i + 1 )
		if( !@inventorylist_expire[.@i] ) {
			if ( getiteminfo( @inventorylist_id[.@i],5 ) & .@calc ) {
				for( set .@j, 0; .@j < @inventorylist_amount[.@i]; set .@j, .@j + 1 ) {
					set .@list_id[ .@size_shop ], @inventorylist_id[.@i];
					set .@size_shop, .@size_shop + 1;
				}
			}
		}

	if( !.@size_shop )
		mes "Hmm I don't see any costumes on your inventory. Please check your inventory.";
	else {
		mes "Okay, here's a list of the costumes in your inventory.";
		next;
		npcshopitem "costume_shop",501,-1;
		for( set .@i, 0; .@i < .@size_shop; set .@i, .@i + 1 )
			npcshopadditem "costume_shop",.@list_id[.@i],0;
		npcshopdelitem "costume_shop",501;
		callshop "costume_shop", 1;
		npcshopattach "costume_shop";
	}
	end;
	
OnBuyItem:
	// if( !checkweight2( .reward_ID,.reward_amount ) ) {
		// message strcharinfo(0),"You need additional weight capacity to complete this trade.";
		// close;
	// }
	set .@count, getarraysize( @bought_nameid );
	for( set .@i, 0; .@i < .size_count; set .@i, .@i + 1 ) {// don't check the weight..
		set .@check, .reward_amount[.@i] * .@count;
		if( .@check > 30000 ) {
			message strcharinfo(0),"You can't purchase that many "+ getitemname( .reward_ID[.@i] ) +".";
			end;
		}
		set .@gain$, .@gain$ + ( getstrlen( .@gain$ ) ? ", " : "" ) + .@check +" "+ getitemname( .reward_ID[.@i] );
	}
	mes "Sell the costume for "+ .@gain$ +"?";
	next;
	if( select( "Yes, I sell", "No" ) -1 ) end;
	
	for( set .@i, 0; .@i < .@count; set .@i, .@i + 1 )
		if ( countitem( @bought_nameid[.@i] ) < @bought_quantity[.@i] ) {
			mes "Have you lost one item?";
			close;
		}
	for( set .@i, 0; .@i < .@count; set .@i, .@i + 1 )
		delitem @bought_nameid[.@i], @bought_quantity[.@i];
	for( set .@i, 0; .@i < .size_count; set .@i, .@i + 1 )
		getitem .reward_ID[.@i], .reward_amount[.@i] * .@count;
	mes "Good bye.";
	close;

OnInit:
	setarray .reward_ID, 7539; // item ID gained - you can add more ID <item ID>, <item ID>,...
	setarray .reward_amount, 10; // item count gained - ( count of the item /element of array of .reward_ID )
	set .size_count, getarraysize( .reward_amount );
	end;
}

 

I modified the script a bit, into this:

 

-	shop	costume_shop	-1,501:-1

alb2trea,56,41,5	script	Capt. Krauser	561,{
	
	mes "^0000ff[Capt. Krauser]^000000";
	mes "Ahoy mate! Do ye have spare costumes";
	mes "that ye wanna get rid 'o?";
	next;
	set .@s, select( "No! Goood bye.", "Trade-in Costumes", "More information" );
	if( .@s == 1 )
		mes "^0000ff[Capt. Krauser]^000000";
		mes "Okay 'ave a nice day.";
	else if( .@s == 3 ) {
		mes "^0000ff[Capt. Krauser]^000000";
		mes "I needs more clothes fer me mates fer our adventures in th' sea, so I be buyin' some fer these ^00ff00Pirate Doubloons^000000 that we 'ave!";
		next;
		mes "^0000ff[Capt. Krauser]^000000";
		mes "These loots might come in handy fer ye someday too mate!";
	}

	getinventorylist;
	.@calc = 1024|2048|4096|8192;// to lazy to calculate
	for( set .@i, 0; .@i < @inventorylist_count; set .@i, .@i + 1 )
		if( !@inventorylist_expire[.@i] ) {
			if ( getiteminfo( @inventorylist_id[.@i],5 ) & .@calc ) {
				for( set .@j, 0; .@j < @inventorylist_amount[.@i]; set .@j, .@j + 1 ) {
					set .@list_id[ .@size_shop ], @inventorylist_id[.@i];
					set .@size_shop, .@size_shop + 1;
				}
			}
		}

	if( !.@size_shop )
		mes "^0000ff[Capt. Krauser]^000000";
		mes "Shiver me timbers!  I don't see any costumes on yer booty mate!";
	else {
		mes "^0000ff[Capt. Krauser]^000000";
		mes "Okay, here's a list o' th' costumes in yer loot.";
		next;
		npcshopitem "costume_shop",501,-1;
		for( set .@i, 0; .@i < .@size_shop; set .@i, .@i + 1 )
			npcshopadditem "costume_shop",.@list_id[.@i],0;
		npcshopdelitem "costume_shop",501;
		callshop "costume_shop", 1;
		npcshopattach "costume_shop";
	}
	end;
	
OnBuyItem:
	// if( !checkweight2( .reward_ID,.reward_amount ) ) {
		// message strcharinfo(0),"You need additional weight capacity to complete this trade.";
		// close;
	// }
	set .@count, getarraysize( @bought_nameid );
	for( set .@i, 0; .@i < .size_count; set .@i, .@i + 1 ) {// don't check the weight..
		set .@check, .reward_amount[.@i] * .@count;
		if( .@check > 30000 ) {
			message strcharinfo(0),"You can't purchase that many "+ getitemname( .reward_ID[.@i] ) +".";
			end;
		}
		set .@gain$, .@gain$ + ( getstrlen( .@gain$ ) ? ", " : "" ) + .@check +" "+ getitemname( .reward_ID[.@i] );
	}
	mes "Sell the costume for "+ .@gain$ +"?";
	next;
	if( select( "Yes, I sell", "No" ) -1 ) end;
	
	for( set .@i, 0; .@i < .@count; set .@i, .@i + 1 )
		if ( countitem( @bought_nameid[.@i] ) < @bought_quantity[.@i] ) {
			mes "Have you lost one item?";
			close;
		}
	for( set .@i, 0; .@i < .@count; set .@i, .@i + 1 )
		delitem @bought_nameid[.@i], @bought_quantity[.@i];
	for( set .@i, 0; .@i < .size_count; set .@i, .@i + 1 )
		getitem .reward_ID[.@i], .reward_amount[.@i] * .@count;
	mes "Nice doin' business wit' ye!";
	close;

OnInit:
	setarray .reward_ID, 7875; // item ID gained - you can add more ID <item ID>, <item ID>,...
	setarray .reward_amount, 1; // item count gained - ( count of the item /element of array of .reward_ID )
	set .size_count, getarraysize( .reward_amount );
	end;
}

 

and I get this error:

 

16ay6ut.jpg

 

What should I do? :/

 

Try changing :

else if( .@s == 3 ) {
        mes "blabla more informations.";
}

to : 

if( .@s == 3 ) {
        mes "blabla more informations.";
}
Link to comment
Share on other sites


  • Group:  Developer
  • Topic Count:  10
  • Topics Per Day:  0.00
  • Content Count:  2407
  • Reputation:   613
  • Joined:  07/05/12
  • Last Seen:  

You forgot the brackets

	if( .@s == 1 ) {
		mes "^0000ff[Capt. Krauser]^000000";
		mes "Okay 'ave a nice day.";
	}
        else if( .@s == 3 ) {
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  43
  • Topics Per Day:  0.01
  • Content Count:  173
  • Reputation:   9
  • Joined:  11/14/12
  • Last Seen:  

You forgot the brackets

	if( .@s == 1 ) {
		mes "^0000ff[Capt. Krauser]^000000";
		mes "Okay 'ave a nice day.";
	}
        else if( .@s == 3 ) {

 

 

yea those freaking brackets haha! Thanks a lot guys! I appreciate all the help :D

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...