Skip to content

ESX.GetPlayers

1
ESX.GetPlayers()

This function returns an array of all online players ID's.

You can use this to access each players data.

ESX.GetPlayers Example

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
local xPlayers = ESX.GetPlayers()

for i=1, #xPlayers, 1 do

  local xPlayer = ESX.GetPlayerFromId(xPlayers[i])

  if xPlayer.getName() == "Gepetto" then

    xPlayer.addMoney(100)

    TriggerClientEvent('esx:showNotification', xPlayer.source, "Blablabla...")

  end

end