Rune_PRC8/_module/nss/xa_bank_onconv.nss
Jaysyn904 d1c309ae63 Initial commit
Initial commit
2024-09-13 09:10:39 -04:00

56 lines
1.7 KiB
Plaintext

#include "nbde_inc"
void main()
{
object oPC = GetLastSpeaker();
string sName = GetName(oPC);
string sLeft = GetStringLeft(sName,4);
string sCampName = "BankGold_" + sLeft;
object oCurrentPC = GetLocalObject(OBJECT_SELF, "CurrentPC");
int iPattern = GetListenPatternNumber();
int iGold, iCampGold;
switch(iPattern)
{
case 1234:
{
if(oPC != oCurrentPC) return;
iGold = StringToInt(GetMatchedSubstring(0));
iCampGold = NBDE_GetCampaignInt(sCampName, "GOLD");
if(iGold > iCampGold)
{
FloatingTextStringOnCreature("You don't have that much in the bank!", oPC, FALSE);
return;
}
GiveGoldToCreature(oPC, iGold);
iCampGold-=iGold;
NBDE_SetCampaignInt(sCampName, "GOLD", iCampGold);
SetListening(OBJECT_SELF, FALSE);
break;
}
case 5678:
{
if(oPC != oCurrentPC) return;
iGold = StringToInt(GetMatchedSubstring(0));
if(GetGold(oPC) < iGold||iGold == 0)
{
FloatingTextStringOnCreature("That amount of gold is too much or too little", oPC, FALSE);
return; //ignores high values
}
TakeGoldFromCreature(iGold, oPC, TRUE); // destroys the gold
iCampGold = NBDE_GetCampaignInt(sCampName, "GOLD");
iCampGold+=iGold;
NBDE_SetCampaignInt(sCampName, "GOLD", iCampGold);
SetListening(OBJECT_SELF, FALSE);
break;
}
case -1:
{
BeginConversation();
break;
}
}
NBDE_FlushCampaignDatabase(sCampName);
}