Engine.GetPlayers: Difference between revisions

From Tomb Raider Mod Launcher Wiki
Jump to navigation Jump to search
Created page with "== Function == <syntaxhighlight lang="javascript"> function array Engine.GetPlayers(); </syntaxhighlight> === Description === This function retrieves all the players that a..."
 
(No difference)

Latest revision as of 19:56, 15 August 2014

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.