Help with if/else if?
Zephirius
Member Posts: 411
I don't understand why the else if isn't firing? Argh! *frustrated*
This is what your money bought you in case your tuning in: ForSerious, Proleric and anyone else who gives a squirt. Lol
#include "x3_inc_skin" string sSound = "gui_learnspell"; void main() { object oPC = GetPCSpeaker(); if ((GetLevelByClass(CLASS_TYPE_BARD, oPC)>0)|| (GetLevelByClass(CLASS_TYPE_SORCERER, oPC)>0)|| (GetLevelByClass(CLASS_TYPE_WIZARD, oPC)>0)|| (GetLevelByClass(CLASS_TYPE_PALEMASTER, oPC)>0)) { if (GetGold(oPC) >= 10000) { TakeGoldFromCreature(10000, oPC); FloatingTextStringOnCreature("You've learned to anticipate your opponents attacks! + FEATS - MOBILITY & HIDE IN PLAIN SIGHT", oPC); object oSkin = SKIN_SupportGetSkin(oPC); itemproperty ipAward = ItemPropertyBonusFeat(IP_CONST_FEAT_DODGE); AddItemProperty(DURATION_TYPE_PERMANENT, ipAward, oSkin); AssignCommand(oPC, PlaySound(sSound)); } //Section that doesn't work else if ((GetLevelByClass(CLASS_TYPE_BARBARIAN, oPC)>0)|| (GetLevelByClass(CLASS_TYPE_CLERIC, oPC)>0)|| (GetLevelByClass(CLASS_TYPE_DRUID, oPC)>0)|| (GetLevelByClass(CLASS_TYPE_FIGHTER, oPC)>0)|| (GetLevelByClass(CLASS_TYPE_MONK, oPC)>0)|| (GetLevelByClass(CLASS_TYPE_PALADIN, oPC)>0)|| (GetLevelByClass(CLASS_TYPE_RANGER, oPC)>0)|| (GetLevelByClass(CLASS_TYPE_ROGUE, oPC)>0)|| (GetLevelByClass(CLASS_TYPE_ASSASSIN, oPC)>0)|| (GetLevelByClass(CLASS_TYPE_BLACKGUARD, oPC)>0)|| (GetLevelByClass(CLASS_TYPE_DIVINECHAMPION, oPC)>0)|| (GetLevelByClass(CLASS_TYPE_DWARVENDEFENDER, oPC)>0)|| (GetLevelByClass(CLASS_TYPE_SHIFTER, oPC)>0)|| (GetLevelByClass(CLASS_TYPE_WEAPON_MASTER, oPC)>0)) { //just can't get this string to fire AssignCommand(oPC, FloatingTextStringOnCreature ("This is a wizardly school of some repute! If you want to smash things, Professor Beadle - Bullrush - Timbly's classroom is just down the hallway!", oPC)); AssignCommand(oPC, PlaySound(sSound)); } // End of broken script else { AssignCommand(oPC, PlaySound(sSound)); AssignCommand(oPC, FloatingTextStringOnCreature ("Insufficient funds! Come back with more coinage.", oPC)); } } }
This is what your money bought you in case your tuning in: ForSerious, Proleric and anyone else who gives a squirt. Lol
Post edited by Zephirius on
0
Comments
(GetLevelByClass(CLASS_TYPE_SORCERER, oPC)>0)||
(GetLevelByClass(CLASS_TYPE_WIZARD, oPC)>0)||
(GetLevelByClass(CLASS_TYPE_PALEMASTER, oPC)>0)), should be, if ((GetLevelByClass(CLASS_TYPE_BARD, oPC)>=0)||
(GetLevelByClass(CLASS_TYPE_SORCERER, oPC)>=0)||
(GetLevelByClass(CLASS_TYPE_WIZARD, oPC)>=0)||
(GetLevelByClass(CLASS_TYPE_PALEMASTER, oPC)>=0))
Looks like you did, if (GetGold(oPC) >= 10000), this right. I could be totally wrong too.
Try this
First you check if they have a magic type class. If yes, you check if they have enough gold. If they don't have gold, you check if they have another type class. If they don't have that other type of class, you tell them they don't have enough gold.
If statements don't need to have an else statement. You can do something like:
Man, as a beginning coder I just get my **** confused sometimes. Ha!
The line to the far left delineates where one curly brace starts and another stops. Perfect for me when I seem to get them mixed up.
Check attached image...