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

91 lines
2.7 KiB
Plaintext

////////////////////////////////////////////////////////////////
// lod_xpbank_inc.nss //
// //
// Include to be used by the XP Bank for the LoD server //
////////////////////////////////////////////////////////////////
// Created By :: SoulFlame //
// Date Created :: March 21st, 2005 //
////////////////////////////////////////////////////////////////
//////////////////
// Constants //
//////////////////
const string XP_BANK_DB = "LoD_xpbank";
const int MAX_XP_AMNT = 780000;
//////////////////
// Functions //
//////////////////
// Take the XP Over the Max limit and donate it to the approp DB
void DonateXP(object oPC);
void DonateXP(object oPC)
{
string sActName = GetPCPlayerName(oPC);
int iCurDB, iDonate, iNewDB;
iCurDB = GetCampaignInt(XP_BANK_DB, sActName); //Gets current amount from DB
if (GetXP(oPC) > MAX_XP_AMNT)
iDonate = GetXP(oPC) - MAX_XP_AMNT; //Gets amount of xp over 40
else
{
SendMessageToPC(oPC, "You are not over level 40. You cannot Donate XP to the Bank");
return;
}
iNewDB = iCurDB + iDonate; //Combines amounts for new total
SetXP(oPC, MAX_XP_AMNT); //Sets PC back to base of lvl 40
SetCampaignInt(XP_BANK_DB, sActName, iNewDB); //Stores new amount to DB
SendMessageToPC(oPC, "New amount in XP Bank is " + IntToString(iNewDB));
}
// Grants XP to character of choice from the bank
void WithdrawXP(object oPC);
void WithdrawXP(object oPC)
{
string sActName = GetPCPlayerName(oPC);
int iCurDB, iWithdraw, iNewDB;
iCurDB = GetCampaignInt(XP_BANK_DB, sActName); //Gets current amount from DB
if (GetXP(oPC) < MAX_XP_AMNT)
{
iWithdraw = MAX_XP_AMNT - GetXP(oPC);
if (iWithdraw > iCurDB) iWithdraw = iCurDB;
}
else
{
SendMessageToPC(oPC, "You are not below level 40. You cannot withdraw from the XP Bank");
return;
}
iNewDB = iCurDB - iWithdraw;
if (iNewDB < 0)
{
SendMessageToPC(oPC, "Result would put DB in negative, cancelling function");
return;
}
SetXP(oPC, GetXP(oPC) + iWithdraw);
SetCampaignInt(XP_BANK_DB, sActName, iNewDB); //Stores new amount to DB
SendMessageToPC(oPC, "New amount in XP 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(XP_BANK_DB, sActName); //Gets current amount from DB
SendMessageToPC(oPC, "Current amount in XP Bank is " + IntToString(iCurDB));
}