Jump to content

Recommended Posts

Hellow everybody. Can somebody advise how to make certain script: After killing 10 east faction units - spawn marker ONE, after killing 20 units - spawn marker TWO. Thanks. Ive tried this code, but it doesnt work properly (its repeating itself)

Spoiler

MyWestKillCounter = 0;

addMissionEventHandler ["EntityKilled",{

    params ["_killedUnit","_killer","_triggerMan"];

    _configSide = [getNumber (configfile >> "CfgVehicles" >> typeOf _killedUnit >> "side")] call BIS_fnc_sideType;
    //hint str _configside;

    if (_configSide isEqualTo east AND side _triggerMan isEqualTo west) then {

        MyWestKillCounter = MyWestKillCounter + 1;

        if (MyWestKillCounter >= 4) then {
//code start
hint "aaaaaaaaaa 1";
_markerstr = createMarker ["cache_1_marker", position cache_1 vectorAdd [100 - random 100, 100 - random 100, 0]];
_markerstr setMarkerShape "ICON";
_markerstr setMarkerType "hd_unknown";
"cache_1_marker" setMarkerText "cache #1 100m";
"cache_1_marker" setMarkerColor "ColorRed";
sleep 3;
terminate cashe_info1;
//code end
};

    };

}];

 

Share this post


Link to post
Share on other sites
17 hours ago, baton1990 said:

Hellow everybody. Can somebody advise how to make certain script: After killing 10 east faction units - spawn marker ONE, after killing 20 units - spawn marker TWO. Thanks. Ive tried this code, but it doesnt work properly (its repeating itself)

  Reveal hidden contents

MyWestKillCounter = 0;

addMissionEventHandler ["EntityKilled",{

    params ["_killedUnit","_killer","_triggerMan"];

    _configSide = [getNumber (configfile >> "CfgVehicles" >> typeOf _killedUnit >> "side")] call BIS_fnc_sideType;
    //hint str _configside;

    if (_configSide isEqualTo east AND side _triggerMan isEqualTo west) then {

        MyWestKillCounter = MyWestKillCounter + 1;

        if (MyWestKillCounter >= 4) then {
//code start
hint "aaaaaaaaaa 1";
_markerstr = createMarker ["cache_1_marker", position cache_1 vectorAdd [100 - random 100, 100 - random 100, 0]];
_markerstr setMarkerShape "ICON";
_markerstr setMarkerType "hd_unknown";
"cache_1_marker" setMarkerText "cache #1 100m";
"cache_1_marker" setMarkerColor "ColorRed";
sleep 3;
terminate cashe_info1;
//code end
};

    };

}];

 

 

>= 4 will return true everytime when 4+ west units have been killed. Hence the code inside the if then statement will execute.

Simply change it to an equal check, like:

MyWestKillCounter == 4
//or
MyWestKillCounter isEqualTo 4

This way the code will run on the fourth kill only.

 

Cheers

 

  • Like 1

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×