Jump to content
Sign in to follow this  
Khalashnikovf

if unit is player then ... How to?

Recommended Posts

Im kinda confused why this is not working?

I want use this part of script which should check if unit is player or player is inside of that unit. But its not working.

Can anyone help me pls?

i[b]f (vehicle player == player) then { SCRIPT };[/b]

Share this post


Link to post
Share on other sites

Where are you trying to use it? If it's in init.sqf or something started from it, then it might try to check the condition before player actually gets hold of the unit. So, try adding

waituntil {!isnull player};

before it.

Share this post


Link to post
Share on other sites
Where are you trying to use it? If it's in init.sqf or something started from it, then it might try to check the condition before player actually gets hold of the unit. So, try adding

waituntil {!isnull player};

before it.

Its used in my nuke script http://forums.bistudio.com/showthread.php?t=112397 where shockwave hit every single unit on map. And what I need is playSound of impact sound when is that unit Player (also to be working in MP).

Share this post


Link to post
Share on other sites

Are you trying to check if the unit is the player or if the unit is a player?

_unit == player will return true if _unit is the same object as player (note that player will be null while the mission is initializing, so a waitUntil {!isNull player}; is needed before you try use the player variable).

isPlayer _unit will return true if _unit is any player, not necessarily the player on the machine running the script (can be used on server as well).

Also, you might find the in command useful.

Share this post


Link to post
Share on other sites

if (vehicle player == player) then { SCRIPT };

Is the standard code to check if the player is on foot or inside a vehicle (since vehicle player will return the player if the unit is not inside a vehicle - otherwise it will naturally return the vehicle of the player). :) So it really has nothing to do with checking whether the player is the player or whatever.

Regards,

Wolfrug

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  

×