Jump to content
Sign in to follow this  
zonekiller

help finding var name from units name

Recommended Posts

Hi

if i know that units name is john smith and its var name is man1

if i only have its name "john smith" how can i find out what its var name is ie "man1"

i need this as the Onplayerdisconnect command only gives you the name and id .

this is for a AI & player revive script

thanks for any help.........

Share this post


Link to post
Share on other sites

Use "player" command instead of "man1"

Share this post


Link to post
Share on other sites

i need to use it for AI as well as players for other parts

Share this post


Link to post
Share on other sites

- create a large trigger to find all objects on map

- traverse the trigger list to find all objects of kind 'man' (ensuring you check vehicle unit crews too)

- traverse the soldier (man) list and compare the names

- return the vehicleVarName of that match

Problem is that the AI do not use unique random names per session. You could easily have 3 'John Smiths' during 1 mission.

Share this post


Link to post
Share on other sites
- create a large trigger to find all objects on map

- traverse the trigger list to find all objects of kind 'man' (ensuring you check vehicle unit crews too)

- traverse the soldier (man) list and compare the names

- return the vehicleVarName of that match

Problem is that the AI do not use unique random names per session. You could easily have 3 'John Smiths' during 1 mission.

I don't believe AI trigger "onPlayerConnected" :-) So there's no relevance for AI.

I believe the only way you can get this system water tight is simply naming all player/playable units in the mission.

Save the names of these units in an array, as strings.

Loop through the array when event onPlayerConnect is triggered and onPlayerDisconnect, maybe also on killed.

Then check the name versus the variables.

When AI doesnt have to be accounted for, I would use the isPlayer function and maybe trigger indeed.

Share this post


Link to post
Share on other sites

i will have to check but if a player disconnects and you use the isplayer   does player still work with the onplayerdisconnected huh.gif

this is what i am doing

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

_name = _this select 0;

_listofdead = [];

_man = objnull;

_listofdead = list sidedead;

_m = 0;

while {_m < count _listofdead} do

{

if (_name == (name (_listofdead select _m))) then {_man = (_listofdead select _m)};

_m = _m + 1;

};

if !(isnull _man) then

{

_manname = format["%1",_man];

_bagname = format ["%1", (_manname + "sBag")];

_bodybag = call compile format ["%1", _bagname];

_padname = format ["%1", (_manname + "spad")];

_pad = call compile format ["%1", _padname];

_man setpos position _bodybag;

deletevehicle _bodybag;

deletevehicle _pad;

deletemarker _name;

};

// this is the problem below it does seem to work 95% of the time even tho i cant see how

//when you disconnect from a unit it losses the addeventhandler , if its a live unit _man is objnull so i cant see how it works it all , but it does 95% of the time this is the onplayerdisconnect script , if the unit is dead thats fine

but to me it seems like loose code and i would like to make it tight.

// problem line below it does need to be at the end of the script

_man addEventHandler ["killed", {_this execVM "respawn\RESPAWN_check.sqf"}];

Michael

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  

×