Inventory Problems
For some reason everything except armor and pistol in my Inventory Hud, Shows as Invalid, Here is my code:
hud.cs
No Syntax Errors are generated.
function InventoryScreen::updateHud( %this, %client, %tag ) { %noSniperRifle = true; %armor = getArmorDatablock( %client, $NameToInv[%client.favorites[0]] ); if (!%client.isAdmin && !%client.isSuperAdmin) { if ($Host::Purebuild == 1) { %client.favorites[0] = "Purebuild"; %armor = getArmorDatablock( %client , "Pure"); } else { if (%client.favorites[0] $= "Purebuild") %client.favorites[0] = "Scout"; } } if ( %client.lastArmor !$= %armor ) { %client.lastArmor = %armor; for ( %x = 0; %x < %client.lastNumFavs; %x++ ) messageClient( %client, 'RemoveLineHud', "", 'inventoryScreen', %x ); %setLastNum = true; } %cmt = $CurrentMissionType; //Auto-Inv Load if($Host::PureBuild) { buyFavorites(%client); } //Create - ARMOR - List %armorList = %client.favorites[0]; for ( %y = 0; $InvArmor[%y] !$= ""; %y++ ) if ( $InvArmor[%y] !$= %client.favorites[0] ) %armorList = %armorList TAB $InvArmor[%y]; //Create - WEAPON - List if(!$Host::RankSystem) { //it's off for ( %y = 0; $InvWeapon[%y] !$= ""; %y++ ) { %notFound = true; for ( %i = 0; %i < getFieldCount( %client.weaponIndex ); %i++ ) { %WInv = $NameToInv[$InvWeapon[%y]]; if ( ( $InvWeapon[%y] $= %client.favorites[getField( %client.weaponIndex,%i )] ) || !%armor.max[%WInv] ) { %notFound = false; break; } } if ( !($InvBanList[%cmt, %WInv]) ) { if ( %notFound && %weaponList $= "" ) { %weaponList = $InvWeapon[%y]; } else if ( %notFound ) { %weaponList = %weaponList TAB $InvWeapon[%y]; } } } } else { //It's on for ( %y = 0; $InvWeapon[%y] !$= ""; %y++ ) { %notFound = true; for ( %i = 0; %i < getFieldCount( %client.weaponIndex ); %i++ ) { %WInv = $NameToInv[$InvWeapon[%y]]; if ( ( $InvWeapon[%y] $= %client.favorites[getField( %client.weaponIndex,%i )] ) || !%armor.max[%WInv] ) { %notFound = false; break; } } //New Rank Check %xpHas = $Rank::XP[%client.guid]; if(%WInv.Image.RankRequire $= "") { %xpNeed = 0; } else { %xpNeed = %WInv.Image.RankRequire; } // if ( !($InvBanList[%cmt, %WInv]) ) { if ( %notFound && %weaponList $= "" ) { if(%xpNeed $= "") { %weaponList = $InvWeapon[%y]; } else { if (%xpHas >= %xpNeed){ %weaponList = $InvWeapon[%y]; } } } else if ( %notFound ) { if(%xpNeed == 0) { %weaponList = %weaponList TAB $InvWeapon[%y]; } else { if (%xpHas >= %xpNeed){ %weaponList = %weaponList TAB $InvWeapon[%y]; } } } } } } //Create - PISTOL - List if(%client.favorites[0] !$= "Purebuild") { if ( %noSniperRifle ) { if ( getFieldCount( %client.pistolIndex ) ) %pistolList = %client.favorites[getField( %client.pistolIndex, 0 )]; else { %pistolList = "EMPTY"; %client.numFavs++; } for ( %y = 0; $InvPistol[%y] !$= ""; %y++ ) { %PistolInv = $NameToInv[$InvPistol[%y]]; if ( ( $InvPistol[%y] !$= %client.favorites[getField( %client.pistolIndex, 0 )]) && %armor.max[%PistolInv] && !($InvBanList[%cmt, %PistolInv])) %pistolList = %pistolList TAB $InvPistol[%y]; } } // %pistolList = CheckPistolPrereqs(%client, %pistolList); } //Create - MELEE - List if(%client.favorites[0] !$= "Purebuild") { if ( %noSniperRifle ) { if ( getFieldCount( %client.meleeIndex ) ) %meleeList = %client.favorites[getField( %client.meleeIndex, 0 )]; else { %meleeList = "EMPTY"; %client.numFavs++; } for ( %y = 0; $InvMelee[%y] !$= ""; %y++ ) { %meleeInv = $NameToInv[$InvMelee[%y]]; if ( ( $InvMelee[%y] !$= %client.favorites[getField( %client.meleeIndex, 0 )]) && %armor.max[%meleeInv] && !($InvBanList[%cmt, %meleeInv])) %meleeList = %meleeList TAB $InvMelee[%y]; } } } //Create - PACK - List if ( %noSniperRifle ) { if ( getFieldCount( %client.packIndex ) ) %packList = %client.favorites[getField( %client.packIndex, 0 )]; else { %packList = "EMPTY"; %client.numFavs++; } for ( %y = 0; $InvPack[%y] !$= ""; %y++ ) { %PInv = $NameToInv[$InvPack[%y]]; if ( ( $InvPack[%y] !$= %client.favorites[getField( %client.packIndex, 0 )]) && %armor.max[%PInv] && !($InvBanList[%cmt, %PInv])) %packList = %packList TAB $Invpack[%y]; } } //Create - Construction - List if(%client.favorites[0] $= "Purebuild") { if ( %noSniperRifle ) { if ( getFieldCount( %client.depIndex ) ) %depList = %client.favorites[getField( %client.depIndex, 0 )]; else { %depList = "EMPTY"; %client.numFavs++; } for ( %y = 0; $InvDep[%y] !$= ""; %y++ ) { %DInv = $NameToInv[$InvDep[%y]]; if ( ( $InvDep[%y] !$= %client.favorites[getField( %client.depIndex, 0 )]) && %armor.max[%DInv] && !($InvBanList[%cmt, %DInv])) %depList = %depList TAB $InvDep[%y]; } } } //Create - GRENADE - List for ( %y = 0; $InvGrenade[%y] !$= ""; %y++ ) { %notFound = true; for(%i = 0; %i < getFieldCount( %client.grenadeIndex ); %i++) { %GInv = $NameToInv[$InvGrenade[%y]]; if ( ( $InvGrenade[%y] $= %client.favorites[getField( %client.grenadeIndex, %i )] ) || !%armor.max[%GInv] ) { %notFound = false; break; } } if ( !($InvBanList[%cmt, %GInv]) ) { if ( %notFound && %grenadeList $= "" ) %grenadeList = $InvGrenade[%y]; else if ( %notFound ) %grenadeList = %grenadeList TAB $InvGrenade[%y]; } } // CheckNadePrereqs(%client, %grenadeList); //Create - MINE - List for ( %y = 0; $InvMine[%y] !$= "" ; %y++ ) { %notFound = true; %MInv = $NameToInv[$InvMine[%y]]; for ( %i = 0; %i < getFieldCount( %client.mineIndex ); %i++ ) if ( ( $InvMine[%y] $= %client.favorites[getField( %client.mineIndex, %i )] ) || !%armor.max[%MInv] ) { %notFound = false; break; } if ( !($InvBanList[%cmt, %MInv]) ) { if ( %notFound && %mineList $= "" ) %mineList = $InvMine[%y]; else if ( %notFound ) %mineList = %mineList TAB $InvMine[%y]; } } //Send - ARMOR - List %client.numFavsCount++; messageClient( %client, 'SetLineHud', "", %tag, 0, "Armor:", %armorList, armor, %client.numFavsCount ); %lineCount = 1; //Send - WEAPONS - List for ( %x = 0; %x < %armor.maxWeapons; %x++ ) { %client.numFavsCount++; if ( %x < getFieldCount( %client.weaponIndex ) ) { %list = %client.favorites[getField( %client.weaponIndex,%x )]; if ( %list $= Invalid ) { %client.favorites[%client.numFavs] = "INVALID"; %client.weaponIndex = %client.weaponIndex TAB %client.numFavs; } } else { %list = "EMPTY"; %client.favorites[%client.numFavs] = "EMPTY"; %client.weaponIndex = %client.weaponIndex TAB %client.numFavs; %client.numFavs++; } if ( %list $= empty ) %list = %list TAB %weaponList; else %list = %list TAB %weaponList TAB "EMPTY"; messageClient( %client, 'SetLineHud', "", %tag, %x + %lineCount, "Weapon Slot " @ %x + 1 @ ": ", %list , weapon, %client.numFavsCount ); } %lineCount = %lineCount + %armor.maxWeapons; //Send - PISTOL - List if(%client.favorites[0] !$= "Purebuild") { %client.numFavsCount++; if ( getField( %pistolList, 0 ) !$= empty && %noSniperRifle ) %pistolList = %pistolList TAB "EMPTY"; %pistolText = %pistolList; %pistolOverFlow = ""; if ( strlen( %pistolList ) > 255 ) { %pistolText = getSubStr( %pistolList, 0, 255 ); %pistolOverFlow = getSubStr( %pistolList, 255, 512 ); } messageClient( %client, 'SetLineHud', "", %tag, %lineCount, "Pistol:", %pistolText, pistol, %client.numFavsCount, %pistolOverFlow ); %lineCount++; } if(%client.favorites[0] !$= "Purebuild") { %client.numFavsCount++; if ( getField( %meleeList, 0 ) !$= empty && %noSniperRifle ) %meleeList = %meleeList TAB "EMPTY"; %meleeText = %meleeList; %meleeOverFlow = ""; if ( strlen( %meleeList ) > 255 ) { %meleeText = getSubStr( %meleeList, 0, 255 ); %meleeOverFlow = getSubStr( %meleeList, 255, 512 ); } messageClient( %client, 'SetLineHud', "", %tag, %lineCount, "Melee:", %meleeText, melee, %client.numFavsCount, %meleeOverFlow ); %lineCount++; } //Send - PACK - List %client.numFavsCount++; if ( getField( %packList, 0 ) !$= empty && %noSniperRifle ) %packList = %packList TAB "EMPTY"; %packText = %packList; %packOverFlow = ""; if ( strlen( %packList ) > 255 ) { %packText = getSubStr( %packList, 0, 255 ); %packOverFlow = getSubStr( %packList, 255, 512 ); } messageClient( %client, 'SetLineHud', "", %tag, %lineCount, "Pack:", %packText, pack, %client.numFavsCount, %packOverFlow ); %lineCount++; //Send - Construction - List if(%client.favorites[0] $= "Pure Build") { %client.numFavsCount++; if ( getField( %depList, 0 ) !$= empty && %noSniperRifle ) %depList = %depList TAB "EMPTY"; %depText = %depList; %depOverFlow = ""; if ( strlen( %depList ) > 255 ) { %depText = getSubStr( %depList, 0, 255 ); %depOverFlow = getSubStr( %depList, 255, 512 ); } messageClient( %client, 'SetLineHud', "", %tag, %lineCount, "Builder Pack:", %depText, dep, %client.numFavsCount, %depOverFlow ); %lineCount++; } for( %x = 0; %x < %armor.maxGrenades; %x++ ) { %client.numFavsCount++; if ( %x < getFieldCount( %client.grenadeIndex ) ) { %list = %client.favorites[getField( %client.grenadeIndex, %x )]; if (%list $= Invalid) { %client.favorites[%client.numFavs] = "INVALID"; %client.grenadeIndex = %client.grenadeIndex TAB %client.numFavs; } } else { %list = "EMPTY"; %client.favorites[%client.numFavs] = "EMPTY"; %client.grenadeIndex = %client.grenadeIndex TAB %client.numFavs; %client.numFavs++; } if ( %list $= empty ) %list = %list TAB %grenadeList; else %list = %list TAB %grenadeList TAB "EMPTY"; messageClient( %client, 'SetLineHud', "", %tag, %x + %lineCount, "Grenade:", %list, grenade, %client.numFavsCount ); } %lineCount = %lineCount + %armor.maxGrenades; for ( %x = 0; %x < %armor.maxMines; %x++ ) { %client.numFavsCount++; if ( %x < getFieldCount( %client.mineIndex ) ) { %list = %client.favorites[getField( %client.mineIndex, %x )]; if ( %list $= Invalid ) { %client.favorites[%client.numFavs] = "INVALID"; %client.mineIndex = %client.mineIndex TAB %client.numFavs; } } else { %list = "EMPTY"; %client.favorites[%client.numFavs] = "EMPTY"; %client.mineIndex = %client.mineIndex TAB %client.numFavs; %client.numFavs++; } if ( %list !$= Invalid ) { if ( %list $= empty ) %list = %list TAB %mineList; else if ( %mineList !$= "" ) %list = %list TAB %mineList TAB "EMPTY"; else %list = %list TAB "EMPTY"; } messageClient( %client, 'SetLineHud', "", %tag, %x + %lineCount, "Mine:", %list, mine, %client.numFavsCount ); } if ( %setLastNum ) %client.lastNumFavs = %client.numFavs; }
hud.cs
function serverCmdSetClientFav(%client, %text) { if ( getWord( getField( %text, 0 ), 0 ) $= armor ) { if (%client.packIndex > 0) %oldPack = %client.favorites[getField(%client.packIndex,0)]; if (%client.depIndex > 0) %oldDep = %client.favorites[getField(%client.depIndex,0)]; %client.curFavList = %text; %validList = checkInventory( %client, %text ); %client.favorites[0] = getField( %text, 1 ); %armor = getArmorDatablock( %client, $NameToInv[getField( %validList,1 )] ); %weaponCount = 0; %pistolCount = 0; %meleeCount = 0; %packCount = 0; %depCount = 0; %grenadeCount = 0; %mineCount = 0; %count = 1; %client.weaponIndex = ""; %client.pistolIndex = ""; %client.meleeIndex = ""; %client.packIndex = ""; %client.depIndex = ""; %client.grenadeIndex = ""; %client.mineIndex = ""; for(%i = 3; %i < getFieldCount(%validList); %i = %i + 2) { %setItem = false; switch$ (getField(%validList,%i-1)) { case weapon: if(%weaponCount < %armor.maxWeapons) { if(!%weaponCount) %client.weaponIndex = %count; else %client.weaponIndex = %client.weaponIndex TAB %count; %weaponCount++; %setItem = true; } case pistol: if(%pistolCount < 1) { %client.pistolIndex = %count; %pistolCount++; %setItem = true; } case melee: if(%meleeCount < 1) { %client.meleeIndex = %count; %meleeCount++; %setItem = true; } case pack: if(%packCount < 1) { %client.packIndex = %count; %packCount++; %setItem = true; } case dep: if(%depCount < 1) { %client.depIndex = %count; %depCount++; %setItem = true; } case grenade: if(%grenadeCount < %armor.maxGrenades) { if(!%grenadeCount) %client.grenadeIndex = %count; else %client.grenadeIndex = %client.grenadeIndex TAB %count; %grenadeCount++; %setItem = true; } case mine: if(%mineCount < %armor.maxMines) { if(!%mineCount) %client.mineIndex = %count; else %client.mineIndex = %client.mineIndex TAB %count; %mineCount++; %setItem = true; } } if(%setItem) { %client.favorites[%count] = getField(%validList, %i); %count++; } } %client.numFavs = %count; %client.numFavsCount = 0; if (%client.packIndex > 0 && %client.depIndex > 0) { %pack = %client.favorites[getField(%client.packIndex,0)]; %dep = %client.favorites[getField(%client.depIndex,0)]; if ((%pack !$= "Empty" && %pack !$= "Invalid") && (%dep !$= "Empty" && %dep !$= "Invalid")) { if (%pack $= %oldPack) %clearPack = true; else if (%dep $= %oldDep) %clearDep = true; if (%clearPack) %client.favorites[%client.packIndex] = "EMPTY"; else if (%clearDep || (!%clearPack && !%clearDep)) %client.favorites[%client.depIndex] = "EMPTY"; } } inventoryScreen::updateHud(1, %client, 'inventoryScreen'); } }
No Syntax Errors are generated.
Comments
EDIT:
I fixed the weapons, and will report back if anything else isn't working.
All fixed:
the problem was funny, and pretty obvious after I looked closely at the for loops. I started the weapon and pack inventories at 1, not 0. :P