Engine.GetPlayers

From Tomb Raider Mod Launcher Wiki
Revision as of 19:56, 15 August 2014 by Jack9267 (talk | contribs) (Created page with "== Function == <syntaxhighlight lang="javascript"> function array Engine.GetPlayers(); </syntaxhighlight> === Description === This function retrieves all the players that a...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Function

function array Engine.GetPlayers();

Description

This function retrieves all the players that are currently on the server.

Returns

The function returns if the server was able to start the resource, possible reasons could include scripts containing errors.

Example

// Add a handler for "online" so that the server will output who is online currently.
//
Engine.AddCommandHandler("online",function(player, commandLine, command, arguments){
	local players = Engine.GetPlayers(); // Get the players that are online
	foreach (k,v in players) // Loop through all the players...
	{
		Engine.OutputChatBox(Engine.GetPlayerName(v),player); // Output their name!
	}
});

Notes

If nobody is online the array is empty.