Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- AT] Infection 3.0
- -- Table.Load and Table.Save --
- function table.save(t, filename)
- local dir = getprofilepath()
- local file = io.open(dir .. "\\data\\" .. filename, "w+")
- local spaces = 1
- local function format(t)
- local function whitespace(num)
- local str = ""
- for i = 1, num do
- str = str .. "\t"
- end
- return str
- end
- local str = ""
- for k,v in pairs(t) do
- if type(v) == "string" then
- v = string.format("%q", v)
- end
- if type(k) == "string" then
- k = string.format("%q", k)
- end
- k = tostring(k)
- if v == math.inf then
- v = "1 / 0"
- end
- if type(v) == "table" then
- if table.len(v) > 0 then
- spaces = spaces + 1
- str = str .. "\n" .. whitespace(spaces - 1) .. "[" .. k .. "] = {" .. format(v) .."\n" .. whitespace(spaces - 1) .. "},"
- spaces = spaces - 1
- else
- str = str .. "\n" .. whitespace(spaces) .. "[" .. k .. "] = {},"
- end
- else
- str = str .."\n" .. whitespace(spaces) .. "[" .. k .. "] = " .. tostring(v) .. ","
- end
- end
- return string.sub(str, 1, string.len(str) - 1)
- end
- file:write("return {" .. format(t) .. "\n}")
- file:close()
- end
- function table.load(filename)
- local dir = getprofilepath()
- local exists = loadfile(dir .. "\\data\\" .. filename)
- local t
- if exists then
- t = exists()
- end
- return t or {}
- end
- -- Mute
- -- You may update this table in this script or via console commands.
- --[[ Mute Table ]]--
- -- To mute specific hashes by default (they will be permanent mutes), simply enter them into the mute_table, surrounded by quotes and separated by commas. Once the script it loaded and unloaded, you can delete them if you want; they will be saved.
- local mute_default = {} -- "eb12931aef01915b20d014c10", "a45c6a5e116fd31b65ade46b3" (these are made-up, invalid hashes)
- mute_table = table.load("mutelist")
- -- Chat Filter
- -- You may update this table in this script or via console commands.
- --[[ Swear Tables and Variables ]]--
- sweartable = table.load("sweartable") or {}
- local swear_default = {}
- -- To specify swear words that players must say exactly to be counted as a swear, enter the word (in lowercase) in the swear_default.exact table, surrounded by quotes and separated by commas. To specify swear words that should be blocked in any context, enter into swear_default.anywhere. Note that swear_default.exact may not have a space, while swear_default.anywhere can.
- swear_default.exact = {} -- "ass", "fu", "shit"
- swear_default.anywhere = {} -- "fuck", "damn", "donkey boner"
- -- Nil check
- sweartable.exact = sweartable.exact or {}
- sweartable.anywhere = sweartable.anywhere or {}
- -- Swear Variables:
- if sweartable.automute == nil then
- automute = true
- else
- automute = sweartable.automute
- end
- -- The amount of times a player needs to swear before they are automuted.
- swears_to_mute = sweartable.tomute or 3
- -- Either "none" (0), "block" (1) or "append" (2). If "block", when a player swears, their entire message will be blocked. If "append", players' messages will be changed to their specified replacement words.
- swear_action = sweartable.action or 2
- -- If a swear word has no specific replacement word, this is what it will be replaced by.
- swear_append = sweartable.append or "**censored**"
- -- If a player swears, this is the message they will receive. If you don't want players to receive swear messages, use "".
- swear_message = sweartable.message or "Please do not swear in this server."
- -- Amount of time a player will be automuted for (-1 = rest of game) (-2 = permanent) (all other values taken in seconds)
- swear_penalty = sweartable.penalty or -1
- -- If a player has been muted this many times, the next time they are muted, the admin who muted them is notified to consider a permanent mute. Use 0 to disable.
- notify_of_mutes = sweartable.mutenotify or 5
- --[[ Editable values ]]--
- -- Teams --
- zombie_team = 1 -- 0 is red, 1 is blue
- human_team = 1 - zombie_team
- -- General Infection Values --
- starting_zombies = 1 -- If values is < 1, this is taken as a percentage of current players. Otherwise, it is taken as an actual value.
- -- General Booleans --
- lastman_zombie = true -- If true, the last man from the previous game will be a zombie this game. If false, zombies for this game will be chosen at random.
- infected_by_zombie = true -- Allows/unallows for a player to be infected by being killed by a zombie
- infected_by_fall = true -- Allows/unallows for a player to be infected by falling to their death
- infected_by_server = true -- Allows/unallows for a player to be infected when killed by the server
- infected_by_suicide = true -- Allows/unallows for a player to be infected by committing suicide
- infected_by_vehicle = false -- Allows/unallows for a player to be infected by being killed by a vehicle
- infected_by_betrayal = false -- Allows/unallows for a player to be infected if they betray a teammate
- infected_by_guardians = false -- Allows/unallows for a player to be infected by the guardians
- zombies_invisible = false -- Allows/unallows zombies to always be invisible
- -- Anti-Block Features --
- anti_block = true -- Allows/unallows the use of Anti-Block, which will warn then penalize a player who is blocking (using the specifications below)
- -- All following values are only relevant if anti_block is true
- block_time_warning = 5 -- Amount of time in seconds before a player is sent a warning that they are blocking
- block_time_action = 10 -- Amount of time in seconds a player is blocking before an action is taken
- block_time_warning_message = "You appear to be blocking. You have " .. block_time_action - block_time_warning .. " seconds to move from your position." -- Message sent to players who appear to be blocking (use nil if you don't want a message to be sent)
- block_time_action_message = "You have been killed for blocking." -- Message sent to a player who has been blocking for the amount of time specified in block_time_action (use nil if you don't want a message to be sent)
- block_action = "sv_kill <player>" -- Command executed on player when they've been blocking for the amount of time specified in block_time_action (use <player> to represent where the player's number should go in the command)
- multiple_offense_action_amount = 3 -- Amount of times the block_action must be performed in this game in order for the multiple_offense_action to be taken (use nil to disable)
- multiple_offense_action_message = nil -- Message sent to a player who has been penalized for blocking the amount of times specified in multiple_offense_action_amount (use nil if you don't want a message to be sent)
- multiple_offense_action = "sv_kick <player>" -- Command executed on player when they've been penalized for blocking the amount of times specified in multiple_offense_action_amount (use <player> to represent where the player's number should go in the command)
- -- Messages --
- welcome_message = "Infection" -- Message players are welcomed with
- infected_message = " was infected!" -- Message printed to the server when a player is infected
- human_message = "You are a human. Survive!" -- Message sent to humans when they become human
- zombie_message = "You are a zombie. Kill the humans!" -- Message sent to zombies when they become zombies
- no_zombies_left_message = "There are no zombies left." -- Message sent to server if there are no zombies left
- no_zombies_timer_message = "A random player will be forced to become a zombie" -- Message sent to server to notify the server will choose a random player to become a zombie
- no_zombies_team_change_message = "Thank you; the game can continue." -- Message sent to the server if a player changes team voluntarily when there are no zombies left
- lastman_message = " is the last man alive!" -- Message sent to the server when there is only one human left
- vehicle_block_message = "You cannot enter vehicles." -- Message sent to players who try to enter a vehicle but are blocked from doing so
- -- Weapon Attributes --
- -- Weapon Tag List
- --[[
- "weapons\\assault rifle\\assault rifle"
- "weapons\\pistol\\pistol"
- "weapons\\plasma pistol\\plasma pistol"
- "weapons\\plasma rifle\\plasma rifle"
- "weapons\\needler\\mp_needler"
- "weapons\\shotgun\\shotgun"
- "weapons\\sniper rifle\\sniper rifle"
- "weapons\\rocket launcher\\rocket launcher"
- "weapons\\plasma_cannon\\plasma_cannon"
- "weapons\\flamethrower\\flamethrower"
- "weapons\\flag\\flag"
- "weapons\\ball\\ball"
- ]]--
- -- If you use an oddball as a team's primary and only weapon, they will be unable to drop it.
- -- Human Weapons (use "" for default and nil for no weapon)
- human_weapons = {}
- human_weapons[1] = "" -- Primary weapon
- human_weapons[2] = "" -- Secondary weapon
- --human_weapons[3] = nil -- Tertiary weapon
- --human_weapons[4] = nil -- Quartenary weapon
- -- Zombie Weapons (use "" for default and nil for no weapon)
- zombie_weapons = {}
- zombie_weapons[1] = "weapons\\shotgun\\shotgun" -- Primary weapon
- zombie_weapons[2] = nil -- Secondary weapon
- --zombie_weapons[3] = nil -- Tertiary weapon
- --zombie_weapons[4] = nil -- Quartenary weapon
- -- Human Ammo OnPlayerSpawn (use nil for default; for plasma weapons, specify the battery percentage in the ammo category)
- human_ammo = {}
- human_clip = {}
- human_ammo[1] = nil -- Ammo for primary weapon
- human_clip[1] = nil -- Clip for primary weapon
- human_ammo[2] = nil -- Ammo for secondary weapon
- human_clip[2] = nil -- Clip for secondary weapon
- --human_ammo[3] = nil -- Ammo for tertiary weapon
- --human_clip[3] = nil -- Clip for teriary weapon
- --human_ammo[4] = nil -- Ammo for quartenary weapon
- --human_clip[4] = nil -- Clip for quartenary weapon
- -- Zombie Ammo OnPlayerSpawn (use nil for default; for plasma weapons, specify the battery percentage in the ammo category)
- zombie_ammo = {}
- zombie_clip = {}
- zombie_ammo[1] = 0 -- Ammo for primary weapon
- zombie_clip[1] = 0 -- Clip for primary weapon
- zombie_ammo[2] = 0 -- Ammo for secondary weapon
- zombie_clip[2] = 0 -- Clip for secondary weapon
- --zombie_ammo[3] = 0 -- Ammo for tertiary weapon
- --zombie_clip[3] = 0 -- Clip for teriary weapon
- --zombie_ammo[4] = 0 -- Ammo for quartenary weapon
- --zombie_clip[4] = 0 -- Clip for quartenary weapon
- -- Human Grenades (use nil for default)
- human_frags = nil
- human_plasmas = nil
- -- Zombie Grenades (use nil for default)
- zombie_frags = 0
- zombie_plasmas = 0
- -- Objects Humans Cannot Interact With (separate entries with a comma)
- human_blocked = {
- "weapons\\flag\\flag",
- }
- -- Objects Zombies Cannot Interact With (separate entires with a comma)
- zombie_blocked = {
- "weapons\\assault rifle\\assault rifle",
- "weapons\\pistol\\pistol",
- "weapons\\plasma pistol\\plasma pistol",
- "weapons\\plasma rifle\\plasma rifle",
- "weapons\\needler\\mp_needler",
- "weapons\\shotgun\\shotgun",
- "weapons\\sniper rifle\\sniper rifle",
- "weapons\\rocket launcher\\rocket launcher",
- "weapons\\plasma_cannon\\plasma_cannon",
- "weapons\\flamethrower\\flamethrower",
- "weapons\\flag\\flag",
- "weapons\\ball\\ball",
- "weapons\\frag grenade\\frag grenade",
- "weapons\\plasma grenade\\plasma grenade",
- }
- -- Vehicle Attributes --
- human_vehicle = true -- Allows/unallows humans to enter vehicles
- zombie_vehicle = false -- Allows/unallows zombies to enter vehicles
- -- Health and Damage Attributes --
- -- Max Health and Shields (use nil for default, 1 = 100%)
- human_vitality = nil
- zombie_vitality = 0.5
- -- Damage Multipliers (use 1 for default)
- human_damage = 1
- zombie_damage = 1
- zombie_melee_damage = 500
- -- General Human Attributes --
- human_speed = 1 -- Speed of a human (1 is normal)
- -- General Zombie Attributes --
- zombie_speed = 1.5 -- Speed of zombie (1 is normal)
- -- Last Man Attributes --
- lastman_damage = 1.5 -- Damage multiplier (use 1 for default)
- lastman_vitality = nil -- Last man's max health and shields (use nil for no change, 1 = 100%)
- lastman_ammo = 600 -- Ammo last man's weapons will have (use nil for no change)
- lastman_clip = nil -- Clip last man's weapons will have (use nil for no change)
- lastman_frags = nil -- Frag grenades the last man should have (use nil for no change, 7 maximum)
- lastman_plasmas = nil -- Plasma grenades the last man should have (use nil for no change, 7 maximum)
- lastman_speed = 1.5 -- Speed of last man (1 is normal)
- lastman_invistime = 15 -- Amount of time (in seconds) the last man is invisible (use nil to disable)
- --[[ Uneditable Values ]]--
- -- Don't mess with these
- hashes = {}
- cur_hashes = {}
- teams = {}
- blocking = {}
- block_offenses = {}
- balls = {}
- phasor_changeteam = changeteam
- game_begin = false
- join_zombie = false
- no_zombies = false
- block_time_warning = block_time_warning * 1000
- block_time_action = block_time_action * 1000
- cur_players = 0
- gametype_base = 0x671340
- writeword(0x4A4DBF, 0x0, 0x9090)
- writeword(0x4A4E7F, 0x0, 0x9090)
- -- Players --
- players = table.load("players")
- players.recent = players.recent or {}
- -- Amount of games player indexes are available and printed via 'sv_players'
- players.recentmemory = players.recentmemory or 2
- players.levels = players.levels or {}
- players.admins = players.admins or {}
- -- Commands --
- commands = {}
- commands.syntax = {}
- commands.info = {}
- -- Syntax displayed when a command is executed incorrectly.
- commands.syntax["sv_ammo"] = {"sv_ammo", "<Player ID or Server Index>", "<opt: Weapon or Slot>", "<Ammo>", "<Clip>"}
- --commands.syntax["cls"] = {"cls"}
- commands.syntax["sv_help"] = {"sv_help", "<Command>"}
- commands.syntax["sv_players"] = {"sv_players", "<opt: Search>"}
- commands.syntax["sv_banlist"] = {"sv_banlist"}
- commands.syntax["sv_ban"] = {"sv_ban", "<Player ID or Server Index>", "<opt: Ban Penalty>"}
- commands.syntax["sv_unban"] = {"sv_unban", "<Server Index>"}
- commands.syntax["sv_kick"] = {"sv_kick", "<Player ID or Server Index>"}
- commands.syntax["sv_ban_penalty"] = {"sv_ban_penalty", "<opt: Bancount>", "<opt: Ban Penalty>"}
- commands.syntax["sv_friendly_fire"] = {"sv_friendly_fire", "<opt: Friendly Fire Value>"}
- commands.syntax["sv_gamelist"] = {"sv_gamelist", "<opt: Search>"}
- commands.syntax["sv_maxplayers"] = {"sv_maxplayers", "<opt: Value>"}
- commands.syntax["sv_name"] = {"sv_name", "<opt: Server Name>"}
- commands.syntax["sv_password"] = {"sv_password", "<opt: Password>"}
- commands.syntax["sv_public"] = {"sv_public", "<opt: Boolean>"}
- commands.syntax["sv_rcon_password"] = {"sv_rcon_password", "<opt: Password>"}
- commands.syntax["sv_single_flag_force_reset"] = {"sv_single_flag_force_reset", "<opt: Boolean>"}
- commands.syntax["sv_status"] = {"sv_status"}
- commands.syntax["sv_timelimit"] = {"sv_timelimit", "<opt: Timelimit>"}
- commands.syntax["sv_tk_ban"] = {"sv_tk_ban", "<opt: Value>"}
- commands.syntax["sv_tk_cooldown"] = {"sv_tk_cooldown", "<opt: Value>"}
- commands.syntax["sv_tk_grace"] = {"sv_tk_grace", "<opt: Value>"}
- commands.syntax["sv_map"] = {"sv_map", "<Map>", "<Gametype>", "<opt: Scripts...>"}
- commands.syntax["sv_map_next"] = {"sv_map_next"}
- commands.syntax["sv_map_reset"] = {"sv_map_reset", "<opt: Count>"}
- commands.syntax["sv_mapcycle"] = {"sv_mapcycle"}
- commands.syntax["sv_mapcycle_add"] = {"sv_mapcycle_add", "<Map>", "<Gametype>", "<opt: Scripts...>"}
- commands.syntax["sv_mapcycle_del"] = {"sv_mapcycle_del", "<Mapcycle Index>"}
- commands.syntax["sv_mapcycle_begin"] = {"sv_mapcycle_begin"}
- commands.syntax["sv_mapcycle_timeout"] = {"sv_mapcycle_timeout", "<opt: Value>"}
- commands.syntax["sv_maplist"] = {"sv_maplist", "<opt: Search>"}
- commands.syntax["sv_gametypes"] = {"sv_gametypes", "<opt: Search>"}
- commands.syntax["sv_scripts"] = {"sv_scripts", "<opt: Search>"}
- commands.syntax["sv_mapvote"] = {"sv_mapvote", "<opt: Boolean>"}
- commands.syntax["sv_mapvote_begin"] = {"sv_mapvote_begin"}
- commands.syntax["sv_mapvote_add"] = {"sv_mapvote_add", "<Map>", "<Gametype>", "<opt: Scripts...>"}
- commands.syntax["sv_mapvote_del"] = {"sv_mapvote_del", "<Mapvote Index>"}
- commands.syntax["sv_mapvote_list"] = {"sv_mapvote_list"}
- commands.syntax["sv_mapvote_info"] = {"sv_mapvote_info", "<Mapvote Index>"}
- commands.syntax["sv_mapvote_options"] = {"sv_mapvote_options", "<opt: Value>"}
- commands.syntax["sv_objects"] = {"sv_objects", "<opt: Search>"}
- commands.syntax["sv_create"] = {"sv_create", "<opt: Player ID or Server Index>", "<Object>", "<opt: Respawn Time>", "<opt: X>", "<opt: Y>", "<opt: Z>"}
- commands.syntax["sv_destroy"] = {"sv_destroy", "<Object ID or Search>"}
- commands.syntax["sv_reloadscripts"] = {"sv_reloadscripts"}
- commands.syntax["sv_teams_balance"] = {"sv_teams_balance"}
- commands.syntax["sv_teams_lock"] = {"sv_teams_lock"}
- commands.syntax["sv_teams_unlock"] = {"sv_teams_unlock"}
- commands.syntax["sv_changeteam"] = {"sv_changeteam", "<Player ID or Server Index>"}
- commands.syntax["sv_teleport"] = {"sv_teleport", "<Player ID or Server Index>", "<Location Name or X>", "<opt: Y>", "<opt: Z>"}
- commands.syntax["sv_teleport_to"] = {"sv_teleport_to", "<Teleported Player ID or Server Index>", "<Destination Player ID or Server Index>"}
- commands.syntax["sv_teleport_add"] = {"sv_teleport_add", "<Location Name>", "<opt: X>", "<opt: Y>", "<opt: Z>"}
- commands.syntax["sv_teleport_del"] = {"sv_teleport_del", "<Teleport Index>"}
- commands.syntax["sv_teleport_list"] = {"sv_teleport_list"}
- commands.syntax["sv_kickafk"] = {"sv_kickafk", "<opt: AFK Time>"}
- commands.syntax["sv_host"] = {"sv_host", "<Value>"}
- commands.syntax["sv_say"] = {"sv_say", "<Message>"}
- commands.syntax["sv_gethash"] = {"sv_gethash", "<Player ID or Server Index>"}
- commands.syntax["sv_chatids"] = {"sv_chatids", "<opt: Boolean>"}
- commands.syntax["sv_disablelog"] = {"sv_disablelog"}
- commands.syntax["sv_logname"] = {"sv_logname", "<Log Type>", "<Log Name>"}
- commands.syntax["sv_savelog"] = {"sv_savelog"}
- commands.syntax["sv_loglimit"] = {"sv_loglimit", "<Log Type>", "<Log Size>"}
- commands.syntax["sv_getobject"] = {"sv_getobject", "<Player ID or Server Index>"}
- commands.syntax["sv_kill"] = {"sv_kill", "<Player ID, Server Index or Team>", "<opt: Killer Player ID or Server Index>"}
- commands.syntax["sv_invis"] = {"sv_invis", "<opt: Player ID, Server Index or Team>", "<opt: Duration>"}
- commands.syntax["sv_setspeed"] = {"sv_setspeed", "<Player ID, Server Index or Team>", "<Speed>", "<opt: Duration>"}
- commands.syntax["sv_unique"] = {"sv_unique"}
- commands.syntax["sv_alias"] = {"sv_alias", "<Player ID or Server Index>"}
- commands.syntax["sv_reset_alias"] = {"sv_reset_alias", "<Player ID or Server Index>"}
- commands.syntax["sv_player_memory"] = {"sv_player_memory", "<Value>"}
- commands.syntax["sv_player_name"] = {"sv_player_name", "<Player ID or Server Index>", "<opt: New Player Name>"}
- commands.syntax["sv_player_index"] = {"sv_player_index", "<Player ID or Server Index>", "<opt: New Server Index>"}
- commands.syntax["sv_message"] = {"sv_message", "<Player ID or Server Index>", "<Message>"}
- commands.syntax["sv_commands"] = {"sv_commands", "<opt: Search, Player ID, Server Index or Admin Level>"}
- commands.syntax["sv_levels"] = {"sv_levels", "<opt: Search>"}
- commands.syntax["sv_level_add"] = {"sv_level_add", "<opt: Level Name>"}
- commands.syntax["sv_level_del"] = {"sv_level_del", "<Admin Level>"}
- commands.syntax["sv_level_admins"] = {"sv_level_admins", "<Admin Level>"}
- commands.syntax["sv_level_id"] = {"sv_level_id", "<Admin Level>", "<opt: Level ID>"}
- commands.syntax["sv_level_name"] = {"sv_level_name", "<Admin Level>", "<opt: Level Name>"}
- commands.syntax["sv_admin_add"] = {"sv_admin_add", "<Player ID or Server Index>", "<opt: Admin Level>"}
- commands.syntax["sv_admin_del"] = {"sv_admin_del", "<Player ID or Server Index>"}
- commands.syntax["sv_command_add"] = {"sv_command_add", "<Admin Level>", "<Command>"}
- commands.syntax["sv_command_del"] = {"sv_command_del", "<Admin Level>", "<Command>"}
- commands.syntax["sv_admins"] = {"sv_admins", "<opt: Search, Player ID, Server Index, Command, or Admin Level>"}
- commands.syntax["sv_admin_level"] = {"sv_admin_level", "<Player ID or Server Index>", "<opt: Admin Level>"}
- commands.syntax["sv_admin_default"] = {"sv_admin_default", "<opt: Admin Level>"}
- commands.syntax["sv_openaccess"] = {"sv_openaccess", "<Admin Level>", "<opt: Boolean>"}
- commands.syntax["sv_mute"] = {"sv_mute", "<Player ID or Server Index>", "<opt: Mute Duration>", "<opt: Mute Message>"}
- commands.syntax["sv_unmute"] = {"sv_unmute", "<Player ID or Server Index>"}
- commands.syntax["sv_permamute"] = {"sv_permamute", "<Player ID or Server Index>", "<opt: Mute Message>"}
- commands.syntax["sv_mute_duration"] = {"sv_mute_duration", "<Player ID or Server Index>", "<opt: New Mute Duration>"}
- commands.syntax["sv_mute_message"] = {"sv_mute_message", "<Player ID or Server Index>", "<opt: New Mute Message>"}
- commands.syntax["sv_mute_info"] = {"sv_mute_info", "<Player ID or Server Index>"}
- commands.syntax["sv_swears"] = {"sv_swears", "<Player ID or Server Index>"}
- commands.syntax["sv_mute_players"] = {"sv_mute_players"}
- commands.syntax["sv_mutelist"] = {"sv_mutelist", "<opt: Search or Sorted By>", "<opt: Sorting Direction>", "<opt: Number of Results>"}
- commands.syntax["sv_mutelog"] = {"sv_mutelog", "<Player ID or Server Index>"}
- commands.syntax["sv_reset_mute_info"] = {"sv_reset_mute_info", "<Player ID or Server Index>"}
- commands.syntax["sv_swear_add"] = {"sv_swear_add", "<Word>", "<opt: Appended Word>", "<opt: Swear Type>"}
- commands.syntax["sv_swear_del"] = {"sv_swear_del", "<Word>", "<opt: Swear Type>"}
- commands.syntax["sv_swear_type"] = {"sv_swear_type", "<Word>"}
- commands.syntax["sv_sweartable"] = {"sv_sweartable", "<opt: Swear Type>"}
- commands.syntax["sv_automute"] = {"sv_automute", "<opt: Boolean>"}
- commands.syntax["sv_swears_to_mute"] = {"sv_swears_to_mute", "<opt: Swears to Mute>"}
- commands.syntax["sv_swear_action"] = {"sv_swear_action", "<opt: Swear Action>"}
- commands.syntax["sv_swear_append"] = {"sv_swear_append", "<opt: Default Swear Append>"}
- commands.syntax["sv_swear_message"] = {"sv_swear_message", "<opt: Swear Message>"}
- commands.syntax["sv_swear_penalty"] = {"sv_swear_penalty", "<opt: Automute Swear Penalty>"}
- commands.syntax["sv_mute_notify"] = {"sv_mute_notify", "<opt: Mutes Until Notifed>"}
- -- Information about command displayed when a player uses sv_help.
- -- Command information:
- --commands.info["cls"] = {"Stops console messages from printing when the rcon console is not open."}
- commands.info["sv_help"] = {"Displays information and syntax about the given command."}
- commands.info["sv_players"] = {"Displays a list of players currently in the server as well as players who have recently left the server if a search is not specified. If a search is specified, this command searches through all players' aliases that have joined the server under and returns a list of matches, their Server Index and Server Name."}
- commands.info["sv_banlist"] = {"Displays a list of players who are currently banned, their Server ID and the amount of times they have been banned."}
- commands.info["sv_ban"] = {"Kicks and bans the specified player from joining the server in the future.", "If no Ban Penalty is specified, the player will be banned for the default amount of time based on how many times they have been banned."}
- commands.info["sv_unban"] = {"Unbans the specified player via their Server Index."}
- commands.info["sv_kick"] = {"Kicks the specified player from the server."}
- commands.info["sv_ban_penalty"] = {"Amount of time a player should be banned for depending on the amount of times they have been banned in the past.", "If no Ban Penalty is specified, the Ban Penalty for the specified Bancount is printed.", "If neither a Bancount nor a Ban Penalty are specified, all Ban Penalties for all Bancounts are printed."}
- commands.info["sv_friendly_fire"] = {"Used to provide a global override for the gametype Friendly Fire setting.", "If no Friendly Fire Value is specified, the current value is printed."}
- commands.info["sv_gamelist"] = {"Prints a list of gametypes sorted alphabetically.", "If no Search is specified, all gametypes are printed."}
- commands.info["sv_maxplayers"] = {"Specifies the maximum amount of players able to join the server at once.", "If no Value is specified, the current maximum players is printed."}
- commands.info["sv_name"] = {"The name of the server.", "If no Server Name is specified, the current Server Name is printed."}
- commands.info["sv_password"] = {"The password players must enter to join the server. Use sv_password \"\" to disable the password.", "If no Password is specified, the current Server Password is printed."}
- commands.info["sv_public"] = {"Specifies if this server is available to players outside of your LAN.", "If no Boolean is specified, the current Public Boolean is printed."}
- commands.info["sv_rcon_password"] = {"The password admins must use to use rcon commands in the rcon console.", "If no Password is specified, the current Rcon Password is printed."}
- commands.info["sv_single_flag_force_reset"] = {"Specifies boolean for in a single-flag CTF game, if the time for a player to be on offense runs out, even if a player is holding the flag, the teams will switch offense and defense and the flag will reset.", "If no Boolean is specified, the current Single Flag Force Reset Boolean is printed."}
- commands.info["sv_status"] = {"Displays the current map and amount of players the server is currently running with."}
- commands.info["sv_timelimit"] = {"Changes the timelimit for the next game and every game after. Use -1 for default and 0 for infinite.", "If no Timelimit is specified, the current Timelimit is printed."}
- commands.info["sv_tk_ban"] = {"Specifies the amount of Team Kill Points a player must have before they are automatically banned by the server.", "If no Value is specified, the current TK Ban Value is printed."}
- commands.info["sv_tk_cooldown"] = {"Specifies the amount of time before a player's Team Kill Points are reset to zero.", "If no Value is specified, the current TK Cooldown Value is printed."}
- commands.info["sv_tk_grace"] = {"Specifies the time window in which multiple team kills only count as one Team Kill Point.", "If no Value is specified, the current TK Grace Value is printed."}
- commands.info["sv_map"] = {"Loads the specified map with the specified gametype and specified scripts.", "If no scripts are specified, only the Main script will be loaded."}
- commands.info["sv_map_reset"] = {"Resets the current map the specified amount of times.", "If no Count is specified, the map will be reset once."}
- commands.info["sv_mapcycle"] = {"Prints the current entries in the mapcycle and their Mapcycle Indexes."}
- commands.info["sv_mapcycle_add"] = {"Adds the specified map, gametype, and script to the mapcycle.", commands.info["sv_map"][2]}
- commands.info["sv_mapcycle_del"] = {"Deletes the specified mapcycle entry via its Mapcycle Index (accessible via \"sv_mapcycle\")"}
- commands.info["sv_mapcycle_begin"] = {"Begins the current mapcycle."}
- commands.info["sv_mapcycle_timeout"] = {"The amount of time in seconds the Post Carnage Report shows after players are able to exit the server by hitting Esc.", "If no Value is specified, the current Mapcycle Timeout Value is printed."}
- commands.info["sv_maplist"] = {"Prints list of map names given a search.", "If no search is specified, all map names are printed."}
- commands.info["sv_scripts"] = {"Prints a list of all valid scripts given the input search.", "If no search is specified, all valid scripts are printed."}
- commands.info["sv_reloadscripts"] = {"Reloads the current script(s)."}
- commands.info["sv_mapvote"] = {"Toggles the allowance of Mapvoting.", "If no Boolean is specified, the current Mapvote Boolean is printed."}
- commands.info["sv_mapvote_add"] = {"Adds the specified map, gametype and scripts to the Mapvote List.", commands.info["sv_map"][2]}
- commands.info["sv_mapvote_del"] = {"Deletes the specified gametype from the Mapvote List via its Mapvote Index (accessible via \"sv_mapvote_list\")."}
- commands.info["sv_mapvote_list"] = {"Lists all gametypes in the Mapvote List and their Mapvote Indexes."}
- commands.info["sv_teams_balance"] = {"Balances the teams by choosing a random person on the favored team and changing their team."}
- commands.info["sv_teams_lock"] = {"Does not allow players to change their team via the pause menu."}
- commands.info["sv_teams_unlock"] = {"Allows players to change their team via the pause menu."}
- commands.info["sv_changeteam"] = {"Changes the team of the specified player."}
- commands.info["sv_teleport"] = {"Teleports the specified player to the specified location name or specified coordinates.", "You must specify either only the location name or X, Y, and Z coordinates."}
- commands.info["sv_teleport_to"] = {"Teleports the specified Teleported Player to the specified Destination Player's coordinates."}
- commands.info["sv_teleport_add"] = {"Adds the specified location the Teleport Location List.", "If only the Location Name is specified, your current coordinates are saved with the given name."}
- commands.info["sv_teleport_del"] = {"Deletes the specified Teleport Location via its Teleport Location Index (accessible via \"sv_teleport_list\")."}
- commands.info["sv_teleport_list"] = {"Lists all Teleport Locations for the current map and their coordinates."}
- commands.info["sv_kickafk"] = {"Specifies the amount of time a player should be AFK before they are kicked from the server.", "If no AFK Time is specified, the current Kick AFK Time is printed."}
- commands.info["sv_host"] = {"WHAT THE HELL DOES THIS DO?"}
- commands.info["sv_say"] = {"Prints the specified Message in the chat as **SERVER**."}
- commands.info["sv_gethash"] = {"Prints the hash of the specified player."}
- commands.info["sv_chatids"] = {"Toggles the numbers that appear next to a player's name when they send messages in the chat.", "If no Boolean is specified, the current Chat ID Boolean is printed."}
- commands.info["sv_disablelog"] = {"Disables Phasor logging."}
- commands.info["sv_logname"] = {"Changes the specified Log Type to have the specified Log Name."}
- commands.info["sv_savelog"] = {"Saves all logs."}
- commands.info["sv_loglimit"] = {"Specifies the limit of size in kB a certain Log Type file can get to before a new file is automatically created."}
- commands.info["sv_getobject"] = {"Returns the Halo Object ID of the specified player."}
- commands.info["sv_kill"] = {"Kills the specified player or team, sending them the specified message.", "If no Message is specified, players will be sent default messages."}
- commands.info["sv_invis"] = {"Gives the specified player active camouflage for the specified amount of time.", "If no Player or Duration is specified, all players who currently have camouflage will be printed.", "If no Duration is specified, the player will be given camouflage until death."}
- commands.info["sv_setspeed"] = {"Changes the current player's speed to the specified value.", "If no Duration is specified, this player's speed will remain until the end of the game or until changed."}
- commands.info["sv_unique"] = {"Displays the amount of unique players who have joined the server."}
- commands.info["sv_alias"] = {"Displays a list of names the specified player has joined this server under sorted from the name they use most often to the name they use least often."}
- commands.info["sv_reset_alias"] = {"Clears the alias list for the specified player."}
- commands.info["sv_player_memory"] = {"Amount of games a player's Server Index and name will be accessible via \"sv_players\".", "If no Value is specified, the current amount of games a player's information is saved for is printed."}
- commands.info["sv_player_name"] = {"Prints or allows you to change the specified player's Player Name.", "If no New Player Name is specified, the specified player's current Player Name is printed.", "Entering \"\" as a player's new name will reset a player's Player Name to their most-used alias."}
- commands.info["sv_player_index"] = {"Prints or allows you to change the specified player's Server Index.", "If no New Server Index is specified, the specified player's current Server Index is printed."}
- commands.info["sv_message"] = {"Sends a message to the specified player in their console chat. If they are not currently in the server, they will receive this message upon joining."}
- commands.info["sv_commands"] = {"Prints a list of admin commands.", "If no Search, Player ID, Server Index or Admin Level is specified, prints all commands you are able to execute."}
- commands.info["sv_levels"] = {"Prints a list of Admin Level IDs and their respective names."}
- commands.info["sv_level_add"] = {"Creates a new Admin Level with the specified Level Name.", "If no Level Name is specified, a default Level Name will be given."}
- commands.info["sv_level_del"] = {"Deletes the specified Admin Level."}
- commands.info["sv_level_admins"] = {"Prints a list of all admins in the specified Admin Level."}
- commands.info["sv_level_id"] = {"The unique integer ID of the specified Admin Level.", "If no Level ID is specified, the current Level ID is printed."}
- commands.info["sv_level_name"] = {"The unique nickname for the specified Admin Level.", "If no Level Name is specified, the current Level Name is printed."}
- commands.info["sv_admin_add"] = {"Adds the specified player to the specified Admin Level."}
- commands.info["sv_admin_del"] = {"Removes the specified player from the admin list."}
- commands.info["sv_command_add"] = {"Adds the specified command to the specified Admin Level."}
- commands.info["sv_command_del"] = {"Removes the specified command from the specified Admin Level."}
- commands.info["sv_admins"] = {"Prints a list of all admins in order of Admin Level."}
- commands.info["sv_admin_level"] = {"Admin Level of the specified player.", "If no Admin Level is specified, the player's current Admin Level is printed."}
- commands.info["sv_openaccess"] = {"Allows/unallows the specified Admin Level to execute any admin command.", "If no Boolean is specified, the current Open-Access Boolean is printed."}
- commands.info["sv_mute"] = {"Mutes the specified player for the specified duration and with the specified Mute Message.", "If no Mute Duration is specified, the default duration is -1 (for the rest of the game).", "If no Mute Message is specified, the default Mute Message is \"You have been muted.\""}
- commands.info["sv_unmute"] = {"Unmutes the specified player."}
- commands.info["sv_permamute"] = {"Permanently mutes the specified player with the specified Mute Message.", "If no Mute Message is specified, the default Mute Message is \"You have been permanently muted.\""}
- commands.info["sv_mute_duration"] = {"Prints or allows you to change the specified player's Mute Duration.", "If no New Mute Duration is specified, the specified player's current Mute Duration is printed."}
- commands.info["sv_mute_message"] = {"Prints or allows you to change the specified player's Mute Message.", "If no New Mute Message is specified, the specified player's current Mute Message is printed."}
- commands.info["sv_mute_info"] = {"Prints specified player's mute information."}
- commands.info["sv_swears"] = {"Prints a list of swears the specified player has attempted to send through chat."}
- commands.info["sv_mute_players"] = {"Prints basic mute information about players currently in the server."}
- commands.info["sv_mutelist"] = {"Displays a list of players based on certain mute categories sorted in the direction specified.", "If no Search or Sorted By entry is specified, the list will be sorted by Server Index.", "If no Number of Results is specified, the default value is 15.", "If no Sorting Direction is specified, a default sorting direction is chosen based on the search criteria."}
- commands.info["sv_mutelog"] = {"Displays the Mute Log of the specified player. Includes mutes and unmutes with details of each."}
- commands.info["sv_reset_mute_info"] = {"Resets the specified player's mute information."}
- commands.info["sv_reset_alias"] = {"Clears a player's alias list."}
- commands.info["sv_swear_add"] = {"Adds the specified word to the Swear Table.", "If no Appended Word is specified, the default Swear Append is applied.", "If no Swear Type is specified, the default Swear Type is \"exact\"."}
- commands.info["sv_swear_del"] = {"Deletes the specified word from the Swear Table.", "If no Swear Type is specified, the specified command will be deleted from both the Exact Swear Table and the Anywhere Swear Table."}
- commands.info["sv_swear_type"] = {"Prints the type of swear word (\"Exact\" or \"Anywhere\") the specified word is."}
- commands.info["sv_sweartable"] = {"Prints the current sweartable given a specific Swear Type."}
- commands.info["sv_automute"] = {"Boolean allowing/unallowing the server to automatically mute a player who attempts to breach the swear filter a certain amount of times."}
- commands.info["sv_swears_to_mute"] = {"Amount of times a player must attempt to swear before they are automuted by the server."}
- commands.info["sv_swear_action"] = {"Action taken when a player attempts to swear through the chat; either blocked, appended, or no action."}
- commands.info["sv_swear_append"] = {"Default string a swear word with no specified append string will be appended to."}
- commands.info["sv_swear_message"] = {"Message players receive when they attempt to swear."}
- commands.info["sv_swear_penalty"] = {"Duration of a player's mute when they are automuted for swearing."}
- commands.info["sv_mute_notify"] = {"Amount of times a player must be muted before an admin is notified while executing ' sv_mute ' of how many times this player has been muted before."}
- -- Parameter Information:
- commands.info["<Player ID>"] = {"Player ID: Unique player number between 1 and 16 obtained by \"sv_players\"."}
- commands.info["<Server Index>"] = {"Server Index: Unique 3-digit ID which allows an admin to access a player's information even if they aren't in the server. You may also specify a player's hash instead."}
- commands.info["<Team>"] = {"Team: Either \"all\", \"red\", \"blue\" or \"me\". Executes this command on all of these players."}
- commands.info["<Player ID or Server Index>"] = {commands.info["<Player ID>"][1], commands.info["<Server Index>"][1]}
- commands.info["<Player ID, Server Index or Team>"] = {commands.info["<Player ID>"][1], commands.info["<Server Index>"][1], commands.info["<Team>"][1]}
- commands.info["<Boolean>"] = {"Boolean: True or False."}
- commands.info["<Word>"] = {"Word: String this command should be applied to."}
- commands.info["<Message>"] = {"Message: Message to be sent."}
- commands.info["<Search>"] = {"Search: Returns matches to these keywords."}
- commands.info["<Search or Sorted By>"] = {commands.info["<Search>"][1], "Sorted By: The criteria the table is sorted by (i.e. name, index, etc)."}
- commands.info["<Number of Results>"] = {"Number of Results: Amount of entries printed."}
- commands.info["<Sorting Direction>"] = {"Sorting Direction: Ascending, descending, or default order for this table to be sorted."}
- commands.info["<Command>"] = {"Command: Admin command."}
- commands.info["<Message>"] = {"Message: Message to be sent."}
- commands.info["<Duration>"] = {"Duration: Amount of time in seconds."}
- commands.info["<Value>"] = {"Value: Value this command should take in."}
- commands.info["<Count>"] = {"Count: Iterations of this characteristic."}
- commands.info["<Special Value>"] = {"This command allows the use of \"cur\" and \"inf\" as well as mathematical operators to represent certain values. \"cur\" is the current value and \"inf\" is infinity. You can mix and match these properties with numbers and mathematical operators to achieve the value you want. Example: \"sv_setspeed 1 cur*2\" would double player 1's speed. Make sure there are no spaces in your Special Value entry."}
- commands.info["<Speed>"] = {"Speed: Speed of player.", commands.info["<Special Value>"][1]}
- commands.info["<Ban Name>"] = {"Ban Name: Name saved in the banlist for this player."}
- commands.info["<Bancount>"] = {"Bancount: Amount of times a player has been banned."}
- commands.info["<Ban Penalty>"] = {"Ban Penalty: Amount of time a player is banned for. Use d for days, h for hours, m for minutes, s for seconds, and inf for Infinite (for example: 5d 6h 7m 8s)."}
- commands.info["<Friendly Fire Value>"] = {"Friendly Fire Value: 0 = \"defaults\" | 1 = \"off\" | 2 = \"shields\" | 3 = \"on\""}
- commands.info["<Server Name>"] = {"Server Name: Name of server players see when they attempt to join it via the Gamespy Lobby."}
- commands.info["<Password>"] = {"Password: Password which must be 8 characters or less."}
- commands.info["<Timelimit>"] = {"Timelimit: Amount of time in minutes before the current game ends."}
- commands.info["<Map>"] = {"Map: Name of map accessible via \"sv_maplist\"."}
- commands.info["<Gametype>"] = {"Gametype: Name of gametype accessible via \"sv_gamelist\"."}
- commands.info["<Scripts>"] = {"Scripts: Names of scripts to be loaded (names available via \"sv_scripts\")."}
- commands.info["<Mapcycle Index>"] = {"Mapcycle Index: Index by which a mapcycle entry is deleted."}
- commands.info["<Mapvote Index>"] = {"Mapvote Index: Index by which a Mapvote entry is deleted."}
- commands.info["<Location Name>"] = {"Location Name: Name of teleportation location to be saved in the Teleport Location List."}
- commands.info["<X>"] = {"X: X-coordinate (east-west)."}
- commands.info["<Y>"] = {"Y: Y-coordinate (north-south)."}
- commands.info["<Z>"] = {"Z: Z-coordinate (up-down)."}
- commands.info["<Location Name or X>"] = {commands.info["<Location Name>"][1], commands.info["<X>"][1]}
- commands.info["<Teleported Player ID or Server Index>"] = {"Teleported Player: Player ID or Server Index of the player who will be teleported.", unpack(commands.info["<Player ID or Server Index>"])}
- commands.info["<Teleport Index>"] = {"Teleport Index: Index by which a Teleport Location is deleted."}
- commands.info["<AFK Time>"] = {"AFK Time: Amount of time in minutes a player is AFK."}
- commands.info["<Log Type>"] = {"Log Type: Type of log such as \"game\", \"rcon\", etc."}
- commands.info["<Log Name>"] = {"Log Name: Name of the file of the specified Log Type."}
- commands.info["<Log Size>"] = {"Log Size: Maximum size in kB of a log of the specified Log Type before a new file is created."}
- commands.info["<Admin Level>"] = {"Admin Level: Specified by either the level's ID or Name."}
- commands.info["<Search, Player ID, Server Index or Admin Level>"] = {commands.info["<Search>"][1], commands.info["<Player ID or Server Index>"][1], commands.info["<Admin Level>"][1]}
- commands.info["<Search, Player ID, Server Index, Command, or Admin Level>"] = {commands.info["<Search>"][1], commands.info["<Player ID or Server Index>"][1], commands.info["<Command>"][1], commands.info["<Admin Level>"][1]}
- commands.info["<Level ID>"] = {"Level ID: Unique value for an Admin Level. All Admin Level ID's begin with L (i.e. L0).w"}
- commands.info["<Level Name>"] = {"Level Name: Nickname given to an Admin Level."}
- commands.info["<Mute Duration>"] = {"Mute Duration: Amount of time the specified player is muted for."}
- commands.info["<Mute Message>"] = {"Mute Message: Message a muted player receives when they attempt to send a message in chat."}
- commands.info["<New Player Name>"] = {"New Player Name: New Player Name you would like for this player to have."}
- commands.info["<New Server Index>"] = {"New Server Index: New unique Server Index to specify this player."}
- commands.info["<New Mute Duration>"] = {"New Mute Duration: New amount of time this player should be muted for (use \"permanent\" for permanent mutes and \"temporary\" for mutes that last the rest of the game)"}
- commands.info["<New Mute Message>"] = {"New Mute Message: New message this player will receive when he/she attempts to send chat."}
- commands.info["<Appended Word>"] = {"Appended Word: Word you would like for the swear word to be changed to when it is attempted to be sent in chat."}
- commands.info["<Swear Type>"] = {"Swear Type: Either \"exact\" or \"anywhere\". Exact Swears are only blocked if the entire word matches, while Anywhere Swears are blocked if the specified string is found anywhere in the message."}
- commands.info["<Swears to Mute>"] = {"Swears to Mute: Amount of swears a player must attempt to send through chat before being automuted."}
- commands.info["<Swear Action>"] = {"Swear Action: Action that should be taken when a player swears. (0 = None) (1 = Block) (2 = Append)"}
- commands.info["<Default Swear Append>"] = {"Default Swear Append: Default string which swear words will be replaced by if they have no specified append string."}
- commands.info["<Swear Message>"] = {"Swear Message: Message players receive when they attempt to send a swear word through the chat. Use \"\" to disable."}
- commands.info["<Automute Swear Penalty>"] = {"Automute Swear Penalty: Duration of a player's mute when they are automuted for swearing."}
- commands.info["<Mutes Until Notified>"] = {"Mutes Until Notified: Amount of times a player must be muted before an administrator is notified when using ' sv_mute ' of how many times this player has been muted in the past."}
- chat = {}
- sprint = {}
- pprint = {}
- cprint = {}
- for i = 0, 15 do
- pprint[i] = {}
- end
- -- Objects --
- objects = {}
- tags = {}
- -- Tag List --
- tags.bipd = {
- ["characters\\cyborg\\cyborg"] = "Cyborg",
- ["characters\\cyborg_mp\\cyborg_mp"] = "Multiplayer Cyborg"
- }
- tags["jpt!"] = {
- ["characters\\cyborg\\melee"] = "Generic Melee Damage",
- ["globals\\distance"] = "Distance Damage",
- ["globals\\falling"] = "Fall Damage",
- ["globals\\flaming_death"] = "Flaming Death Damage",
- ["globals\\vehicle_collision"] = "Vehicle Collision Damage",
- ["globals\\vehicle_hit_environment"] = "Vehicle Hit Damage",
- ["globals\\vehicle_killed_unit"] = "Vehicle Kill Unit Damage",
- ["vehicles\\banshee\\banshee bolt"] = "Banshee Bolt Damage",
- ["vehicles\\banshee\\fuel rod trigger"] = "Banshee Fuel Rod Trigger Damage",
- ["vehicles\\banshee\\mp_fuel rod explosion"] = "Banshee Fuel Rod Explosion Damage",
- ["vehicles\\banshee\\trigger"] = "Banshee Trigger Damage",
- ["vehicles\\c gun turret\\mp bolt"] = "Covenant Turret Bolt Damage",
- ["vehicles\\ghost\\ghost bolt"] = "Ghost Bolt Damage",
- ["vehicles\\ghost\\trigger"] = "Ghost Trigger Damage",
- ["vehicles\\rwarthog\\effects\\trigger"] = "Rocket Warthog Trigger Damage",
- ["vehicles\\scorpion\\bullet"] = "Scorpion Bullet Damage",
- ["vehicles\\scorpion\\secondary trigger"] = "Scorpion Secondary Trigger Damage",
- ["vehicles\\scorpion\\shell explosion"] = "Scorpion Shell Explosion Damage",
- ["vehicles\\scorpion\\shell shock wave"] = "Scorpion Shell Shockwave Damage",
- ["vehicles\\warthog\\bullet"] = "Warthog Bullet Damage",
- ["vehicles\\warthog\\trigger"] = "Warthog Trigger Damage",
- ["weapons\\assault rifle\\bullet"] = "Assault Rifle Bullet Damage",
- ["weapons\\assault rifle\\melee"] = "Assault Rifle Melee Damage",
- ["weapons\\assault rifle\\melee_response"] = "Assault Rifle Melee Response Damage",
- ["weapons\\assault rifle\\trigger"] = "Assault Rifle Trigger Damage",
- ["weapons\\ball\\melee"] = "Oddball Melee Damage",
- ["weapons\\ball\\melee_response"] = "Oddball Melee Response Damage",
- ["weapons\\flag\\melee"] = "Flag Melee Damage",
- ["weapons\\flag\\melee_response"] = "Flag Melee Response Damage",
- ["weapons\\flamethrower\\burning"] = "Flamethrower Burning Damage",
- ["weapons\\flamethrower\\explosion"] = "Flamethrower Explosion Damage",
- ["weapons\\flamethrower\\impact damage"] = "Flamethrower Impact Damage",
- ["weapons\\flamethrower\\melee"] = "Flamethrower Melee Damage",
- ["weapons\\flamethrower\\melee_response"] = "Flamethrower Melee Response Damage",
- ["weapons\\flamethrower\\trigger"] = "Flamethrower Trigger Damage",
- ["weapons\\frag grenade\\explosion"] = "Frag Grenade Explosion Damage",
- ["weapons\\frag grenade\\shock wave"] = "Frag Grenade Shockwave Damage",
- ["weapons\\needler\\detonation damage"] = "Needler Detonation Damage",
- ["weapons\\needler\\explosion"] = "Needler Explosion Damage",
- ["weapons\\needler\\impact damage"] = "Needler Impact Damage",
- ["weapons\\needler\\melee"] = "Needler Melee Damage",
- ["weapons\\needler\\melee_response"] = "Needler Melee Response Damage",
- ["weapons\\needler\\shock wave"] = "Needler Shockwave Damage",
- ["weapons\\needler\\trigger"] = "Needler Trigger Damage",
- ["weapons\\pistol\\bullet"] = "Pistol Bullet Damage",
- ["weapons\\pistol\\melee"] = "Pistol Melee Damage",
- ["weapons\\pistol\\melee_response"] = "Pistol Melee Response Damage",
- ["weapons\\pistol\\trigger"] = "Pistol Trigger Damage",
- ["weapons\\plasma grenade\\attached"] = "Plasma Grenade Attached Damage",
- ["weapons\\plasma grenade\\explosion"] = "Plasma Grenade Explosion Damage",
- ["weapons\\plasma grenade\\shock wave"] = "Plasma Grenade Shockwave Damage",
- ["weapons\\plasma pistol\\bolt"] = "Plasma Pistol Bolt Damage",
- ["weapons\\plasma pistol\\melee"] = "Plasma Pistol Melee Damage",
- ["weapons\\plasma pistol\\melee_response"] = "Plasma Pistol Melee Response Damage",
- ["weapons\\plasma pistol\\misfire"] = "Plasma Pistol Misfire Damage",
- ["weapons\\plasma pistol\\trigger"] = "Plasma Pistol Trigger Damage",
- ["weapons\\plasma pistol\\trigger overcharge"] = "Plasma Pistol Trigger Overcharge Damage",
- ["weapons\\plasma rifle\\bolt"] = "Plasma Rifle Bolt Damage",
- ["weapons\\plasma rifle\\charged bolt"] = "Plasma Pistol Charged Bolt",
- ["weapons\\plasma rifle\\melee"] = "Plasma Rifle Melee Damage",
- ["weapons\\plasma rifle\\melee_response"] = "Plasma Rifle Melee Response Damage",
- ["weapons\\plasma rifle\\misfire"] = "Plasma Rifle Misfire Damage",
- ["weapons\\plasma rifle\\trigger"] = "Plasma Rifle Trigger Damage",
- ["weapons\\plasma_cannon\\effects\\plasma_cannon_explosion"] = "Fuel Rod Explosion Damage",
- ["weapons\\plasma_cannon\\effects\\plasma_cannon_melee"] = "Fuel Rod Melee Damage",
- ["weapons\\plasma_cannon\\effects\\plasma_cannon_melee_response"] = "Fuel Rod Melee Response Damage",
- ["weapons\\plasma_cannon\\effects\\plasma_cannon_misfire"] = "Fuel Rod Misfire Damage",
- ["weapons\\plasma_cannon\\effects\\plasma_cannon_trigger"] = "Fuel Rod Trigger Damage",
- ["weapons\\plasma_cannon\\impact damage"] = "Fuel Rod Impact Damage",
- ["weapons\\rocket launcher\\explosion"] = "Rocket Launcher Explosion Damage",
- ["weapons\\rocket launcher\\melee"] = "Rocket Launcher Melee Damage",
- ["weapons\\rocket launcher\\melee_response"] = "Rocket Launcher Melee Response Damage",
- ["weapons\\rocket launcher\\trigger"] = "Rocket Launcher Trigger Damage",
- ["weapons\\shotgun\\melee"] = "Shotgun Melee Damage",
- ["weapons\\shotgun\\melee_response"] = "Shotgun Melee Response Damage",
- ["weapons\\shotgun\\pellet"] = "Shotgun Pellet Damage",
- ["weapons\\shotgun\\trigger"] = "Shotgun Trigger Damage",
- ["weapons\\sniper rifle\\melee"] = "Sniper Rifle Melee Damage",
- ["weapons\\sniper rifle\\melee_response"] = "Sniper Rifle Melee Response Damage",
- ["weapons\\sniper rifle\\sniper bullet"] = "Sniper Rifle Bullet Damage",
- ["weapons\\sniper rifle\\trigger"] = "Sniper Rifle Trigger Damage"
- }
- tags.eqip = {
- ["powerups\\active camouflage"] = "Active Camouflage",
- ["powerups\\assault rifle ammo\\assault rifle ammo"] = "Assault Rifle Ammo",
- ["powerups\\double speed"] = "Double Speed",
- ["powerups\\flamethrower ammo\\flamethrower ammo"] = "Flamethrower Ammo",
- ["powerups\\full-spectrum vision"] = "Full-Spectrum Vision",
- ["powerups\\health pack"] = "Health Pack",
- ["powerups\\needler ammo\\needler ammo"] = "Needler Ammo",
- ["powerups\\over shield"] = "Overshield",
- ["powerups\\pistol ammo\\pistol ammo"] = "Pistol Ammo",
- ["powerups\\rocket launcher ammo\\rocket launcher ammo"] = "Rocket Launcher Ammo",
- ["powerups\\shotgun ammo\\shotgun ammo"] = "Shotgun Ammo",
- ["powerups\\sniper rifle ammo\\sniper rifle ammo"] = "Sniper Rifle Ammo",
- ["weapons\\frag grenade\\frag grenade"] = "Frag Grenade",
- ["weapons\\plasma grenade\\plasma grenade"] = "Plasma Grenade"
- }
- tags.proj = {
- ["vehicles\\banshee\\banshee bolt"] = "Banshee Bolt",
- ["vehicles\\banshee\\mp_banshee fuel rod"] = "Banshee Fuel Rod",
- ["vehicles\\c gun turret\\mp gun turret"] = "Covenant Turret Bolt",
- ["vehicles\\ghost\\ghost bolt"] = "Ghost Bolt",
- ["vehicles\\scorpion\\bullet"] = "Scorpion Bullet",
- ["vehicles\\scorpion\\tank shell"] = "Scorpion Shell",
- ["vehicles\\warthog\\bullet"] = "Warthog Bullet",
- ["weapons\\assault rifle\\bullet"] = "Assault Rifle Bullet",
- ["weapons\\flamethrower\\flame"] = "Flamethrower Flame",
- ["weapons\\frag grenade\\frag grenade"] = "Frag Grenade Projectile",
- ["weapons\\needler\\mp_needle"] = "Needler Needle",
- ["weapons\\needler\\needle"] = "Campaign Needler Needle",
- ["weapons\\pistol\\bullet"] = "Pistol Bullet",
- ["weapons\\plasma grenade\\plasma grenade"] = "Plasma Grenade Projectile",
- ["weapons\\plasma pistol\\bolt"] = "Plasma Pistol Bolt",
- ["weapons\\plasma rifle\\bolt"] = "Plasma Rifle Bolt",
- ["weapons\\plasma rifle\\charged bolt"] = "Plasma Pistol Charged Bolt",
- ["weapons\\plasma_cannon\\plasma_cannon"] = "Fuel Rod Projectile",
- ["weapons\\rocket launcher\\rocket"] = "Rocket Launcher Rocket",
- ["weapons\\shotgun\\pellet"] = "Shotgun Pellet",
- ["weapons\\sniper rifle\\sniper bullet"] = "Sniper Rifle Bullet"
- }
- tags.weap = {
- ["vehicles\\banshee\\mp_banshee gun"] = "Banshee Gun",
- ["vehicles\\c gun turret\\mp gun turret gun"] = "Covenant Turret Gun",
- ["vehicles\\ghost\\mp_ghost gun"] = "Ghost Gun",
- ["vehicles\\rwarthog\\rwarthog_gun"] = "Rocket Warthog Gun",
- ["vehicles\\scorpion\\scorpion cannon"] = "Scorpion Cannon",
- ["vehicles\\warthog\\warthog gun"] = "Warthog Gun",
- ["weapons\\assault rifle\\assault rifle"] = "Assault Rifle",
- ["weapons\\ball\\ball"] = "Oddball",
- ["weapons\\flag\\flag"] = "Flag",
- ["weapons\\flamethrower\\flamethrower"] = "Flamethrower",
- ["weapons\\gravity rifle\\gravity rifle"] = "Gravity Rifle",
- ["weapons\\needler\\mp_needler"] = "Needler",
- ["weapons\\needler\\needler"] = "Campaign Needler",
- ["weapons\\pistol\\pistol"] = "Pistol",
- ["weapons\\plasma pistol\\plasma pistol"] = "Plasma Pistol",
- ["weapons\\plasma rifle\\plasma rifle"] = "Plasma Rifle",
- ["weapons\\plasma_cannon\\plasma_cannon"] = "Fuel Rod",
- ["weapons\\rocket launcher\\rocket launcher"] = "Rocket Launcher",
- ["weapons\\shotgun\\shotgun"] = "Shotgun",
- ["weapons\\sniper rifle\\sniper rifle"] = "Sniper Rifle"
- }
- tags.vehi = {
- ["vehicles\\banshee\\banshee_mp"] = "Banshee",
- ["vehicles\\c gun turret\\c gun turret_mp"] = "Covenant Turret",
- ["vehicles\\ghost\\ghost_mp"] = "Ghost",
- ["vehicles\\rwarthog\\rwarthog"] = "Rocket Warthog",
- ["vehicles\\scorpion\\scorpion_mp"] = "Scorpion",
- ["vehicles\\warthog\\mp_warthog"] = "Warthog"
- }
- tags.scen = {
- ["levels\\a10\\devices\\h oxy tank\\h oxy tank"] = "Oxygen Tank",
- ["levels\\a10\\devices\\doors\\door_blast_collision\\door_blast_collision"] = "Door Blast Collision",
- ["levels\\b40\\scenery\\b40_doorblinker\\doorblinker"] = "Door Blinker",
- ["levels\\b40\\scenery\\b40_metal_small\\metal_small"] = "Small Metal Scenery",
- ["levels\\b40\\scenery\\b40_metal_tall\\metal_tall"] = "Tall Metal Scenery",
- ["levels\\b40\\scenery\\b40_metal_wide\\metal_wide"] = "Wide Metal Scenery",
- ["levels\\test\\dangercanyon\\scenery\\mp_tree_pine_small\\mp_tree_pine_small"] = "Small Pine Tree",
- ["levels\\test\\timberland\\scenery\\mp_beacon_blue\\mp_beacon_blue"] = "Blue Beacon",
- ["levels\\test\\timberland\\scenery\\mp_beacon_red\\mp_beacon_red"] = "Red Beacon",
- ["levels\\test\\timberland\\scenery\\simple_beacon_blue\\simple_beacon_blue"] = "Simple Blue Beacon",
- ["levels\\test\\timberland\\scenery\\simple_beacon_red\\simple_beacon_red"] = "Simple Red Beacon",
- ["levels\\test\\timberland\\scenery\\mp_boulder_granite_gigantic\\mp_boulder_granite_gigantic"] = "Gigantic Granite Boulder",
- ["levels\\test\\timberland\\scenery\\mp_boulder_granite_large\\mp_boulder_granite_large_00\\mp_boulder_granite_large_00"] = "Large Granite Boulder 00",
- ["levels\\test\\timberland\\scenery\\mp_boulder_granite_large\\mp_boulder_granite_large_01\\mp_boulder_granite_large_01"] = "Large Granite Boulder 01",
- ["levels\\test\\timberland\\scenery\\mp_boulder_granite_large\\mp_boulder_granite_large_02\\mp_boulder_granite_large_02"] = "Large Granite Boulder 02",
- ["levels\\test\\timberland\\scenery\\mp_boulder_granite_large\\mp_boulder_granite_large_03\\mp_boulder_granite_large_03"] = "Large Granite Boulder 03",
- ["levels\\test\\timberland\\scenery\\mp_boulder_granite_large\\mp_boulder_granite_large_04\\mp_boulder_granite_large_04"] = "Large Granite Boulder 04",
- ["levels\\test\\timberland\\scenery\\mp_boulder_granite_medium\\mp_boulder_granite_medium"] = "Medium Granite Boulder",
- ["levels\\test\\timberland\\scenery\\mp_boulder_moss_large\\mp_boulder_moss_large"] = "Large Mossy Boulder",
- ["levels\\test\\timberland\\scenery\\mp_boulder_moss_small\\mp_boulder_moss_small"] = "Small Mossy Boulder",
- ["levels\\test\\timberland\\scenery\\mp_tree_pine_tall\\mp_tree_pine_tall"] = "Tall Pine Tree",
- ["levels\\test\\timberland\\scenery\\waterfall_spray_emitter_small\\waterfall_spray_emitter_small"] = "Small Waterfall",
- ["levels\\test\\icefields\\scenery\\mp_boulder_snow_large_00\\mp_boulder_snow_large_00"] = "Large Snowy Boulder 00",
- ["levels\\test\\icefields\\scenery\\mp_boulder_snow_large_01\\mp_boulder_snow_large_01"] = "Large Snowy Boulder 01",
- ["levels\\test\\icefields\\scenery\\mp_boulder_snow_large_02\\mp_boulder_snow_large_02"] = "Large Snowy Boulder 02",
- ["levels\\test\\icefields\\scenery\\mp_boulder_snow_large_03\\mp_boulder_snow_large_03"] = "Large Snowy Boulder 03",
- ["levels\\test\\icefields\\scenery\\mp_boulder_snow_large_04\\mp_boulder_snow_large_04"] = "Large Snowy Boulder 04",
- ["levels\\test\\icefields\\scenery\\mp_tree_pine_snow_small\\mp_tree_pine_snow_small"] = "Small Snowy Pine Tree",
- ["levels\\test\\icefields\\scenery\\mp_tree_pine_snow_tall\\mp_tree_pine_snow_tall"] = "Tall Snowy Pine Tree",
- ["scenery\\flag_base\\flag_base"] = "Flag Base",
- ["scenery\\floor_arrow\\floor_arrow"] = "Floor Arrow",
- ["scenery\\small beacon\\small blue beacon"] = "Small Blue Beacon",
- ["scenery\\small beacon\\small red beacon"] = "Small Red Beacon",
- ["scenery\\blue landing beacon\\blue landing beacon"] = "Blue Landing Beacon",
- ["scenery\\teleporter_base\\teleporter_base"] = "Teleporter Base",
- ["scenery\\teleporter_shield\\teleporter"] = "Teleporter Shield",
- ["scenery\\h_barricade_large\\h_barricade_large"] = "Large Barricade",
- ["scenery\\h_barricade_large_gap\\h_barricade_large_gap"] = "Large Buffered Barricade",
- ["scenery\\h_barricade_small\\h_barricade_small"] = "Small Barricade",
- ["scenery\\h_barricade_small_visor\\h_barricade_small_visor"] = "Small Visored Barricade",
- ["scenery\\hilltop\\hilltop"] = "Hilltop",
- ["scenery\\c_storage\\c_storage"] = "Covenant Storage",
- ["scenery\\c_storage_large\\c_storage_large"] = "Large Covenant Storage",
- ["scenery\\c_uplink\\c_uplink"] = "Covenant Uplink",
- ["scenery\\c_field_generator\\c_field_generator"] = "Covenant Field Generator",
- ["scenery\\emitters\\glowingdrip\\glowingdrip"] = "Glowing Drip",
- ["scenery\\rocks\\a50_rock_large\\a50_rock_large"] = "Large Rock",
- ["scenery\\rocks\\boulder\\boulder"] = "Boulder",
- ["scenery\\rocks\\boulder_crouch\\boulder_crouch"] = "Crouch Boulder",
- ["scenery\\rocks\\boulder_doublewide\\boulder_doublewide"] = "Doublewide Boulder",
- ["scenery\\rocks\\boulder_large_grey\\boulder_large_grey"] = "Large Grey Boulder",
- ["scenery\\rocks\\boulder_granite_gigantic\\boulder_granite_gigantic"] = "Gigantic Boulder",
- ["scenery\\rocks\\boulder_granite_large\\boulder_granite_large"] = "Large Boulder",
- ["scenery\\rocks\\boulder_granite_medium\\boulder_granite_medium"] = "Medium Boulder",
- ["scenery\\rocks\\boulder_granite_small\\boulder_granite_small"] = "Small Boulder",
- ["scenery\\rocks\\boulder_snow_small\\boulder_snow_small"] = "Small Snowy Boulder",
- ["scenery\\rocks\\b40_snowrocks\\snowrock"] = "Snowy Rock",
- ["scenery\\rocks\\b40_snowrocksmall\\snowrocksmall"] = "Small Snowy Rock",
- ["scenery\\shrubs\\shrub_large\\shrub_large"] = "Large Shrub",
- ["scenery\\plants\\plant fern\\plant fern"] = "Fern",
- ["scenery\\plants\\plant_broadleaf_tall\\plant_broadleaf_tall"] = "Tall Broadleaf",
- ["scenery\\plants\\plant_broadleaf_short\\plant_broadleaf_short"] = "Short Broadleaf",
- ["scenery\\trees\\tree_desert_dead\\tree_desert_dead"] = "Dead Tree",
- ["scenery\\trees\\tree_desert_whitebark\\tree_desert_whitebark"] = "Whitebark Tree",
- ["scenery\\trees\\tree_leafy\\tree_leafy"] = "Leafy Tree",
- ["scenery\\trees\\tree_leafy_medium\\tree_leafy_medium"] = "Medium Leafy Tree",
- ["scenery\\trees\\tree_leafy_sapling\\tree_leafy_sapling"] = "Leafy Sapling Tree",
- ["scenery\\trees\\tree_leafy_doublewide\\tree_leafy_doublewide"] = "Doublewide Leafy Tree",
- ["scenery\\trees\\tree_leafydense_doublewide\\tree_leafydense_doublewide"] = "Doublewide Dense Leafy Tree",
- ["scenery\\trees\\tree_leafy_fallentrunk\\tree_leafy_fallentrunk"] = "Fallen Trunk",
- ["scenery\\trees\\tree_leafy_fallentrunk_short\\tree_leafy_fallentrunk_short"] = "Short Fallen Trunk",
- ["scenery\\trees\\tree_leafy_stump\\tree_leafy_stump"] = "Stump",
- ["scenery\\trees\\tree_leafy_stump_crouch\\tree_leafy_stump_crouch"] = "Crouch Stump"
- }
- -- Gametype Information --
- require "lfs"
- --[[ Gametypes Table ]]--
- gametypes = table.load("gametypes")
- --[[ Script Tables ]]--
- scripts = table.load("scripts")
- function formatbinary(num, digits)
- local binary = convertbase(num, 2)
- while string.len(binary) < digits do
- binary = "0" .. binary
- end
- return binary
- end
- function convertbase(input, base)
- if not base or base == 10 then return tostring(input) end
- local digits = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
- local answer = {}
- repeat
- local digit = (input % base) + 1
- input = math.floor(input / base)
- table.insert(answer, 1, string.sub(digits, digit, digit))
- until input == 0
- return table.concat(answer, "")
- end
- -- Searches the specified table for the specified value. Returns true or false.
- function table.find(t, value, anywhere)
- for k,v in pairs(t) do
- if v == value then
- return true
- end
- if anywhere then
- if k == value then
- return true
- end
- end
- end
- return false
- end
- function string.split(str, ...)
- local subs = {}
- local sub = ""
- local i = 1
- for _,v in ipairs(arg) do
- if v == "" then
- for x = 1, string.len(str) do
- table.insert(subs, string.sub(str, x, x))
- end
- return subs
- end
- end
- for _,v in ipairs(arg) do
- if string.sub(str, 1, 1) == v then
- table.insert(subs, "")
- break
- end
- end
- while i <= string.len(str) do
- local bool, bool2
- for x = 1, #arg do
- if arg[x] ~= "" then
- local length = string.len(arg[x])
- if string.sub(str, i, i + (length - 1)) == arg[x] then
- if i == string.len(str) then
- bool2 = true
- else
- bool = true
- end
- i = i + (length - 1)
- break
- end
- else
- for q = 1, string.len(str) do
- subs = {}
- table.insert(subs, string.sub(str, q, q))
- i = string.len(str)
- break
- end
- end
- end
- if not bool then
- sub = sub .. string.sub(str, i, i)
- end
- if bool or i == string.len(str) then
- if sub ~= "" then
- table.insert(subs, sub)
- sub = ""
- end
- end
- if bool2 then
- table.insert(subs, "")
- end
- i = i + 1
- end
- for k,v in ipairs(subs) do
- for _,d in ipairs(arg) do
- subs[k] = string.gsub(v, d, "")
- end
- end
- return subs
- end
- function LoadScripts()
- local dir = getprofilepath() .. "\\scripts\\"
- for f in lfs.dir(dir) do
- if string.find(f, ".lua") then
- local file = io.open(dir .. f, "r")
- local str = file:read("*all")
- if string.find(str, "function GetRequiredVersion()") then
- if f ~= "gametypes.lua" then
- local script = string.gsub(f, ".lua", "")
- if not table.find(scripts, script) then
- table.insert(scripts, script)
- end
- end
- end
- end
- end
- end
- function LoadGametypes()
- local dir = getprofilepath() .. "\\savegames\\"
- local directories = {}
- local files = {}
- for f in lfs.dir(dir) do
- if f ~= "." and f ~= ".." then
- if lfs.attributes(dir .. f, "mode") == "file" then
- table.insert(files, dir .. f)
- elseif lfs.attributes(dir .. f, "mode") == "directory" then
- table.insert(directories, dir .. f)
- end
- end
- end
- local defdir = getprofilepath() .. "\\saved\\playlists\\default_playlist\\"
- for f in lfs.dir(defdir) do
- if f ~= "." and f ~= ".." then
- if lfs.attributes(defdir .. f, "mode") == "file" then
- table.insert(files, defdir .. f)
- elseif lfs.attributes(defdir .. f, "mode") == "directory" then
- table.insert(directories, defdir .. f)
- end
- end
- end
- for k,v in ipairs(directories) do
- local dirs = string.split(v, "\\")
- local gtname = dirs[#dirs]
- if not gametypes[gtname] then
- for f in lfs.dir(v) do
- if f == "blam.lst" then
- local blam = io.open(v .. "\\blam.lst", "r")
- local str = blam:read("*all")
- local chars = string.split(str, "")
- local name = readgame(chars, 0x0, 0x2F)
- local gametype = tonumber(readgame(chars, 0x30, 0x33, true)) -- 1 = CTF | 2 = Slayer | 3 = Oddball | 4 = KOTH | 5 = Race
- local teamplay = tonumber(readgame(chars, 0x34, 0x37, true)) -- 0 = off | 1 = on
- local parameters = formatbinary(readgame(chars, 0x38, 0x3B, true), 8)
- -- 0 = off | 1 = on
- local players_on_radar = tonumber(string.sub(parameters, 8, 8))
- local friend_indicators = tonumber(string.sub(parameters, 7, 7))
- local infinite_grenades = tonumber(string.sub(parameters, 6, 6))
- local shields = 1 - tonumber(string.sub(parameters, 5, 5))
- local invisible_players = tonumber(string.sub(parameters, 4, 4))
- local starting_equipment = tonumber(string.sub(parameters, 3, 3)) -- 0 = Generic | 1 = Custom
- local only_friends_on_radar = tonumber(string.sub(parameters, 2, 2))
- local objectives_indicator = tonumber(readgame(chars, 0x3C, 0x3F, true)) -- 0 = Motion Tracker | 1 = Navpoints | 2 = None
- local odd_man_out = tonumber(readgame(chars, 0x40, 0x43, true)) -- 0 = off | 1 = on
- local respawn_time_growth = tonumber(readgame(chars, 0x44, 0x47, true)) -- 0 = off | 150 = 5 secs | 300 = 10 secs | 450 = 15 secs
- local respawn_time = tonumber(readgame(chars, 0x48, 0x4B, true)) -- 0 = Instant | 150 = 5 secs | 300 = 10 secs | 450 = 15 secs
- local suicide_penalty = tonumber(readgame(chars, 0x4C, 0x4F, true)) -- 0 = None | 150 = 5 secs | 300 = 10 secs | 450 = 15 secs
- local lives = tonumber(readgame(chars, 0x50, 0x53, true)) -- 0 = Unlimited lives | 1, 3, 5 = 1, 3, 5 lives
- local max_health = tonumber(readgame(chars, 0x57, 0x57, true)) -- 64 = 400% | 63 = 100% (Find others)
- local scorelimit = tonumber(readgame(chars, 0x58, 0x5B, true)) -- check how this is stored for timed gametypes
- local weapon_set = tonumber(readgame(chars, 0x5C, 0x5F, true)) -- 0 = Normal | 1 = Pistols | 2 = Rifles | 3 = Plasma | 4 = Sniper | 5 = No Sniping | 6 = Rockets | 7 = Shotguns | 8 = Shortrange | 9 = Human | 10 = Covenant | 11 = Classic | 12 = Heavy
- -- Insert Vehicle Stuff Here --
- local friendly_fire = tonumber(readgame(chars, 0x6C, 0x6F, true)) -- 0 = off | 1 = on
- local tk_penalty = tonumber(readgame(chars, 0x70, 0x73, true)) -- 0 = off | 150 = 5 secs | 300 = 10 secs | 450 = 15 secs
- local team_balance = tonumber(readgame(chars, 0x74, 0x77, true)) -- 0 = off | 1 = on
- local timelimit = tonumber(readgame(chars, 0x78, 0x7B, true)) -- 0 = No Timelimit | 18000 = 10 min | 27000 = 15 min | 36000 = 20 min | 45000 = 25 min | 54000 = 30 min | 81000 = 45 min
- local assault = tonumber(readgame(chars, 0x7C, 0x7C, true)) -- 0 = CTF | 1 = Assault
- local alternating = tonumber(readgame(chars, 0x81, 0x81, true)) -- 0 = Not Alternating | 14 = Alternating Assault | 35 = Alternating CTF (could have to do with single flag time)
- local moving_hill = tonumber(readgame(chars, 0x7C, 0x7F, true)) -- 0 = off | 1 = on
- local race_type = tonumber(readgame(chars, 0x7C, 0x7F, true)) -- 0 = Normal | 1 = Any Order | 2 = Rally
- local oddball_random_start = tonumber(readgame(chars, 0x7C, 0x7F, true)) -- 0 = off | 1 = on
- local oddball_speed = tonumber(readgame(chars, 0x80, 0x82, true)) -- 0 = Slow | 1 = Normal | 2 = Fast
- local oddball_trait = tonumber(readgame(chars, 0x83, 0x83, true)) -- 0 = None | 1 = Invisible | 2 = Extra Damage | 3 = Damage Resistant
- local no_oddball_trait = tonumber(readgame(chars, 0x88, 0x8B, true)) -- 0 = None | 1 = Invisible | 2 = Extra Damage | 3 = Damage Resistant
- local oddball_type = tonumber(readgame(chars, 0x8C, 0x8C, true)) -- 0 = Normal | 1 = Reverse Tag | 2 = Juggernaut
- local oddball_count = tonumber(readgame(chars, 0x90, 0x90, true)) -- From 0 - 16
- blam:close()
- local function getgame()
- if gametype == 1 then
- return "CTF"
- elseif gametype == 2 then
- return "Slayer"
- elseif gametype == 3 then
- return "Oddball"
- elseif gametype == 4 then
- return "KotH"
- elseif gametype == 5 then
- return "Race"
- end
- end
- local function getteamplay()
- if teamplay == 1 then
- return true
- end
- end
- local function getallonradar()
- if players_on_radar == 1 then
- return true
- end
- end
- local function getfriendindicators()
- if friend_indicators == 1 then
- return true
- end
- end
- local function getinfgrenades()
- if infinite_grenades == 1 then
- return true
- end
- end
- local function getshields()
- if shields == 1 then
- return true
- end
- end
- local function getinvisibleplayers()
- if invisible_players == 1 then
- return true
- end
- end
- local function getstarteqip()
- if starting_equipment == 1 then
- return "Generic"
- else
- return "Custom"
- end
- end
- local function getfriendsonradar()
- if only_friends_on_radar == 1 then
- return true
- end
- end
- local function getobjectivesindicator()
- if objectives_indicator == 0 then
- return "Motion Tracker"
- elseif objectives_indicator == 1 then
- return "Navpoints"
- elseif objectives_indicator == 2 then
- return "None"
- end
- end
- local function getoddmanout()
- if odd_man_out == 1 then
- return true
- end
- end
- local function getlives()
- if lives == 0 then
- return "Unlimited"
- else
- return lives
- end
- end
- local function getmaxhealth()
- if max_health == 63 then
- return 100
- elseif max_health == 64 then
- return 400
- end
- end
- local function getweaponset()
- if weapon_set == 0 then
- return "Normal"
- elseif weapon_set == 1 then
- return "Pistols"
- elseif weapon_set == 2 then
- return "Rifles"
- elseif weapon_set == 3 then
- return "Plasmas"
- elseif weapon_set == 4 then
- return "Snipers"
- elseif weapon_set == 5 then
- return "No Sniping"
- elseif weapon_set == 6 then
- return "Rockets"
- elseif weapon_set == 7 then
- return "Shotguns"
- elseif weapon_set == 8 then
- return "Short-Range"
- elseif weapon_set == 9 then
- return "Human"
- elseif weapon_set == 10 then
- return "Covenant"
- elseif weapon_set == 11 then
- return "Classic"
- elseif weapon_set == 12 then
- return "Heavy"
- end
- end
- local function getfriendlyfire()
- if friendly_fire == 1 then
- return true
- end
- end
- local function getteambalance()
- if team_balance == 1 then
- return true
- end
- end
- local function getassault()
- if assault == 1 then
- return true
- end
- end
- local function getalternating()
- if alternating ~= 0 then
- return true
- end
- end
- local function getmovinghill()
- if moving_hill == 1 then
- return true
- end
- end
- local function getracetype()
- if race_type == 0 then
- return "Normal"
- elseif race_type == 1 then
- return "Any Order"
- elseif race_type == 2 then
- return "Rally"
- end
- end
- local function getoddballtype()
- if oddball_type == 0 then
- return "Normal"
- elseif oddball_type == 1 then
- return "Reverse Tag"
- elseif oddball_type == 2 then
- return "Juggernaut"
- end
- end
- local function getballrandomstart()
- if oddball_random_start == 1 then
- return true
- end
- end
- local function getoddballspeed()
- if oddball_speed == 0 then
- return "Slow"
- elseif oddball_speed == 1 then
- return "Normal"
- elseif oddball_speed == 2 then
- return "Fast"
- end
- end
- local function getoddballtrait()
- if oddball_trait == 0 then
- return "None"
- elseif oddball_trait == 1 then
- return "Invisible"
- elseif oddball_trait == 2 then
- return "Extra Damage"
- elseif oddball_trait == 3 then
- return "Damage Resistant"
- end
- end
- local function getnooddballtrait()
- if no_oddball_trait == 0 then
- return "None"
- elseif no_oddball_trait == 1 then
- return "Invisible"
- elseif no_oddball_trait == 2 then
- return "Extra Damage"
- elseif no_oddball_trait == 3 then
- return "Damage Resistant"
- end
- end
- gametypes[name] = {}
- gametypes[name].game = getgame()
- gametypes[name].team = getteamplay()
- gametypes[name].allonradar = getallonradar()
- gametypes[name].friendindicators = getfriendindicators()
- gametypes[name].infinitegrenades = getinfgrenades()
- gametypes[name].shields = getshields()
- gametypes[name].invisibleplayers = getinvisibleplayers()
- gametypes[name].startingequipment = getstarteqip()
- gametypes[name].friendsonradar = getfriendsonradar()
- gametypes[name].objectivesindicator = getobjectivesindicator()
- gametypes[name].oddmanout = getoddmanout()
- gametypes[name].respawngrowth = respawn_time_growth / 30
- gametypes[name].respawntime = respawn_time / 30
- gametypes[name].suicidepenalty = suicide_penalty / 30
- gametypes[name].lives = getlives()
- gametypes[name].maxhealth = getmaxhealth()
- gametypes[name].scorelimit = scorelimit
- gametypes[name].weaponset = getweaponset()
- gametypes[name].friendlyfire = getfriendlyfire()
- gametypes[name].tkpenalty = tk_penalty / 30
- gametypes[name].teambalance = getteambalance()
- gametypes[name].timelimit = timelimit / 1800
- if gametypes[name].game == "CTF" then
- gametypes[name].assault = getassault()
- gametypes[name].alternating = getalternating()
- elseif gametypes[name].game == "KotH" then
- gametypes[name].movinghill = getmovinghill()
- elseif gametypes[name].game == "Race" then
- gametypes[name].racetype = getracetype()
- elseif gametypes[name].game == "Oddball" then
- gametypes[name].oddballtype = getoddballtype()
- gametypes[name].randomstart = getballrandomstart()
- gametypes[name].oddballspeed = getoddballspeed()
- gametypes[name].oddballtrait = getoddballtrait()
- gametypes[name].nooddballtrait = getnooddballtrait()
- gametypes[name].oddballcount = oddball_count
- end
- end
- end
- end
- end
- end
- function readgame(chars, first, last, byte)
- first = first + 1
- last = last + 1
- local str = ""
- for i = first, last do
- if string.byte(chars[i]) ~= 0 then
- str = str .. chars[i]
- end
- end
- if byte then
- if str ~= "" then
- return string.byte(str)
- else
- return 0
- end
- end
- return str
- end
- -- Messages --
- messages = {}
- -- Values --
- values = table.load("values") or {}
- --[[ Global Booleans ]]--
- execute_original = false
- noprintcmd = false
- --[[ Global Variables ]]--
- gametype_base = 0x671340
- teamplay = readbyte(gametype_base, 0x34)
- this = {}
- -- Loading --
- LoadScripts()
- LoadGametypes()
- function GetRequiredVersion()
- return 10058
- end
- function OnScriptLoad(process)
- hprinttimer = registertimer(334, "HprintTimer", 334)
- registertimer(1000, "BanTimer")
- local file = io.open("lastman", "r")
- if file then
- previous_lastman = file:read("*line")
- file:close()
- end
- os.remove("lastman")
- end
- function OnScriptUnload()
- if lastman_hash then
- local file = io.open("lastman", "w")
- file:write(lastman_hash)
- file:close()
- end
- for k,v in pairs(mute_table) do
- if tonumber(k, 16) then
- if mute_table[k].muted then
- if mute_table[k].duration >= -1 then
- unmute(k)
- mutelog(k, "Unmuted at End of Game by SERVER")
- end
- end
- mute_table[k].swears.count = 0
- mute_table[k].swears.game = 0
- end
- end
- table.save(mute_table, "mutelist")
- local swear_save = {}
- swear_save.exact = sweartable.exact
- swear_save.anywhere = sweartable.anywhere
- swear_save.automute = automute
- swear_save.tomute = swears_to_mute
- swear_save.action = swear_action
- swear_save.append = swear_append
- swear_save.message = swear_message
- swear_save.penalty = swear_penalty
- swear_save.mutenotify = notify_of_mutes
- table.save(swear_save, "sweartable")
- for k,v in pairs(players.recent) do
- players.recent[k] = players.recent[k] - 1
- if players.recent[k] <= 0 then
- players.recent[k] = nil
- players[k].name = mostUsedAlias(k)
- end
- end
- table.save(players, "players")
- table.save(banned, "banlist")
- end
- function OnNewGame(map)
- this.map = map
- this.gametype = readstring(gametype_base, 0x0, 0x2C)
- updateAdmins()
- updateBanlist()
- registertimer(1000, "BeginGame")
- if anti_block then
- registertimer(50, "AntiBlock", map)
- end
- end
- function OnGameEnd(mode)
- end
- function OnServerChat(player, chattype, message)
- local hash = gethash(player)
- -- If you want to change the order of importance of the following blocks of code, place the most important first and least important last.
- -- For example, Admin Chat Commands comes first so even when an admin is muted, he/she can use commands. He/she may also use admin commands that contain swears.
- -- If you don't want the Swear Filter to affect Private Chat, just cut and paste the Private Chat (and Message Tokenization) code above the Swear Check.
- -- Admin Checking
- if isAdmin(player) then
- -- Admin Chat Commands
- local cmd, args = ParseCommand(message)
- local cmd_words = {cmd, unpack(args)}
- if #cmd_words > 0 then
- if validCommand(cmd) then
- chat[gethash(player)] = true
- svcmd(message, player)
- chat[gethash(player)] = nil
- return 0
- end
- end
- end
- -- Mute Check
- if mute_table[hash].muted then
- if mute_table[hash].duration < 0 then
- privatesay(player, mute_table[hash].message)
- else
- privatesay(player, mute_table[hash].message .. " (" .. mute_table[hash].duration .. " seconds left)")
- end
- return 0
- end
- -- Swear Check
- local swears = getSwears(message)
- if swears then
- if swear_action > 0 then
- swear(player, swears)
- if swear_action == 1 then
- return 0
- else
- local appended = appendMessage(message, swears)
- if not mute_table[hash].muted then
- return appended
- else
- return 0
- end
- end
- end
- end
- -- Message Tokenization
- local words = string.split(message, " ")
- local chatcmd = words[1]
- -- Private Chat
- if string.sub(chatcmd, 1, 1) == "@" and tonumber(string.sub(chatcmd, 2, string.len(chatcmd))) then
- local receivernum = tonumber(string.sub(chatcmd, 2, string.len(chatcmd)))
- local receiver = rresolveplayer(receivernum)
- local sendernum = resolveplayer(player)
- local sender = player
- if gethash(receiver) then
- if gethash(sender) then
- local privatemessage = table.concat(words, " ", 2, #words)
- hprint(sender, "to " .. getname(receiver) .. ": (" .. receivernum .. ") " .. privatemessage, 15)
- hprint(receiver, getname(sender) .. ": (" .. sendernum .. ") " .. privatemessage, 15)
- privatesay(sender, "Message sent.")
- end
- else
- privatesay(sender, "There is no player with an ID of " .. receivernum .. ".")
- end
- return 0
- end
- -- Chat Commands
- if message == "cls" then
- if hash then
- messages[hash] = {}
- privatesay(player, "Messages cleared.")
- return 0
- end
- end
- return 1
- end
- function OnServerCommand(player, command)
- local hash = gethash(player)
- if hash then
- messages[hash] = {}
- end
- -- Admin Checking
- if isAdmin(player) or noAdmins() then
- local allow = 1
- if not execute_original then
- --local tokens = getcmdtokens(command)
- local cmd, args = ParseCommand(command)
- local tokens = {cmd, unpack(args)}
- if #tokens > 0 then
- if validCommand(cmd) then
- if canExecute(player, cmd) then
- local executed = Command(player, cmd, tokens)
- if not executed then
- console(getSyntax(cmd) or "<Need a syntax entry here>")
- end
- else
- console("You are not authorized to use this command.")
- end
- allow = 0
- end
- end
- end
- if not noprintcmd then
- if #sprint > 0 then
- for _,v in ipairs(sprint) do
- say(v)
- end
- else
- if pprint[player] then
- if #pprint[player] > 0 then
- for _,v in ipairs(pprint[player]) do
- hprint(player, v, 10)
- end
- else
- for _,v in ipairs(cprint) do
- if gethash(player) then
- if chat[gethash(player)] then
- hprint(player, v, #cprint * 4)
- else
- hprintf(v, player)
- end
- else
- hprintf(v)
- end
- end
- end
- else
- for _,v in ipairs(cprint) do
- hprintf(v)
- end
- end
- end
- end
- sprint = {}
- cprint = {}
- for k,v in pairs(pprint) do
- pprint[k] = {}
- end
- execute_original = false
- return allow
- end
- hprintf("You are not an administrator in this server.")
- return 0
- end
- function OnTeamDecision(team)
- return zombie_team
- end
- function OnPlayerJoin(player, team)
- messages[gethash(player)] = {}
- updatePlayer(player)
- cur_players = cur_players + 1
- local hash = gethash(player)
- table.insert(cur_hashes, hash)
- privatesay(player, welcome_message)
- if game_begin then
- if cur_players == 1 then
- changeteam(player, human_team)
- else
- if no_zombies then
- changeteam(player, zombie_team)
- removetimer(nozombiestimer)
- no_zombies = false
- else
- if hashes[hash] then
- changeteam(player, hashes[hash])
- end
- end
- end
- local team = getteam(player)
- if team == human_team then
- privatesay(player, human_message)
- else
- privatesay(player, zombie_message)
- end
- hashes[hash] = team
- end
- end
- function OnPlayerLeave(player, team)
- local hash = gethash(player)
- players[hash].lastseen = os.time()
- cur_players = cur_players - 1
- local hash = gethash(player)
- cur_hashes[hash] = nil
- hashes[hash] = team
- if cur_players > 0 then
- if getteamsize(zombie_team) == 0 then
- if cur_players > 1 then
- say(no_zombies_left_message)
- no_zombies = true
- nozombiestimer = registertimer(2000, "NoZombiesTimer")
- end
- end
- if getteamsize(human_team) == 0 then
- svcmd("sv_map_next")
- end
- else
- if nozombiestimer then
- removetimer(nozombiestimer)
- no_zombies = false
- end
- end
- end
- function OnPlayerKill(killer, victim, mode)
- if game_begin then
- if getteam(victim) == human_team then
- if mode == 0 then
- if infected_by_server then
- zombify(victim)
- end
- elseif mode == 1 then
- if infected_by_fall then
- zombify(victim)
- end
- elseif mode == 2 then
- if infected_by_guardians then
- zombify(victim)
- end
- elseif mode == 3 then
- if infected_by_vehicle then
- zombify(victim)
- end
- elseif mode == 4 then
- if infected_by_zombie then
- zombify(victim)
- end
- elseif mode == 5 then
- if infected_by_betrayal then
- zombify(killer)
- end
- elseif mode == 6 then
- if infected_by_suicide then
- zombify(victim)
- end
- end
- end
- end
- local hash = gethash(victim)
- if balls[hash] then
- destroyobject(balls[hash])
- balls[hash] = nil
- end
- end
- function OnKillMultiplier(player, multiplier)
- end
- function OnPlayerSpawn(player, m_objId)
- local hash = gethash(player)
- local team = getteam(player)
- local m_object = getobject(m_objId)
- -- Speed
- if team == human_team then
- setspeed(player, human_speed)
- else
- setspeed(player, zombie_speed)
- if zombies_invisible then
- applycamo(player, 0)
- end
- end
- -- Zombie Camo
- if team == zombie_team then
- if zombies_invisible then
- applycamo(player, 0)
- end
- end
- -- Weapons
- if game_begin then
- if team == human_team then
- if #human_weapons == 1 and human_weapons[1] == "weapons\\ball\\ball" then
- balls[hash] = readdword(m_object, 0x2F8)
- end
- else
- if #zombie_weapons == 1 and zombie_weapons[1] == "weapons\\ball\\ball" then
- balls[hash] = readdword(m_object, 0x2F8)
- end
- end
- end
- for i = 0,1 do
- local m_weapId = readdword(m_object, 0x2F8 + i * 4)
- local m_weapon = getobject(m_weapId)
- if team == human_team then
- if human_weapons[i + 1] then
- if human_ammo[i + 1] then
- writeword(m_weapon, 0x2B6, human_ammo[i + 1])
- writeword(m_weapon, 0x240, (1 - human_ammo[i + 1] / 100))
- end
- if human_clip[i + 1] then
- writeword(m_weapon, 0x2B8, human_clip[i + 1])
- end
- updateammo(m_weapId)
- end
- else
- if zombie_weapons[i + 1] then
- if zombie_ammo[i + 1] then
- writeword(m_weapon, 0x2B6, zombie_ammo[i + 1])
- writeword(m_weapon, 0x240, (1 - zombie_ammo[i + 1] / 100))
- end
- if zombie_clip[i + 1] then
- writeword(m_weapon, 0x2B8, zombie_clip[i + 1])
- end
- updateammo(m_weapId)
- end
- end
- end
- --[[for i = 3,0,-1 do
- local m_weapId = readdword(m_object, 0x2F8 + i * 4)
- local m_weapon = getobject(m_weapId)
- if team == human_team then
- if human_weapons[i + 1] ~= "" and human_weapons[i + 1] then
- if m_weapon then
- destroyobject(m_weapId)
- end
- local m_objId = createobject("weap", human_weapons[i + 1], 0, 30, false, 0, 0, 0)
- local m_object = getobject(m_objId)
- registertimer((i * 1000) + 10, "DelayAssign", player, m_objId, i + 1)
- elseif not human_weapons[i + 1] then
- if m_weapon then
- destroyobject(m_weapId)
- end
- else
- if human_ammo[i + 1] then
- writeword(m_weapon, 0x2B6, human_ammo[i + 1])
- writefloat(m_weapon, 0x240, (1 - human_ammo[i + 1] / 100))
- end
- if human_clip[i + 1] then
- writeword(m_weapon, 0x2B8, human_clip[i + 1])
- end
- updateammo(m_weapId)
- end
- else
- if zombie_weapons[i + 1] ~= "" and zombie_weapons[i + 1] then
- if m_weapon then
- destroyobject(m_weapId)
- end
- local m_objId = createobject("weap", human_weapons[i + 1], 0, 30, false, 0, 0, 0)
- local m_object = getobject(m_objId)
- registertimer((i * 1000) + 10, "DelayAssign", player, m_objId, i + 1)
- elseif not zombie_weapons[i + 1] then
- if m_weapon then
- destroyobject(m_weapId)
- end
- else
- if zombie_ammo[i + 1] then
- writeword(m_weapon, 0x2B6, zombie_ammo[i + 1])
- writefloat(m_weapon, 0x240, (1 - zombie_ammo[i + 1] / 100))
- end
- if zombie_clip[i + 1] then
- writeword(m_weapon, 0x2B8, zombie_clip[i + 1])
- end
- updateammo(m_weapId)
- end
- end
- end--]]
- -- Grenades
- if game_begin then
- if team == human_team then
- if human_frags then
- writebyte(m_object, 0x31E, human_frags)
- end
- if human_plasmas then
- writebyte(m_object, 0x31F, human_plasmas)
- end
- elseif team == zombie_team then
- if zombie_frags then
- writebyte(m_object, 0x31E, zombie_frags)
- end
- if zombie_plasmas then
- writebyte(m_object, 0x31F, zombie_plasmas)
- end
- end
- else
- writebyte(m_object, 0x31E, 0)
- writebyte(m_object, 0x31F, 0)
- end
- end
- function OnPlayerSpawnEnd(player, m_objId)
- end
- function OnTeamChange(relevant, player, cur_team, dest_team)
- if not no_zombies then
- return 0
- else
- removetimer(nozombiestimer)
- no_zombies = false
- say(no_zombies_team_change_message)
- return 1
- end
- end
- function OnObjectCreation(m_objId, player, tagName)
- newObject(m_objId)
- end
- function OnObjectDestruction(m_objId, tagType, tagName)
- end
- function OnObjectInteraction(player, m_objId, tagType, tagName)
- local team = getteam(player)
- local hash = gethash(player)
- if m_objId == balls[hash] then
- assignweapon(player, m_objId)
- end
- if team == human_team then
- if table.find(human_blocked, tagName) then
- return 0
- end
- else
- if table.find(zombie_blocked, tagName) then
- return 0
- end
- end
- return 1
- end
- function OnWeaponAssignment(player, m_objId, slot, tagName)
- local team = getteam(player)
- if team == human_team then
- if human_weapons[slot + 1] == "" then
- return 0
- elseif human_weapons[slot + 1] then
- return lookuptag("weap", human_weapons[slot + 1])
- else
- return lookuptag("weap", human_weapons[1])
- end
- else
- if zombie_weapons[slot + 1] == "" then
- return 0
- elseif zombie_weapons[slot + 1] then
- return lookuptag("weap", zombie_weapons[slot + 1])
- else
- return lookuptag("weap", zombie_weapons[1])
- end
- end
- end
- function OnWeaponReload(player, m_weapId)
- return 1
- end
- function OnDamageLookup(receiver, causer, tagData, tagName)
- local c_player = objecttoplayer(causer)
- if c_player then
- local c_hash = gethash(c_player)
- local c_team = getteam(c_player)
- local min_damage = readfloat(tagData, 0x1D0)
- local med_damage = readfloat(tagData, 0x1D4)
- local max_damage = readfloat(tagData, 0x1D8)
- if c_team == human_team then
- if c_hash ~= lastman_hash then
- writefloat(tagData, 0x1D0, min_damage * human_damage)
- writefloat(tagData, 0x1D4, med_damage * human_damage)
- writefloat(tagData, 0x1D8, max_damage * human_damage)
- else
- writefloat(tagData, 0x1D0, min_damage * lastman_damage)
- writefloat(tagData, 0x1D4, med_damage * lastman_damage)
- writefloat(tagData, 0x1D8, max_damage * lastman_damage)
- end
- else
- if string.find(tagName, "melee") then
- writefloat(tagData, 0x1D0, zombie_melee_damage)
- writefloat(tagData, 0x1D4, zombie_melee_damage)
- writefloat(tagData, 0x1D8, zombie_melee_damage)
- else
- writefloat(tagData, 0x1D0, zombie_damage)
- writefloat(tagData, 0x1D4, zombie_damage)
- writefloat(tagData, 0x1D8, zombie_damage)
- end
- end
- end
- local r_player = objecttoplayer(receiver)
- if r_player then
- local r_hash = gethash(r_player)
- local r_team = getteam(r_player)
- local min_edit = readfloat(tagData, 0x1D0)
- local med_edit = readfloat(tagData, 0x1D4)
- local max_edit = readfloat(tagData, 0x1D8)
- if r_team == human_team then
- if r_hash ~= lastman_hash then
- if human_vitality then
- writefloat(tagData, 0x1D0, min_edit / human_vitality)
- writefloat(tagData, 0x1D4, med_edit / human_vitality)
- writefloat(tagData, 0x1D8, max_edit / human_vitality)
- end
- else
- if lastman_vitality then
- writefloat(tagData, 0x1D0, min_edit / lastman_vitality)
- writefloat(tagData, 0x1D4, med_edit / lastman_vitality)
- writefloat(tagData, 0x1D8, max_edit / lastman_vitality)
- end
- end
- else
- if zombie_vitality then
- writefloat(tagData, 0x1D0, min_edit / zombie_vitality)
- writefloat(tagData, 0x1D4, med_edit / zombie_vitality)
- writefloat(tagData, 0x1D8, max_edit / zombie_vitality)
- end
- end
- end
- end
- function OnVehicleEntry(relevant, player, m_vehicleId, tagName, seat)
- local team = getteam(player)
- if team == human_team then
- if not human_vehicle then
- privatesay(player, vehicle_block_message)
- return 0
- end
- else
- if not zombie_vehicle then
- privatesay(player, vehicle_block_message)
- return 0
- end
- end
- return 1
- end
- function OnVehicleEject(player, forced)
- return 1
- end
- function OnClientUpdate(player, m_objId)
- for k,v in pairs(objects) do
- if k ~= "unique" then
- if not objects[k].destroyed then
- if not getobject(k) then
- objects[k].destroyed = true
- OnObjectDestruction(k, objects[k].tagtype, objects[k].tagname)
- end
- end
- end
- end
- end
- -- Infection Functions --
- function BeginGame(id, count)
- if count < 5 then
- say("The game will begin in " .. 5 - count .. " seconds.")
- else
- local zombie_size = 0
- if cur_players > 1 then
- for i = 0,15 do
- local hash = gethash(i)
- if hash then
- if hash == previous_lastman then
- changeteam(i, zombie_team)
- privatesay(i, zombie_message)
- zombie_size = zombie_size + 1
- break
- end
- end
- end
- for i in irand(0, 15) do
- local hash = gethash(i)
- if hash then
- if hash ~= previous_lastman then
- if starting_zombies >= 1 then
- if zombie_size < starting_zombies then
- changeteam(i, zombie_team)
- privatesay(i, zombie_message)
- zombie_size = zombie_size + 1
- else
- changeteam(i, human_team)
- privatesay(i, human_message)
- end
- else
- if zombie_size / cur_players < starting_zombies then
- changeteam(i, zombie_team)
- privatesay(i, zombie_message)
- zombie_size = zombie_size + 1
- else
- changeteam(i, human_team)
- privatesay(i, human_message)
- end
- end
- end
- end
- end
- else
- for i = 0,15 do
- if gethash(i) then
- changeteam(i, human_team)
- privatesay(human_message)
- break
- end
- end
- end
- for i = 0,15 do
- if gethash(i) then
- local m_player = getplayer(i)
- local m_objId = readdword(m_player, 0x34)
- local m_object = getobject(m_objId)
- if m_object then
- destroyobject(m_objId)
- end
- end
- end
- game_begin = true
- return 0
- end
- return 1
- end
- function DelayAssign(id, count, player, m_objId, slot)
- local team = getteam(player)
- local hash = gethash(player)
- local m_object = getobject(m_objId)
- if team == human_team then
- if #human_weapons == 1 and human_weapons[1] == "weapons\\ball\\ball" then
- balls[hash] = m_objId
- end
- if human_ammo[slot] then
- writeword(m_object, 0x2B6, human_ammo[slot])
- writefloat(m_object, 0x240, (1 - human_ammo[slot]) / 100)
- end
- if human_clip[slot] then
- writeword(m_object, 0x2B8, human_clip[slot])
- end
- else
- if #zombie_weapons == 1 and zombie_weapons[1] == "weapons\\ball\\ball" then
- balls[hash] = m_objId
- end
- if zombie_ammo[slot] then
- writeword(m_object, 0x2B6, zombie_ammo[slot])
- writefloat(m_object, 0x240, (1 - zombie_ammo[slot]) / 100)
- end
- if zombie_clip[slot] then
- writeword(m_object, 0x2B8, zombie_clip[slot])
- end
- end
- updateammo(m_objId)
- assignweapon(player, m_objId)
- return 0
- end
- function NoZombiesTimer(id, count)
- if count < 5 then
- say(no_zombies_timer_message .. " in " .. (10 - 2 * count) .. " seconds!")
- else
- changeteam(getrandomplayer(), zombie_team)
- return 0
- end
- return 1
- end
- block_coords = {}
- block_coords.dangercanyon = {}
- block_coords.dangercanyon[1] = {12, 3, -2.5, 0.9, 0.9, 0.9}
- block_coords.dangercanyon[2] = {-12, 3, -2.5, 0.9, 0.9, 0.9}
- block_coords.beavercreek = {}
- block_coords.beavercreek[1] = {10.949, 20.900, 0.76, 0.1, 0.1, 2.2}
- block_coords.beavercreek[2] = {17.918, 6.419, 1.045, 0.1, 0.1, 2.55}
- block_coords.chillout = {}
- block_coords.chillout[1] = {8, 5.672, 3.55, 2, 0.3, 1}
- function AntiBlock(id, count, map)
- for i = 0,15 do
- local hash = gethash(i)
- if hash then
- local m_player = getplayer(i)
- local m_objId = readdword(m_player, 0x34)
- local m_object = getobject(m_objId)
- if m_object then
- local bool
- for k,v in ipairs(block_coords[map]) do
- if inVolume(m_objId, unpack(v)) then
- bool = true
- local old_time
- if not blocking[hash] then
- old_time = 0
- blocking[hash] = 0
- else
- old_time = blocking[hash]
- blocking[hash] = blocking[hash] + 50
- end
- if old_time < block_time_warning and blocking[hash] >= block_time_warning then
- if block_time_warning_message then
- privatesay(i, block_time_warning_message)
- end
- elseif old_time < block_time_action and blocking[hash] >= block_time_action then
- if block_time_action_message then
- privatesay(i, block_time_action_message)
- end
- svcmd(string.gsub(block_action, "<player>", resolveplayer(i)))
- if multiple_offense_action_amount then
- block_offenses[hash] = (block_offenses[hash] or 0) + 1
- if block_offenses[hash] >= multiple_offense_action_amount then
- if multiple_offense_action_message then
- privatesay(i, multiple_offense_action_message)
- end
- svcmd(string.gsub(multiple_offense_action, "<player>", resolveplayer(i)))
- end
- end
- end
- end
- end
- if not bool then
- blocking[hash] = nil
- end
- end
- end
- end
- return 1
- end
- function inVolume(m_objId, x, y, z, xd, yd, zd)
- local m_object = getobject(m_objId)
- if m_object then
- local ox, oy, oz = getobjectcoords(m_objId)
- local x_dist = math.abs(x - ox)
- local y_dist = math.abs(y - oy)
- local z_dist = math.abs(z - oz)
- if x_dist < xd and y_dist < yd and z_dist < zd then
- return true
- end
- end
- return false
- end
- function getrandomplayer()
- local players = {}
- for i = 0,15 do
- if gethash(i) then
- table.insert(players, i)
- end
- end
- if unpack(players) then
- return players[getrandomnumber(1, #players + 1)]
- end
- end
- function zombify(player)
- local hash = gethash(player)
- changeteam(player, false)
- hashes[hash] = zombie_team
- setspeed(player, zombie_speed)
- privatesay(player, zombie_message)
- say(getname(player) .. infected_message)
- if getteamsize(human_team) == 1 then
- OnLastMan()
- elseif getteamsize(human_team) == 0 then
- svcmd("sv_map_next")
- end
- end
- function changeteam(player, dest_team, killed)
- local cur_team = getteam(player)
- if cur_team ~= dest_team then
- phasor_changeteam(player, killed or false)
- end
- end
- function OnLastMan()
- for i = 0,15 do
- if getteam(i) == human_team then
- lastman_hash = gethash(i)
- local m_player = getplayer(i)
- local m_objId = readdword(m_player, 0x34)
- local m_object = getobject(m_objId)
- if m_object then
- for i = 0,3 do
- local m_weapId = readdword(m_object, 0x2F8 + i * 4)
- local m_weapon = getobject(m_weapId)
- local ammo = readword(m_object, 0x2B6)
- local clip = readword(m_object, 0x2B8)
- writeword(m_object, 0x2B6, lastman_ammo or ammo)
- writeword(m_object, 0x2B8, lastman_clip or clip)
- end
- end
- local frags = readbyte(m_object, 0x31E)
- local plasmas = readbyte(m_object, 0x31F)
- writebyte(m_object, 0x31E, lastman_frags or frags)
- writebyte(m_object, 0x31F, lastman_plasmas or plasmas)
- setspeed(i, lastman_speed)
- if lastman_invistime then
- applycamo(i, lastman_invistime)
- end
- say(getname(i) .. lastman_message)
- end
- end
- end
- function irand(min, max)
- local u = {}
- for i = min,max do
- table.insert(u, i)
- end
- return function()
- if unpack(u) then
- local rand = getrandomnumber(1, #u + 1)
- local value = u[rand]
- table.remove(u, rand)
- return value
- end
- end
- end
- -- Player and Admin Functions --
- -- Returns the hash of the specified index.
- local function validIndex(id)
- if id then
- for k,_ in pairs(players) do
- if tonumber(k, 16) then
- if string.lower(id) == string.lower(players[k].index) then
- return k
- end
- end
- end
- end
- return nil
- end
- local function invalidIndex(id)
- if id == "red" or id == "blue" or id == "all" or id == "me" or id == "this" then
- return true
- elseif tonumber(id) then
- if tonumber(id) < 17 and tonumber(id) > 0 then
- if string.len(id) ~= 3 then
- return true
- end
- end
- end
- end
- -- Creates a new Server Index based on amount of unique players.
- local function newIndex()
- local x = 0
- local id
- repeat
- id = convertbase((players.unique or 1) - 1 + x, 36)
- while string.len(id) < 3 do
- id = "0" .. id
- end
- x = x + 1
- until not validIndex(id) and not invalidIndex(id)
- return id
- end
- function mostUsedAlias(hash)
- local max = 0
- local name
- for k,v in pairs(players[hash].alias or {}) do
- if v > max then
- max = v
- name = k
- end
- end
- return name
- end
- function validPlayer(hash, name)
- if not players[hash] then
- players.unique = (players.unique or 0) + 1
- local index = newIndex()
- players[hash] = {}
- local player = hashtoplayer(hash)
- players[hash].name = name or getname(player) or "Anonymous"
- players[hash].index = index
- players[hash].alias = {}
- players[hash].messages = {}
- players[hash].adminlevels = {}
- players[hash].commands = {}
- players[hash].shortcuts = {}
- players[hash].banned = false
- players[hash].bancount = 0
- players[hash].bos = false
- players[hash].kickcount = 0
- players[hash].lastseen = math.inf
- end
- end
- -- Create a new player if they don't already exist and updates that player's information.
- function updatePlayer(player)
- local hash = gethash(player)
- if not players[hash] then
- players.unique = (players.unique or 0) + 1
- end
- local index
- if players[hash] then
- index = players[hash].index
- else
- index = newIndex()
- end
- players[hash] = players[hash] or {}
- players[hash].name = players[hash].savedname or getname(player) or mostUsedAlias(hash)
- players[hash].index = index
- players[hash].alias = players[hash].alias or {}
- players[hash].messages = players[hash].messages or {}
- players[hash].adminlevels = {}
- players[hash].commands = {}
- players[hash].shortcuts = {}
- players[hash].banned = players[hash].banned or false
- players[hash].bancount = players[hash].bancount or 0
- players[hash].bos = players[hash].bos or false
- players[hash].kickcount = players[hash].kickcount or 0
- players[hash].alias[getname(player)] = (players[hash].alias[getname(player)] or 0) + 1
- players[hash].lastseen = 0
- players.recent[hash] = players.recentmemory
- players[hash].maps = players[hash].maps or {}
- players[hash].gametypes = players[hash].gametypes or {}
- players[hash].scripts = players[hash].scripts or {}
- -- Check messages.
- if #players[hash].messages > 0 then
- for _,v in ipairs(players[hash].messages) do
- hprint(player, v, 30)
- end
- if not mute_table[hash].muted then
- hprint(player, "Type cls in the chat to clear this screen.", 30)
- end
- players[hash].messages = {}
- end
- -- Ban on Sight.
- if players[hash].bos then
- ban(hash, players[hash].name, players[hash].bantime)
- players[hash].bos = false
- end
- -- Call other updating functions
- updateMute(player)
- end
- -- Converts Player ID or Server Index to a hash.
- function tohash(id, rcon, admin, name)
- local hash
- if id then
- if id == "me" then
- return gethash(admin)
- elseif id == "all" or id == "red" or id == "blue" then
- local hashes = {}
- if id == "all" then
- for i = 0, 15 do
- if gethash(i) then table.insert(hashes, gethash(i)) end
- end
- if #hashes == 0 then
- console("There are no players in the server.")
- end
- elseif id == "red" then
- if teamplay == 1 then
- for i = 0, 15 do
- if gethash(i) then
- if getteam(i) == 0 then table.insert(hashes, gethash(i)) end
- end
- end
- else
- console("This is not a team game.")
- return nil
- end
- if #hashes == 0 then
- console("There is nobody on the red team.")
- end
- elseif id == "blue" then
- if teamplay == 1 then
- for i = 0, 15 do
- if gethash(i) then
- if getteam(i) == 1 then table.insert(hashes, gethash(i)) end
- end
- end
- else
- console("This is not a team game.")
- return nil
- end
- if #hashes == 0 then
- console("There is nobody on the blue team.")
- end
- end
- return unpack(hashes)
- end
- if string.len(id) >= 3 and string.len(id) < 32 then
- local valid = validIndex(id)
- if not valid then
- for i = 0, 15 do
- if getname(i) then
- if string.find(getname(i), id) then
- hash = gethash(i)
- end
- end
- end
- else
- hash = valid
- end
- elseif string.len(id) == 32 then
- hash = id
- else
- if rcon then
- if (tonumber(id) or 0) > 0 and (tonumber(id) or 17) <= 16 then
- hash = gethash(rresolveplayer(id))
- end
- else
- if (tonumber(id) or -1) >= 0 and (tonumber(id) or 16) < 16 then
- hash = gethash(id)
- end
- end
- end
- end
- if hash then
- validPlayer(hash, name)
- end
- return hash
- end
- function validId(input)
- if input == "all" or input == "red" or input == "blue" or input == "me" or input == "this" or validIndex(input) or gethash(tonumber(input)) or string.len(input) == 32 then
- return true
- end
- end
- function toTeam(input)
- if input == "red" then
- return "Red Team"
- elseif input == "blue" then
- return "Blue Team"
- elseif input == "all" then
- return "All"
- end
- end
- function sv_unique(admin)
- console(players.unique .. " unique hashes have joined this server.")
- return true
- end
- function sv_players(admin, search)
- if not search then
- console("Player ID Server ID Player Name Most Common Alias")
- for i = 0, 15 do
- local hash = gethash(i)
- if hash then
- local message = "[" .. resolveplayer(i) .. "] [" .. players[hash].index .. "] " .. getname(i)
- if getname(i) ~= mostUsedAlias(hash) then
- message = message .. " " .. mostUsedAlias(hash)
- end
- console(message)
- end
- end
- local t = {}
- for k,_ in pairs(players.recent) do
- if not hashtoplayer(k) then
- table.insert(t, "[" .. players[k].index .. "] " .. players[k].name)
- end
- end
- if #t > 0 then
- console("Recent Players:")
- local mprint = printlist(t, 5, " | ")
- for _,v in ipairs(mprint) do
- console(v)
- end
- end
- else
- search = string.lower(search)
- local matches = {}
- for k,v in pairs(players) do
- if tonumber(k, 16) then
- if string.find(string.lower(players[k].name), search) then
- table.insert(matches, k)
- end
- end
- end
- for k,v in pairs(players) do
- if tonumber(k, 16) then
- for a,_ in pairs(players[k].alias) do
- if string.find(string.lower(a), search) then
- if not table.find(matches, k) then
- table.insert(matches, k)
- end
- end
- end
- end
- end
- if #matches > 0 then
- table.sort(matches, function(a, b) return players[a].lastseen < players[b].lastseen end)
- console("Player names matching search \"" .. search .. "\":")
- local min = math.min(25, #matches)
- for i = 1, min do
- console("[" .. players[matches[i]].index .. "] " .. players[matches[i]].name)
- end
- else
- console("Your search returned no matches.")
- end
- end
- return true
- end
- function sv_player_memory(admin, value)
- if value then
- value = tonumber(value)
- if value then
- players.recentmemory = value
- console("Players will now be remembered for " .. value .. " games.")
- return true
- else
- console("Invalid Value.")
- end
- else
- console("Players are remembered for " .. players.recentmemory .. " games.")
- return true
- end
- return false
- end
- function sv_player_index(admin, id, index)
- local hash = tohash(id, true, admin)
- if hash then
- if index then
- if not validIndex(index) then
- if not invalidIndex(index) then
- if string.len(index) < 32 then
- players[hash].index = index
- console((players[hash].name or "This player") .. "'s Server Index changed to \"" .. index .. "\".")
- return true
- else
- console("Index must be less than 32 characters.")
- end
- else
- console("Index may not be \"red\", \"blue\", \"all\", \"me\" or an integer between 1 and 16.")
- end
- else
- console("\"" .. index .. "\" is already in use.")
- end
- else
- console("[" .. players[hash].index .. "] " .. players[hash].name)
- return true
- end
- else
- console("Invalid Player.")
- end
- return false
- end
- function sv_player_name(admin, id, name)
- local hash = tohash(id, true, admin)
- if hash then
- if name then
- if name ~= "" then
- local oldname = players[hash].name
- players[hash].savedname = name
- players[hash].name = name
- console((oldname or "This player") .. "'s name changed to \"" .. name .. "\".")
- else
- players[hash].savedname = nil
- console((players[hash].name or "This player") .. "'s name will now be based on his/her most common alias.")
- players[hash].name = mostUsedAlias(hash) or getname(player) or ""
- end
- else
- console("[" .. players[hash].index .. "] " .. players[hash].name)
- end
- return true
- end
- console("Invalid Player.")
- return false
- end
- function sv_alias(admin, id)
- local hash = tohash(id, true, admin)
- if hash then
- local aliases = {}
- for k,_ in pairs(players[hash].alias) do
- table.insert(aliases, k)
- end
- table.sort(aliases, function(a, b) return players[hash].alias[a] > players[hash].alias[b] end)
- for k,v in ipairs(aliases) do
- aliases[k] = "[" .. players[hash].alias[v] .. "] " .. v
- end
- console("Aliases and number of times joined under an alias:")
- local mprint = printlist(aliases, 5, " | ")
- for _,v in ipairs(mprint) do
- console(v)
- end
- return true
- end
- console("Invalid Player.")
- return false
- end
- function sv_reset_alias(admin, id)
- local hash = tohash(id, true, admin)
- if hash then
- local name = mostUsedAlias(hash)
- players[hash].alias = {}
- console((name or getname(hashtoplayer(hash)) or "This player") .. "'s aliases have been reset.")
- return true
- end
- console("Invalid Player.")
- return false
- end
- function sv_message(admin, id, message)
- local hash = tohash(id, true, admin)
- if hash then
- if hashtoplayer(hash) then
- hprint(hashtoplayer(hash), message, 15)
- console("Message sent.")
- else
- table.insert(players[hash].messages, message)
- console(players[hash].name .. " will receive this message next time they join the server.")
- end
- return true
- end
- console("Invalid Player.")
- return false
- end
- --[[ Admin Handling ]]--
- --[[ Levels Table Structure ]]--
- --[[
- players.levels.default
- players.levels[k]
- players.levels[k].id = "L" .. k
- players.levels[k].name
- players.levels[k].openaccess
- players.levels[k].access
- players.levels[k].members = {}
- players.levels[k].commands = {}
- --]]
- function validLevel(id)
- if id then
- for k,v in ipairs(players.levels) do
- if string.lower(id) == string.lower(players.levels[k].id) or string.lower(id) == string.lower(players.levels[k].name) then
- return k
- end
- end
- end
- end
- function nextLevel()
- for i = 0,9 do
- local id = "L" .. i
- if not validLevel(id) then
- return i
- end
- end
- end
- function sv_levels(admin, search)
- local matches = {}
- if search then
- for k,v in ipairs(players.levels) do
- if string.find(players.levels[k].name, search) or string.find(players.levels[k].id, search) then
- table.insert(matches, k)
- end
- end
- else
- for k,v in ipairs(players.levels) do
- table.insert(matches, k)
- end
- end
- table.sort(matches, function(a, b) return players.levels[a].id > players.levels[b].id end)
- for k,v in ipairs(matches) do
- console("[" .. players.levels[k].id .. "] " .. players.levels[k].name)
- end
- return true
- end
- function sv_level_admins(admin, level)
- level = validLevel(level)
- if level then
- console("Admins in Level \"" .. players.levels[level].name .. "\":")
- for k,v in ipairs(players.levels[level].members) do
- console("[" .. players[v].index .. "] " .. players[v].name)
- end
- return true
- end
- console("Invalid Admin Level.")
- return false
- end
- function sv_level_add(admin, name)
- local id = nextLevel()
- if id then
- if not name then
- local x = id - 1
- repeat
- name = "Level " .. (x + 1)
- until not validLevel(name)
- end
- if string.len(name) > 3 then
- local index = "L" .. (id)
- if validLevel(name) then
- console("The name \"" .. name .. "\" is already in use.")
- return false
- end
- if not players.levels.default or players.levels.default == "L" .. (#players.levels - 1) then
- players.levels.default = index
- end
- local t = {}
- t.id = index
- t.name = name
- t.members = {}
- t.commands = {"sv_players", "sv_unique", "sv_admins", "sv_commands", "sv_shortcut"}
- table.insert(players.levels, t)
- console("New Admin Level \"" .. name .. "\" created with index " .. index .. ".")
- return true, index
- else
- console("Name must be longer than 3 characters.")
- end
- else
- console("You have already reached your maximum of 10 Admin Levels.")
- console("You may use sv_command_add on individual players, or delete a current Admin Level before creating a new one.")
- end
- return false
- end
- function sv_level_del(admin, id)
- local level = validLevel(id)
- if level then
- for _,h in ipairs(players.levels[level].members) do
- for k,L in ipairs(players[h].adminlevels) do
- if L == level then
- table.remove(players[h].adminlevels, k)
- end
- end
- end
- console("Admin Level \"" .. players.levels[level].name .. "\" has been deleted.")
- table.remove(players.levels, level)
- return true
- else
- console("Invalid Admin Level.")
- end
- return false
- end
- function noAdmins()
- if #players.admins == 0 then
- return true
- end
- end
- function isAdmin(id)
- local hash = tohash(id)
- if hash then
- if players.admins[hash] then
- return true
- end
- if #players[hash].commands > 0 then
- return true
- end
- else
- return true
- end
- end
- function sv_admin_add(admin, id, level)
- local hash = tohash(id, true, admin)
- if hash then
- if not level then
- if #players.levels > 0 then
- level = players.levels.default
- else
- ncmd("sv_level_add")
- ncmd("sv_openaccess L0")
- level = "L0"
- end
- end
- level = validLevel(level)
- if level then
- for k,v in ipairs(players[hash].adminlevels) do
- if v == level then
- console(players[hash].name .. " is already in Admin Level \"" .. players.levels[level].name .. "\".")
- return false
- end
- end
- players.admins[hash] = true
- table.insert(players[hash].adminlevels, level)
- table.insert(players.levels[level].members, hash)
- console(players[hash].name .. " has been added to Admin Level \"" .. players.levels[level].name .. "\".")
- if hashtoplayer(hash) then
- hprint(hashtoplayer(hash), "You are now an administrator in Admin Level \"" .. players.levels[level].name .. "\".", 20)
- hprint(hashtoplayer(hash), "Type sv_commands in the chat to view a list of commands you may execute.", 20)
- hprint(hashtoplayer(hash), "Use sv_help on a command to view information about that command. (For example: sv_help sv_commands)", 20)
- hprint(hashtoplayer(hash), "Ask the server provider on information about how to use the RCON console.", 20)
- hprint(hashtoplayer(hash), "Type cls to clear this screen.", 20)
- end
- return true
- else
- console("Invalid Admin Level.")
- end
- else
- console("Invalid Player.")
- end
- return false
- end
- function sv_admin_del(admin, id, level)
- local hash = tohash(id, true, admin)
- if hash then
- if players.admins[hash] then
- if not level then
- for _,v in ipairs(players[hash].adminlevels) do
- for k,h in ipairs(players.levels[v].members) do
- if h == hash then
- table.remove(players.levels[v].members, k)
- break
- end
- end
- end
- players.admins[hash] = nil
- players[hash].adminlevels = {}
- players[hash].commands = {}
- players[hash].shortcuts = {}
- console(players[hash].name .. " is no longer an admin.")
- else
- level = validLevel(level)
- if level then
- for k,h in ipairs(players.levels[v].members) do
- if h == hash then
- table.remove(players.levels[v].members, k)
- break
- end
- end
- for k,v in ipairs(players[hash].adminlevels) do
- if level == v then
- table.remove(players[hash].adminlevels, k)
- break
- end
- end
- console(players[hash].name .. " has been removed from Admin Level " .. players.levels[level].name .. ".")
- else
- console("Invalid Admin Level.")
- return false
- end
- end
- return true
- else
- console(players[hash].name .. " is not an admin.")
- end
- else
- console("Invalid Player.")
- end
- return false
- end
- function sv_admin_default(admin, level)
- if level then
- level = validLevel(level)
- if level then
- players.levels.default = players.levels[level].id
- console("The Default Admin Level is now \"" .. players.levels[level].name .. "\".")
- console("If an admin is added without a level specification, they will be added to this level.")
- end
- else
- level = validLevel(players.levels.default)
- if level then
- console(players.levels[level].name)
- else
- console("There are currently no Admin Levels.")
- end
- end
- return true
- end
- function sv_admins(admin, search)
- local matches = {}
- if search then
- for k,v in pairs(players.admins) do
- if string.find(string.lower(players[k].name), string.lower(search)) then
- table.insert(matches, k)
- else
- for a,_ in pairs(players[k].alias) do
- if string.find(string.lower(a), string.lower(search)) then
- table.insert(matches, k)
- end
- end
- end
- end
- if #matches > 0 then
- console("Admins with names matching \"" .. search .. "\":")
- for k,v in ipairs(matches) do
- console("[" .. players[v].index .. "] " .. players[v].name)
- end
- return true
- end
- if validLevel(search) then
- local level = validLevel(search)
- for k,v in ipairs(players.levels[level].members) do
- table.insert(matches, v)
- end
- console("Admins in Admin Level \"" .. players.levels[level].name .. "\":")
- for k,v in ipairs(matches) do
- console("[" .. players[v].index .. "] " .. players[v].name)
- end
- return true
- end
- local hash = tohash(search, true, admin)
- if hash then
- if players.admins[hash] then
- console("true")
- else
- console("false")
- end
- return true
- end
- if validCommand(search) then
- for k,v in pairs(players.admins) do
- if canExecute(k, search) then
- table.insert(matches, k)
- end
- end
- console("Admins capable of executing \"" .. search .. "\":")
- for k,v in ipairs(matches) do
- console("[" .. players[v].index .. "] " .. players[v].name)
- end
- return true
- end
- for k,v in pairs(commands.syntax) do
- if string.find(string.lower(k), string.lower(search)) then
- for h,_ in pairs(players.admins) do
- if canExecute(h, k) then
- table.insert(matches, h)
- end
- end
- end
- end
- if #matches > 0 then
- console("Admins capable of executing commands matching \"" .. search .. "\":")
- for k,v in ipairs(matches) do
- console("[" .. players[v].index .. "] " .. players[v].name)
- end
- return true
- end
- console("Your search returned no results.")
- else
- console("Server Administrators:")
- for k,v in pairs(players.admins) do
- console("[" .. players[k].index .. "] " .. players[k].name)
- end
- end
- return true
- end
- function canExecute(id, command)
- if noAdmins() then
- return true
- else
- local hash = tohash(id)
- if hash then
- if validCommand(command) then
- local cmds = {}
- for k,v in ipairs(players[hash].commands) do
- if command == v then
- return true
- end
- end
- for k,v in ipairs(players[hash].adminlevels) do
- for _,c in ipairs(players.levels[v].commands) do
- if command == c then
- return true
- end
- end
- end
- else
- for k,v in ipairs(players[hash].shortcuts) do
- if command == v then
- return true
- end
- end
- end
- else
- return true
- end
- end
- end
- function sv_commands(admin, search)
- local matches = {}
- if search then
- if validLevel(search) then
- local level = validLevel(search)
- for k,v in ipairs(players.levels[level].commands) do
- table.insert(matches, v)
- end
- console("Commands executable by Admin Level \"" .. players.levels[level].name .. "\":")
- table.sort(matches)
- local mprint = printlist(matches, 4, " ")
- for k,v in ipairs(mprint) do
- console(v)
- end
- return true
- end
- for k,v in pairs(commands.syntax) do
- if string.find(k, search) then
- table.insert(matches, k)
- end
- end
- if #matches > 0 then
- console("Commands matching search \"" .. search .. "\":")
- table.sort(matches)
- local mprint = printlist(matches, 4, " ")
- for k,v in ipairs(mprint) do
- console(v)
- end
- return true
- end
- local hash = tohash(search, true, admin)
- if hash then
- for k,v in pairs(commands.syntax) do
- if canExecute(hash, k) then
- table.insert(matches, k)
- end
- end
- if #matches > 0 then
- console("Commands executable by [" .. players[hash].index .. "] " .. players[hash].name .. ":")
- local m = {}
- for k,v in ipairs(matches) do
- if not table.find(m, v) then
- table.insert(m, v)
- end
- end
- table.sort(m)
- local mprint = printlist(m, 4, " ")
- for k,v in ipairs(mprint) do
- console(v)
- end
- return true
- else
- console(players[hash].name .. " is not an administrator.")
- end
- end
- else
- local hash = gethash(admin)
- if hash then
- sv_commands(admin, hash)
- else
- for k,v in pairs(commands.syntax) do
- table.insert(matches, k)
- end
- table.sort(matches)
- local mprint = printlist(matches, 4, " ")
- for k,v in ipairs(mprint) do
- console(v)
- end
- end
- return true
- end
- console("Your search returned no results.")
- return false
- end
- function sv_command_add(admin, id, command)
- if validCommand(command) then
- if validLevel(id) then
- local level = validLevel(id)
- if not table.find(players.levels[level].commands, command) then
- table.insert(players.levels[level].commands, command)
- console("\"" .. command .. "\" can now be executed by Admin Level \"" .. players.levels[level].name .. "\".")
- else
- console("Admin Level \"" .. players.levels[level].name .. "\" can already execute \"" .. command .. "\".")
- end
- return true
- else
- local hash = tohash(id, true, admin)
- if hash then
- if not table.find(players[hash].commands, command) then
- table.insert(players[hash].commands, command)
- players.admins[hash] = true
- console(players[hash].name .. " can now execute \"" .. command .. "\".")
- else
- console(players[hash].name .. " can already execute \"" .. command .. "\".")
- end
- return true
- else
- console("Invalid Player or Admin Level.")
- end
- end
- else
- console("Invalid Command.")
- end
- return false
- end
- function sv_command_del(admin, id, command)
- if validCommand(command) then
- if validLevel(id) then
- local level = validLevel(id)
- for k,v in ipairs(players.levels[level].commands) do
- if v == command then
- table.remove(players.levels[level].commands, k)
- console("\"" .. command .. "\" can no longer be executed by Admin Level \"" .. players.levels[level].name .. "\".")
- return true
- end
- end
- console("Admin Level \"" .. players.levels[level].name .. "\" is not able to execute \"" .. command .. "\".")
- return true
- else
- local hash = tohash(id, true, admin)
- if hash then
- for k,v in ipairs(players[hash].commands) do
- if v == command then
- table.remove(players[hash].commands, k)
- console(players[hash].name .. " can no longer execute \"" .. command .. "\".")
- return true
- end
- end
- console(players[hash].name .. " is not able to execute \"" .. command .. "\".")
- return true
- else
- console("Invalid Player or Admin Level.")
- end
- end
- else
- console("Invalid Command.")
- end
- return false
- end
- function openaccess(id)
- local hash = tohash(id)
- if hash then
- if players[hash].openaccess then
- for c,_ in pairs(commands.syntax) do
- if not table.find(players[hash].commands, c) then
- table.insert(players[hash].commands, c)
- end
- end
- end
- end
- end
- function sv_openaccess(admin, id, boolean)
- if validLevel(id) then
- local level = validLevel(id)
- if boolean then
- if boolean == "true" or boolean == "1" then
- if players.levels[level].openaccess then
- console("Admin Level \"" .. players.levels[level].name .. "\" is already Open-Access.")
- else
- players.levels[level].openaccess = true
- for k,v in pairs(commands.syntax) do
- table.insert(players.levels[level].commands, k)
- end
- for k,v in ipairs(players.levels[level].members) do
- players[v].openaccess = true
- openaccess(v)
- end
- console("Admin Level \"" .. players.levels[level].name .. "\" is now Open-Access.")
- end
- elseif boolean == "false" or boolean == "0" then
- if players.levels[level].openaccess then
- players.levels[level].openaccess = nil
- for k,v in ipairs(players.levels[level].members) do
- players[v].openaccess = nil
- end
- console("Admin Level \"" .. players.levels[level].name .. "\" is no longer Open-Access.")
- else
- console("Admin Level \"" .. players.levels[level].name .. "\" isn't Open-Access.")
- end
- else
- console("Invalid Boolean.")
- return false
- end
- else
- if players.levels[level].openaccess then
- console("true")
- else
- console("false")
- end
- end
- else
- local hash = tohash(id, true, admin)
- if hash then
- if boolean then
- if boolean == "true" or boolean == "1" then
- if players[hash].openaccess then
- console(players[hash].name .. " is already an Open-Access administrator.")
- else
- players[hash].openaccess = true
- if not table.find(players.admins, hash) then
- table.insert(players.admins, hash)
- end
- openaccess(hash)
- console(players[hash].name .. " is now an Open-Access administrator.")
- end
- elseif boolean == "false" or boolean == "0" then
- if players[hash].openaccess then
- players[hash].openaccess = nil
- console(players[hash].name .. " is no longer an Open-Access administrator.")
- else
- console(players[hash].name .. " isn't an Open-Access administrator.")
- end
- else
- console("Invalid Boolean.")
- return false
- end
- else
- if players[hash].openaccess then
- console("true")
- else
- console("false")
- end
- end
- else
- console("Invalid Player or Admin Level.")
- return false
- end
- end
- return true
- end
- function addAdmin(hash, name, level)
- validPlayer(hash, name)
- local index = newLevelFromAccess(level, hash)
- if index then
- if not players.admins[hash] then
- svcmd("sv_admin_add " .. hash .. " " .. index)
- end
- end
- end
- function getaccess(level)
- local dir = getprofilepath()
- local access = io.open(dir .. "\\access.ini", "r")
- if access then
- local bool
- for line in access:lines() do
- if not bool then
- if string.find(line, "[" .. level .. "]") then
- bool = true
- end
- else
- if string.find(line, "data=") then
- return string.split(line:gsub("data=", ""), ",")
- end
- end
- end
- access:close()
- end
- end
- function newLevelFromAccess(id, hash)
- for k,v in ipairs(players.levels) do
- if players.levels[k].access == id then
- return players.levels[k].id
- end
- end
- local level = id - 1
- local overshoot
- repeat
- level = level + 1
- if level == 10 then
- level = 0
- end
- local index = "L" .. level
- if level == id - 1 then
- overshoot = true
- end
- until not validLevel(index) or level == id - 1
- if overshoot then
- return "L9"
- else
- local index = "L" .. level
- local cmds = getaccess(id)
- if cmds then
- local t = {}
- t.id = index
- t.name = "Level " .. level
- t.access = id
- t.members = {}
- t.commands = {"sv_players", "sv_unique", "sv_admins", "sv_commands", "sv_shortcut"}
- table.insert(players.levels, t)
- if tonumber(cmds[1]) == -1 then
- svcmd("sv_openaccess " .. index .. " true")
- else
- for k,v in ipairs(cmds) do
- svcmd("sv_command_add " .. index .. " " .. v)
- end
- end
- end
- return index
- end
- end
- --[[ Open-Access Handling ]]--
- for k,v in pairs(players) do
- if tonumber(k, 16) then
- openaccess(k)
- end
- end
- for k,v in ipairs(players.levels) do
- if players.levels[k].openaccess then
- for _,h in ipairs(players.levels[k].members) do
- openaccess(h)
- end
- end
- end
- -- Command Functions --
- -- Executes the given command.
- function Command(admin, cmd, tokens, noprint)
- local command = formatCommand(cmd, tokens, admin)
- if command then
- local bool, returned = execute(cmd, admin, unpack(command))
- if bool then
- return returned
- end
- end
- if noprint then
- clear()
- end
- end
- -- Formats command into a table in the correct order to be executed.
- function formatCommand(cmd, tokens, admin)
- admin = resolveplayer(admin)
- if validCommand(cmd) then
- if cmd == "sv_ban" or cmd == "sv_ban_penalty" then
- if tokens[3] then
- tokens[3] = table.concat(tokens, " ", 3, #tokens)
- for i = 4, #tokens do
- table.remove(tokens, 4)
- end
- end
- end
- local min_tokens = getMandatory(cmd)
- local max_tokens = getMaxTokens(cmd)
- if #tokens >= min_tokens and #tokens <= max_tokens then
- local command = {}
- if #commands.syntax[cmd] == 1 then
- command = {}
- elseif #commands.syntax[cmd] == 2 then
- command = {tokens[2]}
- elseif #commands.syntax[cmd] == 3 then
- command = {tokens[2], tokens[3]}
- else
- if cmd == "sv_mute" then
- local duration, message
- if tonumber(tokens[3]) then
- duration = tokens[3]
- message = tokens[4]
- else
- message = tokens[3]
- end
- command = {tokens[2], duration, message}
- elseif cmd == "sv_mutelist" then
- local search, direction, length
- if tonumber(tokens[2]) then
- length = tokens[2]
- elseif tonumber(tokens[3]) then
- search = tokens[2]
- length = tokens[3]
- else
- search = tokens[2]
- direction = tokens[3]
- length = tokens[4]
- end
- command = {search, direction, length}
- elseif cmd == "sv_swear_add" then
- local append, sweartype
- if #tokens == 3 then
- if getSweartype(tokens[3]) then
- sweartype = tokens[3]
- else
- append = tokens[3]
- end
- elseif #tokens == 4 then
- append = tokens[3]
- sweartype = tokens[4]
- end
- command = {tokens[2], append, sweartype}
- elseif cmd == "sv_create" then
- local player, object, respawn_time, x, y, z
- if #tokens == 7 then
- player = tokens[2]
- object = tokens[3]
- respawn_time = tokens[4]
- x = tokens[5]
- y = tokens[6]
- z = tokens[7]
- elseif #tokens == 6 then
- if tohash(tokens[2]) then
- player = tokens[2]
- object = tokens[3]
- respawn_time = 0
- x = tokens[4]
- y = tokens[5]
- z = tokens[6]
- else
- player = admin
- object = tokens[2]
- respawn_time = tokens[3]
- x = tokens[4]
- y = tokens[5]
- z = tokens[6]
- end
- elseif #tokens == 5 then
- player = admin
- object = tokens[2]
- respawn_time = 0
- x = tokens[3]
- y = tokens[4]
- z = tokens[5]
- elseif #tokens == 4 then
- player = tokens[2]
- object = tokens[3]
- respawn_time = tokens[4]
- elseif #tokens == 3 then
- if tohash(tokens[2]) then
- player = tokens[2]
- object = tokens[3]
- else
- player = admin
- object = tokens[2]
- respawn_time = tokens[3]
- end
- elseif #tokens == 2 then
- player = admin
- object = tokens[2]
- end
- command = {player, object, respawn_time, x, y, z}
- elseif cmd == "sv_ammo" then
- local weap, ammo, clip
- if #tokens == 5 then
- weap = tokens[3]
- ammo = tokens[4]
- clip = tokens[5]
- elseif #tokens == 4 then
- weap = "all"
- ammo = tokens[3]
- clip = tokens[4]
- end
- command = {tokens[2], weap, ammo, clip}
- else
- for i = 2, #tokens do
- table.insert(command, tokens[i])
- end
- end
- end
- return command
- end
- end
- end
- -- Returns the amount of mandatory parameters for a given command.
- function getMandatory(cmd)
- local count = 0
- for _,v in ipairs(commands.syntax[cmd]) do
- if not string.find(v, "opt: ") then
- count = count + 1
- end
- end
- return count
- end
- function getMaxTokens(cmd)
- for k,v in ipairs(commands.syntax[cmd]) do
- if string.find(v, "...") then
- return math.inf
- end
- end
- return #commands.syntax[cmd]
- end
- function validCommand(cmd)
- for k,_ in pairs(commands.syntax) do
- if cmd == k then
- return true
- end
- end
- end
- function getSyntax(cmd)
- if commands.syntax[cmd] then
- return "Syntax: " .. table.concat(commands.syntax[cmd], " ")
- end
- end
- function ncmd(tokens, player)
- local cmd = tokens[1]
- if validCommand(cmd) then
- Command(admin, cmd, tokens, true)
- end
- end
- function clear()
- cprint = {}
- sprint = {}
- for k,v in ipairs(pprint) do
- pprint[k] = {}
- end
- end
- -- Help Command
- function sv_help(admin, cmd)
- if validCommand(cmd) then
- console(cmd .. ":")
- for _,v in ipairs(commands.syntax[cmd]) do
- if v == cmd then
- console(commands.info[cmd][1] .. "\n ")
- console("Syntax: " .. table.concat(commands.syntax[cmd], " ") .. "\n ")
- else
- local s = string.gsub(v, "opt: ", "")
- local p = string.gsub(s, "...", "")
- if commands.info[p] then
- for __,value in ipairs(commands.info[p]) do
- console(value)
- end
- else
- console(p .. ": <Need an Information Entry here>")
- end
- end
- end
- console("\n ")
- for i = 2, #commands.info[cmd] do
- console(commands.info[cmd][i])
- end
- return true
- end
- console("Invalid Command.")
- return false
- end
- -- Command Rewrites --
- -- Rewrites
- --[[ Rewritten Halo DS Command Functions ]]--
- local function getPrint(command)
- local msg = svcmd(command, 16)
- return string.split(msg, "\n")
- end
- function defcmd(player, command)
- local hash = gethash(player)
- execute_original = true
- if hash then
- if chat[hash] then
- local msgs = getPrint(command)
- for _,v in ipairs(msgs) do
- console(v)
- end
- else
- svcmd(command, player)
- end
- else
- svcmd(command)
- end
- end
- -- Ban Commands
- banned = table.load("banlist") or {}
- local function toSeconds(entry)
- if entry then
- if string.find(entry, "inf") then
- return -1
- elseif tonumber(entry) then
- return tonumber(entry) * 60 * 60 * 24
- elseif entry == "0s" then
- return 0
- else
- local time = 0
- local num = ""
- for i = 1, string.len(entry) do
- local char = string.sub(entry, i, i)
- if tonumber(char) then
- num = num .. char
- else
- local seconds = 0
- if char == "s" then
- seconds = tonumber(num)
- elseif char == "m" then
- seconds = tonumber(num) * 60
- elseif char == "h" then
- seconds = tonumber(num) * 60 * 60
- elseif char == "d" then
- seconds = tonumber(num) * 60 * 60 * 24
- end
- time = time + seconds
- num = ""
- end
- end
- if time > 0 then
- return time
- end
- end
- end
- end
- function banpenalty(bancount, penalty)
- if tonumber(bancount) then
- bancount = tonumber(bancount)
- if penalty ~= "" then
- local bantime = toSeconds(penalty)
- if bantime then
- values.banpenalty = values.banpenalty or {}
- values.banpenalty[bancount] = bantime
- else
- return "Invalid Ban Penalty."
- end
- else
- values.banpenalty[bancount] = nil
- end
- else
- return "Invalid Bancount."
- end
- end
- function sv_ban_penalty(admin, bancount, penalty)
- if bancount then
- if penalty then
- local err = banpenalty(bancount, penalty)
- if not err then
- if penalty ~= "" then
- local bantime = toSeconds(penalty)
- console("Bancount Penalty")
- console("[" .. bancount .. "] " .. secondsToTime(bantime))
- else
- console("There is no longer a default Ban Penalty for players who have been banned " .. bancount .. " times.")
- end
- return true
- end
- console(err)
- return false
- else
- if tonumber(bancount) then
- bancount = tonumber(bancount)
- if values.banpenalty[bancount] then
- console("Bancount: " .. bancount .. " | Penalty: " .. secondsToTime(values.banpenalty[bancount]))
- return true
- else
- console("There is no specific penalty for being banned " .. bancount .. " times.")
- end
- else
- console("Invalid Bancount.")
- end
- return false
- end
- else
- local bancounts = {}
- for k,v in pairs(values.banpenalty) do
- table.insert(bancounts, k)
- end
- table.sort(bancounts, function(a, b) return a < b end)
- console("Bancount Penalty")
- for k,v in ipairs(bancounts) do
- console("[" .. v .. "] " .. secondsToTime(values.banpenalty[v]))
- end
- return true
- end
- end
- -- Ban Updating
- if not values.banpenalty then
- banpenalty(1, "inf")
- end
- function BanTimer(id, count)
- for k,v in ipairs(banned) do
- players[v].bantime = players[v].bantime - 1
- if math.ceil(players[v].bantime) == 0 then
- unban(v)
- end
- end
- return 1
- end
- function ban(id, name, bantime)
- if not toSeconds(bantime) then
- name = bantime
- bantime = nil
- end
- local hash = tohash(id, false, -1, name)
- if hash then
- if not players[hash].banned then
- local player = hashtoplayer(hash)
- if player then
- local playernum = resolveplayer(player)
- execute_original = true
- svcmd("sv_ban " .. playernum)
- players[hash].banned = true
- players[hash].bancount = players[hash].bancount + 1
- players[hash].bantime = players[hash].bantime or toSeconds(bantime) or values.banpenalty[players[hash].bancount] or -1
- table.insert(banned, hash)
- else
- players[hash].bos = true
- players[hash].bantime = toSeconds(bantime) or values.banpenalty[players[hash].bancount] or -1
- end
- else
- return players[hash].name .. " is already banned."
- end
- else
- return "Invalid Player."
- end
- end
- function sv_ban(admin, id, bantime)
- local hash = tohash(id, true, admin)
- if hash then
- local name
- if players[hash] then
- name = players[hash].name
- else
- name = "Anonymous"
- end
- local err = ban(hash, name, bantime)
- if not err then
- if hashtoplayer(hash) then
- console("[" .. players[hash].index .. "] " .. getname(hashtoplayer(hash)) .. " has been banned for " .. secondsToTime(players[hash].bantime) .. ".")
- say(getname(hashtoplayer(hash)) .. " has been banned.")
- else
- console("[" .. players[hash].index .. "] " .. players[hash].name .. " will be banned on sight.")
- end
- return true
- else
- console(err)
- end
- else
- console("Invalid Player.")
- end
- return false
- end
- function unban(id)
- local hash = tohash(id)
- if hash then
- local dir = getprofilepath()
- local banlist = io.open(dir .. "\\banned.txt", "r")
- if banlist then
- local index = -1
- for line in banlist:lines() do
- local info = string.split(line, ",")
- if hash == info[2] then
- execute_original = true
- svcmd("sv_unban " .. index)
- banlist:close()
- for k,v in ipairs(banned) do
- if v == hash then
- table.remove(banned, k)
- end
- end
- players[hash].banned = false
- players[hash].bantime = nil
- return nil
- end
- index = index + 1
- end
- banlist:close()
- return players[hash].name .. " is not banned."
- else
- return "Unable to access banlist file."
- end
- else
- return "Invalid Player."
- end
- end
- function sv_unban(admin, id)
- local hash = tohash(id, true, admin)
- local err = unban(hash)
- if not err then
- console("[" .. players[hash].index .. "] " .. players[hash].name .. " has been unbanned.")
- return true
- end
- console(err)
- return false
- end
- function sv_banlist(admin)
- local banlist = {}
- for _,v in ipairs(banned) do
- table.insert(banlist, "[" .. players[v].index .. "] " .. players[v].name .. " (" .. players[v].bancount .. ")")
- end
- if #banlist > 0 then
- console("Banned players by Server Index, Name, and Bancount:")
- local mprint = printlist(banlist, 3, " | ")
- for _,v in ipairs(mprint) do
- console(v)
- end
- else
- console("The banlist is empty.")
- end
- return true
- end
- -- Kick
- function sv_kick(admin, id)
- local hash = tohash(id, true, admin)
- if hash then
- local player = hashtoplayer(hash)
- if player then
- local playernum = resolveplayer(player)
- execute_original = true
- svcmd("sv_kick " .. playernum)
- players[hash].kickcount = players[hash].kickcount + 1
- console("[" .. players[hash].index .. "] " .. getname(player) .. " has been kicked.")
- say(getname(player) .. " has been kicked.")
- if players[hash].kickcount > 4 then
- console(getname(player) .. " has been kicked " .. players[hash].kickcount .. " times. Consider a ban if their behavior continues.")
- end
- return true
- else
- console(players[hash].name .. " is not currently in the server.")
- end
- else
- console("Invalid Player.")
- end
- return false
- end
- -- Friendly Fire
- function sv_friendly_fire(admin, entry)
- if entry then
- local value
- if string.find(entry, "def") then
- value = 0
- elseif entry == "off" then
- value = 1
- elseif string.find(entry, "shiel") then
- value = 2
- elseif entry == "on" then
- value = 3
- else
- value = tonumber(entry)
- end
- if value then
- defcmd(admin, "sv_friendly_fire " .. value)
- else
- console("Invalid Value.")
- end
- else
- defcmd(admin, "sv_friendly_fire")
- return true
- end
- return false
- end
- -- Gamelist
- function sv_gamelist(admin, search)
- defcmd(admin, "sv_gamelist " .. (search or '""'))
- return true
- end
- -- Map Commands
- function sv_map(admin, map, gametype, ...)
- defcmd(admin, "sv_map " .. map .. " " .. gametype .. " " .. table.concat({...}, " "))
- return true
- end
- function sv_map_next(admin)
- defcmd(admin, "sv_map_next")
- return true
- end
- function sv_map_reset(admin, count)
- if count then
- if tonumber(count) then
- registertimer(500, "MapResetTimer", tonumber(count))
- console("Map reset " .. count .. " times.")
- return true
- else
- console("Invalid Count.")
- end
- else
- defcmd(admin, "sv_map_reset")
- return true
- end
- return false
- end
- function MapResetTimer(id, count, times)
- if count <= times then
- svcmd("sv_map_reset")
- return 1
- end
- return 0
- end
- function sv_mapcycle(admin)
- defcmd(admin, "sv_mapcycle")
- return true
- end
- function sv_mapcycle_add(admin, map, gametype, ...)
- defcmd(admin, "sv_mapcycle_add " .. map .. " " .. gametype .. " " .. (... or ""))
- return true
- end
- function sv_mapcycle_del(admin, index)
- defcmd(admin, "sv_mapcycle_del " .. index)
- return true
- end
- function sv_mapcycle_begin(admin)
- defcmd(admin, "sv_mapcycle_begin")
- return true
- end
- function sv_mapvote(admin, bool)
- defcmd(admin, "sv_mapvote " .. bool)
- end
- function sv_mapvote_add(admin, map, gametype, description, ...)
- defcmd(admin, "sv_mapvote_add " .. map .. " " .. gametype .. " " .. (... or ""))
- return true
- end
- function sv_mapvote_del(admin, index)
- defcmd(admin, "sv_mapvote_del " .. index)
- return true
- end
- function sv_mapvote_list(admin)
- defcmd(admin, "sv_mapvote_list")
- return true
- end
- function sv_mapcycle_timeout(admin, value)
- if value then
- if tonumber(value) then
- defcmd(admin, "sv_mapcycle_timeout " .. value)
- return true
- end
- console("Invalid Value.")
- return false
- end
- defcmd(admin, "sv_mapcycle_timeout")
- return true
- end
- function sv_maplist(admin, search)
- defcmd(admin, "sv_maplist " .. (search or "\b"))
- return true
- end
- function sv_maxplayers(admin, value)
- if value then
- if tonumber(value) then
- if tonumber(value) <= 16 then
- defcmd(admin, "sv_maxplayers " .. value)
- return true
- else
- console("Maxplayers must be between 0 and 16.")
- end
- else
- console("Invalid Value.")
- end
- else
- defcmd(admin, "sv_maxplayers")
- return true
- end
- return false
- end
- function sv_name(admin, name)
- if name then
- defcmd(admin, "sv_name " .. name)
- else
- defcmd(admin, "sv_name")
- end
- return true
- end
- function sv_password(admin, password)
- local server_password = readstring(0x69B93C, 0x1, 8) -- Confirmed. Current server password for the server (will be nullstring if there is no password)
- if password then
- if string.len(password) <= 8 then
- defcmd(admin, "sv_password " .. password)
- return true
- else
- console("Password must be 8 characters or less.")
- end
- else
- defcmd(admin, "sv_password")
- return true
- end
- return false
- end
- function sv_public(admin, boolean)
- if boolean then
- if boolean == "1" or boolean == "true" then
- defcmd(admin, "sv_public 1")
- elseif boolean == "0" or boolean == "false" then
- defcmd(admin, "sv_public 0")
- else
- console("Invalid Boolean.")
- return false
- end
- else
- defcmd(admin, "sv_public")
- end
- return true
- end
- function sv_rcon_password(admin, password)
- local rcon_password = readstring(0x69BA5C, 0x0, 0x2C) -- Confirmed. Current rcon password for the server.
- if password then
- if string.len(password) <= 8 then
- defcmd(admin, "sv_rcon_password " .. password)
- return true
- else
- console("Password must be 8 characters or less.")
- end
- else
- defcmd(admin, "sv_rcon_password")
- return true
- end
- return false
- end
- function sv_single_flag_force_reset(admin, boolean)
- if boolean then
- if boolean == "1" or boolean == "true" then
- defcmd(admin, "sv_single_flag_force_reset 1")
- elseif boolean == "0" or boolean == "false" then
- defcmd(admin, "sv_single_flag_force_reset 0")
- else
- console("Invalid Boolean.")
- return false
- end
- else
- defcmd(admin, "sv_single_flag_force_reset")
- end
- return true
- end
- function sv_status(admin)
- defcmd(admin, "sv_status")
- return true
- end
- function sv_timelimit(admin, timelimit)
- local gametype_time_passed = readdword(readdword(gametype_base, 0xE0), 0xC) -- Confirmed. (1 second = 30 ticks)
- defcmd(admin, "sv_timelimit " .. (timelimit or "\b"))
- return true
- end
- function sv_tk_ban(admin, value)
- defcmd(admin, "sv_tk_ban " .. (value or "\b"))
- return true
- end
- function sv_tk_cooldown(admin, value)
- defcmd(admin, "sv_tk_cooldown " .. (value or "\b"))
- return true
- end
- function sv_tk_grace(admin, value)
- defcmd(admin, "sv_tk_grace " .. (value or "\b"))
- return true
- end
- --[[ Rewritten Phasor Command Functions ]]--
- phasorinvis = applycamo
- function sv_reloadscripts(admin)
- defcmd(admin, "sv_reloadscripts")
- return true
- end
- function sv_mapvote_begin(admin)
- defcmd(admin, "sv_mapvote_begin")
- return true
- end
- function sv_teams_balance(admin)
- defcmd(admin, "sv_teams_balance")
- return true
- end
- function sv_teams_lock(admin)
- defcmd(admin, "sv_teams_lock")
- return true
- end
- function sv_teams_unlock(admin)
- defcmd(admin, "sv_teams_unlock")
- return true
- end
- function sv_changeteam(admin, id)
- local hash = tohash(id, true, admin)
- if hash then
- local player = hashtoplayer(hash)
- if player then
- local playerId = resolveplayer(player)
- defcmd(admin, "sv_changeteam " .. playerId)
- return true
- else
- console(players[hash].name .. " is not currently in the server.")
- end
- else
- console("Invalid Player.")
- end
- return false
- end
- function teleport(id, ...)
- local hash = tohash(id)
- if hash then
- local player = hashtoplayer(hash)
- if player then
- if #args > 0 then
- if #args == 1 then
- local dir = getprofilepath()
- local locations = io.open(dir .. "\\data\\locations.txt")
- for line in locations:lines() do
- local tokens = string.split(line, ",")
- local map = tokens[1]
- local name = tokens[2]
- local x = tonumber(tokens[3])
- local y = tonumber(tokens[4])
- local z = tonumber(tokens[5])
- if map == this.map then
- if string.lower(args[1]) == string.lower(name) then
- teleport(id, x, y, z)
- end
- end
- end
- locations:close()
- elseif #args == 3 then
- local x = tonumber(args[1])
- local y = tonumber(args[2])
- local z = tonumber(args[3])
- local m_player = getplayer(player)
- local m_objId = readdword(m_player, 0x34)
- if m_objId ~= 0xFFFFFFFF then
- movobjcoords(m_objId, x, y, z)
- else
- return getname(player) .. " is dead."
- end
- else
- return "Invalid Location."
- end
- else
- return "Invalid Location."
- end
- else
- return players[hash].name .. " is not currently in the server."
- end
- else
- return "Invalid Player."
- end
- end
- function sv_teleport(admin, id, ...)
- local hash = tohash(id, true, admin)
- local err = teleport(hash, ...)
- if not err then
- local player = hashtoplayer(hash)
- if #args == 1 then
- private(player, "You have been teleported to location \"" .. args[1] .. "\".")
- console(getname(player) .. " has been teleported to location \"" .. args[1] .. "\".")
- else
- private(player, "You have been teleported to [" .. args[1] .. " " .. args[2] .. " " .. args[3] .. "].")
- console(getname(player) .. " has been teleported to [" .. args[1] .. " " .. args[2] .. " " .. args[3] .. "].")
- end
- return true
- end
- console(err)
- return false
- end
- function sv_teleport_to(admin, tp_id, dest_id)
- local tp_hash = tohash(tp_id, true, admin)
- local dest_hash = tohash(dest_id, true, admin)
- if tp_hash then
- if dest_hash then
- local tp_player = hashtoplayer(tp_hash)
- local dest_player = hashtoplayer(dest_hash)
- if tp_player then
- if dest_player then
- local tp_playerId = resolveplayer(tp_player)
- local dest_playerId = resolveplayer(dest_player)
- defcmd(admin, "sv_teleport_pl " .. tp_playerId .. " " .. dest_playerId)
- return true
- else
- console(players[dest_hash].name .. " is not currently in the server.")
- end
- else
- console(players[tp_hash].name .. " is not currently in the server.")
- end
- else
- console("Invalid Destination Player.")
- end
- else
- console("Invalid Teleporting Player.")
- end
- return false
- end
- function sv_teleport_add(admin, location, x, y, z)
- if not y and not z then
- defcmd(admin, "sv_teleport_add " .. location)
- else
- defcmd(admin, "sv_teleport_add " .. location .. " " .. x .. " " .. y .. " " .. (z or ""))
- end
- return true
- end
- function sv_teleport_del(admin, index)
- defcmd(admin, "sv_teleport_del " .. index)
- return true
- end
- function sv_teleport_list(admin)
- defcmd(admin, "sv_teleport_list")
- return true
- end
- function sv_kickafk(admin, time)
- defcmd(admin, "sv_kickafk " .. (time or ""))
- return true
- end
- function sv_host(admin, details)
- defcmd(admin, "sv_host " .. details)
- return true
- end
- function sv_say(admin, message)
- server(message)
- hprintf("**SERVER** " .. message)
- return true
- end
- function sv_gethash(admin, id)
- local hash = tohash(id, true, admin)
- if hash then
- console(hash)
- return true
- end
- console("Invalid Player.")
- return false
- end
- function sv_chatids(admin, boolean)
- defcmd(admin, "sv_chatids " .. (boolean or ""))
- return true
- end
- function sv_disablelog(admin)
- defcmd(admin, "sv_disablelog")
- return true
- end
- function sv_logname(admin, logtype, logname)
- defcmd(admin, "sv_logname " .. logtype .. " " .. logname)
- return true
- end
- function sv_savelog(admin)
- defcmd(admin, "sv_savelog")
- return true
- end
- function sv_loglimit(admin, logtype, logsize)
- defcmd(admin, "sv_loglimit " .. logtype .. " " .. logsize)
- return true
- end
- function sv_getobject(admin, id)
- local hash = tohash(id, true, admin)
- if hash then
- local player = hashtoplayer(hash)
- if player then
- local playerId = resolveplayer(player)
- defcmd(admin, "sv_getobject " .. playerId)
- return true
- else
- console(players[hash].name .. " is not currently in the server.")
- end
- else
- console("Invalid Player.")
- end
- return false
- end
- function sv_kill(admin, victim, killer)
- local hashes = pack(tohash(victim, true, admin))
- if #hashes > 1 then
- for _,v in ipairs(hashes) do
- sv_kill(admin, v, message)
- end
- server(toTeam(id) .. " players have been killed by the server.")
- return true
- else
- local hash = unpack(hashes)
- if hash then
- local player = hashtoplayer(hash)
- if player then
- local m_player = getplayer(player)
- local m_objId = readdword(m_player, 0x34)
- local m_object = getobject(m_objId)
- if m_object then
- if not killer then
- kill(player)
- private(player, "You have been killed by the server.")
- console(getname(player) .. " has been killed.")
- return true
- --[[else
- local khash = tohash(killer, true, admin)
- if khash then
- local kplayer = hashtoplayer(khash)
- if kplayer then
- local k_objId = readdword(m_player, 0x34)
- local k_object = getobject(k_objId)
- for i = 1, 50 do
- local x, y, z = getobjectcoords(m_objId)
- createobject("jpt!", "globals\\flaming_death", k_objId, 0, false, x, y, z)
- end
- console(getname(player) .. " was killed by " .. getname(kplayer))
- return true
- else
- console(players[khash].name .. " is not currently in the server.")
- end
- else
- console("Invalid Killer.")
- end--]]
- end
- else
- console(getname(player) .. " is already dead.")
- end
- else
- console(players[hash].name .. " is not currently in the server.")
- end
- else
- console("Invalid Player.")
- end
- end
- return false
- end
- -- Camo Stuff --
- invis = {}
- function applycamo(id, duration)
- local hash = tohash(id)
- if hash then
- local player = hashtoplayer(hash)
- if player then
- duration = tonumber(duration)
- if duration then
- if duration > 0 then
- invis[hash] = duration
- registertimer(1000, "InvisTimer", player, duration)
- else
- invis[hash] = math.inf
- registertimer(1000, "InvisTimer", player, math.inf)
- end
- end
- end
- end
- end
- function sv_invis(admin, id, duration)
- if id then
- if not duration or tonumber(duration) then
- local hashes = pack(tohash(id, true, admin))
- if #hashes > 1 then
- for _,v in ipairs(hashes) do
- sv_invis(admin, v, duration)
- end
- if duration then
- server(toTeam(id) .. " players have been given camouflage for " .. duration .. " seconds.")
- else
- server(toTeam(id) .. " players have been given camouflage until death.")
- end
- return true
- else
- local hash = unpack(hashes)
- if hash then
- local player = hashtoplayer(hash)
- if player then
- duration = tonumber(duration)
- if duration then
- if duration >= 1093 then
- duration = nil
- end
- end
- if duration then
- invis[hash] = duration
- registertimer(1000, "InvisTimer", player, duration)
- private(player, "You have been given camouflage for " .. duration .. " seconds.")
- console(getname(player) .. " has been given camouflage for " .. duration .. " seconds.")
- else
- invis[hash] = math.inf
- registertimer(1000, "InvisTimer", player, math.inf)
- private(player, "You have been given camouflage until death.")
- console(getname(player) .. " has been given camouflage until death.")
- end
- return true
- else
- console(players[hash].name .. " is not currently in the server.")
- end
- else
- console("Invalid Player.")
- end
- end
- else
- console("Invalid Duration.")
- end
- else
- local pl = {}
- for i = 0, 15 do
- local hash = gethash(i)
- if hash then
- local invistime = invis[hash]
- if invistime then
- if invistime > 0 then
- if invistime < 1093 then
- table.insert(pl, getname(i) .. ": " .. invistime .. " seconds")
- else
- table.insert(pl, getname(i) .. ": Until Death")
- end
- end
- end
- end
- end
- if #pl > 0 then
- console("Invisible players and Invis Time left:")
- for k,v in ipairs(pl) do
- console(v)
- end
- else
- console("No players are currently invisible.")
- end
- return true
- end
- return false
- end
- function InvisTimer(id, count, player, duration)
- local hash = gethash(player)
- if hash then
- if invis[hash] then
- invis[hash] = invis[hash] - 1
- if invis[hash] > 0 then
- phasorinvis(player, 1)
- return 1
- end
- end
- end
- return 0
- end
- function sv_uninvis(admin, id)
- local hashes = pack(tohash(id, true, admin))
- if #hashes > 1 then
- for _,v in ipairs(hashes) do
- sv_uninvis(admin, v)
- end
- server(toTeam(id) .. " players are no longer invisible.")
- else
- local hash = unpack(hashes)
- if hash then
- local player = hashtoplayer(hash)
- if player then
- if invis[hash] then
- invis[hash] = nil
- console(players[hash].name .. " is no longer invisible.")
- else
- console(players[hash].name .. " is not invisible.")
- end
- return true
- else
- console(players[hash].name .. " is not currently in the server.")
- end
- else
- console("Invalid Player.")
- end
- end
- return false
- end
- function setspeed(id, speed, duration)
- local hash = tohash(id)
- if hash then
- local player = hashtoplayer(hash)
- if player then
- local m_player = getplayer(player)
- if m_player then
- local cur_speed = readfloat(m_player, 0x6C)
- if tonumber(speed) then
- writefloat(m_player, 0x6C, tonumber(speed))
- if duration then
- if tonumber(duration) then
- registertimer(1000, "SpeedTimer", player, tonumber(duration), cur_speed)
- else
- return "Invalid Duration Entry."
- end
- end
- else
- local value = editValue(cur_speed, speed)
- if value then
- writefloat(m_player, 0x6C, value)
- else
- return "Invalid Speed Entry."
- end
- end
- else
- return players[hash].name .. " is inaccessible at this time."
- end
- else
- return players[hash].name .. " is not currently in the server."
- end
- else
- return "Invalid Player."
- end
- end
- function getspeed(id)
- local hash = tohash(id)
- if hash then
- local player = hashtoplayer(id)
- if player then
- local m_player = getplayer(player)
- if m_player then
- return readfloat(m_player, 0x6C)
- end
- end
- end
- end
- function sv_setspeed(admin, id, speed, duration)
- local hashes = pack(tohash(id, true, admin))
- if #hashes > 1 then
- for _,v in ipairs(hashes) do
- local executed = sv_setspeed(v, speed, duration)
- if not executed then
- return false
- end
- end
- if tonumber(speed) then
- server(toTeam(id) .. " players' speeds have been changed to " .. speed)
- else
- server(toTeam(id) .. " players' speeds have been edited.")
- end
- return true
- else
- local hash = unpack(hashes)
- if hash then
- local err = setspeed(hash, speed, duration)
- if not err then
- local player = hashtoplayer(hash)
- local cur_speed = getspeed(hash)
- local new_speed = editValue(cur_speed, speed)
- if not duration then
- private(player, "Your speed has been changed to " .. math.round(new_speed, 2) .. ".")
- else
- private(player, "Your speed has been changed to " .. math.round(new_speed, 2) .. " for " .. duration .. " seconds.")
- end
- return true
- else
- console(err)
- end
- else
- console("Invalid Player.")
- end
- end
- return false
- end
- function SpeedTimer(id, count, player, duration, old_speed)
- if count >= duration then
- setspeed(player, old_speed)
- hprint(player, "Your speed is now " .. math.round(old_speed, 2) .. ".")
- return 0
- elseif count >= duration - 5 then
- hprint(player, "Your speed will return to " .. math.round(old_speed, 2) .. " in " .. math.ceil(duration - count) .. " seconds.", 1)
- end
- return 1
- end
- -- Object Functions --
- local function newObjectIndex()
- local id = convertbase((objects.unique or 1) - 1, 36)
- while string.len(id) < 4 do
- id = "0" .. id
- end
- return id
- end
- function isDestroyed(m_objId)
- if getobject(m_objId) then
- return false
- end
- return true
- end
- function newObject(m_objId)
- objects.unique = (objects.unique or 0) + 1
- local tagtype, tagname = getobjecttag(m_objId)
- m_objId = tostring(m_objId)
- objects[m_objId] = {}
- objects[m_objId].tagtype = tagtype
- objects[m_objId].tagname = tagname
- objects[m_objId].index = newObjectIndex()
- end
- function getobjid(id)
- if string.len(id) == 4 then
- for k,v in pairs(objects) do
- if k ~= "unique" then
- if objects[k].index == id then
- return k
- end
- end
- end
- else
- if getobject(id) then
- return id
- end
- end
- end
- function toTag(search)
- search = string.lower(search)
- local matches = {}
- local function matchAdd(tagtype, tagname)
- local tag = {tagtype, tagname}
- table.insert(matches, tag)
- end
- -- Check if search is a tag type (i.e. "weap", "proj", "jpt!", etc)
- for t,v in pairs(tags) do
- t = string.lower(t)
- if search == t then
- for n,s in pairs(v) do
- matchAdd(t, n)
- end
- return unpack(matches)
- end
- end
- -- Check if search is a tag name (i.e. "weapons\\assault rifle\\assault rifle") or a shortcut exactly (i.e. "Assault Rifle")
- for t,v in pairs(tags) do
- for n,s in pairs(v) do
- n = string.lower(n)
- s = string.lower(s)
- if search == n or search == s then
- return {t, n}
- end
- end
- end
- -- Key words
- -- Exact matches:
- -- Scenery Items:
- if search == "rock" or search == "rocks" or search == "boulder" or search == "boulders" then
- for n,s in pairs(tags.scen) do
- s = string.lower(s)
- if string.find(s, "rock") or string.find(s, "boulder") then
- matchAdd("scen", n)
- end
- end
- return unpack(matches)
- elseif search == "tree" or search == "trees" then
- for n,s in pairs(tags.scen) do
- s = string.lower(s)
- if string.find(s, "tree") then
- matchAdd("scen", n)
- end
- end
- return unpack(matches)
- elseif search == "bush" or search == "bushes" or search == "shrub" or search == "shrubs" then
- for n,s in pairs(tags.scen) do
- s = string.lower(s)
- if string.find(s, "shrub") or string.find(s, "fern") or string.find(s, "broadleaf") then
- matchAdd("scen", n)
- end
- end
- return unpack(matches)
- elseif search == "shield" then
- return {"scen", "scenery\\c_field_generator\\c_field_generator"}
- -- Projectile:
- elseif search == "needle" then
- return {"proj", "weapons\\needler\\mp_needle"}
- -- Weapons:
- elseif search == "rocket" then
- return {"weap", "weapons\\rocket launcher\\rocket launcher"}
- elseif search == "ar" or search == "assaultrifle" then
- return {"weap", "weapons\\assault rifle\\assault rifle"}
- elseif search == "pp" or search == "plasmapistol" then
- return {"weap", "weapons\\plasma pistol\\plasma pistol"}
- elseif search == "pr" or search == "plasmarifle" then
- return {"weap", "weapons\\plasma rifle\\plasma rifle"}
- elseif search == "sniper" then
- return {"weap", "weapons\\sniper rifle\\sniper rifle"}
- elseif search == "ball" then
- return {"weap", "weapons\\ball\\ball"}
- elseif search == "flag" then
- return {"weap", "weapons\\flag\\flag"}
- -- Powerups:
- elseif search == "camo" or search == "invis" then
- return {"eqip", "powerups\\active camouflage"}
- elseif search == "os" then
- return {"eqip", "powerups\\over shield"}
- elseif search == "doublespd" or search == "dblspd" then
- return {"eqip", "powerups\\double speed"}
- -- Vehicles:
- elseif search == "hog" then
- return {"vehi", "vehicles\\warthog\\mp_warthog"}
- elseif search == "rockethog" or search == "rocket hog" then
- return {"vehi", "vehicles\\rwarthog\\rwarthog"}
- elseif search == "shee" then
- return {"vehi", "vehicles\\banshee\\banshee_mp"}
- elseif search == "turret" then
- return {"vehi", "vehicles\\c gun turret\\c gun turret_mp"}
- elseif search == "tank" or search == "scorp" then
- return {"vehi", "vehicles\\scorpion\\scorpion_mp"}
- -- Biped:
- elseif search == "cyborg" or search == "masterchief" or search == "mc" then
- return {"bipd", "characters\\cyborg_mp\\cyborg_mp"}
- end
- -- Loose search
- -- Projectiles:
- if string.find(search, "proj") then
- if string.find(search, "rocket") then
- return {"proj", "weapons\\rocket launcher\\rocket"}
- elseif string.find(search, "flamethrower") then
- return {"proj", "weapons\\flamethrower\\flame"}
- end
- end
- search = search:gsub("tank", "scorpion")
- search = search:gsub("rocket", "Rocket")
- search = search:gsub("rock", "rock boulder")
- search = search:gsub("boulder", "rock boulder")
- search = string.lower(search)
- for t,v in pairs(tags) do
- for n,s in pairs(v) do
- n = string.lower(n)
- s = string.lower(s)
- if string.find(n, search) or string.find(s, search) then
- matchAdd(t, n)
- end
- end
- end
- return unpack(matches)
- end
- function sv_objects(admin, search)
- local matches = {}
- if not search then
- for k,v in pairs(objects) do
- if k ~= "unique" then
- table.insert(matches, k)
- end
- end
- else
- local tags = pack(toTag(search))
- if unpack(tags) then
- for k,v in pairs(objects) do
- if k ~= "unique" then
- for _,t in ipairs(tags) do
- if objects[k].tagname == t[2] then
- table.insert(matches, k)
- end
- end
- end
- end
- end
- end
- if unpack(matches) then
- table.sort(matches)
- console("Objects matching search \"" .. (search or "") .. "\":")
- local count = 0
- for k,v in ipairs(matches) do
- if gethash(admin) then
- if count == 20 then break end
- else
- console("[" .. objects[v].index .. "] " .. objects[v].tagname)
- count = count + 1
- end
- end
- else
- console("Your search returned no matches.")
- end
- return true
- end
- function sv_destroy(admin, id)
- local m_objId = getobjid(id)
- if m_objId then
- destroyobject(m_objId)
- console("[" .. id .. "] \"" .. objects[m_objId].tagname .. "\" destroyed.")
- else
- local matches = {}
- local tagmatches = pack(toTag(id))
- if unpack(tagmatches) then
- for _,t in ipairs(tagmatches) do
- for k,v in pairs(objects) do
- if k ~= "unique" then
- if not objects[k].destroyed then
- if objects[k].tagname == t[2] then
- local tagType, tagName = objects[k].tagtype, objects[k].tagname
- local name = tags[tagType][tagName]
- destroyobject(k)
- table.insert(matches, name)
- end
- end
- end
- end
- end
- end
- if unpack(matches) then
- local matches2 = {}
- for k,v in ipairs(matches) do
- if not table.find(matches2, v) then
- table.insert(matches2, v)
- end
- end
- console("Objects destroyed:")
- local mprint = printlist(matches2, 5, " ")
- for k,v in ipairs(mprint) do
- console(v)
- end
- server("The following objects have been destroyed:")
- local mprint2 = printlist(matches2, 5, " | ")
- for k,v in ipairs(mprint2) do
- server(v)
- end
- else
- console("Your search returned no matches.")
- end
- end
- return true
- end
- function sv_create(admin, id, search, respawn_time, x, y, z)
- id = id or admin
- respawn_time = tonumber(respawn_time or 0)
- local tagTable = toTag(search)
- local tagType, tagName = unpack(tagTable)
- if tagType and tagName then
- if respawn_time then
- if (not x and not y and not z) or (tonumber(x) and tonumber(y) and tonumber(z)) then
- local hashes = pack(tohash(id, true, admin))
- if #hashes > 1 then
- for _,v in ipairs(hashes) do
- sv_create(admin, v, object, respawn_time, x, y, z)
- end
- server("A " .. tags[tagType][tagName] .. " has spawned at " .. toTeam(id) .. " players' locations.")
- return true
- else
- local hash = unpack(hashes)
- if hash then
- local player = hashtoplayer(hash)
- if player then
- local m_player = getplayer(player)
- local m_objId = readdword(m_player, 0x34)
- local m_object = getobject(m_objId)
- if m_object then
- local px, py, pz = getobjectcoords(m_objId)
- local camera_base = 0x69C2F8
- local aim = readfloat(camera_base, 0x30 * player)
- if not x and not y and not z then
- if tagType == "vehi" then
- aim = aim - math.pi / 12
- x = px + math.cos(aim) * 4
- y = py + math.sin(aim) * 4
- z = pz + 1
- elseif tagType == "weap" or tagType == "eqip" then
- x = px + math.cos(aim) * 2.5
- y = py + math.sin(aim) * 2.5
- z = pz + 1
- elseif tagType == "proj" then
- x = px
- y = py
- z = pz + 1.5
- else
- x = px
- y = py
- z = pz
- end
- end
- x, y, z = tonumber(x), tonumber(y), tonumber(z)
- local respawn = false
- if respawn_time > 0 then
- respawn = true
- end
- local new_objId = createobject(tagType, tagName, 0, respawn_time, respawn, x, y, z)
- if tagType == "proj" then
- local new_object = getobject(new_objId)
- local z_aim = readfloat(camera_base, (0x30 * player) + 0x4)
- local vx = readfloat(new_object, 0x68)
- local vy = readfloat(new_object, 0x6C)
- local vz = readfloat(new_object, 0x70)
- local velocity = math.sqrt(vx ^ 2 + vy ^ 2 + vz ^ 2)
- writefloat(new_object, 0x68, velocity * math.cos(aim))
- writefloat(new_object, 0x6C, velocity * math.sin(aim))
- writefloat(new_object, 0x70, velocity * math.sin(z_aim))
- end
- console("A " .. tags[tagType][tagName] .. " has spawned at " .. players[hash].name .. "'s location.")
- console("Coords | x: " .. x .. " | y: " .. " | z: " .. z)
- console("Respawn: " .. tostring(respawn) .. " | Respawn Time: " .. respawn_time)
- private(player, "A " .. tags[tagType][tagName] .. " has spawned at your location.")
- return true
- else
- console(players[hash].name .. " is dead.")
- end
- else
- console(players[hash].name .. " is not currently in the server.")
- end
- else
- console("Invalid Player.")
- end
- end
- else
- console("Invalid Coordinates.")
- end
- else
- console("Invalid Respawn Time.")
- end
- else
- console("Invalid Object Search.")
- end
- return false
- end
- -- Message Functions --
- -- Messages
- function hprint(player, message, time)
- time = time or 5
- local hash = gethash(player)
- if hash then
- if string.len(message) > 79 then
- message = wordwrap(message, 79, true)
- end
- table.insert(messages[hash], {["message"] = message, ["time"] = time})
- end
- end
- function HprintTimer(id, count, delay)
- if messages ~= {} then
- for k,v in pairs(messages) do
- if messages[k] ~= {} then
- for key,value in ipairs(messages[k]) do
- messages[k][key].time = messages[k][key].time - (delay / 1000)
- if messages[k][key].time < 0 then
- table.remove(messages[k], key)
- end
- end
- end
- end
- for k,v in pairs(messages) do
- if #messages[k] > 0 then
- local player = hashtoplayer(k)
- local newline = ""
- for i = 1, 30 do
- newline = newline .. "\n "
- end
- hprintf(newline, player)
- for key,value in ipairs(messages[k]) do
- hprintf(messages[k][key].message, player)
- end
- end
- end
- end
- return 1
- end
- function wordwrap(str, linelength, tabbed)
- local newstr = ""
- local count = 0
- local space_index = 0
- local begin = 1
- for i = 1, string.len(str) do
- local sub = string.sub(str, i, i)
- if sub == " " then
- space_index = i
- end
- count = count + 1
- if count == linelength then
- newstr = newstr .. string.sub(str, begin, space_index) .. "\n"
- begin = space_index + 1
- count = 0
- if tabbed then
- repeat
- newstr = newstr .. " "
- count = count + 1
- until count == math.floor(1 + linelength / 10)
- end
- end
- if i == string.len(str) then
- newstr = newstr .. string.sub(str, begin, string.len(str))
- break
- end
- end
- return newstr
- end
- function console(message)
- table.insert(cprint, message)
- end
- function private(player, message)
- table.insert(pprint[player], message)
- end
- function server(message)
- if not table.find(sprint, message) then
- table.insert(sprint, message)
- end
- end
- -- Update Functions
- function updateBanlist()
- local dir = getprofilepath()
- local banlist = io.open(dir .. "\\banned.txt", "r")
- if banlist then
- local index = -1
- local hashes = {}
- for line in banlist:lines() do
- if not string.find(line, "# Name, CD key hash, ban count,") then
- local info = string.split(line, ",")
- local name = info[1]
- local hash = info[2]
- local numBans = info[3]
- local banEnd = info[4]
- validPlayer(hash, name)
- table.insert(hashes, hash)
- if not players[hash].banned then
- players[hash].bancount = (players[hash].bancount or 0) + (tonumber(numBans) or 0)
- local seconds
- if not string.find(banEnd, "--") then
- local today = os.date()
- local date_time = string.split(today, " ")
- local date = string.split(date_time[1], "/")
- local month = date[1]
- local day = date[2]
- local year = date[3]
- local formatted = "20" .. year .. "-" .. month .. "-" .. day .. " " .. date_time[2]
- seconds = dateDiff(banEnd, formatted)
- if seconds < 0 then
- seconds = 1
- end
- else
- seconds = -1
- end
- table.insert(banned, hash)
- players[hash].banned = true
- players[hash].bantime = seconds
- hprintf("Banning " .. players[hash].name .. "...")
- end
- end
- end
- banlist:close()
- for k,h in ipairs(banned) do
- if not table.find(hashes, h) then
- table.remove(banned, k)
- players[h].banned = false
- players[h].bantime = nil
- hprintf("Unbanning " .. players[h].name .. "...")
- end
- end
- end
- end
- function updateAdmins()
- local dir = getprofilepath()
- local adminlist = io.open(dir .. "\\admin.txt", "r")
- if adminlist then
- for line in adminlist:lines() do
- local split = string.split(line, ",")
- local name = split[1]
- local hash = split[2]
- local level = tonumber(split[3])
- addAdmin(hash, name, level)
- end
- adminlist:close()
- end
- end
- -- Swear Functions --
- --[[ Functions ]]--
- function getSwears(message)
- local swears = {}
- local words = string.split(message, " ")
- for k,_ in pairs(sweartable.exact) do
- for __,v in ipairs(words) do
- if k == string.lower(v) then
- table.insert(swears, v)
- end
- end
- end
- for k,_ in pairs(sweartable.anywhere) do
- if string.find(string.lower(message), k) then
- local i1, i2 = string.find(string.lower(message), k)
- local swear = string.sub(message, i1, i2)
- table.insert(swears, swear)
- end
- end
- if #swears > 0 then
- return swears
- end
- end
- function swear(player, swears)
- local hash = gethash(player)
- for _,v in ipairs(swears) do
- table.insert(mute_table[hash].swears, v)
- end
- mute_table[hash].swears.count = mute_table[hash].swears.count + 1
- mute_table[hash].swears.game = mute_table[hash].swears.game + 1
- if automute then
- if mute_table[hash].swears.count == swears_to_mute then
- mute(player, swear_penalty, "You have been auto-muted.")
- privatesay(player, "You have been auto-muted " .. getDuration(hash, true) .. " due to excessive swearing.")
- say(getname(player) .. " has been auto-muted " .. getDuration(hash, true) .. ".")
- mutelog(hash, getname(player) .. " | " .. getDuration(hash) .. " | " .. mute_table[hash].message .. " | Auto-muted")
- elseif mute_table[hash].swears.count == swears_to_mute - 1 then
- if swear_message ~= "" then
- privatesay(player, "Swearing again will get you auto-muted.")
- end
- else
- if swear_message ~= "" then
- privatesay(player, swear_message)
- end
- end
- else
- if swear_message ~= "" then
- privatesay(player, swear_message)
- end
- end
- end
- function appendMessage(message, swears)
- for _,s in ipairs(swears) do
- if sweartable.anywhere[string.lower(s)] then
- message = string.gsub(message, s, sweartable.anywhere[string.lower(s)])
- else
- message = string.gsub(message, s, sweartable.exact[string.lower(s)])
- end
- end
- return message
- end
- function getSweartype(entry)
- if entry then
- if string.find(entry, "any") or tonumber(entry) == 1 then
- return "anywhere"
- elseif string.find(entry, "exa") or tonumber(entry) == 0 then
- return "exact"
- else
- if sweartable.anywhere[entry] then
- return "anywhere"
- elseif sweartable.exact[entry] then
- return "exact"
- end
- end
- end
- end
- function addSwear(word, append, sweartype)
- word = string.lower(word)
- -- Make sure values are assigned to the correct variable.
- if not sweartype then
- if getSweartype(append) then
- sweartype = getSweartype(append)
- append = nil
- else
- sweartype = "exact"
- end
- end
- if not sweartable[sweartype][word] then
- if sweartype == "exact" and string.find(word, " ") then
- return "Exact swears cannot contain spaces."
- end
- sweartable[sweartype][word] = append or swear_append
- else
- return "\"" .. word .. "\" is already in the " .. capitalize(sweartype) .. " Sweartable."
- end
- end
- function sv_swear_add(admin, word, append, sweartype)
- -- Call function; check for errors.
- local err = addSwear(word, append, sweartype)
- if not err then
- console("Word: \"" .. word .. "\" | Replaced by: \"" .. (append or swear_append) .. "\" | " .. capitalize(getSweartype(word)) .. " Sweartable")
- return true
- end
- console(err)
- return false
- end
- function removeSwear(word, sweartype)
- word = string.lower(word)
- local found
- if not sweartype then
- for k,_ in pairs(sweartable.exact) do
- if word == k then
- sweartable.exact[k] = nil
- found = true
- end
- end
- for k,_ in pairs(sweartable.anywhere) do
- if word == k then
- sweartable.anywhere[k] = nil
- found = true
- end
- end
- else
- if getSweartype(sweartype) then
- local sweartype = getSweartype(sweartype)
- for k,v in pairs(sweartable[sweartype]) do
- if word == k then
- sweartable[sweartype][k] = nil
- found = true
- end
- end
- else
- return removeSwear(word, "exact")
- end
- end
- if not found then
- return "\"" .. word .. "\" is not in the sweartable."
- end
- end
- function sv_swear_del(admin, word, sweartype)
- local old_sweartype = getSweartype(word)
- local err = removeSwear(word, sweartype)
- if not err then
- console("\"" .. word .. "\" has been removed from the " .. capitalize(old_sweartype or "") .. " Sweartable.")
- return true
- end
- console(err)
- return false
- end
- function sv_swear_type(admin, word)
- if getSweartype(word) then
- return getSweartype(word)
- end
- console("\"" .. word .. "\" is not in the sweartable.")
- return false
- end
- function sv_sweartable(admin, sweartype)
- if sweartype then
- sweartype = getSweartype(sweartype) or "exact"
- local swears = {}
- for k,_ in pairs(sweartable[sweartype]) do
- table.insert(swears, k)
- end
- if #swears > 0 then
- console(sweartype .. " sweartable:")
- local mprint = printlist(swears, 7, " | ")
- for _,v in ipairs(mprint) do
- console(v)
- end
- else
- console("There are no swears in the " .. capitalize(sweartype) .. " Sweartable.")
- end
- else
- sv_sweartable(admin, "exact")
- sv_sweartable(admin, "anywhere")
- end
- return true
- end
- function sv_automute(admin, boolean)
- if boolean ~= nil then
- if boolean == "true" then
- boolean = true
- elseif boolean == "false" then
- boolean = false
- else
- console("Invalid Boolean.")
- return false
- end
- if boolean then
- if automute then
- console("Automute is already enabled.")
- return false
- else
- console("Automute is now enabled.")
- end
- else
- if automute then
- console("Automute is now disabled.")
- else
- console("Automute is already disabled.")
- return false
- end
- end
- automute = boolean
- return true
- else
- console(tostring(automute))
- return true
- end
- return false
- end
- function sv_swears_to_mute(admin, num)
- if num then
- if tonumber(num) then
- num = math.ceil(tonumber(num))
- swears_to_mute = num
- console("Swears to Mute changed to " .. num)
- return true
- else
- console("Invalid Swears to Mute.")
- end
- else
- console("Swears to Mute: " .. swears_to_mute)
- return true
- end
- return false
- end
- local function getSwearAction(entry)
- if entry == "none" or tonumber(entry) == 0 then
- return "None", 0
- elseif entry == "block" or tonumber(entry) == 1 then
- return "Block", 1
- elseif entry == "append" or tonumber(entry) == 2 then
- return "Append", 2
- end
- end
- function sv_swear_action(admin, action)
- if action then
- local action, id = getSwearAction(action)
- if id then
- swear_action = id
- console("Swear Action changed to \"" .. action .. "\"")
- return true
- else
- console("Invalid Swear Action.")
- end
- else
- console("Swear Action: " .. getSwearAction(swear_action))
- return true
- end
- return false
- end
- function sv_swear_append(admin, append)
- if append then
- swear_append = append
- console("Default Swear Append changed to \"" .. append .. "\"")
- else
- console("Default Swear Append: \"" .. swear_append .. "\"")
- end
- return true
- end
- function sv_swear_message(admin, message)
- if message then
- swear_message = message
- console("Swear Message changed to \"" .. message .. "\"")
- else
- console("Swear Message: \"" .. swear_message .. "\"")
- end
- return true
- end
- function sv_swear_penalty(admin, penalty)
- if penalty then
- if toDuration(penalty) then
- swear_penalty = toDuration(penalty)
- console("Automute Swear Penalty changed to " .. getDuration(swear_penalty))
- return true
- else
- console("Invalid Automute Swear Penalty.")
- end
- else
- console("Automute Swear Penalty: " .. getDuration(swear_penalty))
- return true
- end
- return false
- end
- function sv_mute_notify(admin, mutes)
- if mutes then
- if tonumber(mutes) then
- mutes = math.ceil(tonumber(mutes))
- console("Mutes Until Notified changed to " .. mutes)
- return true
- else
- console("Invalid Mutes Until Notified.")
- end
- else
- console("Mutes Until Notified: " .. notify_of_mutes)
- return true
- end
- return false
- end
- --[[ Validity Checks ]]--
- if not type(automute) == "boolean" then
- automute = true
- end
- if not tonumber(swear_action) then
- swear_action = getSwearAction(swear_action) or 0
- end
- if not tonumber(swear_penalty) then
- swear_penalty = -1
- end
- --[[ Miscellaneous Updating ]]--
- -- Update tables with values from the swear table, making sure sweartable.exact and sweartable.anywhere have been initialized as arrays and making sure no repeats are inserted.
- for _,v in ipairs(swear_default.exact) do
- addSwear(v, "exact")
- end
- for _,v in ipairs(swear_default.anywhere) do
- addSwear(v, "anywhere")
- end
- -- Mute Functions
- --[[ Functions ]]--
- -- Logs the specified player's mute information with the given message.
- function mutelog(hash, message)
- -- Nil check
- mute_table[hash] = mute_table[hash] or {}
- mute_table[hash].mutelog = mute_table[hash].mutelog or {}
- table.insert(mute_table[hash].mutelog, "[" .. os.date() .. "]: " .. message)
- end
- -- Update player's mute information (meant to be called OnPlayerJoin).
- function updateMute(player)
- local hash = gethash(player)
- -- Make sure all mute values exist
- mute_table[hash] = mute_table[hash] or {}
- mute_table[hash].muted = mute_table[hash].muted or false
- mute_table[hash].duration = mute_table[hash].duration or 0
- mute_table[hash].message = mute_table[hash].message or ""
- mute_table[hash].swears = mute_table[hash].swears or {}
- mute_table[hash].swears.count = mute_table[hash].swears.count or 0
- mute_table[hash].swears.game = mute_table[hash].swears.game or 0
- mute_table[hash].mutes = mute_table[hash].mutes or 0
- mute_table[hash].mutelog = mute_table[hash].mutelog or {}
- end
- -- Returns the actual duration as an int value.
- function toDuration(input)
- if string.find(input, "perm") then
- return -2
- elseif string.find(input, "temp") or string.find(input, "game") then
- return -1
- end
- return tonumber(input)
- end
- -- Returns a string formatted for a sentence or a list based on mute duration.
- function getDuration(input, sentence)
- if tonumber(input, 16) and string.len(input) == 32 then
- return getDuration(mute_table[input].duration, sentence)
- else
- local duration = toDuration(input)
- if sentence then
- if duration == -2 then
- return "permanently"
- elseif duration == -1 then
- return "for the rest of the game"
- else
- return "for " .. duration .. " seconds"
- end
- else
- if duration == -2 then
- return "Permanent"
- elseif duration == -1 then
- return "Rest of Game"
- else
- return duration .. " seconds"
- end
- end
- end
- end
- function MuteTimer(id, count, hash)
- if mute_table[hash].duration > 0 then
- mute_table[hash].duration = mute_table[hash].duration - 1
- return 1
- end
- -- Unmute player and log the unmute.
- local err = unmute(hash)
- if not err then
- mutelog(hash, "Mute Expired. Unmuted by SERVER.")
- end
- local player = hashtoplayer(hash)
- if player then
- privatesay(player, "Your mute has expired.")
- say(getname(player) .. " has been unmuted.")
- end
- return 0
- end
- -- Mute by Player ID, hash, or Server Index with a specified Duration (-1: rest of game) (-2: permanent) (all other values in seconds) with a specified Mute Message.
- function mute(id, duration, message)
- -- Find hash based on input
- local hash = tohash(id)
- if hash then
- -- Make sure "duration" and "message" are assigned the correct values
- duration = duration or -1
- if not toDuration(duration) then
- message = duration
- duration = -1
- end
- if not mute_table[hash].muted then
- -- Set all mute values accordingly.
- mute_table[hash].muted = true
- mute_table[hash].duration = toDuration(duration)
- mute_table[hash].message = message or "You have been muted."
- mute_table[hash].mutes = (mute_table[hash].mutes or 0) + 1
- if mute_table[hash].duration >= 0 then
- registertimer(1000, "MuteTimer", hash)
- end
- else
- return (players[hash].name or "This player") .. " is already muted."
- end
- else
- return "Invalid Player."
- end
- end
- -- sv_mute <Player ID or Server Index> <opt: Duration> <opt: Message>
- function sv_mute(admin, id, duration, message)
- -- Make sure if a Player ID is entered, it is the player's memory ID.
- local hash = tohash(id, true, admin)
- -- Call mute function; make sure there are no errors.
- local err = mute(hash, duration, message)
- if not err then
- -- Server messages
- local player = hashtoplayer(hash)
- local name
- if player then
- name = getname(player)
- privatesay(player, "You have been muted " .. getDuration(hash, true) .. ".")
- say(name .. " has been muted " .. getDuration(hash, true) .. ".")
- else
- name = players[hash].name or "Anonymous"
- end
- -- Log this mute.
- local admin_hash = gethash(admin)
- mutelog(hash, name .. " | " .. getDuration(mute_table[hash].duration) .. " | \"" .. mute_table[hash].message .. "\" | Muted by: " .. (players[(admin_hash or 0)].name or "SERVER"))
- -- Console print.
- console(name .. " | " .. getDuration(hash) .. " | \"" .. mute_table[hash].message .. "\"")
- -- If this player has been muted many times, let the admin know.
- duration = duration or -1
- if toDuration(duration) > -2 then
- if notify_of_mutes > 0 then
- if mute_table[hash].mutes >= notify_of_mutes then
- console(name .. " has been muted " .. mute_table[hash].mutes .. " times.")
- console("Consider a permamute if their behavior continues.")
- end
- end
- end
- return true
- end
- -- Print the error.
- console(err)
- return false
- end
- -- sv_permamute <Player ID or Server Index> <opt: Message>
- function sv_permamute(admin, id, message)
- return sv_mute(admin, id, -2, message or "You have been permanently muted.")
- end
- -- Unmutes by Player ID, hash, or Server Index.
- function unmute(id)
- local hash = tohash(id)
- if hash then
- mute_table[hash] = mute_table[hash] or {}
- if mute_table[hash].muted then
- mute_table[hash].muted = false
- mute_table[hash].duration = 0
- mute_table[hash].message = ""
- mute_table[hash].swears.count = 0
- else
- return (players[hash].name or "This player") .. " is not muted."
- end
- else
- return "Invalid Player."
- end
- end
- -- sv_unmute <Player ID or Server Index>
- function sv_unmute(admin, id)
- -- Make sure if a Player ID is entered, it is the player's memory ID.
- local hash = tohash(id, true, admin)
- -- Call unmute function; make sure there are no errors.
- local err = unmute(hash)
- if not err then
- -- Server messages
- local player = hashtoplayer(hash)
- local name
- if player then
- name = getname(player)
- privatesay(player, "You have been unmuted.")
- say(name .. " has been unmuted.")
- else
- name = players[hash].name or "Anonymous"
- end
- -- Log this unmute.
- mutelog(hash, "Unmuted by " .. (players[(admin_hash or 0)].name or "SERVER"))
- -- Console print.
- console(name .. " has been unmuted.")
- return true
- end
- -- Print the error.
- console(err)
- return false
- end
- function sv_mute_duration(admin, id, newDuration)
- local hash = tohash(id, true, admin)
- if hash then
- if newDuration then
- local duration = toDuration(newDuration)
- if duration then
- local old_duration = mute_table[hash].duration
- mute_table[hash].duration = duration
- if old_duration < 0 and duration >= 0 then
- registertimer(1000, "MuteTimer", hash)
- end
- console(players[hash].name .. "'s Mute Duration has been changed to " .. getDuration(hash) .. ".")
- return true
- else
- console("Invalid Duration Entry.")
- end
- else
- if mute_table[hash].muted then
- console("[" .. players[hash].index .. "] " .. players[hash].name .. " | " .. getDuration(hash))
- else
- console(players[hash].name .. " is not muted.")
- end
- return true
- end
- end
- console("Invalid Player.")
- return false
- end
- function sv_mute_message(admin, id, message)
- local hash = tohash(id, true, admin)
- if hash then
- if message then
- mute_table[hash].message = message
- console(players[hash].name .. "'s Mute Message has been changed to \"" .. message .. "\".")
- else
- if mute_table[hash].muted then
- console("[" .. players[hash].index .. "] " .. players[hash].name .. " | \"" .. mute_table[hash].message .. "\"")
- else
- console(players[hash].name .. " is not muted.")
- end
- end
- return true
- end
- console("Invalid Player.")
- return false
- end
- function sv_mute_info(admin, id)
- local hash = tohash(id, true, admin)
- if hash then
- console("[" .. players[hash].index .. "] " .. players[hash].name .. " | Muted: " .. tostring(mute_table[hash].muted))
- if mute_table[hash].muted then
- console("Duration: " .. getDuration(hash) .. " | Message: \"" .. mute_table[hash].message .. "\"")
- end
- local counts = "# of Mutes: " .. mute_table[hash].mutes .. " | # of Swears | This Game: " .. mute_table[hash].swears.game .. " | Overall: " .. #mute_table[hash].swears
- if automute then
- counts = counts .. " | Until Auto-mute: " .. swears_to_mute - mute_table[hash].swears.count
- end
- console(counts)
- return true
- end
- console("Invalid Player.")
- return false
- end
- function sv_swears(admin, id)
- local hash = tohash(id, true, admin)
- if hash then
- mute_table[hash].swears = mute_table[hash].swears or {}
- if #mute_table[hash].swears > 0 then
- local mprint = printlist(mute_table[hash].swears, 8, " ")
- console(#mute_table[hash].swears .. " total logged swears:")
- for _,v in ipairs(mprint) do
- console(v)
- end
- else
- console("This player has no logged swears.")
- end
- return true
- end
- console("Invalid Player.")
- return false
- end
- function sv_mute_players(admin)
- console("Players and their corresponding Mute Information:")
- for i = 0, 15 do
- local hash = gethash(i)
- if hash then
- console("[" .. players[hash].index .. "] " .. getname(i) .. " | Muted: " .. tostring(mute_table[hash].muted))
- end
- end
- return true
- end
- function sv_mutelog(admin, id)
- local hash = tohash(id, true, admin)
- if hash then
- mute_table[hash].mutelog = mute_table[hash].mutelog or {}
- if #mute_table[hash].mutelog > 0 then
- for _,v in ipairs(mute_table[hash].mutelog) do
- console(v)
- end
- else
- console("This player has never been muted.")
- end
- return true
- end
- console("Invalid Player.")
- return false
- end
- function sv_reset_mute_info(admin, id)
- local hash = tohash(id, true, admin)
- if hash then
- if mute_table[hash] then
- local player = hashtoplayer(hash)
- local name
- if player then
- name = getname(player)
- privatesay(player, "Your mute information has been reset.")
- else
- name = ""
- end
- players[hash].name = name
- mute_table[hash].muted = false
- mute_table[hash].duration = 0
- mute_table[hash].message = ""
- mute_table[hash].swears = {}
- mute_table[hash].swears.count = 0
- mute_table[hash].swears.game = 0
- mute_table[hash].mutes = 0
- mute_table[hash].mutelog = {}
- console("Player's mute information reset.")
- return true
- end
- end
- console("Invalid Player.")
- return false
- end
- local function toCategory(entry)
- if string.find(entry, "ind") or entry == "id" then
- return "index"
- elseif string.find(entry, "name") then
- return "name"
- elseif string.find(entry, "duration") then
- return "duration"
- elseif string.find(entry, "swears") then
- return "swears"
- elseif string.find(entry, "mutes") then
- return "mutes"
- end
- end
- local function toDirection(entry)
- if string.find(entry, "ascend") or string.find(entry, "incre") or entry == "up" or entry == "+" or entry == 1 then
- return 1
- elseif string.find(entry, "descend") or string.find(entry, "decre") or entry == "down" or entry == "-" or entry == -1 then
- return -1
- end
- return 0
- end
- function sv_mutelist(admin, search, direction, length)
- if not search and not direction and not length then
- local muted = {}
- for k,_ in ipairs(muted) do
- if tonumber(k, 16) and string.len(k) == 32 then
- if mute_table[k].muted then
- local player = hashtoplayer(k)
- local name
- if player then
- name = getname(player)
- else
- name = players[k].name
- end
- table.insert(muted, "[" .. players[k].index .. "] " .. name .. " | Duration: " .. getDuration(k))
- end
- end
- end
- if #muted > 0 then
- console("Players in the server who are muted:")
- for _,v in ipairs(muted) do
- console(v)
- end
- else
- console("No players are currently muted.")
- end
- else
- search = search or ""
- sortby = toCategory(search)
- direction = toDirection(direction or 0)
- length = tonumber(length or 15) or 15
- if sortby then
- local hashes = {}
- for k,v in pairs(mute_table) do
- if tonumber(k, 16) and string.len(k) == 32 then
- table.insert(hashes, k)
- end
- end
- if length > #hashes then
- length = #hashes
- end
- if direction == 0 then
- if sortby == "duration" then
- table.sort(hashes, function(a, b) return mute_table[a][sortby] < mute_table[b][sortby] end)
- elseif sortby == "name" or sortby == "index" then
- table.sort(hashes, function(a, b) return string.lower(players[a][sortby]) < string.lower(players[b][sortby]) end)
- elseif sortby == "swears" then
- table.sort(hashes, function(a, b) return #mute_table[a].swears > #mute_table[b].swears end)
- else
- table.sort(hashes, function(a, b) return mute_table[a][sortby] > mute_table[b][sortby] end)
- end
- elseif direction == 1 then
- if sortby == "swears" then
- table.sort(hashes, function(a, b) return #mute_table[a].swears < #mute_table[b].swears end)
- else
- table.sort(hashes, function(a, b) return mute_table[a][sortby] < mute_table[b][sortby] end)
- end
- else
- if sortby == "swears" then
- table.sort(hashes, function(a, b) return #mute_table[a].swears > #mute_table[b].swears end)
- else
- table.sort(hashes, function(a, b) return mute_table[a][sortby] > mute_table[b][sortby] end)
- end
- end
- local dirprint = ""
- if direction == 1 then
- dirprint = " in ascending order"
- elseif direction == -1 then
- dirprint = " in descending order"
- end
- console("Mutelist sorted by \"" .. sortby .. "\"" .. dirprint .. ":")
- for i = 1, length do
- if sortby == "swears" then
- console("[" .. players[hashes[i]].index .. "] " .. players[hashes[i]].name .. " | Total Swears: " .. #mute_table[hashes[i]].swears)
- elseif sortby == "name" or sortby == "index" then
- console("[" .. players[hashes[i]].index .. "] " .. players[hashes[i]].name .. " | " .. capitalize(sortby) .. ": " .. players[hashes[i]][sortby])
- else
- console("[" .. players[hashes[i]].index .. "] " .. players[hashes[i]].name .. " | " .. capitalize(sortby) .. ": " .. mute_table[hashes[i]][sortby])
- end
- end
- else
- local matches = {}
- for k,_ in pairs(mute_table) do
- if tonumber(k, 16) and string.len(k) == 32 then
- for key,v in pairs(mute_table[k]) do
- if type(v) ~= "table" then
- if string.find(tostring(v), search) then
- table.insert(matches, "[" .. players[k].index .. "] " .. players[k].name .. " | " .. capitalize(k) .. ": " .. tostring(v))
- end
- end
- end
- end
- end
- if #matches > 0 then
- for i = 1, length do
- console(matches[i])
- end
- else
- console("Invalid Search")
- end
- end
- end
- return true
- end
- --[[ Miscellaneous Updating ]]--
- -- Update mute table with default mutes
- for k,v in ipairs(mute_default) do
- mute(v, -2)
- table.remove(k)
- end
- -- Gametype Functions
- function sv_gametypes(admin, search)
- local matches = {}
- for k,v in pairs(gametypes) do
- if not search then
- table.insert(matches, k)
- else
- if string.find(string.lower(k), string.lower(search)) then
- table.insert(matches, k)
- end
- end
- end
- table.sort(matches)
- console("Gametypes matching search \"" .. (search or "") .. "\":")
- for k,v in ipairs(matches) do
- console(v)
- end
- return true
- end
- function sv_scripts(admin)
- local mprint = printlist(scripts, 3, " ")
- for k,v in ipairs(mprint) do
- console(v)
- end
- return true
- end
- -- Other Command Functions --
- -- Add feature allowing all weapons' ammo to be edited in one command
- function sv_ammo(admin, id, weapon, ammo, clip)
- if tonumber(ammo) and tonumber(clip) then
- if toTag(weapon) or (tonumber(weapon) and tonumber(weapon) > 0 and tonumber(weapon) < 5) then
- local hashes = pack(tohash(id, true, admin))
- if #hashes > 1 then
- for k,v in ipairs(hashes) do
- sv_ammo(admin, v, weapon, ammo, clip)
- end
- if toTag(weapon) then
- local tagtype, tagname = unpack(toTag(weapon))
- server(toTeam(id) .. " players' " .. tags[tagtype][tagname] .. "s' ammo counts have been edited.")
- else
- server(toTeam(id) .. " players' weapons' ammo counts in slot " .. weapon .. " have been edited.")
- end
- return true
- else
- local hash = unpack(hashes)
- if hash then
- local player = hashtoplayer(hash)
- if player then
- local m_player = getplayer(player)
- local m_objId = readdword(m_player, 0x34)
- local m_object = getobject(m_objId)
- if m_object then
- local slot, m_weapId, m_weapon
- if tonumber(weapon) then
- slot = weapon
- m_weapId = readdword(m_object, 0x2F8 + (slot - 1) * 4)
- m_weapon = getobject(m_weapId)
- if not m_weapon then
- console("Invalid Weapon Slot")
- end
- else
- local tagtype, tagname = unpack(toTag(weapon))
- for i = 0,3 do
- m_weapId = readdword(m_object, 0x2F8 + (i * 4))
- m_weapon = getweapon(m_weapId)
- if m_weapon then
- if tagname == objects[m_weapId].tagname then break end
- end
- end
- end
- if m_weapId then
- if not string.find(objects[m_weapId].tagname, "plasma") then
- writeword(m_weapon, 0x2B6, ammo)
- writeword(m_weapon, 0x2B8, clip)
- updateammo(m_weapId)
- console(players[hash].name .. "'s ammo has been edited.")
- console("Weapon: " .. tags[objects[m_weapId].tagtype][objects[m_weapId].tagname])
- console("Ammo: " .. ammo .. " | Clip: " .. clip)
- else
- console("Use sv_battery for plasma weapons.")
- end
- return true
- else
- console(players[hash].name .. " does not have a \"" .. weapon .. "\".")
- end
- else
- console(players[hash].name .. " is dead.")
- end
- else
- console(players[hash].name .. " is not currently in the server.")
- end
- else
- console("Invalid Player.")
- end
- end
- else
- console("Invalid Weapon.")
- end
- else
- console("Invalid Ammo or Clip.")
- end
- return false
- end
- -- General Functions --
- -- Math Globals
- math.inf = 1 / 0
- -- General Functions
- function hashtoplayer(hash)
- for i = 0, 15 do
- if gethash(i) == hash then return i end
- end
- return nil
- end
- -- Oxide helped make this better
- function execute(func, ...)
- if _G[func] and type(_G[func]) == "function" then
- return true, _G[func](...)
- end
- end
- function locals()
- local variables = {}
- local idx = 1
- while true do
- local name, value = debug.getlocal(2, idx)
- if name then
- variables[name] = value
- else break end
- idx = 1 + idx
- end
- return variables
- end
- function pack(...)
- return arg
- end
- -- String functions
- function string.wild(match, wild, case_sensative)
- if not case_sensative then
- match, wild = string.lower(match), string.lower(wild)
- end
- -- Initial Checks
- if string.sub(wild, 1, 1) == "?" then wild = string.gsub(wild, "?", string.sub(match, 1, 1), 1) end
- if string.sub(wild, string.len(wild), string.len(wild)) == "?" then wild = string.gsub(wild, "?", string.sub(match, string.len(match), string.len(match)), 1) end
- if not string.find(wild, "*") and not string.find(wild, "?") and wild ~= match then return false end
- if string.sub(wild, 1, 1) ~= string.sub(match, 1, 1) and string.sub(wild, 1, 1) ~= "*" then return false end
- if string.sub(wild, string.len(wild), string.len(wild)) ~= string.sub(match, string.len(match), string.len(match)) and string.sub(wild, string.len(wild), string.len(wild)) ~= "*" then return false end
- local substrings = string.split(wild, "*")
- local begin = 1
- for k,v in ipairs(substrings) do
- local sublength = string.len(v)
- local temp_begin = begin
- local temp_end = begin + sublength - 1
- local matchsub = string.sub(match, begin, temp_end)
- local bool
- repeat
- local wild = v
- local indexes = pack(string.findchar(wild, "?"))
- if #indexes > 0 then
- for _,i in ipairs(indexes) do
- wild = string.gsub(wild, "?", string.sub(matchsub, i, i), 1)
- end
- end
- if matchsub == wild then
- bool = true
- break
- end
- matchsub = string.sub(match, temp_begin, temp_end)
- temp_begin = temp_begin + 1
- temp_end = temp_end + 1
- until temp_end >= string.len(match)
- if not bool then
- return false
- end
- begin = sublength + 1
- end
- return true
- end
- function string.findchar(str, char)
- local chars = string.split(str, "")
- local indexes = {}
- for k,v in ipairs(chars) do
- if v == char then
- table.insert(indexes, k)
- end
- end
- return unpack(indexes)
- end
- -- Written by Chalonic --
- function ParseCommand(command)
- local cmd = nil
- local args = {}
- local arg = ""
- local in_quote = false
- for i = 1, #command do
- local c = command:sub(i, i)
- if c == "\"" then
- if in_quote then
- in_quote = false
- table.insert(args, arg)
- arg = ""
- else
- in_quote = true
- end
- elseif c == " " then
- if in_quote then
- arg = arg .. c
- else
- if #arg > 0 then
- table.insert(args, arg)
- arg = ""
- end
- end
- else
- arg = arg .. c
- end
- end
- if #arg > 0 then
- table.insert(args, arg)
- arg = ""
- end
- if #args > 0 then
- cmd = table.remove(args, 1)
- end
- return cmd, args
- end
- function printlist(list, linelength, delimiter)
- local mprint = {}
- local x = 1
- local count = 0
- mprint[1] = ""
- while x <= #list do
- if (x - 1) % linelength == 0 then
- count = count + 1
- mprint[count] = ""
- end
- if x < #list then
- mprint[count] = mprint[count] .. list[x] .. delimiter
- else
- mprint[count] = mprint[count] .. list[x]
- end
- x = x + 1
- end
- return mprint
- end
- function capitalize(str, limit)
- local words = string.split(str, " ")
- limit = limit or #words
- if #words > 0 then
- for k,v in ipairs(words) do
- if k <= limit then
- local first = string.sub(v, 1, 1)
- words[k] = string.gsub(words[k], first, string.upper(first))
- else break end
- end
- return table.concat(words, " ")
- end
- return str
- end
- function getTuple(num)
- num = tonumber(num)
- if num == 1 then
- return "Single"
- elseif num == 2 then
- return "Double"
- elseif num == 3 then
- return "Triple"
- elseif num == 4 then
- return "Quadruple"
- elseif num == 5 then
- return "Quintuple"
- elseif num == 6 then
- return "Sextuple"
- elseif num == 7 then
- return "Septuple"
- elseif num == 8 then
- return "Octuple"
- elseif num == 9 then
- return "Nonuple"
- elseif num == 10 then
- return "Decuple"
- end
- end
- -- Time Functions
- function secondsToTime(seconds)
- if seconds == -1 then
- return "Infinite"
- end
- if seconds == 0 then
- return "0 seconds"
- end
- local days = math.floor(seconds / (60 * 60 * 24))
- seconds = seconds % (60 * 60 * 24)
- local hours = math.floor(seconds / (60 * 60))
- seconds = seconds % (60 * 60)
- local minutes = math.floor(seconds / 60)
- seconds = seconds % 60
- local time = {}
- if days > 0 then
- if days > 1 then
- table.insert(time, days .. " days")
- else
- table.insert(time, days .. " day")
- end
- end
- if hours > 0 then
- if hours > 1 then
- table.insert(time, hours .. " hours")
- else
- table.insert(time, hours .. " hour")
- end
- end
- if minutes > 0 then
- if minutes > 1 then
- table.insert(time, minutes .. " minutes")
- else
- table.insert(time, minutes .. " minute")
- end
- end
- if seconds > 0 then
- if seconds > 1 then
- table.insert(time, seconds .. " seconds")
- else
- table.insert(time, seconds .. " second")
- end
- end
- if #time > 1 then
- table.insert(time, #time, "and")
- time[#time - 1] = table.concat(time, " ", #time - 1, #time)
- table.remove(time, #time)
- end
- local str
- if #time <= 2 then
- str = table.concat(time, " ")
- else
- str = table.concat(time, ", ")
- end
- return str
- end
- -- Math Functions
- function editValue(current, edit)
- edit = string.gsub(edit, "inf", "math.inf")
- cur = tonumber(current)
- if not tonumber(edit) then
- local f = loadstring("return " .. edit)
- local value = f()
- if value == math.inf then
- value = 10^25
- elseif value == -math.inf then
- value = -10^25
- end
- return value
- else
- return tonumber(edit)
- end
- end
- function math.round(input, precision)
- return math.floor(input * (10 ^ precision) + 0.5) / (10 ^ precision)
- end
- -- Tag Functions
- -- The following functions were written by Smiley
- function getobjecttag(m_objId)
- local m_object = getobject(m_objId)
- local object_map_id = readdword(m_object, 0x0)
- local map_pointer = 0x460678
- local map_base = readdword(map_pointer, 0x0)
- local map_tag_count = todec(endian(map_base, 0xC, 0x3))
- local tag_table_base = map_base + 0x28
- local tag_table_size = 0x20
- for i = 0, (map_tag_count - 1) do
- local tag_id = todec(endian(tag_table_base, 0xC + (tag_table_size * i), 0x3))
- if tag_id == object_map_id then
- local tag_class = readstring(tag_table_base, (tag_table_size * i), 0x3, 1)
- local tag_name_address = endian(tag_table_base, 0x10 + (tag_table_size * i), 0x3)
- local tag_name = readtagname("0x" .. tag_name_address)
- return tag_class, tag_name
- end
- end
- end
- function gettagaddress(tagtype, tagname)
- -- map header
- local map_header_size = 0x800 -- Confirmed. (2048 bytes)
- local map_header_head = readstring(map_header_base, 0x0, 1) -- Confirmed. (head = daeh)
- local map_header_version = readbyte(map_header_base, 0x4) -- Confirmed. (Xbox = 5) (Trial = 6) (PC = 7) (CE = 0x261 = 609)
- local map_header_map_size = todec(endian(map_header_base, 0x8, 0x3)) -- Confirmed. (Bytes)
- local map_header_index_offset = endian(map_header_base, 0x10, 0x2) -- Confirmed. (Hex)
- local map_header_meta_data_size = endian(map_header_base, 0x14, 0x2) -- Confirmed. (Hex)
- local map_header_map_name = readstring(map_header_base, 0x20, 0x9) -- Confirmed.
- local map_header_build = readstring(map_header_base, 0x40, 0xC) -- Confirmed.
- local map_header_map_type = readbyte(map_header_base, 0x60) -- Confirmed. (SP = 0) (MP = 1) (UI = 2)
- -- Something from 0x64 to 0x67.
- local map_header_foot = readstring(map_header_base, 0x7FC, 0x3, 1) -- Confirmed. (foot = toof)
- --tag table setup
- local map_base = readdword(map_pointer, 0x0) -- Confirmed. (0x40440000)
- local map_magic = tohex(map_base - todec(map_header_index_offset)) -- Confirmed. (Hex)
- local tag_table_base_pointer = endian(map_base, 0x0, 0x3)
- local tag_table_first_tag_id = endian(map_base, 0x4, 0x3)
- local map_id = endian(map_base, 0x8, 0x3)
- local map_tag_count = todec(endian(map_base, 0xC, 0x3)) -- Confirmed.
- local map_verticie_count = todec(endian(map_base, 0x10, 0x3))
- local map_verticie_offset = endian(map_base, 0x14, 0x2)
- local map_indicie_count = todec(endian(map_base, 0x18, 0x3))
- local map_indicie_offset = endian(map_base, 0x1C, 0x2)
- local map_model_data_size = endian(map_base, 0x20, 0x2)
- local tag_table_tags = readstring(map_base, 0x24, 0x3, 1) -- Confirmed. "Tags"
- local tag_table_base = map_base + 0x28 -- Confirmed. (0x40440028)
- local tag_table_size = 0x20 -- Confirmed.
- -- tag table
- local scnr_tag_class = readstring(tag_table_base, 0x0, 0x3, 1) -- Confirmed.
- local scnr_tag_class2 = readstring(tag_table_base, 0x4, 0x7, 1) -- Confirmed.
- local scnr_tag_class3 = readstring(tag_table_base, 0x8, 0xB, 1) -- Confirmed.
- local scnr_tag_id = endian(tag_table_base, 0xC, 0x3) -- Confirmed.
- local scnr_tag_name_address = endian(tag_table_base, 0x10, 0x3) -- Confirmed.
- local scnr_tag_address = endian(tag_table_base, 0x14, 0x3) -- Confirmed.
- local scnr_tag_name = readtagname("0x" .. scnr_tag_name_address) -- Confirmed.
- local tag_address = 0
- for i=0,(map_tag_count - 1) do
- local tag_class = readstring(tag_table_base, (tag_table_size * i), 0x3, 1)
- local tag_id = todec(endian(tag_table_base, 0xC + (tag_table_size * i), 0x3))
- local tag_name_address = endian(tag_table_base, 0x10 + (tag_table_size * i), 0x3)
- local tag_name = readtagname("0x" .. tag_name_address)
- if tag_id == tagtype or (tag_class == tagtype and tag_name == tagname) then
- tag_address = todec(endian(tag_table_base, 0x14 + (tag_table_size * i), 0x3))
- break
- end
- end
- return tag_address
- end
- -- Reading Functions --
- function readstring(address, offset, length, endian)
- local char_table = {}
- local string = ""
- for i=0,length do
- if readbyte(address, (offset + (0x1 * i))) ~= 0 then
- table.insert(char_table, string.char(readbyte(address, (offset + (0x1 * i)))))
- end
- end
- for k,v in pairs(char_table) do
- if endian == 1 then
- string = v .. string
- else
- string = string .. v
- end
- end
- return string
- end
- function readtagname(address)
- local char_table = {}
- local i = 0
- local string = ""
- while readbyte(address, (0x1 * i)) ~= 0 do
- table.insert(char_table, string.char(readbyte(address, (0x1 * i))))
- i = i + 1
- end
- for k,v in pairs(char_table) do
- string = string .. v
- end
- return string
- end
- -- Other --
- function endian(address, offset, length)
- local data_table = {}
- local data = ""
- for i=0,length do
- local hex = string.format("%X", readbyte(address, offset + (0x1 * i)))
- if tonumber(hex, 16) < 16 then
- hex = 0 .. hex
- end
- table.insert(data_table, hex)
- end
- for k,v in pairs(data_table) do
- data = v .. data
- end
- return data
- end
- function tohex(number)
- return string.format("%X", number)
- end
- function todec(number)
- return tonumber(number, 16)
- end
- -- Table Functions --
- -- Returns the key of the maximum numerical value of the specified table.
- function table.max(t)
- local key, max = 0, 0
- for k,v in pairs(t) do
- if type(v) == "number" then
- if v > max then
- max = v
- key = k
- end
- end
- end
- return key
- end
- function table.len(t)
- local count = 0
- for k,v in pairs(t) do
- count = count + 1
- end
- return count
- end
- function table.random(array, n, allow_multiple)
- n = math.min(n, #array)
- local chosen = {}
- for i = 1, n do
- local rand
- if not allow_multiple then
- repeat
- rand = getrandomnumber(1, #array + 1)
- until not table.find(chosen, rand)
- table.insert(chosen, array[rand])
- else
- table.insert(chosen, array[getrandomnumber(1, #array + 1)])
- end
- end
- return chosen
- end
Advertisement
Add Comment
Please, Sign In to add comment