Jump to content
Sign in to follow this  
eLectryx

Execute script on player from trigger

Recommended Posts

Hi all:

Looking for a bit of help on something. I have a trigger called gotoprison. The cond is score player < -50 and in the activation I have prison = [] execVM "go_to_prison.sqf";

The trigger and script fire just fine. The problem is in the script. Basically I am trying to check if a player is inside a vehicle, and if so, move him out before doing the attachTo. If not, just do the attachTo. Now when I had just the attachTo and removeAllWeapons in the trigger, it worked fine UNLESS the player was in a vehicle which is why I went to a script solution instead.

Basically, I can't even get past the if statement. Any assistance appreciated.

_player = (list gotoprison) select 0;
_vehicle = vehicle _player;

if(_vehicle != _player) then {
hint "recognizes I am in a vehicle";
unassignvehicle _player;
sleep 0.3;
_player attachTo [prison,[-0.0,-1.5,-0.6]];
removeAllWeapons _player;
};
else {
_player attachTo [prison,[-0.0,-1.5,-0.6]];
removeAllWeapons _player;
};

Share this post


Link to post
Share on other sites

I can't make much of what the problem is, but essentially you could try this:

_veh = vehicle player;

if (vehicle player != player) then {player action ["eject", _veh]; player attachTo [prison,[-0.0,-1.5,-0.6]]; removeAllWeapons player;} else {player attachTo [prison,[-0.0,-1.5,-0.6]]; removeAllWeapons player;};

if your playerunit is grouped to the vehicle then by all means use the unAssignVehicle command as well. but this should work, else look at the arma 2 error log and see where the snag is. I'm not sure sleeps can be used within if statements, also be aware of using the 'private' command for any further scripting with if statements.

---------- Post added at 01:37 PM ---------- Previous post was at 01:36 PM ----------

btw be aware that player is recognised by the engine as an entity, better than using the whole list thing to create an assignment.

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  

×