Jump to content
pliskin124

Creating a Vehicle Selection Script

Recommended Posts

I need a script that will spawn a vehicle on a marker through an addaction, and then despawn it if another selection is made.

 

For instance, I want a jet pilot to be able to go up to a computer, make their selection on an aircraft, get in it, fly it around, park it anywhere, go back to the computer and select a new aircraft, but delete the old aircraft in order to save server resources.

 

The first half of the script, spawning a vehicle on a marker is the easy part and I can probably figure out, the second half about deleting the previous vehicle and replacing it is the part I'm lost on.

 

Any assistance would be helpful thanks.

Share this post


Link to post
Share on other sites

Rough flow:
Select vehicle
Check if player has vehicle associated with them
Delete old vehicle
Spawn new vehicle
Save vehicle variable to player for retrieval later

Sent from my D6503 using Tapatalk

Share this post


Link to post
Share on other sites

Not sure how the vehicle would be associated with the player if they're not in it? Also not really sure where to go from there as far as scripting goes.

Share this post


Link to post
Share on other sites
5 hours ago, pliskin124 said:

Not sure how the vehicle would be associated with the player if they're not in it? Also not really sure where to go from there as far as scripting goes.

tirpitz means that the player now has an assigned vehicle.

Just like if you were to plop a unit into a helo, now you can see that it's assigned to the unit and you can tell if the unit has flown or ridden in the helo.

if((assignedVehicle player) isEqualTo objNull)  then  { hint "player has no vehicle assigned" } 
else 
{  hint format["Player has vehicle : %1  assigned to it",(assignedVehicle player)];};

example.

Share this post


Link to post
Share on other sites

Not sure that assigning the vehicle is the best solution in case of shift or respawn or else. What you can do is to set a variable for the vehicle when spawned:

_veh setVariable ["creator", _thisPlayer];

then, you can delete it:

{deleteVehicle _X} forEach (vehicles select {_x getVariable "creator" == _thisPlayer});

Share this post


Link to post
Share on other sites

That's not what I meant
I meant something along the lines of
Player setvariable ["veh", _veh]


Sent from my D6503 using Tapatalk

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

×