LoD_PRC8/_module/nss/lod_gpbank_inc.nss
Jaysyn904 94990edc60 Initial Upload
Initial Upload
2023-09-21 21:20:34 -04:00

85 lines
2.3 KiB
Plaintext

////////////////////////////////////////////////////////////////
// lod_gpbank_inc.nss //
// //
// Include to be used by the GP Bank for the LoD server //
////////////////////////////////////////////////////////////////
// Created By :: SoulFlame //
// Date Created :: March 23rd, 2005 //
////////////////////////////////////////////////////////////////
//////////////////
// Constants //
//////////////////
const string GP_BANK_DB = "LoD_gpbank";
//////////////////
// Functions //
//////////////////
void DepositGP(object oPC, int iAmount);
void DepositGP(object oPC, int iAmount)
{
string sActName = GetPCPlayerName(oPC);
int iCurDB, iNewDB;
iCurDB = GetCampaignInt(GP_BANK_DB, sActName); //Gets current amount from DB
if (iAmount > GetGold(oPC))
{
SendMessageToPC(oPC, "You don't have this much gold to deposit.");
return;
}
else
{
iNewDB = iCurDB + iAmount;
TakeGoldFromCreature(iAmount, oPC);
}
SetCampaignInt(GP_BANK_DB, sActName, iNewDB); //Stores new amount to DB
SendMessageToPC(oPC, "New amount in XP Bank is " + IntToString(iNewDB));
}
void WithdrawGP(object oPC, int iAmount);
void WithdrawGP(object oPC, int iAmount)
{
string sActName = GetPCPlayerName(oPC);
int iCurDB, iNewDB;
iCurDB = GetCampaignInt(GP_BANK_DB, sActName); //Gets current amount from DB
if (iAmount > iCurDB)
{
SendMessageToPC(oPC, "You don't have this much gold to withdraw.");
return;
}
else
{
iNewDB = iCurDB - iAmount;
GiveGoldToCreature(oPC, iAmount);
}
if (iNewDB < 0)
{
SendMessageToPC(oPC, "Result would put DB in negative, cancelling function");
return;
}
SetCampaignInt(GP_BANK_DB, sActName, iNewDB); //Stores new amount to DB
SendMessageToPC(oPC, "New amount in GP Bank is " + IntToString(iNewDB));
}
// Gets amount of XP available from the Bank
void BalanceXP(object oPC);
void BalanceXP(object oPC)
{
string sActName = GetPCPlayerName(oPC);
int iCurDB = GetCampaignInt(GP_BANK_DB, sActName); //Gets current amount from DB
SendMessageToPC(oPC, "Current amount in GP Bank is " + IntToString(iCurDB));
}