Jump to content
Sign in to follow this  
calo_mir

Action on entering vehicle

Recommended Posts

I've created an object with createVehicle and then attached it to a unit. The unit enters a vehicle. The object stays fixed in place, floating outside. If the vehicle drives away, the object stays where it was when the unit entered.

Without adding an event handler to every single vehicle that the unit might possibly enter (including remembering to add one for every vehicle that might be created via a script), is it possible to have some code executed when a unit enters a vehicle?

I'd like to hide the attached object temporarily, whilst the unit's in the vehicle. Alternately, I'll attach the object to the vehicle and then reattach it to the unit when it exits.

The reason I don't want to create an event handler for all vehicles is because I'm intending to create a reusable script and it's unreasonable to expect the user of that script to fiddle with all the vehicles in their scenario in that way.

Share this post


Link to post
Share on other sites

Certainly, yes. The problem is knowing when to call it. I could call it periodically on all players with attached objects, but that's likely to be expensive and not exactly very pretty...

Share this post


Link to post
Share on other sites

Not exactly what you asked, but here's a method I used in a mission to have an action available for the player, on foot or in any vehicle.

while {true} do {
 waituntil {vehicle player == player};
 if (!isnil "_veh") then { _veh removeaction _id };
 _id = player addAction ["ActText", "script.sqf",[],1,false,true,"",""];

 waituntil {vehicle player != player};
 player removeaction _id;
 _veh = vehicle player;
 _id = _veh addAction ["ActText", "script.sqf",[],1,false,true,"",""];
};

Edited by Shuko

Share this post


Link to post
Share on other sites
Not exactly what you asked, but here's a method I used in a mission to have an action available for the player, on foot or in any vehicle.

Ah, yeah, I see. I didn't grasp what you meant at first.

Not a bad idea. I'd expect people to register their units with my script (it's essential for the type of game it manages anyway). I'd spawn one process per unit that keeps an eye on their vehicle usage.

Thanks, I'll try this.

Share this post


Link to post
Share on other sites

as for hiding the object this works quit well

just have a trigger set up

on act player in vehicle

cond object hideobject true

then another trigger

on act !(player in vehicle)

cond object hideobject false

Share this post


Link to post
Share on other sites

Suspect I'll be checking the running version at runtime...

Share this post


Link to post
Share on other sites
But only with the beta patch. 1.05 hasnt got the hideObject command. 1.06 will have it.

E: with version 1.05 use deleteCollection

http://community.bistudio.com/wiki/deleteCollection

but this wont work with the beta patch or 1.06

Good point I'd forgotten about that.

I'm not sure about deletecollection how do you restore it?

You cloud just delete the object and respawn it in the second trigger.

Share this post


Link to post
Share on other sites
I'm not sure about deletecollection how do you restore it?

Seems theres no way to restore that. But whats about detach the object, moving it to [0,0,0] and then attach it again? of course only if you cant use hideObject.

E:

You cloud just delete the object and respawn it in the second trigger.

or this.

Edited by MichaelGER

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  

×