Jump to content
  • 0

Dynamic Shop when buy delete


hakuren

Question


  • Group:  Members
  • Topic Count:  120
  • Topics Per Day:  0.03
  • Content Count:  295
  • Reputation:   6
  • Joined:  12/02/11
  • Last Seen:  

this is possible to this script when buy a potion it automatically deleted to the selection?
here the script
 

prontera,150,188,6 script Middle Trader 895,{
mes .name$;
mes "You currently have "+countitem(.custom_item)+" Poring Coin.";
mes "Would you like to look at the shop?";
next;
if(select("Yes:No") == 2) {
close;
}
close2;
callshop "USABLE_SHOP",1;
npcshopattach "USABLE_SHOP";
dispbottom "You currently have "+countitem(.custom_item)+" Poring Coin.";
end;
OnBuyItem:
for(set @i,0; @i < getarraysize(@bought_nameid); set @i,@i+1) {
for(set @j,0; @j < getarraysize(.CUSTOM_ITEMS); set @j,@j+2) {
if(.CUSTOM_ITEMS[@j] == @bought_nameid[@i]) {
set @itemcost,(.CUSTOM_ITEMS[(@j+1)]*@bought_quantity[@i]);
set @totalcost,(@totalcost+@itemcost);
break;
}
}
}
if(@totalcost > countitem(.custom_item)) {
dispbottom "You don't have enough Poring Coin.";
}
else {
for(set @i,0; @i < getarraysize(@bought_nameid); set @i,@i+1) {
getitem @bought_nameid[@i],@bought_quantity[@i];
}
delitem .custom_item,@totalcost;
dispbottom "Thank you for shopping.";
dispbottom "You now have "+countitem(.custom_item)+" Poring Coin left.";
}
set @totalcost,0;
deletearray @bought_nameid[0],128;
deletearray @bought_quantity[0],128;
end;OnInit:
npcshopdelitem "USABLE_SHOP",909;   // Leave this alone
set .name$,"[CUSTOM Trader]";
set .custom_item,7539;   // Input TCG ID
setarray .CUSTOM_ITEMS[0],501,50,502,50; // Input as many items as you want (item::price)
 
 
for(set .@i,0; .@i < getarraysize(.CUSTOM_ITEMS); set .@i,.@i+2) {
npcshopadditem "USABLE_SHOP",.CUSTOM_ITEMS[.@i],.CUSTOM_ITEMS[(.@i+1)];
}
}
- shop USABLE_SHOP 139,909:100

 

for ex. player 1 already buys this item ex. red potion it will automatically deleted to the item list of player 1 but if player 2 if he does not but it that item is on his shop categories

Edited by hakuren
Link to comment
Share on other sites

2 answers to this question

Recommended Posts


  • Group:  Members
  • Topic Count:  3
  • Topics Per Day:  0.00
  • Content Count:  52
  • Reputation:   6
  • Joined:  01/06/12
  • Last Seen:  

Oh, this is a really interesting idea.

 

Think a clean way to do it would be to have a script command that creates a 'temporary' shop unique to the player, and then builds that shop, and then deletes it after the user quits.

 

static const char* npc_parse_shop(char* w1, char* w2, char* w3, char* w4, const char* start, const char* buffer, const char* filepath) in npc.c is the function you'll want to look at for creating shops

 

int npc_unload(struct npc_data* nd, bool single) for free'ing memory.

 

------

 

Unfortunately, because clif_buylist has this line:

 

struct item_data* id = itemdb_exists(nd->u.shop.shop_item.nameid);

 

It really screws things up if you're editing the same shop for multiple people, so you pretty much need to have a separate shop for every person. 

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  120
  • Topics Per Day:  0.03
  • Content Count:  295
  • Reputation:   6
  • Joined:  12/02/11
  • Last Seen:  

sir Veriant i think i saw the same script that need but i dont remember were i think its a quest dynamic shop then when this item quest is already completed it will be disappear to the selection on the shop because it already completed :(

Oh, this is a really interesting idea.

 

Think a clean way to do it would be to have a script command that creates a 'temporary' shop unique to the player, and then builds that shop, and then deletes it after the user quits.

 

static const char* npc_parse_shop(char* w1, char* w2, char* w3, char* w4, const char* start, const char* buffer, const char* filepath) in npc.c is the function you'll want to look at for creating shops

 

int npc_unload(struct npc_data* nd, bool single) for free'ing memory.

 

------

 

Unfortunately, because clif_buylist has this line:

 

struct item_data* id = itemdb_exists(nd->u.shop.shop_item.nameid);

 

It really screws things up if you're editing the same shop for multiple people, so you pretty much need to have a separate shop for every person. 

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