mirror of
https://github.com/SWG-Source/dsrc.git
synced 2026-09-29 15:12:58 -04:00
94 lines
2.5 KiB
Plaintext
94 lines
2.5 KiB
Plaintext
/* Title: target.script
|
|
* Description: temp actor script for handling pay transactions
|
|
*/
|
|
|
|
/***** INCLUDES ********************************************************/
|
|
|
|
include library.money;
|
|
|
|
/***** CONSTANTS *******************************************************/
|
|
|
|
const string HANDLER_DETACH_ME = "handleDetachMe";
|
|
|
|
/***** TRIGGERS *************************************************/
|
|
trigger OnInitialize()
|
|
{
|
|
detachScript(self, money.SCRIPT_ACCT_PAY);
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
/***** MESSAGEHANDLERS *************************************************/
|
|
messageHandler handleDetachMe()
|
|
{
|
|
detachScript(self, money.SCRIPT_ACCT_PAY);
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
messageHandler acctToPass()
|
|
{
|
|
//debugSpeakMsg(self, "handlePayDeposit - " + params.toString());
|
|
//debugSpeakMsg(self, "handlePayDeposit: entering");
|
|
|
|
if ( (params == null) || (params.isEmpty()) )
|
|
{
|
|
messageTo(self, HANDLER_DETACH_ME, null, 0, isObjectPersisted(self));
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
int amt = params.getInt(money.DICT_AMOUNT);
|
|
if ( amt < 1 )
|
|
{
|
|
//debugSpeakMsg(self, "handlePayDeposit: passed invalid args in params");
|
|
messageTo(self, HANDLER_DETACH_ME, null, 0, isObjectPersisted(self));
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
obj_id target = params.getObjId(money.DICT_TARGET_ID);
|
|
if ( !isIdValid(target) )
|
|
{
|
|
//debugSpeakMsg(self, "handlePayDeposit: passed invalid args in params");
|
|
messageTo(self, HANDLER_DETACH_ME, null, 0, isObjectPersisted(self));
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
withdrawCashFromBank(target, amt, "withdrawPass", "xferFail", params);
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
messageHandler withdrawPass()
|
|
{
|
|
//debugSpeakMsg(self, "handlePayPass: payment success!");
|
|
if ( (params == null) || (params.isEmpty()) )
|
|
{
|
|
messageTo(self, HANDLER_DETACH_ME, null, 0, isObjectPersisted(self));
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
params.put(money.DICT_CODE, money.RET_SUCCESS);
|
|
|
|
string returnHandler = params.getString(money.DICT_PAY_HANDLER);
|
|
messageTo(self, returnHandler, params, 0, true);
|
|
|
|
messageTo(self, HANDLER_DETACH_ME, null, 0, isObjectPersisted(self));
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
messageHandler xferFail()
|
|
{
|
|
//debugSpeakMsg(self, "handlePayFail: payment failed!");
|
|
if ( (params == null) || (params.isEmpty()) )
|
|
{
|
|
messageTo(self, HANDLER_DETACH_ME, null, 0, isObjectPersisted(self));
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
params.put(money.DICT_CODE, money.RET_FAIL);
|
|
|
|
string returnHandler = params.getString(money.DICT_PAY_HANDLER);
|
|
messageTo(self, returnHandler, params, 0, true);
|
|
|
|
messageTo(self, HANDLER_DETACH_ME, null, 0, isObjectPersisted(self));
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|