mirror of
https://bitbucket.org/seefoe/dsrc.git
synced 2026-07-31 01:15:55 -04:00
107 lines
2.7 KiB
Plaintext
107 lines
2.7 KiB
Plaintext
//File to be attached to vendor
|
|
|
|
include library.static_item;
|
|
include library.sui;
|
|
include library.chat;
|
|
include library.money;
|
|
include library.utils;
|
|
|
|
const string STF = "npe";
|
|
|
|
messageHandler npeHandleBuy()
|
|
{
|
|
obj_id player = sui.getPlayerId(params);
|
|
int price = 1000;
|
|
|
|
if(( params == null) || (params.isEmpty()))
|
|
{
|
|
sendSystemMessageTestingOnly(player, "Failing, params were empty!");
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
int btn = sui.getIntButtonPressed(params);
|
|
int idx = sui.getListboxSelectedRow(params);
|
|
int totalMoney = getTotalMoney(player);
|
|
dictionary d = new dictionary();
|
|
d.put("price", price);
|
|
obj_id pInv = utils.getInventoryContainer(player);
|
|
|
|
if (btn == sui.BP_CANCEL)
|
|
{
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
switch (idx)
|
|
{
|
|
case 0: //Stimpack Buff
|
|
obj_id stimpack = static_item.createNewItemFunction("item_stimpack_a_02_01", player);
|
|
if(isIdValid(stimpack))
|
|
{
|
|
d.put("player", player);
|
|
d.put("item", stimpack);
|
|
d.put("npc", self);
|
|
money.requestPayment(player, "Tyrral", price, "handleTransaction", d, true);
|
|
break;
|
|
}
|
|
else
|
|
{
|
|
CustomerServiceLog("NPE_VENDOR: ", "tried to create a item_stimpack_a_02_01 that had an invalid id.");
|
|
break;
|
|
}
|
|
case 1: //Agility Buff
|
|
boolean playerHasItem = utils.playerHasStaticItemInBankOrInventory(player, "item_npe_tatooine_bug_juice_01_01");
|
|
if(!playerHasItem)
|
|
{
|
|
obj_id bugJuice = static_item.createNewItemFunction("item_npe_tatooine_bug_juice_01_01", player);
|
|
if(isIdValid(bugJuice))
|
|
{
|
|
d.put("player", player);
|
|
d.put("item", bugJuice);
|
|
d.put("npc", self);
|
|
money.requestPayment(player, "Tyrral", price, "handleTransaction", d, true);
|
|
break;
|
|
}
|
|
else
|
|
{
|
|
CustomerServiceLog("NPE_VENDOR: ", "tried to create a item_npe_tatooine_bug_juice_01_01 that had an invalid id.");
|
|
break;
|
|
}
|
|
}
|
|
string_id msgHasItem = new string_id (STF, "has_item");
|
|
chat.publicChat(self, player, msgHasItem);
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
|
|
messageHandler handleTransaction()
|
|
{
|
|
if ( params == null || params.isEmpty() )
|
|
{
|
|
debugSpeakMsg(self, "null?");
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
obj_id player = params.getObjId("player");
|
|
obj_id item = params.getObjId("item");
|
|
int price = params.getInt("price");
|
|
|
|
if ( !isIdValid(player) || !isIdValid(item) || price < 1 )
|
|
{
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
if ( params.getInt(money.DICT_CODE) == money.RET_FAIL )
|
|
{
|
|
chat.publicChat(self, player, new string_id(STF,"no_money"));
|
|
destroyObject(item);
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
string_id msgBoughtItem = new string_id (STF, "bought_item");
|
|
chat.publicChat(self, player, msgBoughtItem);
|
|
playMusic(player, "sound/music_acq_academic.snd");
|
|
return SCRIPT_CONTINUE;
|
|
}
|