Silent Lua
silEnT servers support Lua 5.1.4 scripts up till version 0.8.2.
Since version 0.9.0 silEnT mod supports Lua 5.3.1 compiled to be compatible with Lua version 5.2.
Starting from version 0.5.1 the Lua interpreter is inbuilt into the server side mod. Before the vesion 0.5.1, the Lua was installed as an external module. A separate build of the silEnT mod is supplied within the download to admins who still want to use separate Lua library. silEnT's Lua API is aiming to be fully compatible to ETPro's Lua API. The origin of the silEnT Lua API is the Lua module in ETPub version 0.9.1.
Cvars
lua_modules
Description:
List of files to be loaded by the Lua API engine. Can be separated by space, comma or semicolon. The paths are relative to the mod's directory, and can optionally be placed inside pk3 archieves. We are aiming for compatibility with ETPro's Lua Mod API found at http://wolfwiki.anime.net/index.php/Lua_Mod_API.
Type: string
Default: ""
lua_allowedModules
Description:
List of sha1 signatures for the lua modules to be loaded by the Lua API engine. Can be separated by space, comma or semicolon. Only lua modules with the matching sha1 signature listed in this cvar will be allowed to load by the Lua API engine (ACL). If this string is empty, all loaded modules are allowed.
Type: string
Default: ""
Commands
lua_status
Shows information about the scripts currently loaded by the Lua API server engine. This command works also from the client so that players can check what modules are currently loaded by the server.
Interface Function Reference
Modules
RegisterModname
Description
Registers a descriptive name for this Lua module.
Syntax
et.RegisterModname( modname )
- modname is the name to register the Lua module
Portability
Function is ETPro compatible.
FindSelf
Description
Returns a number indicating the VM slot the current mod is loaded into.
Syntax
vmnumber = et.FindSelf()
Portability
Function is ETPro compatible.
FindMod
Description
Returns the registered module name and the SHA-1 signature of the module loaded in the VM. Do note that each loaded Lua module will have it's own VM.
Syntax
modname, signature = et.FindMod( vmnumber )
- vmnumber is the number of the VM in where the Lua module is loaded
- return value (modname, signature) is the registered module's name and the SHA-1 signature. Returns (nil, nil) if there is no module loaded into the given VM number
Portability
Function is ETPro compatible.
IPCSend
Description
Inter Process Communication. This function enables communication between different loaded Lua modules.
Syntax
success = et.IPCSend( vmnumber, message )
- vmnumber is the number of the loaded module message is sent
- message is the string to send
- return value success is 1 if success and 0 if function fails
Portability
Function is ETPro compatible.
Printing
G_Print
Description
Prints text to the server console.
Syntax
et.G_Print( text )
- text is the printed string
Portability
Function is ETPro compatible.
G_LogPrint
Description
Prints text to the server console and also to the log.
Syntax
et.G_LogPrint( text )
- text is the printed and logged string
Portability
Function is ETPro compatible.
Argument Handling
ConcatArgs
Description
Function concatenates server command arguments into one string.
Syntax
args = et.ConcatArgs( index )
- index is the index of the first argument in the concatenated string. First command argument index in general is 1.
- return value args is the concatenated string
Portability
Function is ETPro compatible.
trap_Argc
Description
Function returns the number of the arguments in the server command.
Syntax
argc = et.trap_Argc()
- return value argc is the count of arguments. For example for the command "/m gao message", the function would return 2.
Portability
Function is ETPro compatible.
trap_Argv
Description
Function returns argument in the given index.
Syntax
arg = et.trap_Argv( index )
- index is the argument index to return.
- return value arg is the argument
Portability
Function is ETPro compatible.
Cvars
trap_Cvar_Get
Description
Returns the value of the given cvar.
Syntax
cvarvalue= et.trap_Cvar_Get( cvar )
- cvar is the name of the cvar
- return value cvarvalue is a string containing the value. If there is no cvar with the given name, the returning string has zero length.
Portability
Function is ETPro compatible.
trap_Cvar_Set
Description
Sets value to a cvar.
Syntax
et.trap_Cvar_Set( name, value )
- name is the name of the cvar to set
- value is the new value for the cvar
Portability
Function is ETPro compatible.
Configstrings
trap_GetConfigstring
Description
Returns contents of the configstring at index.
Syntax
configstringvalue = et.trap_GetConfigstring( index )
- index is the index of the configstring
- return value configstring contains the full config string
Portability
Function is ETPro compatible.
trap_SetConfigstring
Description
Function sets the full configstring.
Syntax
et.trap_SetConfigstring( index, configstringvalue )
- index is the configstring index
- configstringvalue is the full configstring to set
Portability
Function is ETPro compatible.
Server Console and Client Handling
trap_SendConsoleCommand
Description
Sends command to the server console.
Syntax
et.trap_SendConsoleCommand( when, command )
- when tells when the command is executed. Possible values are
- et.EXEC_NOW - executes instantly
- et.EXEC_INSERT - inserts at the current position but doesn't run yet
- et.EXEC_APPEND - appends at the end of the command buffer
- command is the full command to execute
Portability
Function is ETPro compatible.
trap_DropClient
Description
Disconnects client from the server.
Syntax
et.trap_DropClient( clientnum, reason, ban_time )
- clientnum is the slot number of the client to disconnect
- reason is the descriptive reason for the kick. This is also displayed to the client.
- ban_time is optional length of the kick. If this is not set, the g_defaultBanTime is used.
Portability
Function is ETPro compatible.
trap_SendServerCommand
Description
Function sends reliable server command to a client. I.e. the command is acknowledged by the client to ensure it has received it.
Syntax
et.trap_SendServerCommand( clientnum, command )
- clientnum is the slot number of the client to send the command. If the number is -1, the command is sent to all connected clients.
- command is the full command string to send
Portability
Function is ETPro compatible.
ClientNumberFromString
Description
Function finds one matching player name based on the given string.
Syntax
clientnum = et.ClientNumberFromString( string )
- string is a pattern to match against client names
- return value clientnum is the client slot number if one match is found, otherwise -1 is returned
Portability
ETPro does not implement this function. Function is derived to silEnT from ETPub implementation.
G_Say
Description
Writes to chat on behalf of a client.
Syntax
et.G_Say( clientNum, mode, text )
- clientNum is the slot number of the client on behalf to write chat
- mode is the type of chat to write. Possible values are
- et.SAY_ALL - writes to the global chat
- et.SAY_TEAM - writes to the team chat of the client
- et.SAY_BUDDY - writes to the fireteam chat of the client
- et.SAY_TEAMNL - writes to the team chat of the client without position
- text is the chat message to write
Portability
Function is ETPro compatible.
ClientUserinfoChanged
Description
Loads the new userinfo string of the client and sets the client settings to match it.
Syntax
et.ClientUserinfoChanged( clientNum )
- clientNum is the slot number of the client who's userinfo is loaded
Portability
Function is ETPro compatible.
trap_GetUserinfo
Description
Returns the userinfo string of a client.
Syntax
userinfo = et.trap_GetUserinfo( clientnum )
- clientnum is the slot number of the client who's userinfo is returned
- return value userinfo is the full userinfo string of that client
Portability
Function is ETPro compatible.
trap_SetUserinfo
Description
Sets the userinfo string of the client to the passed userinfo. To make the changes to take effect in the game, ClientUserinfoChanged must be called after this function.
Syntax
et.trap_SetUserinfo( clientnum, userinfo )
- clientnum is the slot number of the client who's userinfo is changed
- userinfo is the full new userinfo of the client
Portability
Function is ETPro compatible.
G_Damage
Description
Damages target entity on behalf of the attacker entity.
Syntax
et.G_Damage( target, inflictor, attacker, damage, dflags, mod )
- target is the entity number to damage, value must be 0 or more
- inflictor is the entity number that does the damage, value must be 0 or more
- attacker is the entity number that causes the inflictor entity to cause damage to target, value must be 0 or more
- damage is the amount of damage to inflict
- dflags is the type of damage to inflict, possible values are
- DAMAGE_RADIUS - damage was indirect (from a nearby explosion)
- DAMAGE_NO_ARMOR - armor does not protect from this damage
- DAMAGE_NO_KNOCKBACK - do not affect velocity, just view angles
- DAMAGE_NO_PROTECTION - kills godmode, armor, everything
- mod is the means of death, possible values are:
- 0 - MOD_UNKNOWN
- 1 - MOD_MACHINEGUN
- 2 - MOD_BROWNING
- 3 - MOD_MG42
- 4 - MOD_GRENADE
- 5 - MOD_ROCKET
- 6 - MOD_KNIFE
- 7 - MOD_LUGER
- 8 - MOD_COLT
- 9 - MOD_MP40
- 10 - MOD_THOMPSON
- 11 - MOD_STEN
- 12 - MOD_GARAND
- 13 - MOD_SNOOPERSCOPE
- 14 - MOD_SILENCER
- 15 - MOD_FG42
- 16 - MOD_FG42SCOPE
- 17 - MOD_PANZERFAUST
- 18 - MOD_GRENADE_LAUNCHER
- 19 - MOD_FLAMETHROWER
- 20 - MOD_GRENADE_PINEAPPLE
- 21 - MOD_CROSS
- 22 - MOD_MAPMORTAR
- 23 - MOD_MAPMORTAR_SPLASH
- 24 - MOD_KICKED
- 25 - MOD_GRABBER
- 26 - MOD_DYNAMITE
- 27 - MOD_AIRSTRIKE
- 28 - MOD_SYRINGE
- 29 - MOD_AMMO
- 30 - MOD_ARTY
- 31 - MOD_WATER
- 32 - MOD_SLIME
- 33 - MOD_LAVA
- 34 - MOD_CRUSH
- 35 - MOD_TELEFRAG
- 36 - MOD_FALLING
- 37 - MOD_SUICIDE
- 38 - MOD_TARGET_LASER
- 39 - MOD_TRIGGER_HURT
- 40 - MOD_EXPLOSIVE
- 41 - MOD_CARBINE
- 42 - MOD_KAR98
- 43 - MOD_GPG40
- 44 - MOD_M7
- 45 - MOD_LANDMINE
- 46 - MOD_SATCHEL
- 47 - MOD_TRIPMINE
- 48 - MOD_SMOKEBOMB
- 49 - MOD_MOBILE_MG42
- 50 - MOD_SILENCED_COLT
- 51 - MOD_GARAND_SCOPE
- 52 - MOD_CRUSH_CONSTRUCTION
- 53 - MOD_CRUSH_CONSTRUCTIONDEATH
- 54 - MOD_CRUSH_CONSTRUCTIONDEATH_NOATTACKER
- 55 - MOD_K43
- 56 - MOD_K43_SCOPE
- 57 - MOD_MORTAR
- 58 - MOD_AKIMBO_COLT
- 59 - MOD_AKIMBO_LUGER
- 60 - MOD_AKIMBO_SILENCEDCOLT
- 61 - MOD_AKIMBO_SILENCEDLUGER
- 62 - MOD_SMOKEGRENADE
- 63 - MOD_SWAP_PLACES
- 64 - MOD_SWITCHTEAM
- 65 - MOD_GOOMBA
- 66 - MOD_POISON
- 67 - MOD_FEAR
- 68 - MOD_THROWN_KNIFE
- 69 - MOD_REFLECTED_FF
- 70 - MOD_PPSH
- 71 - MOD_SHOVE
Portability
Function is implemented in ETPro but some of the mod values may differ.
ClientIsFlooding
Description
Tells if g_floodthreshold has been exceeded for the player. In other words, the client is sending more than a g_floodthreshold amount of messages per second to the server. Admins with shrubbot flag 2 are excluded.
Syntax
flooding = et.ClientIsFlooding( clientnum )
- clientnum is the slotnumber of the client that is checked
- return value flooding is 1 if the clientis flooding, 0 otherwise
Portability
Function is not implemented in the ETPro Lua API. Function was derived to silEnT from the ETPub's Lua module.
G_AddSkillPoints
Description
Adds points to the client's skill.
Syntax
et.G_AddSkillPoints( clientNum, skill, points )
- clientNum is the slot number of the client
- skill identifies the skill that the points are added, possible values are
- 0 - SK_BATTLE_SENSE
- 1 - SK_EXPLOSIVES_AND_CONSTRUCTION
- 2 - SK_FIRST_AID
- 3 - SK_SIGNALS
- 4 - SK_LIGHT_WEAPONS
- 5 - SK_HEAVY_WEAPONS
- 6 - SK_MILITARY_INTELLIGENCE_AND_SCOPED_WEAPONS
- 7 - SK_NUM_SKILLS
- points is the amount of points to add
Portability
Function is not implemented in the ETPro Lua API. Function was derived to silEnT from the ETPub's Lua module.
G_LoseSkillPoints
Description
Causes player to lose skill points.
Syntax
et.G_LoseSkillPoints( clientNum, skill, points )
- clientNum is the slot number of the client
- skill is the skill from where the points are taken, possible values are
- 0 - SK_BATTLE_SENSE
- 1 - SK_EXPLOSIVES_AND_CONSTRUCTION
- 2 - SK_FIRST_AID
- 3 - SK_SIGNALS
- 4 - SK_LIGHT_WEAPONS
- 5 - SK_HEAVY_WEAPONS
- 6 - SK_MILITARY_INTELLIGENCE_AND_SCOPED_WEAPONS
- 7 - SK_NUM_SKILLS
- points is the amount of points to remove
Portability
Function is not implemented in the ETPro Lua API. Function was derived to silEnT from the ETPub's Lua module.
G_QueryClientCvar
Lua scripts can query cvar values from connected players. The values are returned in a different callback function.
Syntax
et.G_QueryClientCvar( clientNum, cvarName)
- clientNum is the slot number of the player
- cvarName is the name of the cvar that is requested
Portability
Function was added in silEnT version 0.6.2 and it is not present in ETPro or ETPub Lua APIs.
String Utility Functions
Info_RemoveKey
Description
Removes a key and it's associated value from an infostring.
Syntax
infostring = et.Info_RemoveKey( infostring, key )
- infostring as a passed parameter is the infostring from which to remove the key
- key is the key to remove
- return value infostring is the infostring without the key
Portability
Function is ETPro compatible.
Info_SetValueForKey
Description
Sets a value in an infostring.
Syntax
infostring = et.Info_SetValueForKey( infostring, key, value )
- infostring as passed parameter is the original infostring
- key is the key to set
- value is the value to set to the key
- return value infostring is the modified infostring
Portability
Function is ETPro compatible.
Info_ValueForKey
Description
Returns a value from an infostring.
Syntax
keyvalue = et.Info_ValueForKey( infostring, key )
- infostring is the infostring from where to search the key
- key is the key which value is returned
- return value keyvalue is the value from the searched key
Portability
Function is ETPro compatible.
Q_CleanStr
Description
Removes all Enemy Territory color codes and special characters from a string. The returning string will be ASCII characters of the range [32,126] in decimal numbers.
Syntax
cleanstring = et.Q_CleanStr( string )
- string is the string to clean
- cleanstring is the cleaned string
Portability
Function is ETPro compatible.
Filesystem
trap_FS_FOpenFile
Description
Opens a file in the local file system.
Syntax
fd, len = et.trap_FS_FOpenFile( filename, mode )
- filename is the name of the file to open. The file is opened under the current working directory and absolute paths will not work.
- mode is the mode the file is opened, possible values are
- et.FS_READ - opens the file for reading only
- et.FS_WRITE - opens the file for writing, truncates the old file if a file with name filename already exists
- et.FS_APPEND - opens the file for writing at the end of file, the old file is not erased if it already exists
- et.FS_APPEND_SYNC - like et.FS_APPEND but the file buffer is flushed to the file on hard drive directly after every write operation
- return value (fd, len) is the descriptor (or handle in Windows terminology) of the file and the length of the file
Portability
Function is ETPro compatible.
trap_FS_Read
Description
Reads from an open file.
Syntax
filedata = et.trap_FS_Read( fd, count )
- fd is the descriptor of the file to read
- count is the amount of bytes to read
- return value filedata will have the read bytes
Portability
Function is ETPro compatible.
trap_FS_Write
Description
Writes at the end of an open file.
Syntax
count= et.trap_FS_Write( filedata, count, fd )
- filedata is a block of bytes to write
- count is the size of the block to write
- fd is the descriptor of the file
- return value count is the amount of bytes written to the file
Portability
Function is ETPro compatible.
trap_FS_Rename
Description
Renames a file in the loal file system.
Syntax
et.trap_FS_Rename( oldname, newname )
- oldname is the name of the file to rename
- newname is the name the old file name is changed
Portability
Function is ETPro compatible.
trap_FS_FCloseFile
Description
Closes an opened file.
Syntax
et.trap_FS_FCloseFile( fd )
- fd is the descriptor of the opened file
Portability
Function is ETPro compatible.
Sounds and Models
G_SoundIndex
Description
Returns the configstring index that includes the searched sound name.
Syntax
soundindex = et.G_SoundIndex( filename )
- filename is the sound file name that is searched
- return value soundindex is the config string index that includes the filename or 0 if the name was not found
Portability
Function is ETPro compatible.
G_ModelIndex
Description
Returns an index to the configstring that include the searched model.
Syntax
modelindex = et.G_ModelIndex( filename )
- filename is the name that is searched through the config strings
- return value modelindex is the configstring number that included the filename or 0 if not found
Portability
Function is ETPro compatible.
G_globalSound
Description
Plays a sound to all connected clients.
Syntax
et.G_globalSound( sound )
- sound is the name of the sound to play
Portability
Function is ETPro compatible.
G_Sound
Description
Plays a sound originating from position of an entity.
Syntax
et.G_Sound( entnum, soundindex )
- entnum is the number of the entity which position is used as the sound origin
- soundindex is the index of the sound that is played
Portability
Function is ETPro compatible.
G_ClientSound
Description
Plays a sound originating from a client entity to the team members of that client.
Syntax
et.G_ClientSound( clientnum, soundindex )
- clientnum is the slot number of the connected player
- soundindex is the index to the sound to play
Portability
Function is not implemented in the ETPro Lua API. Function was derived to silEnT from the ETPub Lua implementation.
Entities
G_Spawn
Description
Spawns a new entity.
Syntax
entnum = et.G_Spawn()
- return value entnum is the number of the new entity
Portability
Function is ETPro compatible.
G_TempEntity
Description
Spawns a new temp entity to a location.
Syntax
entnum = et.G_TempEntity( origin, event )
- origin is the location the temp entity is placed
- event is the event type of the entity, this is a number from the range [1, 118]
- return value entnum is the number of the new entity
Portability
Function is ETPro compatible, but some event types do differ from mod to mod.
G_FreeEntity
Description
Deletes an entity.
Syntax
et.G_FreeEntity( entnum )
- entnum is the number of the entity to remove
Portbility
Function is ETPro compatible.
G_EntitiesFree
Description Calculates all free entities. Free client entities (slots) are not counted.
Syntax
count = et.G_EntitiesFree()
- return value count is the number of free entities
Portability
Function is not implemented in the ETPro Lua API. Function was derived to silEnT from the ETPub Lua implementation, where it is broken.
G_GetSpawnVar
Description
Return a value of a spawnvar.
Syntax
spawnval = et.G_GetSpawnVar( entnum, key )
- entnum is the entity number of the target
- key is the key for the value to return, possible values are
- classname
- origin
- model
- model2
- spawnflags
- eflags
- svflags
- maxs
- mins
- speed
- closespeed
- target
- targetname
- message
- popup
- book
- team
- wait
- random
- count
- health
- light - ignored
- dmg
- angles
- angle
- duration
- rotate
- degrees
- time
- skin
- _color
- color
- stylestring
- shader
- key
- harc
- varc
- delay
- radius
- missionlevel
- start_size
- end_size
- shard
- spawnitem
- track
- scriptName
- shortname
- constages
- desstages
- partofstage
- override
- damageparent
- contents
- clipmask
- count2
- pos_trType
- pos_trDelta
- apos_trType
- apos_trDelta
- allowteams
- return value spawnval is the value associated with the key or nil if the function fails
Portability
Function is ETPro compatible.
G_SetSpawnVar
Description Sets spawn value to an entity.
Syntax
et.G_SetSpawnVar( entnum, key, value )
- entitynum is the target entity
- key is the key for the value, the possible keys are the same as in G_GetSpawnVar
- value is the new value for the key
Portability
Function is ETPro compatible.
trap_LinkEntity
Description
Links an entity.
Syntax
et.trap_LinkEntity( entnum )
- entnum is the entity number to link
Portability
Function is ETPro compatible.
trap_UnlinkEntity
Description
Unlinks an entity.
Syntax
et.trap_UnlinkEntity( entnum )
- entnum is the entity number to unlink
Portability
Function is ETPro compatible.
gentity_get
Description
Returns a field value associated with an entity.
Syntax
variable = et.gentity_get( entnum, fieldname, arrayindex )
- entnum is the number of the entity
- fieldname is the name of the field to get, possible values are
- Field names for player entities only
- "inactivityTime"
- "inactivityWarning"
- "pers.connected" - this is the connection status of the client, possible values are
- 0 - disconnected
- 1 - connecting
- 2 - connected
- "pers.netname" - the name of the client, including color codes
- "pers.localClient" - 1 if the player is from localhost, 0 otherwise
- "pers.initialSpawn" - 1 if the player has not spawned yet, 0 otherwise
- "pers.enterTime" - the level time the player connected
- "pers.connectTime" - the level time the player connected
- "pers.teamState.state" - the state of the player. This value changes on every team change and entering to the server. But it does not change on deaths and revives. Possible values are
- 0 - beginning, spawn at base
- 1 - actively playing
- "pers.voteCount" - the number of failed votes the player has initiated
- "pers.teamVoteCount" - unused
- "pers.complaints" - the number of complaints the player has received
- "pers.complaintClient" - the client number the player who teamkilled, if the complaint is possible
- "pers.complaintEndTime" - the level time the option for complaint ends
- "pers.lastReinforceTime" - time of the previous respawn
- "pers.applicationClient" - the client number of the player who is applying to a fireteam. This value is stored only to the fireteam leader.
- "pers.applicationEndTime" - the level time when the fireteam application expires. This value is stored only to the fireteam leader.
- "pers.invitationClient" - the client number of the player who is inviting a player to the fireteam. This value is stored only to the invited player.
- "pers.invitationEndTime" - the level time when the invitation expires. This data is stored only to the invited player.
- "pers.propositionClient" - the client number of the player who is proposed to the fireteam. This value is stored only to the fireteam leader.
- "pers.propositionClient2" - the client number of the player who is proposing a player to the fireteam. This value is stored only to the fireteam leader.
- "pers.propositionEndTime" - the level time when the proposition ends
- "pers.autofireteamEndTime" - the level time when prompt for making fireteam private expires
- "pers.autofireteamCreateEndTime" - the level time when automatic prompt for creating fireteam expires
- "pers.autofireteamJoinEndTime" - the level time when automatic prompt for joining existing fireteam ends
- "pers.lastSpawnTime" - the level time when the player spawned fresh into the world
- "pers.ready" - 1 if player is ready during intermission, 0 otherwise
- "ps.stats" - an array of 16 integers for different purposes, the most interesting fields are
- player health at index 0
- player sprint time at index 7, this is a read only and changing this does not affect the game in any way
- player XP at index 8
- player XP overflow at index 9
- "ps.persistant" - an array of 16 integers for different purposes
- "ps.ping" - the ping of the player. The g_truePing setting does not affect this.
- "ps.powerups" - an array of 16 integers for powerups. The indexes are as follows
- 0 - none
- 1 - invulnerable, level time when the player is vulnerable again
- 2 - unused
- 3 - unused
- 4 - breath, time left with air underwater
- 5 - nofatigue, time left before sprint time starts to reduce
- 6 - red flag, axis flag carried
- 7 - blue flag, allied flag carried
- 8 - disguised, 1 if disguised, 0 otherwise
- 9 - information of the covert op
- 10 - information of the covert op
- 11 - information of the covert op
- 12 - adrenaline, time left of adrenaline
- 13 - unused
- 14 - blackout, specs see only black screen
- 15 - multiview, unused
- "ps.origin" - the player position, this is an array of 3 floats
- "ps.ammo" - an array of 64 integers holding total ammo for each weapon separately
- "ps.ammoclip" - an array of 64 integers holding ammo in the clip for each weapon separately
- "sess.sessionTeam" - the team of the player. Possible values are
- 0 - not in any team
- 1 - axis
- 2 - allies
- 3 - spectators
- "sess.spectatorTime" - the time when the player joined spectator
- "sess.spectatorState" - the state of the player in the specator team. Possible values are
- 0 - not a spectator
- 1 - not following any players
- 2 - following a player
- "sess.spectatorClient" - the client number of the player this player is following
- "sess.playerType" - the class of the player. Possible values are
- 0 - soldier
- 1 - medic
- 2 - engineer
- 3 - fieldops
- 4 - covert ops
- "sess.playerWeapon" - the weapon of the player
- "sess.playerWeapon2" - the sidearm of the player
- "sess.spawnObjectiveIndex" - the player spawn
- "sess.latchPlayerType" - the class of the player after next spawn
- "sess.latchPlayerWeapon" - the weapon of the player after next spawn
- "sess.latchPlayerWeapon2" - the sidearm of the player after next spawn
- "sess.damage_given" - the amount of damage to other team's players this player has inflicted
- "sess.damage_received" - the amount of damage this player has received from the other team
- "sess.deaths" - the amount of deaths
- "sess.game_points" - score
- "sess.kills" - the amount of kills this player has made
- "sess.medals" - an array of 7 integers for medals of each skill
- "sess.muted" and "sess.auto_unmute_time" - both of these point to the same data. This is the seconds left until unmute.
- "sess.rank" - the rank of the player
- "sess.referee" - the players referee/rcon status. Possible values are
- 0 - none
- 1 - referee
- 2 - rcon
- "sess.rounds" - the number of round. This has meaning only when playing stopwatch mode.
- "sess.skill" - an array of 7 integers for the level in each skill. Do note that this doesn't have an effect on the player abilities. Different indexes are
- 0 - battle sense
- 1 - explosives and construction (engineer)
- 2 - first aid (medic)
- 3 - signals (field ops)
- 4 - light weapons
- 5 - heavy weapons (soldier)
- 6 - military intelligence and scoped weapons (covert ops)
- "sess.spec_invite" - the which the player is invited to spectate
- "sess.spec_team" - the team the spectator is allowed to follow
- "sess.suicides" - the amount of suicides of the player. This does not limit to /kill.
- "sess.team_kills" - the amount of team kills made by this player
- "sess.team_damage_given" - the amount of damage to the own team made by this player
- "sess.team_damage_received" - the amount of damage this player has received from his/hers own team.
- "sess.aWeaponStats" - weapon statistics of the player. This is read only.
- "client.inactivityTime" - this is a ETPro compatibility alias for the "inactivityTime" field.
- "client.inactivityWarning" - this is a ETPro compatibility alias for the "inactivityWarning" field.
- "origin" - this is an alias for the "ps.origin" field
- "sess.team_damage" - this is an alias for the "sess.team_damage_given" field
- "sess.team_received" - this is an alias for the "sess.team_damage_received" field
- "sess.guid" - this is the silEnT GUID of the player. This has been validated by the mod. Validation in this context does not mean it can not have been spoofed.
- "sess.ip" - this is the IP address of the player
- "sess.uci" - this is the country flag number of the player
- "sess.ignoreClients" - this is a bitfield of ignored clients
- "sess.skillpoints" - an array of 7 floats for skill points in each skill
- "sess.kstreak" - the killing spree
- "sess.dstreak" - the death spree
- "sess.rstreak" - the revive spree
- "sess.shoutcaster" - 1 if the player is shoutcaster, 0 otherwise
- "sess.rating" - the player win probability rating
- "sess.rating_variance" - the player win probability variance
- "sess.overall_killrating" - the player kill rating
- "sess.overall_killvariance" - the player kill rating variance
- "pers.lastkilled_client" - the client number of the last kill
- "pers.lastrevive_client" - the client number of the player who revived this player last
- "pers.lastkiller_client" - the client number of the player who killed this player last
- "pers.lastammo_client" - the client number of the player who gave ammo to this player last
- "pers.lasthealth_client" - the client number of the player who gave health to this player last
- Field names for all entities
- never ending list of fields continued later
- arrayindex is the index in an array if the entity field is an array, indexes start from 0
Portability
Function is ETPro compatible.
gentity_set
Description
Sets a value in an entity. See gentity_get for possible values.
Syntax
et.gentity_set( entnum, fieldname, arrayindex, value )
- entnum is the entity number that is manipulated
- fieldname is the name of the field to manipulate
- arrayindex is either the value that is set or an array index if the field is an array
- value is the new value if arrayindex is used as an array index
Portability
Function is ETPro compatible.
G_AddEvent
Description
Adds an event to the entity event sequence.
Syntax
et.G_AddEvent( ent, event, eventparm )
- ent is the entity which event sequnce is handled
- event is the event to add
- eventparm is optional parameter for the event
Portability
Function is ETPro compatible.
Shrubbot
G_shrubbot_permission
Description
Tells if the given player has the given shrubbot flag set.
Syntax
permission = et.G_shrubbot_permission( ent, flag )
- ent is the slot number of the player whos permission is checked
- flag is the flag character that is checked
- return value permission is 1 if the player has the flag set, 0 otherwise
Portability
Function is derived from the ETPub Lua API.
G_shrubbot_level
Description
Returns the shrubbot level of the player.
Syntax
level = et.G_shrubbot_level( ent )
- ent is the slot number of the player whos permission is checked
- return value level is the shrubbot level of the player.
Portability
Function was derived from the ETPub Lua API.
Time
trap_Milliseconds
Description
Returns level time in milliseconds.
Syntax
milliseconds = et.trap_Milliseconds()
Portability
Note
Callbacks
Callbacks are functions that are called by the qagame automatically, if function implementations are present in the Lua scripts. Every Lua script needs to implement at least one callback or it will not be run at all.
et_InitGame
Description
Called when the server game initializes. Called once after every level change and after warmup.
Syntax
et_InitGame( levelTime, randomSeed, restart )
- levelTime is the current level time in milliseconds
- randomSeed is a number that can be used to seed random number generators
- restart tells if the function is called due to a map restart
Portability
Callback is ETPro compatible.
et_ShutdownGame
Description
Called when the server game shuts down.
Syntax
et_ShutdownGame( restart )
- restart indicates if the server is doing map restart
Portability
Callback is ETPro compatible.
et_RunFrame
Description
Called at the end of each server frame.
Syntax
et_RunFrame( levelTime )
- levelTime is the current level time in milliseconds
Portability
Callback is ETPro compatible.
et_ClientConnect
Description
Called for each connecting client. After the mod has performed most of its own actions. Connecting player can still be refused by this function.
Syntax
rejectreason = et_ClientConnect( clientNum, firstTime, isBot )
- clientNum is the number of the client entity. Client number range is [0,63].
- firstTime indicates if the player is connecting the first time or as a result of a map change or a map restart.
- isBot indicates if the player is a server bot. Omni-bots do have this set.
- return value rejectreason is a string describing why the player is refused. If nil is returned, the player is allowed to connect.
Portability
Callback is ETPro compatible.
et_ClientDisconnect
Description
Called everytime a player is disconnected before any actions by the mod to the player data.
Syntax
et_ClientDisconnect( clientNum )
- clientNum is the entity number of the player.
Portability
Function is ETPro compatible.
et_ClientBegin
Description
Called when the player is ready to be put into the world. After all mod actions. Function is called only once during the map.
Syntax
et_ClientBegin( clientNum )
- clientNum is the entity number of the player
Portability
Function is ETPro compatible.
et_ClientUserinfoChanged
Description
Called if the player userinfo has changed.
Syntax
et_ClientUserinfoChanged( clientNum )
- clientNum the entity number of the player
Portability
Callback is ETPro compatible.
et_ClientSpawn
Description
Called when a player is spawned.
Syntax
et_ClientSpawn( clientNum, revived, teamChange, restoreHealth )
- clientNum is the entity number of the spawned player
- revive is 1 if the player was revived, 0 otherwise
- teamChange is 1 if the player changed team, 0 otherwise
- restoreHealth is 1 if the player health bar is restored to full, 0 otherwise
Portability
Callback is ETPro compatible.
et_ClientCommand
Description
Called when a command is received from a player.
Syntax
intercepted = et_ClientCommand( clientNum, command )
- clientNum is the entity number of the player
- command is the command as a string
- return value intercepted must be set to 1 if the command execution is stopped at the Lua script. With value 0 the command is then processed in the server mod binary.
Portability
Callback is ETPro compatible.
et_ConsoleCommand
Description
Called when a command is entered to the server console.
Syntax
intercepted = et_ConsoleCommand( command )
- command is the command name as a string
- return value intercepted is set to 1 if the command execution is stopped in the Lua script, 0 if the command is then executed in the server mod binary
Portability
Callback is ETPro compatible.
et_UpgradeSkill
Description
Called when a player receives a skill upgrade.
Syntax
result = et_UpgradeSkill( cno, skill )
- cno is the entity number of the player
- skill is the skill type that is upgraded
- return value result will abort the skill upgrade if set to -1, any other value will allow the skill upgrade progress through
Portability
Callback is in ETPro compatible.
et_SetPlayerSkill
Description
Called when a player skill level is set.
Syntax
intercepted = et_SetPlayerSkill( cno, skill )
- cno is the entity number of the player
- skill is the skil type of the player
- return value intercepted is set to -1 if the skill set is aborted, with any other value the set is allowed
Portability
Callback is ETPro compatible.
et_Print
Description
Called when server is printing to the console.
Syntax
et_Print( text )
- text is the full printed text
Portability
Function is ETPro compatible. Differences may exist between ETPro, ETPub and silEnT.
et_Obituary
Description
Called when a player is killed. If a string is returned from the callback, it will replace the obituary message. The custom obituary can be printed to either chat or as a popup. This behaviour is defined with g_logOptions flag 1.
Syntax
(customObit) = et_Obituary( victim, killer, meansOfDeath )
- victim is the entity number of the killed player
- killer is the entity number of the killer, this can be also 1022 which means that the world was the killer
- meansOfDeath is the means of death number
- return value customObit can be set to create customary obituary messages. If a custom obituary message is returned, only the custom obituary is printed.
Portability
Callback is ETPro compatible.
et_CvarValue
Description
Called when a client cvar value is ready to be passed to Lua scripts.
Syntax
et_CvarValue( clientNum, cvar, value )
- clientNum is the slot number of the player
- cvar is the name of the cvar
- value is the value of the cvar
Portability
Callback was added in silEnT 0.6.2 and it is not present in ETPro or ETPub Lua APIs.
et_ClientBinary
Description
Called when a player connects with an unrecognized client executable. Also called if the player connects with a known cheat binary.
Syntax
et_ClientBinary( clientNum, checksum )
- clientNum is the slot number of the player
- checksum is the 32 character MD5 checksum of the client executable (ET.exe)
Portability
Callback was added in silEnT 0.6.2 and it is not present in ETPro or ETPub Lua APIs.
et_IntermissionStarts
Description
Called one server frame before the game enters intermission.
Syntax
et_IntermissionStarts( round )
- round is value of the g_currentRound cvar
Portability
Callback was added in silEnT 0.8.0 and it is not present in ETPro or ETPub Lua APIs.
References
- Document was constructed using information at http://wolfwiki.anime.net/index.php/ETPro:Lua_Mod_API as well as reading the mod source.
- Official Lua http://www.lua.org/