Module plugin_helpers

SparkMod server plugin helpers.

These helpers are only available to server plugins

Functions

Format (format [, ...]) Formats a string, supports %t for context based translations
PrintToChatAll (format [, ...]) Send a chat message to all players
PrintToChat ( [target], format [, ...]) Send a private chat message to a client or player
SendToAdmin (client, format, ...) Send a private message to a server admins console
SendReply (format [, ...]) Send a reply from a command or chat message callback
SendError (format [, ...]) Send a reply from a command or chat message callback and stop processing the command
GetCmdArg (arg_number) Gets a specific argument from a command or chat message callback
GetCmdArgString () Gets the full argument string from a command or chat message callback
GetPlayers () Get a table of players
EachPlayer (callback) Loops through each player
EachRealPlayer (callback) Loops through each real player
EachClient (callback) Loops through each client
EachRealClient (callback) Loops through each real client
GetClientFromSteamId (steam_id) Finds a client matching the given steam id
GetPlayerFromSteamId (steam_id) Finds a player matching the given steam id
GetPlayersMatchingName (partial_name) Find all players whos name includes the partial name
FindPlayerMatchingName (partial_name, allow_none) Find a single connected player matching a partial name or returns with an error message.
GetClient (target) Returns a client for a client or player
GetPlayer (target) Returns a player for a client or player
GetClientLanguage (client) Gets the current language set for a client, defaults to the default language for the server
IsClientEnabled (client) Checks if a client is running SparkMod client-side
GetClientTeam (target) Returns the targets current team index
GetTeamName (team_index) Returns a lower case NS2 team name for the given team index
JoinTeam (target, team_number) Joins a target to a team Joins a player to a team and sets clients[client].moving_user_to_team to the team number so that you can allow the join if you are using an OnJoinTeam forward
JoinRandomTeam (target) Joins a target to a random team
GetClientOrigin (target) Gets a target current origin
GetClientTechId (target) Gets a clients tech id
IsClientInGame (target) Checks if the target is still on the server
IsClientAlive (target) Checks if a player is alive
IsPlayerAlive (target) SourceMod compatible alias for IsClientAlive
RespawnClientNearby (target [, max_range=8]) Respawns an alive target in a nearby location which is not near a resource point
ClientCommand (target, format [, ...]) Executes a console command on a client
SetUserIdCookie (user_id, cookie_name, value) Sets a cookie for a user from a steam id
SetClientCookie (client, cookie_name, value) Sets a cookie for a connected client
GetUserIdRawCookie (user_id, cookie_name) Gets a raw cookie table for a specific cookie beloning to a user from a steam id
GetUserIdCookie (user_id, cookie_name) Gets a cookie value for a user from a steam id
GetClientCookie (client, cookie_name) Gets a cookie value for a connected client
GetClientCookieTime (client, cookie_name) Gets the time a cookies value was last changed for a user from a steam id
CommandAlias (command_name, alias_name) Registers an alias for a registered client or admin command
PrintToScreen (target, x, y, text, duration, color [, tag]) Prints a text message at a specific location of a targets screen
PrintToScreenAll (x, y, text, duration, color [, tag]) Prints a text message at a specific location of all connected players screens
PrintCenterText (target, format [, ...]) Prints a text message to the center of a targets screen
PrintCenterTextAll (format [, ...]) Prints a text message to the center of all connected players screens
ArgCount (...) Counts the number of arguments given
ArgString (...) Joins the arguments given together with spaces


Functions

Format (format [, ...])
Formats a string, supports %t for context based translations

Parameters:

  • format string a string to be formatted
  • ... any arguments to be formatted
PrintToChatAll (format [, ...])
Send a chat message to all players

Parameters:

  • format string string to format before sending
  • ... any number of format arguments
PrintToChat ( [target], format [, ...])
Send a private chat message to a client or player

Parameters:

  • target ServerClient or Player the target that the message will be sent to
  • format string string to format before sending
  • ... any number of format arguments
SendToAdmin (client, format, ...)
Send a private message to a server admins console

Parameters:

  • client ServerClient the client to send the message to
  • format string string to format before sending
  • ... any number of format arguments
SendReply (format [, ...])
Send a reply from a command or chat message callback

Parameters:

  • format string string to format before sending
  • ... any number of format arguments
SendError (format [, ...])
Send a reply from a command or chat message callback and stop processing the command

Parameters:

  • format string string to format before sending
  • ... any number of format arguments
GetCmdArg (arg_number)
Gets a specific argument from a command or chat message callback

Parameters:

  • arg_number int argument number starting from 1

Returns:

    string an argument that was entered after the command
GetCmdArgString ()
Gets the full argument string from a command or chat message callback

Returns:

    string all arguments that were entered after the command
GetPlayers ()
Get a table of players

Returns:

    table a table containing all Player entities
EachPlayer (callback)
Loops through each player

Parameters:

  • callback func a callback which will be called for each player
EachRealPlayer (callback)
Loops through each real player

Parameters:

  • callback func a callback which will be called for each real player
EachClient (callback)
Loops through each client

Parameters:

  • callback func a callback which will be called for each client
EachRealClient (callback)
Loops through each real client

Parameters:

  • callback func a callback which will be called for each real client
GetClientFromSteamId (steam_id)
Finds a client matching the given steam id

Parameters:

  • steam_id int a steam id of a connected client

Returns:

    ServerClient the connected client who the steam id belongs to
GetPlayerFromSteamId (steam_id)
Finds a player matching the given steam id

Parameters:

  • steam_id int a steam id of a connected player

Returns:

    ServerClient the connected player who the steam id belongs to
GetPlayersMatchingName (partial_name)
Find all players whos name includes the partial name

Parameters:

  • partial_name string a partial name of a connected player

Returns:

    table all players whos names contain the partial name
FindPlayerMatchingName (partial_name, allow_none)
Find a single connected player matching a partial name or returns with an error message. If there are are multiple or no matches, an error message will be sent to the client and the command will not be processed any further.

Parameters:

  • partial_name string a partial name of a connected player
  • allow_none bool if true, return nil and continus processing the command if there are no matches
GetClient (target)
Returns a client for a client or player

Parameters:

  • target ServerClient or Player the target client or player

Returns:

    ServerClient the client associated with the target
GetPlayer (target)
Returns a player for a client or player

Parameters:

  • target ServerClient or Player the target client or player

Returns:

    Player the client associated with the target
GetClientLanguage (client)
Gets the current language set for a client, defaults to the default language for the server

Parameters:

  • client ServerClient the client whos language you want to get

Returns:

    string the language the client has set or the servers default language
IsClientEnabled (client)
Checks if a client is running SparkMod client-side

Parameters:

  • client ServerClient the target client

Returns:

    boolean true if the clients game is running SparkMod
GetClientTeam (target)
Returns the targets current team index

Parameters:

  • target ServerClient or Player the target client or player

Returns:

    number the targets current team number
GetTeamName (team_index)
Returns a lower case NS2 team name for the given team index

Parameters:

  • team_index int the index of a NS2 team
JoinTeam (target, team_number)
Joins a target to a team Joins a player to a team and sets clients[client].moving_user_to_team to the team number so that you can allow the join if you are using an OnJoinTeam forward

Parameters:

  • target ServerClient or Player the target client or player
  • team_number number the team number
JoinRandomTeam (target)
Joins a target to a random team

Parameters:

  • target ServerClient or Player the target client or player
GetClientOrigin (target)
Gets a target current origin

Parameters:

  • target ServerClient or Player the target client or player

Returns:

    table a vector containing the current origin of the target
GetClientTechId (target)
Gets a clients tech id

Parameters:

  • target ServerClient or Player the target client or player

Returns:

    number the targets tech id
IsClientInGame (target)
Checks if the target is still on the server

Parameters:

  • target ServerClient or Player the target client or player

Returns:

    boolean true if the target is still on the server
IsClientAlive (target)
Checks if a player is alive

Parameters:

  • target ServerClient or Player the target client or player

Returns:

    boolean true if the target is alive
IsPlayerAlive (target)
SourceMod compatible alias for IsClientAlive

Parameters:

  • target ServerClient or Player the target client or player

Returns:

    true if the target is alive
RespawnClientNearby (target [, max_range=8])
Respawns an alive target in a nearby location which is not near a resource point

Parameters:

  • target ServerClient or Player the target client or player
  • max_range number
ClientCommand (target, format [, ...])
Executes a console command on a client

Parameters:

  • target ServerClient or Player the target client or player
  • format string a string to be formatted
  • ... any arguments to be formatted
SetUserIdCookie (user_id, cookie_name, value)
Sets a cookie for a user from a steam id

Parameters:

  • user_id number the steam id of the user
  • cookie_name string the name of the cookie
  • value the value to set
SetClientCookie (client, cookie_name, value)
Sets a cookie for a connected client

Parameters:

  • client ServerClient the connected client
  • cookie_name string the name of the cookie
  • value the value to set
GetUserIdRawCookie (user_id, cookie_name)
Gets a raw cookie table for a specific cookie beloning to a user from a steam id

Parameters:

  • user_id number the steam id of the user
  • cookie_name string the name of the cookie

Returns:

    the cookie value
GetUserIdCookie (user_id, cookie_name)
Gets a cookie value for a user from a steam id

Parameters:

  • user_id number the steam id of the user
  • cookie_name string the name of the cookie

Returns:

    the cookie value
GetClientCookie (client, cookie_name)
Gets a cookie value for a connected client

Parameters:

  • client ServerClient the connected client
  • cookie_name string the name of the cookie

Returns:

    the cookie value
GetClientCookieTime (client, cookie_name)
Gets the time a cookies value was last changed for a user from a steam id

Parameters:

  • client ServerClient the connected client
  • cookie_name string the name of the cookie

Returns:

    float the time that the cookies value last changed
CommandAlias (command_name, alias_name)
Registers an alias for a registered client or admin command

Parameters:

  • command_name string the registered command name
  • alias_name string the name of the alias you want to register
PrintToScreen (target, x, y, text, duration, color [, tag])
Prints a text message at a specific location of a targets screen

Parameters:

  • target ServerClient or Player the target to send the message to
  • x number a ratio between 0 and 1.0 representing the x position on the clients screen
  • y number a ratio between 0 and 1.0 representing the y position on the clients screen
  • text string the text message you want to display
  • duration number the amount of seconds the message should be visible for
  • color tab the RGB color of the text
  • tag string a tag to associate with the message which can be used to remove it
PrintToScreenAll (x, y, text, duration, color [, tag])
Prints a text message at a specific location of all connected players screens

Parameters:

  • x number a ratio between 0 and 1.0 representing the x position on the clients screen
  • y number a ratio between 0 and 1.0 representing the y position on the clients screen
  • text string the text message you want to display
  • duration number the amount of seconds the message should be visible for
  • color tab the RGB color of the text
  • tag string a tag to associate with the message which can be used to remove it
PrintCenterText (target, format [, ...])
Prints a text message to the center of a targets screen

Parameters:

  • target ServerClient or Player the target to send the message to
  • format string a string to format
  • ... any arguments to format
PrintCenterTextAll (format [, ...])
Prints a text message to the center of all connected players screens

Parameters:

  • format string a string to format
  • ... any arguments to format
ArgCount (...)
Counts the number of arguments given

Parameters:

  • ... the arguments to count

Returns:

    number the number of arguments
ArgString (...)
Joins the arguments given together with spaces

Parameters:

  • ... the arguments to join

Returns:

    string the arguments given joined together with spaces
generated by LDoc 1.3.11