Es setindexprop

From EventScripts Community Encyclopedia


Overview

Syntax: es_setindexprop <index> "<property>" <value>

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: {{{x}}}

Description

Set the value of a class property from the entity defined by index.

Parameters

  • index - Index of the entity to assign the property to.
  • property - Direct name of the variable from source, i.e. CBaseCombatWeapon.m_hOwner (id of player holding the weapon)
  • value - Value to assign to the property.


Examples

Example: (Silence all dropped m4's)

//populate a database 'm4list' with information
//about all m4's on the map or in player's hands
es_xcreateentitylist m4list weapon_m4a1
 
//for each m4 in the database, if it's not held by a player, set it's silencer to 1:
es_foreachkey m4index in m4list "es_xdoblock script/silence"
 
block silence
{
  es_xsetinfo held_by_player 0
  es_getindexprop held_by_player server_var(m4index) "CBaseCombatWeapon.m_hOwner"
 
  //if the weapon has been dropped, it's owner is set to -1
  if (server_var(held_by_player) == -1) then es_setindexprop server_var(m4index) "CWeaponM4A1.m_bSilencerOn" 1
}


Notes

  • CBaseEntity is the base class of all entities. This contains basic entity properties such as m_vecOrigin.
  • Use with caution! - Improperly assigning a value to an entity property can cause a server to crash.


See also


External links

es_xsetindexprop


{{{category}}}

blog comments powered by Disqus