Jump to content
Sign in to follow this  
MuffEater

[help] addAction counter

Recommended Posts

hi guys,

so there's a code I wrote to be able to use a "medic ability" without being a medic (I placed an addAction in the init. sqf which is : "player addAction ["Use a medikit","healing.sqf"];"):

cnt = 0;
if (cnt <= 3) then {
player playMove "AinvPknlMstpSnonWrflDnon_medic1";
sleep 2;
player setDamage 0;
hintSilent "Good to go.";
cnt = cnt +1;
};

I wanted it to be usable only 3 times, but it is unlimited ATM...

Any ideas?

Edited by MuffEater

Share this post


Link to post
Share on other sites

This is the "healing.sqf" right?

cnt = 0;
if (cnt <= 3) then {
player playMove "AinvPknlMstpSnonWrflDnon_medic1";
sleep 2;
player setDamage 0;
hintSilent "Good to go.";
cnt = cnt +1;
};

Just look at your code.

Every time you use this script the variable "cnt" will be set to 0.

Use:

if (isNil "cnt") then {cnt = 0};

if (cnt <= 3) then {
player playMove "AinvPknlMstpSnonWrflDnon_medic1";
sleep 2;
player setDamage 0;
hintSilent "Good to go.";
cnt = cnt +1;
};

By using "isNil" the variable "cnt" will be created only once.

Share this post


Link to post
Share on other sites

ID1 = this addAction["Heal","Heal.sqf"]; iCount = 0;

Heal.sqf:

iCount = iCount + 1;

player playMove "AinvPknlMstpSnonWrflDnon_medic1";

sleep 2;

player setDamage 0;

hintSilent "Good to go.";

if (iCount >= 3) then {player removeAction ID1};

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
Sign in to follow this  

×