Blockland Forums > Modification Help

noShootCrouch package problem

(1/1)

BlockAlpha:

I found out that the code that $trinick made for me a long time ago activated on any player in my server, so I tried to make it work only for my playertype :

--- Code: ---package noShootCrouch
{
    function Armor::onTrigger(%db, %this, %slot, %pos)
{
        if(%slot == 3 && isObject(%this.getMountedImage(%pos?0:2)) )
{
if(%this.getName() $= "BlockSoldierArmor" || %this.getName() $= "BlockSoldierSArmor") //<-- this is the line I added
{
%this.mountImage(%this.getMountedImage(%pos?0:2), %pos*2);
%this.unMountImage(%pos?0:2);
}
}
        parent::onTrigger(%db, %this, %slot, %pos);
    }
};
activatePackage(noShootCrouch);
--- End code ---
but it seems not working,it looks like the game thinks i'm using the wrong playertype,
 %this is the player datablock, am i right?
What should I do for making it work only with my shooter playertype? thanks

jes00:
The first arguement(%db) is the datablock. %this is the specific player.

phflack:
can also add echo(%this.getName()); and echo(%db.getName()); to verify, and make sure the names are correct

PhantOS:
you should add a field to any player armor you want this strategy to be used on. instead of if(%db == BlockSoldierArmor) you should create a field in BlockSoldierArmor called "noShootCrouch" and set it to true and check using if(%db.noShootCrouch).

that way if you/modders want to create any new armors like BlockSoldierArmorHighHealth or BlockSoldierArmorFast all they have to do is add a field to them called noShootCrouch and set it to true for the package to work, rather than add a condition to check the name for each one. Or even easier, just derive their new armor from BlockSoldierArmor and then the field will be inherited automatically. Or if you structure this as a support add-on then modders can use the script in their own playertypes and all they have to do again is add noShootCrouch to their playertype armor.

this is entirely optional and unnecessary but it's good scalable design

BlockAlpha:
Thanks guys! I'm so glad

Navigation

[0] Message Index

Go to full version