Jump to content
Sign in to follow this  
D. Patterson

Correlate UID to player?

Recommended Posts

Basically I have an array of UID's stored on server. I randomly select one of the UIDs, check if they are online, then addAction. What is best way to correlate the UID to an object that I can use addAction with? Note: It's inside a for do loop, with _i correlating to the UID entry in the array.

Edited by mcrow900

Share this post


Link to post
Share on other sites
if (getPlayerUID player in _arrayOfUIDs) then 
{
//addAction
};

Share this post


Link to post
Share on other sites
private ["_uidList","_randomUID","_exitLoop"];
_uidList = [PUID1, PUID2, PUID3];
_randomUID = _uidList select (floor random (count _uidList));

_exitLoop = false;
{
if (isPlayer _x) then
{
	if ((getPlayerUID _x) == _randomUID) then
	{
		//add action here //note: action will only be added on computer this is run. if dedicated, then command fails because dedicated servers can't use actions
		_exitLoop = true;
	};
};
if (_exitLoop) exitWith {}; //exit loop after finding player object to save resources
}forEach allUnits;

Share this post


Link to post
Share on other sites
[color="#FF8040"][color="#1874CD"]_selectRandomAndOnline[/color] [color="#8B3E2F"][b]=[/b][/color] [color="#8B3E2F"][b]{[/b][/color]
[color="#1874CD"]_online[/color] [color="#8B3E2F"][b]=[/b][/color] [color="#8B3E2F"][b][[/b][/color][color="#8B3E2F"][b]][/b][/color][color="#8B3E2F"][b];[/b][/color]
[color="#1874CD"]_cnt[/color] [color="#8B3E2F"][b]=[/b][/color] [color="#8B3E2F"][b]{[/b][/color]
	[color="#191970"][b]if[/b][/color] [color="#8B3E2F"][b]([/b][/color][color="#191970"][b]getPlayerUID[/b][/color] [color="#000000"]_x[/color] [color="#191970"][b]in[/b][/color] [color="#000000"]_this[/color][color="#8B3E2F"][b])[/b][/color] [color="#191970"][b]then[/b][/color] [color="#8B3E2F"][b]{[/b][/color]
		[color="#1874CD"]_online[/color] [color="#191970"][b]pushBack[/b][/color] [color="#000000"]_x[/color][color="#8B3E2F"][b];[/b][/color]
		[color="#000000"]true[/color]
	[color="#8B3E2F"][b]}[/b][/color][color="#8B3E2F"][b];[/b][/color]
[color="#8B3E2F"][b]}[/b][/color] [color="#191970"][b]count[/b][/color] [color="#191970"][b]playableUnits[/b][/color][color="#8B3E2F"][b];[/b][/color]
[color="#191970"][b]if[/b][/color] [color="#8B3E2F"][b]([/b][/color][color="#1874CD"]_cnt[/color] [color="#8B3E2F"][b]>[/b][/color] [color="#FF0000"]0[/color][color="#8B3E2F"][b])[/b][/color] [color="#191970"][b]then[/b][/color] [color="#8B3E2F"][b]{[/b][/color]
	[color="#1874CD"]_online[/color] [color="#191970"][b]select[/b][/color] [color="#191970"][b]floor[/b][/color] [color="#191970"][b]random[/b][/color] [color="#1874CD"]_cnt[/color]
[color="#8B3E2F"][b]}[/b][/color] [color="#191970"][b]else[/b][/color] [color="#8B3E2F"][b]{[/b][/color]
	[color="#000000"]objNull[/color]
[color="#8B3E2F"][b]}[/b][/color][color="#8B3E2F"][b];[/b][/color]
[color="#8B3E2F"][b]}[/b][/color][color="#8B3E2F"][b];[/b][/color]

[color="#1874CD"]_UIDs[/color] [color="#8B3E2F"][b]=[/b][/color] [color="#8B3E2F"][b][[/b][/color][color="#7A7A7A"]"342342"[/color][color="#8B3E2F"][b],[/b][/color][color="#7A7A7A"]"32423432"[/color][color="#8B3E2F"][b],[/b][/color][color="#7A7A7A"]"324324324"[/color][color="#8B3E2F"][b]][/b][/color][color="#8B3E2F"][b];[/b][/color]
[color="#1874CD"]_player[/color] [color="#8B3E2F"][b]=[/b][/color] [color="#1874CD"]_UIDs[/color] [color="#191970"][b]call[/b][/color] [color="#1874CD"]_selectRandomAndOnline[/color][color="#8B3E2F"][b];[/b][/color]
[color="#191970"][b]if[/b][/color] [color="#8B3E2F"][b]([/b][/color][color="#8B3E2F"][b]![/b][/color][color="#191970"][b]isNull[/b][/color] [color="#1874CD"]_player[/color][color="#8B3E2F"][b])[/b][/color] [color="#191970"][b]then[/b][/color] [color="#8B3E2F"][b]{[/b][/color]
whatever [color="#8B3E2F"][b]=[/b][/color] [color="#8B3E2F"][b][[/b][/color][color="#7A7A7A"]"whatever"[/color][color="#8B3E2F"][b]][/b][/color][color="#8B3E2F"][b];[/b][/color]
[color="#191970"][b]owner[/b][/color] [color="#1874CD"]_player[/color] [color="#191970"][b]publicVariableClient[/b][/color] [color="#7A7A7A"]"whatever"[/color][color="#8B3E2F"][b];[/b][/color]
[color="#8B3E2F"][b]}[/b][/color][color="#8B3E2F"][b];[/b][/color][/color]

Made with KK's SQF to BBCode Converter

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  

×