GetAllPlayers: Difference between revisions
From Onset Developer Wiki
Created page with "{{Info|Function|Server|1.0}} {{FuncDescription|__EDIT_ME__}} {{FuncSyntax|GetAllPlayers()}} {{FuncParameters}} {{FuncNoParam}} {{FuncReturnValue|__EDIT_ME__}} == Example..." |
FlyingFork (talk | contribs) No edit summary |
||
(2 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
{{Info|Function|Server|1.0}} | {{Info|Function|Server|1.0}} | ||
{{FuncDescription| | {{FuncDescription|Get all players on the server. Useful for loops.}} | ||
{{FuncSyntax|GetAllPlayers()}} | {{FuncSyntax|GetAllPlayers()}} | ||
Line 8: | Line 8: | ||
{{FuncNoParam}} | {{FuncNoParam}} | ||
{{FuncReturnValue| | {{FuncReturnValue|Returns a table of all players.}} | ||
== Example == | == Example == | ||
<syntaxhighlight lang="Lua"> | |||
function cmd_healall(player) | |||
if (PlayerData[player].admin < 4) then | |||
return AddPlayerChat(player, "Insufficient permission") | |||
end | |||
for _, v in pairs(GetAllPlayers()) do | |||
SetPlayerHealth(v, 100.0) | |||
end | |||
AddPlayerChatAll("Admin "..GetPlayerName(player).." has healed all players!") | |||
end | |||
AddCommand("healall", cmd_healall) | |||
</syntaxhighlight> | |||
{{RelatedFunctions}} | {{RelatedFunctions}} | ||
{{ServerPlayerFunctions}} |
Latest revision as of 14:38, 26 June 2021
Description
Get all players on the server. Useful for loops.
Syntax
GetAllPlayers()
Parameters
- This function has no parameters.
Return Value
- Returns a table of all players.
Example
function cmd_healall(player)
if (PlayerData[player].admin < 4) then
return AddPlayerChat(player, "Insufficient permission")
end
for _, v in pairs(GetAllPlayers()) do
SetPlayerHealth(v, 100.0)
end
AddPlayerChatAll("Admin "..GetPlayerName(player).." has healed all players!")
end
AddCommand("healall", cmd_healall)
See also
- GetPlayerBySteamId
- SetPlayerRagdoll
- SetPlayerDimension
- GetPlayerDimension
- SetPlayerPropertyValue
- GetPlayerPropertyValue
- IsValidPlayer
- GetPlayerCount
- GetAllPlayers
- GetNearestPlayer2D
- GetPlayersInRange2D
- GetPlayersInRange3D
- GetStreamedPlayersForPlayer
- SetPlayerName
- GetPlayerName
- GetPlayerSteamId
- GetPlayerNetworkStats
- SetPlayerSpawnLocation
- IsPlayerStreamedIn
- SetPlayerVoiceRange
- SetPlayerVoiceChannel
- IsPlayerVoiceChannel
- SetPlayerVoiceEnabled
- IsPlayerVoiceEnabled
- IsPlayerTalking
- AddPlayerChat
- AddPlayerChatRange
- AddPlayerChatAll
- GetPlayerState
- GetPlayerMovementMode
- GetPlayerMovementSpeed
- IsPlayerAiming
- IsPlayerReloading
- GetPlayerVehicle
- GetPlayerVehicleSeat
- SetPlayerInVehicle
- RemovePlayerFromVehicle
- SetPlayerLocation
- GetPlayerLocation
- SetPlayerWeaponStat
- SetPlayerWeapon
- GetPlayerWeapon
- GetPlayerEquippedWeaponSlot
- EquipPlayerWeaponSlot
- GetPlayerEquippedWeapon
- SetPlayerHeading
- GetPlayerHeading
- SetPlayerSpectate
- IsPlayerDead
- SetPlayerHealth
- GetPlayerHealth
- SetPlayerArmor
- GetPlayerArmor
- SetPlayerRespawnTime
- GetPlayerRespawnTime
- GetPlayerIP
- GetPlayerPing
- KickPlayer
- GetPlayerLocale
- GetPlayerGUID
- GetPlayerGameVersion
- SetPlayerAnimation
- AttachPlayerParachute
- SetPlayerHeadSize
- GetPlayerHeadSize