Es createplayerlist

From EventScripts Community Encyclopedia


Overview

Syntax: es_createplayerlist <keygroup-name> [userid]

Note: Command parameters are described inside the < and > characters. Optional parameters are contained within [ and ] characters.

Variation of this command that doesn't expand variables: es_xcreateplayerlist

Description

Creates a keygroup with a list of all players with info about them. It uses userids as the keys within that keygroup.


Parameters

  • keygroup-name - name of the keygroup to create (be sure it doesn't already exist)
  • userid - optional parameter which causes the command to retrieve only information for a single player.


Examples

es_createplayerlist test

would create the following if only one bot were on-line:

"test"
{
	"2"
	{
		"name"		"Mattie!"
		"steamid"		"STEAM_ID_LAN"
		"index"		"1"
		"teamid"		"3"
		"kills"		"0"
		"deaths"		"0"
		"armor"		"0"
		"model"		"models/player/ct_gign.mdl"
		"isdead"		"0"
		"isbot"		"0"
		"ishltv"		"0"
		"isobserver"		"0"
		"isinavehicle"		"0"
		"health"		"100"
		"serialnumber"		"395"
		"weapon"		"weapon_scout"
		"handle"		"85504001"
		"ping"		"5"
		"packetloss"		"0"
		"timeconnected"		"22.330658"
		"address"		"127.0.0.1:27005"
		"x"		"640.000000"
		"y"		"-760.000000"
		"z"		"-615.968750"
		"language"		"english"
	}
}

Sample code for a single player:

event player_say
{
  // create the player info for a single player
  es_createplayerlist singleplayer event_var(userid)
  // now look-up an item from the player info
  es_xsetinfo splayer_isdead 0
  es_keygetvalue splayer_isdead singleplayer event_var(userid) isdead
	
  if (server_var(splayer_isdead) > 0) do
  {
    es_msg The player is dead!
  }
}


Notes

  • You need to call es_keygroupdelete on the keygroup created by this, or the keygroup will stay around forever.
  • This is particularly handy when you need to loop through players with es_foreachkey.
  • v1.2 added network-based information for the player.
  • For human players, the output keygroup will be empty when player_connect and es_player_validated are fired


See also

blog comments powered by Disqus