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

97 lines
3.3 KiB
Plaintext

//* This does all the actions connected to Rule Tokens for oPlayer.
void RuleCheck(object oPlayer);
//* This checks what, if any, Rule Token we have.
int IsRuleItem(object oItem);
//* This creates the right ammount of Rule Tokens and sets the Campaign Integer to right value.
void DoRuleCheck(int nNumber, string sRule, object oPlayer, string sRuleToken);
void RuleCheck(object oPlayer)
{
int nNumber1 = 0, nNumber2 = 0, nNumber3 = 0, nNumber4 = 0, nNumber5 = 0, nNumber6 = 0;
int nNumber7 = 0, nNumber8 = 0, nNumber9 = 0, nNumber10 = 0;
int nRule, nStack;
object oItem = GetFirstItemInInventory(oPlayer);
while(GetIsObjectValid(oItem))
{
nRule = IsRuleItem(oItem);
if(nRule)
{
nStack = GetItemStackSize(oItem);
if(nRule == 1){nNumber1 = nNumber1 + nStack;}
else if(nRule == 2){nNumber2 = nNumber2 + nStack;}
else if(nRule == 3){nNumber3 = nNumber3 + nStack;}
else if(nRule == 4){nNumber4 = nNumber4 + nStack;}
else if(nRule == 5){nNumber5 = nNumber5 + nStack;}
else if(nRule == 6){nNumber6 = nNumber6 + nStack;}
else if(nRule == 7){nNumber7 = nNumber7 + nStack;}
else if(nRule == 8){nNumber8 = nNumber8 + nStack;}
else if(nRule == 9){nNumber9 = nNumber9 + nStack;}
else if(nRule == 10){nNumber10 = nNumber10 + nStack;}
}
oItem = GetNextItemInInventory(oPlayer);
}
DoRuleCheck(nNumber1, "BR_RULE1", oPlayer, "bb_rules_cheat");
DoRuleCheck(nNumber2, "BR_RULE2", oPlayer, "bb_rules_disarm");
DoRuleCheck(nNumber3, "BR_RULE3", oPlayer, "bb_rules_farming");
DoRuleCheck(nNumber4, "BR_RULE4", oPlayer, "bb_rules_kilspaw");
DoRuleCheck(nNumber5, "BR_RULE5", oPlayer, "bb_rules_maldisp");
DoRuleCheck(nNumber6, "BR_RULE6", oPlayer, "bb_rules_grief");
DoRuleCheck(nNumber7, "BR_RULE7", oPlayer, "bb_rules_pickp");
DoRuleCheck(nNumber8, "BR_RULE8", oPlayer, "bb_rules_swear");
DoRuleCheck(nNumber9, "BR_RULE9", oPlayer, "bb_rules_spetown");
DoRuleCheck(nNumber10, "BR_RULE10", oPlayer, "bb_rules_monweak");
}
int IsRuleItem(object oItem)
{
string sTag = GetTag(oItem);
if(sTag == "bb_rules_cheat") return 1;
else if(sTag == "bb_rules_disarm") return 2;
else if(sTag == "bb_rules_farming") return 3;
else if(sTag == "bb_rules_kilspaw") return 4;
else if(sTag == "bb_rules_maldisp") return 5;
else if(sTag == "bb_rules_grief") return 6;
else if(sTag == "bb_rules_pickp") return 7;
else if(sTag == "bb_rules_swear") return 8;
else if(sTag == "bb_rules_spetown") return 9;
else if(sTag == "bb_rules_monweak") return 10;
else return FALSE;
}
void DoRuleCheck(int nNumber, string sRule, object oPlayer, string sRuleToken)
{
int nOld;
int nDifrence;
string sPlayer = GetPCPlayerName(oPlayer);
sRule = sRule + "_" + sPlayer;
if(nNumber != 0)
{
nOld = GetCampaignInt("LOD-HOTU", sRule);
if(nNumber > nOld)
SetCampaignInt("LOD-HOTU", sRule, nNumber);
else if(nOld > nNumber)
{
nDifrence = nOld - nNumber;
CreateItemOnObject(sRuleToken, oPlayer, nDifrence);
}
}
else
{
nOld = GetCampaignInt("LOD-HOTU", sRule);
if(nOld > nNumber)
CreateItemOnObject(sRuleToken, oPlayer, nOld);
}
}