Bot type mask isnt working

Author Topic: Bot type mask isnt working  (Read 998 times)

Im trying to make a system where the light key is used to activate things (Pick up items, Interact)
and it worked fine until I add in the type mask for bots, thats when it stops working
Code: [Select]
function serverCmdLight(%client, %brick)
{
%player = %client.player;

    if(!isObject(%object = getWord(containerRaycast(%player.getEyePoint(), vectorAdd(%player.getEyePoint(), vectorScale(%player.getEyeVector(), 7)), $TypeMasks::FxBrickObjectType | $TypeMasks::PlayerObjectType),0)))
        return;
    %brick = %object;

    if(%object.getDatablock() == brickSingleBottleCapData.getID())
{
%client.backPack["Caps"]++;
%client.backPack["Stim"]++;
messageClient(%client, '',"<font:Arial Bold:25><color:5bb611>[(1) Bottle Cap Added]");
%brick.disappear(32);
}
if(%object.getDatablock() == brickStackBottleCapData.getID())
{
%Amount = (getRandom(10,20));
%client.backPack["Caps"] += %Amount;
messageClient(%client, '',"<font:Arial Bold:25><color:5bb611>[ (" @ %Amount SPC ") Bottle Cap Added]");
%brick.disappear(32);
serverPlay3D(CapPickupSound, %client.player.getPosition());
}

if(%object.getDatablock() == brickTireData.getID())
{
%client.backPack["Rubber"] += 5;
%client.backPack["ScrapMetal"] += 2;
messageClient(%client, '',"<font:Arial Bold:25><color:5bb611>[Rubber Added]");
messageClient(%client, '',"<font:Arial Bold:25><color:5bb611>[Scrap Metal Added]");
%brick.disappear(32);
}

if(%object.getDatablock() == brickNukaBottleData.getID())
{
%client.backPack["Glass"]++;
messageClient(%client, '',"<font:Arial Bold:25><color:5bb611>[Glass Added]");
%brick.disappear(32);
serverPlay3D(CapPickupSound, %client.player.getPosition());

}

if(%object.getDatablock() == brickScrapMetalTeapotData.getID())
{
%client.backPack["ScrapMetal"] += 5;
messageClient(%client, '',"<font:Arial Bold:25><color:5bb611>[(5) Scrap Metal Added]");
%brick.disappear(32);
}

if(%object.getDatablock() == brickBentTincanData.getID())
{
%client.backPack["ScrapMetal"]++;
messageClient(%client, '',"<font:Arial Bold:25><color:5bb611>[Scrap Metal Added]");
%brick.disappear(32);
}

if(%object.getDatablock() == brickTincanData.getID())
{
%client.backPack["ScrapMetal"]++;
messageClient(%client, '',"<font:Arial Bold:25><color:5bb611>[Scrap Metal Added]");
%brick.disappear(32);
}

if(%object.getDatablock() == brickHamRadioData.getID())
{
%client.backPack["ScrapElectronics"]++;
%client.backPack["LightBulb"]++;
messageClient(%client, '',"<font:Arial Bold:25><color:5bb611>[ScrapElectronics Added]");
messageClient(%client, '',"<font:Arial Bold:25><color:5bb611>[Light Bulb Added]");
%brick.disappear(32);
}
if(%object.getDatablock() == brickTV1Data.getID())
{
%client.backPack["Glass"] += 3;
%client.backPack["ScrapElectronics"] += 2;
messageClient(%client, '',"<font:Arial Bold:25><color:5bb611>[(3) Glass Added]");
messageClient(%client, '',"<font:Arial Bold:25><color:5bb611>[(2) Scrap Electronics Added]");
%brick.disappear(32);
}
if(%object.getDatablock() == brickTV1Data.getID())
{
%client.backPack["Wood"] += 5;
messageClient(%client, '',"<font:Arial Bold:25><color:5bb611>[(5) Wood Added]");
%brick.disappear(32);
}

if(%object.getDatablock() == brickXO1HeadData.getID())
{
%client.X01Head += 1;
messageClient(%client, '',"<font:Arial Bold:25><color:5bb611>[X-01 PowerArmor Head Added]");
%brick.disappear(32);
}

if(%object.getDatablock() == brickXO1BodyData.getID())
{
%client.X01Body += 1;
messageClient(%client, '',"<font:Arial Bold:25><color:5bb611>[X-01 PowerArmor Body Added]");
%brick.disappear(32);
}

if(%object.getDatablock() == brickXO1LegsData.getID())
{
%client.X01Legs += 1;
messageClient(%client, '',"<font:Arial Bold:25><color:5bb611>[X-01 PowerArmor Legs Added]");
%brick.disappear(32);
}
}

What does 'stop working mean'. Also, learn to use either switches or understand when to use else If instead of just if. Also, take pride in formatting your code as this can help debugging.

You have the playerobject type, but you don't have an if statement for when the raycast hits the bot.

What does 'stop working mean'. Also, learn to use either switches or understand when to use else If instead of just if. Also, take pride in formatting your code as this can help debugging.

You have the playerobject type, but you don't have an if statement for when the raycast hits the bot.
else would be inapropriate wouldnt it? I mean it would have an if statement later to check the bricks datablock anyways, And it quite literally stops working, it wont cone up with any indication of it running the function, I had a if statement to check for a bot but I removed it to try and find out exactly where it stoped working, also no indication of a syntax error

else would be inapropriate wouldnt it? I mean it would have an if statement later to check the bricks datablock anyways, And it quite literally stops working, it wont cone up with any indication of it running the function, I had a if statement to check for a bot but I removed it to try and find out exactly where it stoped working, also no indication of a syntax error
else is used to skip unneeded checks. with the current code, since you dont return the function early, if the datablock is single bottle cap brick, it will still check every other if statement since they are not in an else

else literally works at face value. if this, then this. Else if this, then this.
without else, both would get checked unless the first if resulted in a premature return