Jump to content
Doggifast

Player in a specific vehicle

Recommended Posts

Is there any way to identify if a player is in a specific vehicle? Please help. I'm a noob programmer so i thought of something like this:
 

(vehicle player) = _vehicleclassname

But it doesn't work.
Please help.

Share this post


Link to post
Share on other sites

Tell us the whole story. What do you want to do and what did you try to achieve it?

Share this post


Link to post
Share on other sites
7 minutes ago, sarogahtyp said:

Telk us the whole story. What do you want to do and what did you try to achieve it?

So i thought of an idea of creating a mod for Role-play scenarios, where the pilot/driver will have an action to disable vehicle's parts (like engine) for immersion of it being broken down. It looks something like this:

[] spawn 
while {(vehicle player) = B_T_Plane_CAS_01_dynamicLoadout_F} do //B_T_Plane_CAS_01_dynamicLoadout_F - basegame A-10
{
player addAction ["Engine 1 crash",{(vehicle player) setHitPointDamage ["HitEngine", 1]},nil,1.5,true,true,"","true",20,false,"",""]; 
player addAction ["Engine 2 crash",{(vehicle player) setHitPointDamage ["HitEngine2", 1]},nil,1.5,true,true,"","true",20,false,"",""];
}

I haven't found any mods like that so i just wanted to make it.
The code itself works, but the "while {}" part doesn't. Also, the action doesn't disappear on use.

Edited by Doggifast
More info

Share this post


Link to post
Share on other sites

I did not check the whole script but the condition for the while loop to reun has to be:

while { not isNull objectParent player and { typeOf objectParent player isEqualTo "B_T_Plane_CAS_01_dynamicLoadout_F" } } do

you should use the wiki to get a clue of the things you are doin.

= is not a comparision operator but an assignment operator

== or isEqualTo are for comparision

a classname is a string and needs always quotes

 

and maybe there is some more which the wiki could answer for you.

Share this post


Link to post
Share on other sites
32 minutes ago, sarogahtyp said:

I did not check the whole script but the condition for the while loop to reun has to be:


while { not isNull objectParent player and { typeOf objectParent player isEqualTo "B_T_Plane_CAS_01_dynamicLoadout_F" } } do

you should use the wiki to get a clue of the things you are doin.

= is not a comparision operator but an assignment operator

== or isEqualTo are for comparision

a classname is a string and needs always quotes

 

and maybe there is some more which the wiki could answer for you.

Didn't work. No errors, just actions didn't appear.
Made a little change with brackets and syntax:

while {(not isNull objectParent player) && (typeOf objectParent player isEqualTo "B_T_Plane_CAS_01_dynamicLoadout_F")} do {}

Btw, tested the commands in actions with the blackfish, but didn't change them for the A-10. It doesn't matter though as it is easily fixable, and the problem is the action didn't appear.
Edit: nevermind, i forgot to activate the trigger i put it in.
Now the problem is it just creates actions non-stop. Guess I'll put it in if then else system.

Edited by Doggifast
I'm stupid

Share this post


Link to post
Share on other sites
1 minute ago, Doggifast said:

Now the problem is it just creates actions non-stop. Guess I'll put it in if then else system.

My arma crashed because of this, lol

Share this post


Link to post
Share on other sites

That's normal! You create addAction endlessly.

addAction has condition you should use for testing your kind of plane.

see addAction in biki

 

Btw, it's weird to addAction on player as you want to manage the engines' plane. You should think about addAction on the plane itself.

Share this post


Link to post
Share on other sites

Well the problem is, it doesn't create two actions. It creates a whole lot of them, my computer even crashed.

Share this post


Link to post
Share on other sites
Just now, Doggifast said:

Well the problem is, it doesn't create two actions. It creates a whole lot of them, my computer even crashed.

Yes. Normal. Forget the while loop and read what I wrote.

Share this post


Link to post
Share on other sites
6 minutes ago, pierremgi said:

Yes. Normal. Forget the while loop and read what I wrote.

Took me a minute re-reading your comment to understand what you mean. I think i got it now, I'll try if (vehicle player != player) then {code with actions with dependency on vehicle}. I'll reply in a minute.

Share this post


Link to post
Share on other sites
26 minutes ago, pierremgi said:

Btw, it's weird to addAction on player as you want to manage the engines' plane. You should think about addAction on the plane itself.

By the way, if used on a helicopter, literally any passangeer can interact with it and frick up everything. Hm, That is except if in arguments of the action it is put that the interactor is the driver.

Share this post


Link to post
Share on other sites
Just now, Doggifast said:

Took me a minute re-reading your comment to understand what you mean. I think i got it now, I'll try if (vehicle player != player) then {code with actions with dependency on vehicle}. I'll reply in a minute.

Not exactly

If you apply on player, the addAction condition is always checked. By default condition is set to TRUE. You have to add a condition like this:
 

player addAction ["Engine 1 crash",{
  params ["_tgt", "_caller", "_id", "_args"];
  objectParent _caller setHitPointDamage ["HitEngine", 1];
  },
  nil,1.5,true,true,"","objectParent _this isKindOf 'B_T_Plane_CAS_01_dynamicLoadout_F'",20,false
];

Read BIKI if you want to understand parameters for code and variable(s) in condition string.

 

Now, better way, if you can define your plane (edited or scripted) by a variable, you could write something like:
 

yourPlane addAction ["Engine 1 crash", {
  params ["_tgt","_caller"];
  _tgt setHitPointDamage ["HitEngine",1];
  },
  nil,1.5,true,true,"","_target == objectParent _this",20,false
];

 

  • Like 1

Share this post


Link to post
Share on other sites
2 minutes ago, pierremgi said:

Not exactly

If you apply on player, the addAction condition is always checked. By default condition is set to TRUE. You have to add a condition like this:
 


player addAction ["Engine 1 crash",{
  params ["_tgt", "_caller", "_id", "_args"];
  objectParent _caller setHitPointDamage ["HitEngine", 1];
  },
  nil,1.5,true,true,"","objectParent _this isKindOf 'B_T_Plane_CAS_01_dynamicLoadout_F'",20,false
];

Read BIKI if you want to understand parameters for code and variable(s) in condition string.

 

Now, better way, if you can define your plane (edited or scripted) by a variable, you could write something like:
 


yourPlane addAction ["Engine 1 crash", {
  params ["_tgt","_caller"];
  _tgt setHitPointDamage ["HitEngine",1];
  },
  nil,1.5,true,true,"","_target == objectParent _this",20,false
];

Alright, thank you very much. I guess that concludes this post.

 

Share this post


Link to post
Share on other sites

For driver, you don't need anything if you play with an A10!

 

If more generic, just add in stringed condition :

- for an addAction on player (1st case) :   .... &&  _this == driver objectParent _this

- for an addAction on a plane/helo (2nd case):   .... && _this == driver _target

 

 

 

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

×