Jump to content
Sign in to follow this  
carlostex

First Aid-- I fail to create a script without help

Recommended Posts

Can someone tell me why my script fails to work?

//First Aid Kit
//Code by =WB=Tex

if (!isDedicated) exitWith {};

_unit = _this select 0;
_caller = _this select 1;
_id = _this select 2;
_sw = _this select 5;
_hide = _this select 6;

while (alive local player) do {

if ((damage _unit) >= 0.5 && (damage _unit) <= 0.7) then {
_unit setdamage 0.4; 
_unit playMove "AinvPknlMstpSlayWrflDnon_medic"; 
_unit sidechat "Still need a Medic";
} else {if ((damage _unit) > 0.7 && (damage _unit) < 1) then {_unit sideChat "MEDIC!"}
};

if ((damage _unit) < 0.4) then {
_unit setdamage 0.1;
_unit playMove "AinvPknlMstpSlayWrflDnon_medic"; 
_unit sidechat "Feel better now";
};

sleep 1;

};

if (true) exitWith {};

I get the action on the action menu but it does nothing. I get no sidechat message and animation does not play

Share this post


Link to post
Share on other sites

Thanks you Celery. But i really wanna have my script working. The thing is nothing happens when i press first aid kit on the action menu. I have this on a init.sqf:

player addAction ["First Aid Kit", "FirstAidKit.sqf", [], 1, false, true];

I guess select is not selecting anything.

Edited by CarlosTex

Share this post


Link to post
Share on other sites

Try to insert a few hints to see what works in your script and what not.

1. What is _sw and _hide for?

2. while (alive local player)

does this ever return true? I don´t know much about the mp stuff but biki says it checks if someone is local. I don´t think this one checks the right condition.

Share this post


Link to post
Share on other sites

if (!isDedicated) exitWith {};

Well, since you are calling the script with a action, and actions are local and scripts that they run are also local to players machine, that check will always return true and exit every time after this line, so your script, has never passed this line of code.

while (alive local player) do {

This is also wrong, not sure if you want to check if its local to player or player is alive, Ill assume that the player should be alive:

while {alive player} do

Also note the { }, info here.

if (true) exitWith {};

This is one of those checks...:p

This does absolutely nothing...And makes no sense if not when debugging like:

...some code...
if (true) exitWith {};
...unwanted code for testing purposes...

_neo_

Edited by neokika

Share this post


Link to post
Share on other sites

Thanks to all and nevermind i have it working like this:

//First Aid Kit
//Code by =WB=Tex

if (isDedicated) exitWith {}; 

_unit = _this select 0;

if ((damage _unit) >= 0.52) then {
_unit playMove "AinvPknlMstpSlayWrflDnon_medic"; 
_unit setdamage 0.51; 
_unit sidechat "50% Health";
} else {
if ((damage _unit) <= 0.5) then {
_unit playMove "AinvPknlMstpSlayWrflDnon_medic"; 
_unit setdamage 0.2; 
_unit sidechat "80% Health";
}
};

---------- Post added at 05:46 PM ---------- Previous post was at 03:56 PM ----------

Working even better like this:

//First Aid Kit
//Code by =WB=Tex

if (isDedicated) exitWith {}; 

_unit = _this select 0;

if ((damage _unit) >= 0.52) then {
_unit playMove "AinvPknlMstpSlayWrflDnon_medic"; 
_unit setdamage 0.51; 
_unit sidechat "50% Health";
} else {
if ((damage _unit) == 0) then {
_unit sideChat "Full Health Already"
	} else {if ((damage _unit) < 0.51 && (damage _unit) != 0.1) then {
											_unit playMove "AinvPknlMstpSlayWrflDnon_medic"; 
											_unit setdamage 0.1; 
											_unit sidechat "90% Health";
											}
			};
	};
{};

Shuko got me into using conditions inside conditions. :p

Anyone said that .sqf is not good?

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  

×