Author Topic: noShootCrouch package problem  (Read 241 times)

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: [Select]
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);
        parent::onTrigger(%db, %this, %slot, %pos);
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

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

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

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
« Last Edit: May 08, 2019, 01:57:17 PM by PhantOS »

Thanks guys! I'm so glad