hakuren Posted December 7, 2013 Posted December 7, 2013 (edited) 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 December 7, 2013 by hakuren Quote
Variant Posted December 7, 2013 Posted December 7, 2013 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. Quote
hakuren Posted December 7, 2013 Author Posted December 7, 2013 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. Quote
Question
hakuren
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 hakuren2 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.