Jump to content
🛡️FORUMS ARE IN READ-ONLY MODE Read more... ×
KokaKolaA3

Check if solider has Helmet & addheadgear

Recommended Posts

Hey, i really don't know where to start.

I need a script which basicly doing the following things:

 

If player has Helmet_A then he has the action "Switch Helmet to B" and becomes Helmet_B. (this have to work in MP too)

If player has Helmat_B then he has the action "Switch Helmet to A" and becomes Helmet_A.

 

Im a noob in scripting :P

 

Thank You!

 

 

 

Share this post


Link to post
Share on other sites

add file initPlayerLocal.sqf to your mission and put this in that file

 

//initPlayerLocal.sqf

//if have helmet A
if (headgear player in ["H_HelmetB_desert"]) then {

    player addAction["Switch Helmet to B", {
        removeHeadgear player;
        player addHeadgear "H_HelmetB_camo"; //helmet B
        player removeAction (_this select 2);
    }];

};


//if have helmet B
if (headgear player in ["H_HelmetB_camo"]) then {

    player addAction["Switch Helmet to A", {
        removeHeadgear player;
        player addHeadgear "H_HelmetB_desert"; //helmet A
        player removeAction (_this select 2);
    }];

};

Not tested, just pseudo code to get you on point.

  • Like 2

Share this post


Link to post
Share on other sites

 

add file initPlayerLocal.sqf to your mission and put this in that file

 

//initPlayerLocal.sqf

//if have helmet A
if (headgear player in ["H_HelmetB_desert"]) then {

    player addAction["Switch Helmet to B", {
        removeHeadgear player;
        player addHeadgear "H_HelmetB_camo"; //helmet B
        player removeAction (_this select 2);
    }];

};


//if have helmet B
if (headgear player in ["H_HelmetB_camo"]) then {

    player addAction["Switch Helmet to A", {
        removeHeadgear player;
        player addHeadgear "H_HelmetB_desert"; //helmet A
        player removeAction (_this select 2);
    }];

};

Not tested, just pseudo code to get you on point.

 

You can switch to Helmet A, but not back to helmet B.

But it works, thank you alot!

 

 

Edit:

It does work only once, so if you have the Helmet A, then switching to B, and pick up another Helmet A, you can't switch to Helmet B

Edited by KokaKolaA3

Share this post


Link to post
Share on other sites

You can modify it like this to select it back.

//initPlayerLocal.sqf

while { alive player } do { 

    //if have helmet A
    if (headgear player in ["H_HelmetB_desert"]) then {

        player addAction["Switch Helmet to B", {
            removeHeadgear player;
            player addHeadgear "H_HelmetB_camo"; //helmet B
            player removeAction (_this select 2);
        }];

    };

    //wait until player have helmet B
    waitUntil { sleep 1; headgear player in ["H_HelmetB_camo"] };

    //if have helmet B
    if (headgear player in ["H_HelmetB_camo"]) then {

        player addAction["Switch Helmet to A", {
            removeHeadgear player;
            player addHeadgear "H_HelmetB_desert"; //helmet A
            player removeAction (_this select 2);
        }];

    };

    //wait until player have helmet A
    waitUntil { sleep 1; headgear player in ["H_HelmetB_desert"] };

};
  • Like 1

Share this post


Link to post
Share on other sites

put some sleep 1 in those waitUntils!!! I think there is no need to know what helmet has the player every 0.000000000001 seconds!!!!

  • Like 1

Share this post


Link to post
Share on other sites

put some sleep 1 in those waitUntils!!! I think there is no need to know what helmet has the player every 0.000000000001 seconds!!!!

 

Good thinking. As I said earlier. This is pseudo code. Not tested or optimized.

Share this post


Link to post
Share on other sites

put some sleep 1 in those waitUntils!!! I think there is no need to know what helmet has the player every 0.000000000001 seconds!!!!

Sleep would be good in this situation, but waituntil runs the code only once a frame or less.

  • Like 1

Share this post


Link to post
Share on other sites

×