Jump to content
Sign in to follow this  
Twix

vehicle player makes no sense, could use some help

Recommended Posts

Hello,

I've been trying to get something to happen when a player get in a given helicopter and insanely weird stuff keeps happening. I just can't figure it out so could use some help.

This is an example of code

waitUntil {sleep 0.5; vehicle player != player};

_v = vehicle player;

hint format["IN - _v: %1, player: %2, vehicule of player: %3, driver de v: %4",_v,player,vehicle player,driver _v];

if (_v isKindOf "Helicopter") then {blabla;};

Now...the weird stuff!

The waitUntil works perfectly and when I get into the chopper, it exits and continues. The problem is that in the hint box, _v, player, vehicule of player AND driver de _v are ALL the same, in that they are the player!!

I turned this around thousands of times and I don't understand how the waituntil can exit, and yet the vehicle of player IS the player in the next line!

The crazy stuff continues though because the IF statement actually WORKS!

If any clever mind can sort this out for me, I'd be grateful.

Thanks in advance.

Edit:

Also, related, how do you check if a vehicle is of a specific name (given in mission editor).

Share this post


Link to post
Share on other sites

Well:

_v = vehicle player; aka _v = vehicle.

so

_v == _vehicle player.

vehicle player = the vehicle. But if you output a vehicle with a player inside it outputs the players name. Once a player enters a vehicle he gets bound/connected to it.

I'm not sure if I'm making any sence but yeah it's correct that it shows 4 times the same. It's just for the name tho, the objects are actually seperate. The reason it works this way is (i believe) because things like position, velocity etc get bound to eachother.

Change the script to this and you will understand:

hint format["IN - _v: %1, player: %2, vehicule of player: %3, driver de v: %4",name _v,name player,name vehicle player,name driver _v];

Share this post


Link to post
Share on other sites
Well:

_v = vehicle player; aka _v = vehicle.

so

_v == _vehicle player.

vehicle player = the vehicle. But if you output a vehicle with a player inside it outputs the players name. Once a player enters a vehicle he gets bound/connected to it.

I'm not sure if I'm making any sence but yeah it's correct that it shows 4 times the same. It's just for the name tho, the objects are actually seperate. The reason it works this way is (i believe) because things like position, velocity etc get bound to eachother.

Change the script to this and you will understand:

hint format["IN - _v: %1, player: %2, vehicule of player: %3, driver de v: %4",name _v,name player,name vehicle player,name driver _v];

with this

waitUntil

{

sleep 0.5;

diag_log format["OUT - player: %1, vehicule of player: %2",name player,name vehicle player];

vehicle player != player

};

_v = vehicle player;

diag_log format["IN - _v: %1, player: %2, vehicule of player: %3, driver de v: %4",name _v,name player,name vehicle player,name driver _v];

I got this

"OUT - player: Kemor, vehicule of player: Kemor"

"IN - _v: Kemor, player: Kemor, vehicule of player: Kemor, driver de v: Kemor"

Still doesn't make ANY sense.

typeOf returned B_MH9_F, which is a good start, thanks.

However, how do you get the NAME (as defined in the name parameter on mission editor) of the vehicule in which is the player?

Share this post


Link to post
Share on other sites

Well if you really really really need the vehicle's name (i'm not sure why tho) you could put this in the vehicles init:

this setVariable ["vehicleName", name this];

Share this post


Link to post
Share on other sites

Well, the idea is to have a script running to make sure only pilots can fly any of the helicopters on the map, even dynamically spawned ones.

However, I have ONE helicopter that I want specific players to be able to use, even if not pilots. The issue came from trying to identify THIS specific chopper amongst the entire fleet of choppers running around on the map, so I gave it a specific name in the editor.

Just can't get it back in scripts :)

Share this post


Link to post
Share on other sites

If you name a object in the editor for example: THE_CHOPPER_EVERYONE_CAN_USE

it will actually become a "object" available in your script.

So you can actually do this anywhere in your scripts:

_driver = driver THE_CHOPPER_EVERYONE_CAN_USE;

So you will have your awsome noone can fly scip and will have to change it to:

if(vehicle player == THE_CHOPPER_EVERYONE_CAN_USE) then
{
//allowed
}
else
{
moveOut player;
};

Share this post


Link to post
Share on other sites

I see, thanks, I'll try that.

Share this post


Link to post
Share on other sites

What you were seing is textual representation mainly intended for debuging.

Behind it is a reference (number) describing where in memory the object is.

And the engine compares those references which are both different.

When iam on quadbike the it says: B Alpha 1-2:1 (aeroson)

And when iam on foot, it says: 396c4080# 162990: quadbike.p3d

Share this post


Link to post
Share on other sites

Yea I understood what I was seeing but not why. The why made no sense and still doesn't.

Got it working with the naming procedure, once you know..well...you know and it all seems so simple. Lost a lot of time scratching my head on that one though...

Thanks for the help in any case! Another day learning something new is another good day :)

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  

×