Could someone help me figure out the issue with this if statement?
-
Im trying to set up an if-statement for a wonderfizz mod to be universal. Essentially im trying to add a new function which specifically checks which perks the player has per whatever respective map they're on, this is the first snippet from an elseif chain I use to establish that. It checks the map, then checks which perks the player has drank, and returns the mPerks list at the end with a int.
getMPerks() { mperks = []; if(level.script == "zm_highrise"){ if(isDefined( level.zombiemode_using_juggernaut_perk) && level.zombiemode_using_juggernaut_perk) { mperks[mperks.size] = "specialty_armorvest"; } if ( isDefined( level.zombiemode_using_sleightofhand_perk ) && level.zombiemode_using_sleightofhand_perk ) { mperks[mperks.size] = "specialty_fastreload"; } if ( isDefined( level.zombiemode_using_revive_perk ) && level.zombiemode_using_revive_perk ) { mperks[mperks.size] = "specialty_quickrevive"; } if ( isDefined( level.zombiemode_using_doubletap_perk ) && level.zombiemode_using_doubletap_perk ) { mperks[mperks.size] = "specialty_rof"; } if(isDefined( level.zombiemode_using_additionalprimaryweapon_perk) && level.zombiemode_using_additionalprimaryweapon_perk) { mperks[mperks.size] = "specialty_additionalprimaryweapon"; } if ( isDefined( level.zombiemode_using_chugabud_perk ) && level.zombiemode_using_chugabud_perk ) { mperks[mperks.size] = "specialty_finalstand"; } return mPerks; }
This is another function I use which checks the current map and returns the base amount of perks, regardless of what the player has drank.
mLimit = 0; if(level.script == "zm_highrise"){ mLimit = 6; } else if(level.script == "zm_transit") { mLimit = 6; } else if(level.script == "zm_buried") { mLimit = 7; } else if(level.script == "zm_prison") { mLimit = 5; } else if(level.script == "zm_nuked") { mLimit = 4; } else if(level.script == "zm_tomb") { mLimit = 9; } return mlimit; }
My problem lies here, these if statements checks to see which perks the player has drank, and compares it to the map's perk limit. Then, it checks if the perks they've drank is less than the base limit per the map.
But when I load into a game, the machine functions fine until you've drank the max amount of perks, originally it prompts you that you have either reached the map limit, or cant drink anymore perks. But if you use it once more from the perks available on the map, the game crashes. Why arent these if statements working?