GetAllPlayers

From GTA Network Wiki
Jump to: navigation, search

GetAllPlayers
Server-Side Function

utilities-terminal.png Server-Side csharp.png C#

Gets all currently connected players in the server

Syntax

List<Client> NAPI.Pools.GetAllPlayers();

NOTE: This function returns data as a List of Client type.

Usage example(s)

Example Description

foreach (var player in NAPI.Pools.GetAllPlayers())
{
    player.SendChatMessage($"Hello, {player.Name}");
}

// Or much simpler one-liner using Linq
NAPI.Pools.GetAllPlayers().ForEach(player => player.SendChatMessage($"Hello, {player.Name}"));

Changelog

Version Description
1.0 Release.

References

SendChatMessageToPlayer