Setting

From EventScripts Community Encyclopedia

Contents

Overview

Syntax: setting <command> [settingname] <parameters>

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

Description

Allows you to save global or player based settings and display them in a menu.


Note: It doesn't expand server variables. Prefix the command with es to expand variables (es setting).

Parameters

  • command - tells what to do to your setting
  • settingname - unique name for the setting to be modified
  • parameters - command specific parameters


Commands

setting create <settingname> "<description>" [type]

Creates a new setting in memory and saves it. You need to create a setting using this command before using any other commands on it. The type is how the setting will handle the options and what the user can do with it. There are two types of a setting at the moment, list and toggle. If you do not provide a type it will be automatically set to list
setting delete <settingname>

Completly removes a setting. You should only call this command if you want to delete everything related to this setting!
setting clear <settingname> [time-difference]

Removes players from the setting storage. You can also submit a time-difference and it will only remove players that weren't on the server since time-difference seconds.
setting exists <return-var> <settingname>

Checks if the provided settingname exists. Returns 1 if true and 0 if false.
setting addoption <settingname> <option-key> <option-name> "[description]"

Adds a new option to the setting. The option-key has to be unique.
setting remoption <settingname> <option-key>

Removes an option from the setting.
setting clearoption <settingname>

Removes all options from the setting.
setting addsound <settingname> <sound-path>

Adds a sound to the setting. The sound is played everytime a player submits an option inside the menu.
setting remsound <settingname>

Removes the sound the setting.
setting send <settingname> <userid>

Sends the automatically created setting menu to a player. The player can either choose one of the options or toggle each of the options on/off, depending on the setting type.
setting list

Lists all registered settings in the server console.

Special syntax for list type

setting setdefault <settingname> <option-key>

Sets the default option of the setting to option-key.
setting get <return-var> <settingname> [userid]

Returns the active option of a setting. If you provide a userid it will be depend on the player.
setting set <settingname> <option-key> [userid]

Sets the active option of a setting to option-key. If you provide a userid it will be depend on the player.

Special syntax for toggle type

setting setdefault <settingname> <option-key> <1/0>

Sets the default status of the option-key in the setting to 1 or 0.
setting get <return-var> <settingname> <option-key> [userid]

Returns the status of an option in the setting. If you provide a userid it will be depend on the player.
setting set <settingname> <option-key> <1/0> [userid]

Sets the status of an option in a setting to 1 or 0. If you provide a userid it will be depend on the player.
setting toggle <settingname> <option-key> [userid]

Sets the status of an option in a setting from 1 to 0 and from 0 to 1. If you provide a userid it will be depend on the player.

Examples

Example setting popups:

Example setting popups.

1 - 2: List mode examples 3 - 5: Toggle mode examples 6: Toggle mode examples: Bomb Timer Settings


Example script using setting command:

addons/eventscripts/damagedisplay/es_damagedisplay.txt

event load
{
  es_xsetinfo damage_temp 0
 
  setting exists damage_temp damagedisplay
  if (server_var(damage_temp) == 0) do
  {
    setting create damagedisplay "Damage Display Settings" toggle
    setting addoption damagedisplay hit "Hit Damage"
    setting addoption damagedisplay impressive "Impressive Info"
    setting setdefault damagedisplay hit 1
    setting setdefault damagedisplay impressive 1
    setting addsound damagedisplay "ui/buttonclick.wav"
  }
 
  es_xsetinfo dm_show 1
}
event unload
{
  es_xsetinfo dm_show 0
}
event enable
{
  es_xsetinfo dm_show 1
}
event disable
{
  es_xsetinfo dm_show 0
}
event player_hurt
{
  if (server_var(dm_show) == 1) do
  {
    if (event_var(es_attackername) != 0) do
    {
      if ("STEAM" in event_var(es_attackersteamid)) do
      {
        es setting get damage_temp damagedisplay hit event_var(attacker)
        if (server_var(damage_temp) == 1) do
        {
          es_tell event_var(attacker) #multi #greenYou shot#lightgreen event_var(es_username) #green-#lightgreen event_var(health) #greenHP remaining
        }
      }
      if ("STEAM" in event_var(es_attackersteamid)) do
      {
        es setting get damage_temp damagedisplay impressive event_var(attacker)
        if (server_var(damage_temp) == 1) do
        {
          es_xsetinfo damage_total 0
          es_math damage_total + event_var(dmg_health)
          es_math damage_total + event_var(dmg_armor)
          if (server_var(damage_total) >= 100) do
          {
            es_msg #multi #greenImpressive#lightgreen event_var(es_attackername) #green -#lightgreen server_var(damage_total) #greendamage
          }
        }
      }
      else do
      {
        es_xsetinfo damage_total 0
        es_math damage_total + event_var(dmg_health)
        es_math damage_total + event_var(dmg_armor)
        if (server_var(damage_total) >= 100) do
        {
          es_msg #multi #greenImpressive#lightgreen event_var(es_attackername) #green -#lightgreen server_var(damage_total) #greendamage
        }
      }
    }
  }
}
event player_say
{
  if ("!damage" in event_var(text)) do
  {
    es setting send damagedisplay event_var(userid)
  }
}

Notes

  • Setting is only in EventScripts v1.5 or higher
  • Every _ in settingname's are changed to - (Please do not make use of this as it can be changed sometimes!)

See also

blog comments powered by Disqus