Jump to content
Pasi

setVariable on Object and Player

Recommended Posts

Hello BI Forum :)

 

I want to set a player specific Variable on every Object from the same Type. Can anyone help me ?

when i set the Variable i want to make a IF condition when the Player with the same Variable of the Object klick on a addaction.

 

but i dont know as i set the Variable on the Object :/

 

for example

 

every SUV_01_base_red_F setVariable "Playerid of the player he have spawnd the SUV";

 

if (playerid == playeridcar) then

{

blablablabla

}

 

pls help me :/

 

Pasi

Share this post


Link to post
Share on other sites

Let's think you are spawning the vehicle on the client PC, ok?

 

After the createVehicle thing, put this:

 

_veh setVariable ["owner", getPlayerUID player,true]

 

Then, when you want to make the check, (I suppose in a GetIn eventHandler or something, but this example is simpler) you can do like this:

 

if (driver _veh != _veh getVariable "owner") then {moveOut driver _veh};

Share this post


Link to post
Share on other sites

wow thank you for the fast Help :)

 

thank you thank you

Share this post


Link to post
Share on other sites

Sorry sorry, I had a tipo.

 

The checking must be done this way:

 

if (getPlayerUID (driver _veh) != _veh getVariable "owner") then {moveOut driver _veh};

Share this post


Link to post
Share on other sites

I don't know the scope of use with this, but I do recommend a more unique variable name aside from "owner", as it's generic and could cause issues on a larger scale, especially if you use lots of other scripts/addons/mods. (It's a good coding convention too :p)

  • Like 1

Share this post


Link to post
Share on other sites

@barbolani i have a new probleme i want to delete the Object when the object is near a place

i have made this but it dons´t perform

 

if(nearestObject [_veh, "verarbeiter_1"] && _veh getVariable "owner") then {
deleteVehicle _veh;
};

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

×