object shop_item : tdm_gui_message { float price; float amount; float playerAmount; float isAmountLimited; string message; string item; void init(); void messageOutput(entity e,float f); }; void shop_item::init() { item=getKey("item"); if (item=="") return; setFrobable(1); ResponseAdd(0); ResponseSetAction(0,"sell_item"); ResponseEnable(0,1); isAmountLimited=1; price=getFloatKey("price"); amount=getFloatKey("amount"); if (amount<=0) { isAmountLimited=0; } message=getKey("text"); if (message!="") { ResponseAdd(23); ResponseSetAction(23,"messageOutput"); ResponseEnable(23,1); } } void shop_item::sell_item(entity e,float f) { if ($player1.getLootAmount(LOOT_TOTAL)gold) { toPay-=gold; $player1.changeLootAmount(LOOT_GOLD,-gold); } else { $player1.changeLootAmount(LOOT_GOLD,-toPay); toPay=0; } if (toPay && toPay>jewelry) { toPay-=jewelry; $player1.changeLootAmount(LOOT_JEWELRY,-jewelry); } else { $player1.changeLootAmount(LOOT_JEWELRY,-toPay); toPay=0; } if (toPay && toPay>goods) { toPay-=goods; $player1.changeLootAmount(LOOT_GOODS,-goods); } else { $player1.changeLootAmount(LOOT_GOODS,-toPay); toPay=0; } if (isAmountLimited) { amount--; if (!amount) { remove(); } } entity g=sys.spawn(item); $player1.addInvItem(g); $player1.getNextInvItem(); $player1.getPrevInvItem(); } void shop_item::messageOutput(entity e,float f) { if(!isHilighted()) return; showMessage(); }