Jump to content
  • 0

NPC with this feature


Question

Posted

Hi all. I have a request...

I'm not good in explaining, but I'll try give it a shot.

I have custom items within ID 8000 and 8200, and I'm looking for a NPC that let's players trade their custom item for another custom item/ID in that ID-range. Like if the item is in that range then a window pops up and the player is able to trade their current item for another item within those IDs.

Does a script like that exist?

  • Upvote 1

4 answers to this question

Recommended Posts

Posted

Ah, I've been meaning to write something like this for a while but forgot about it. Here's a cooler script than Joseph's, :3~

prontera,163,168,4	script	Item Trader	797,{
mes "[item Trader]";
mes "Would you like to";
mes "trade something in?";
mes "The item ID must be";
mes "between ^0055FF["+.Bounds[0]+"]^000000 and ^0055FF["+.Bounds[1]+"]^000000.";
next;
if(select("Sure.:No, thanks.") == 2) close;
mes "[item Trader]";
mes "Select a single item to trade in.";
mes "You can change your mind later, don't worry.";
callshop "item_trader",2;
npcshopattach "item_trader";
end;
OnSellItem:
mes "[item Trader]";
if (@sold_nameid < .Bounds[0] || @sold_nameid > .Bounds[1]) {
	mes "I'm afraid I can't do anything with this ^0055FF"+getitemname(@sold_nameid)+"^000000...";
	close;
}
mes "You want to trade in your ^0055FF"+getitemname(@sold_nameid)+"^000000?";
sleep2 1000;
doevent strnpcinfo(0)+"::OnContinue";
end;
OnContinue:
mes "Pick one item you'd like, then.";
callshop "item_trader",1;
npcshopattach "item_trader";
end;
OnBuyItem:
mes "[item Trader]";
mes "Are you sure you want to trade your ^0055FF"+getitemname(@sold_nameid)+"^000000 for a ^0055FF"+getitemname(@bought_nameid)+"^000000?";
next;
if(select("Yes, I'm sure.:Wait a second...") == 2) {
	mes "[item Trader]";
	mes "Okay, take your time.";
	close;
}
mes "[item Trader]";
mes "Here you go.";
mes "Enjoy!";
delitem @sold_nameid,1;
getitem @bought_nameid,1;
close;
OnInit:
// Write the lower and upper bounds of item IDs to trade in.
setarray .Bounds[0],500,550;
// List the items available to purchase.
setarray .@Items[0],501,502,503,504,505,506,507,508,509,510,511;
freeloop(1);
npcshopdelitem "item_trader",512;
for(set .@i,0; .@i<getarraysize(.@Items); set .@i,.@i+1)
	npcshopadditem "item_trader",.@Items[.@i],0;
freeloop(0);
end;
}
-	shop	item_trader	-1,512:-1

upaste: http://upaste.me/raw/e99b962ab10812a

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.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...