Advertisement
it300

Commands v1.3.4 Phasor 2.0+

Jan 4th, 2015
345
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 63.89 KB | None | 0 0
  1. -- Commands by: Skylace
  2. -- Website: bud.boards.net
  3. -- Thanks to Kennan & others for helping making and testing this script.
  4. -- PUBLIC VERSION 1.3.4
  5.  
  6. ------------------------------------------------------------------------------------------
  7. -------------------------------------- [[Presets]] ---------------------------------------
  8. ------------------------------------------------------------------------------------------
  9.  
  10. -- This will ban players trying to use a bruteforcer to find your rcon since the the server
  11. -- does not validate hashes while running this script.
  12. rcon_fails_to_ban = 5
  13.  
  14. rtv_enabled = true -- Enables map skipping
  15. rtv_needed = 0.65 -- amount needed to skip 1 = 100% 0.50 = 50%
  16.  
  17. votekick_enabled = false -- Enables votekick
  18. votekick_needed = 0.7 -- Amount needed to kick 1 = 100% 0.50 = 50%
  19. votekick_timeout = 5 -- Minutes
  20.  
  21. fall_damage = true -- Turn fall damage on or off.
  22.  
  23. -- This will count how many unique names have joined the server while the script has been loaded.
  24. unique_counter = true
  25. -- Welcome back message (Tells players their number of visits under a specific name.)
  26. welcome_back_msg = false
  27.  
  28. -- Should we allow players on the same ip or hash to connect to the server at the same time?
  29. allow_ip_duplicates = true
  30. allow_hash_duplicates = true
  31.  
  32. ------------------------------------------------------------------------------------------
  33. --------------------------------- [[Tables (Don't Touch)]] -------------------------------
  34. ------------------------------------------------------------------------------------------
  35.  
  36. rtvcount = 0
  37. kickcount = 0
  38. unique_count = 0
  39. vname = nil
  40. vindex = nil
  41. players = {}
  42. hidden = {}
  43. rtved = {}
  44. kills = {}
  45. deaths = {}
  46. votekick = {}
  47. voted = {}
  48. dyslexic = {}
  49. bannedips = {}
  50. ipadmin = {}
  51. haxed = {}
  52. uniques = {}
  53. failedrcons = {}
  54. forcedentry = {}
  55.  
  56. commands = {
  57.  
  58. {"sv_setammo"},{"sv_setscore"},{"sv_setassists"},{"sv_setdeaths"},{"sv_setkills"},
  59. {"sv_dyslexic"},{"sv_undyslexic"},{"sv_pl"},{"sv_hax"},{"sv_unhax"},{"sv_kil"},
  60. {"sv_ipbanlist"},{"sv_ipunban"},{"sv_ipban"},{"sv_god"},{"sv_ungod"},{"sv_ghost"},
  61. {"sv_unghost"},{"sv_hide"},{"sv_unhide"},{"sv_teamswap"},{"sv_spawn"},{"sv_give"},
  62. {"sv_enter"}
  63.  
  64. }
  65.  
  66.  
  67. ------------------------------------------------------------------------------------------
  68. ---------------------------------- [[Main Function(s)]] ----------------------------------
  69. ------------------------------------------------------------------------------------------
  70.  
  71. function GetRequiredVersion()
  72.     return 200
  73. end
  74.  
  75. function OnScriptLoad(processId, game, persistent)
  76.     GetGameAddresses(game)
  77.     getTagIds()
  78.     savetables()
  79.     log_file = getprofilepath() .. "\\logs\\commands.log"
  80.     svcmd("sv_admin_check false") -- This will let the script work.
  81.     if allow_hash_duplicates then
  82.         writebit(hash_duplicate_patch, 0, 0)
  83.     else
  84.         writebit(hash_duplicate_patch, 0, 1)
  85.     end
  86. end
  87.  
  88. function OnNewGame(map)
  89.     rtvactive = false
  90.     kickactive = false
  91.     readtables()
  92.     getTagIds()
  93. end
  94.  
  95. function OnScriptUnload()
  96.     savetables()
  97. end
  98.  
  99. function OnGameEnd(stage)
  100.     if stage == 2 then
  101.         savetables()
  102.     end
  103.     haxedtimer = false
  104.     -- stage 1: F1 Screen
  105.     -- stage 2: PGCR Appears
  106.     -- stage 3: Players may quit
  107. end
  108.  
  109. function readtables()
  110.     uniques = table.load("uniques.data")
  111.     kills = table.load("kills.data")
  112.     deaths = table.load("deaths.data")
  113.     bannedips = table.load("bannedips.data")
  114.     ipadmin = table.load("ipadmins.data")
  115. end
  116.  
  117. function savetables()
  118.     table.save(uniques, "uniques.data")
  119.     table.save(kills, "kills.data")
  120.     table.save(deaths, "deaths.data")
  121.     table.save(bannedips, "bannedips.data")
  122.     table.save(ipadmin, "ipadmins.data")
  123. end
  124.  
  125. function OnServerChat(player, type, message)
  126.     local allowchat = true
  127.     if player then
  128.         local name = getname(player)
  129.  
  130.         if dyslexic[name] then
  131.             newmsg = getnewmessage(message)
  132.             allowchat = true, newmsg
  133.         end
  134.  
  135.         local t = tokenizecmdstring(message)
  136.  
  137.         if (string.sub(message, 1, 1) == "\\" or string.sub(message, 1, 1) == "/") then
  138.             local ip = getip(player)
  139.             if isadmin(player) == true or ipadmin[ip] == true then
  140.                 allowchat = false
  141.                 newcommands(message, player)
  142.             else
  143.                 allowchat = false
  144.                 local line = "(Non-Admin User: %s) (Attempted Command: %s)"
  145.                 local Line = string.format(line, getname(player), message)
  146.                 WriteLog(log_file, Line)
  147.                 --sendconsoletext(player, "You are not an admin!!! This incident has been reported!")
  148.             end
  149.         else
  150.             local chatlog = getprofilepath() .. "\\logs\\chatlog.log"
  151.             local line = "(User: %s) (Message: %s)"
  152.             local Line = string.format(line, getname(player), message)
  153.             WriteLog(chatlog, Line)
  154.         end
  155.  
  156.         if t[1] == "\\stats" or t[1] == "/stats" then
  157.             if tonumber(deaths[name]) ~= nil then else deaths[name] = 0 end
  158.             if tonumber(kills[name]) ~= nil then else kills[name] = 0 end
  159.             privatesay(player, "Overall stats for this server.")
  160.             privatesay(player, "Kills: " .. kills[name])
  161.             privatesay(player, "Deaths: " .. deaths[name])
  162.             privatesay(player, "K/D Ratio: " .. getplayerkdr(player))
  163.             allowchat = false
  164.         elseif t[1] == "\\info" or t[1] == "/info" then
  165.             local server_name = readwidestring(network_struct + 0x8, 0x42)
  166.             local svmap = readstring(network_struct + 0x8C, 0x80)
  167.             local svgt = readwidestring(network_struct + 0x10C, 0x18)
  168.             local curplayers = readword(network_struct + (0x1A8+ce))
  169.             local maxplayers = readbyte(network_struct + (0x1A5+ce))
  170.             if curplayers ~= nil then else curplayers = 0 end
  171.             privatesay(player, "Server Name: " .. tostring(server_name))
  172.             privatesay(player, "Map: " .. tostring(svmap) .. " Gametype: " .. tostring(svgt))
  173.             privatesay(player, "Players: " .. tonumber(curplayers) .. "/" .. tonumber(maxplayers))
  174.             allowchat = false
  175.         elseif t[1] == "\\lead" or t[1] == "/lead" then
  176.             privatesay(player, "This server does not have nolead!")
  177.             privatesay(player, "You have to lead now!")
  178.             allowchat = false
  179.         end
  180.  
  181.         if t[1] == "rtv" or t[1] == "skip" then
  182.             local needed = math.ceil(getteamsize(0) + getteamsize(1) / rtv_needed)
  183.             if not rtvactive then
  184.                 rtvactive = true
  185.                 if not rtved[name] then
  186.                     rtved[name] = true
  187.                     say(name .. " has voted to skip the map! Type 'rtv' or 'skip' in chat to join.")
  188.                     if rtvcount then
  189.                         rtvcount = tonumber(rtvcount) + 1
  190.                         if rtvcount >= needed then
  191.                             say("Enough votes to skip the map. The game will now end!")
  192.                             svcmd("sv_map_next")
  193.                         else
  194.                             say(rtvcount .. " / " .. needed.. " votes needed to skip the current map!")
  195.                         end
  196.                     else
  197.                         rtvcount = 1
  198.                     end
  199.                 else
  200.                     privatesay(player, "You have already voted to skip the map!")
  201.                 end
  202.             else
  203.                 if not rtved[name] then
  204.                     say(name .. " has voted to skip the map! Type 'rtv' or 'skip' in chat to join.")
  205.                     rtved[name] = true
  206.                     if rtvcount then
  207.                         rtvcount = rtvcount + 1
  208.                         if rtvcount >= needed then
  209.                             say("Enough votes to skip the map. The game will now end!")
  210.                             svcmd("sv_map_next")
  211.                         else
  212.                             say(rtvcount .. " / " .. needed.. " votes needed to skip the current map!")
  213.                         end
  214.                     else
  215.                         rtvcount = 1
  216.                     end
  217.                 else
  218.                     privatesay(player, "You have already voted to skip the map!")
  219.                 end
  220.             end
  221.             allowchat = false
  222.         elseif t[1] == "votekick" or t[1] == "kick" then
  223.             allowchat = false
  224.             local needed = math.ceil(getteamsize(0) + getteamsize(1) / votekick_needed)
  225.             if not kickactive then
  226.                 if t[2] ~= nil then
  227.                     for i = 0,15 do
  228.                         if getplayer(i) ~= nil then
  229.                             if tonumber(t[2]) ~= nil then
  230.                                 if rresolveplayer(t[2]) == i then
  231.                                     votekick[getname(i)] = true
  232.                                     voted[name] = true
  233.                                     kickactive = true
  234.                                     kickcount = 1
  235.                                     say(name .. " has started a votekick on " .. getname(i) .. "! Type 'votekick' or 'kick' in chat to join.")
  236.                                     vname = getname(i)
  237.                                     registertimer(votekick_timeout*60*1000, "vktimeout", i)
  238.                                 else
  239.                                     privatesay(player, "Invalid Player! Must use number or full name!")
  240.                                 end
  241.                             elseif tostring(t[2]) ~= nil then
  242.                                 if t[2] == getname(i) then
  243.                                     votekick[getname(i)] = true
  244.                                     voted[name] = true
  245.                                     kickactive = true
  246.                                     kickcount = 1
  247.                                     say(name .. " has started a votekick on " .. getname(i) .. "! Type 'votekick' or 'kick' in chat to join.")
  248.                                     vname = getname(i)
  249.                                     vindex = i
  250.                                     registertimer(votekick_timeout*60*1000, "vktimeout", i)
  251.                                 else
  252.                                     privatesay(player, "Invalid Player! Must use number or full name!")
  253.                                 end
  254.                             else
  255.                                 privatesay(player, "Invalid Player! Must use number or full name!")
  256.                             end
  257.                         end
  258.                     end
  259.                 end
  260.             else
  261.                 if t[2] == nil then
  262.                     if kickactive then
  263.                         if not voted[name] then
  264.                             say(name .. " has voted to kick " .. vname)
  265.                             if kickcount then
  266.                                 kickcount = kickcount + 1
  267.                                 if kickcount >= needed then
  268.                                     say("Enough votes to kick " .. vname .. "!")
  269.                                     svcmd("sv_kick " .. resolveplayer(vindex))
  270.                                     kickactive = false
  271.                                     kickcount = 0
  272.                                     vname = nil
  273.                                     vindex = nil
  274.                                 else
  275.                                     say(kickcount .. " / " .. needed .. " votes to kick " .. vname .. "!")
  276.                                 end
  277.                             else
  278.                                 kickcount = 1
  279.                             end
  280.                         else
  281.                             privatesay(player, "You have already voted to kick " .. vname .. ".")
  282.                         end
  283.                     else
  284.                         privatesay(player, "A votekick has not been called.")
  285.                     end
  286.                 end
  287.             end
  288.         end
  289.     end
  290.     return allowchat
  291. end
  292.  
  293. function vktimeout(idk, idk1, player)
  294.     if kickactive then
  295.         if getplayer(player) ~= nil then
  296.             say("The votekick on " .. vname .. " is no longer active!")
  297.             kickactive = false
  298.             kickcount = 0
  299.             vname = nil
  300.             vindex = nil
  301.         else
  302.             say("The votekick on " .. vname .. " is no longer active!")
  303.             kickactive = false
  304.             kickcount = 0
  305.             vname = nil
  306.             vindex = nil
  307.         end
  308.     end
  309. end
  310.  
  311. function OnServerCommandAttempt(player, command, password)
  312.     local allow = false
  313.     local real = true
  314.     local ip = getip(player)
  315.  
  316.     if isadmin(player) == true or ipadmin[ip] == true then
  317.  
  318.         allow = true
  319.  
  320.         if string.sub(command, 0,3) ~= "cls" then
  321.             if "sv_" ~= string.sub(command, 0,3) then
  322.                 command = "sv_" .. command
  323.             end
  324.         end
  325.  
  326.         local t = tokenizecmdstring(command)
  327.  
  328.         for i=1,#commands do
  329.             if t[1] == commands[i][1] then
  330.                 real = false
  331.             end
  332.         end
  333.  
  334.         if real == false then
  335.             newcommands(command, player)
  336.             allow = false
  337.         end
  338.  
  339.     else
  340.         allow = false
  341.         sendconsoletext(player, "Incorrect Rcon!")
  342.         if failedrcons[ip] then
  343.             failedrcons[ip] = tonumber(failedrcons[ip]) + 1
  344.             if tonumber(failedrcons[ip]) < 2 then -- warning level
  345.                 privatesay(player, "WARNING!!! Failed RCON attempt number: " .. tonumber(failedrcons[ip]) .. " Your next attempt may result in a ban!")
  346.                 if tonumber(failedrcons[ip]) <= rcon_fails_to_ban then
  347.                     svcmd("sv_ban " .. resolveplayer(player) .. " 1d")
  348.                 end
  349.             end
  350.         else
  351.             failedrcons[ip] = 1
  352.         end
  353.     end
  354.     return allow
  355. end
  356.  
  357. function OnServerCommand(player, command)
  358.     local allow = true
  359.     local real = true
  360.  
  361.     if string.sub(command, 0,3) ~= "cls" then
  362.         if "sv_" ~= string.sub(command, 0,3) then
  363.             command = "sv_" .. command
  364.         end
  365.     end
  366.  
  367.     local t = tokenizecmdstring(command)
  368.  
  369.     for i=1,#commands do
  370.         if t[1] == commands[i][1] then
  371.             real = false
  372.         end
  373.     end
  374.  
  375.     if real == false then
  376.         newcommands(command, player)
  377.         allow = false
  378.     end
  379.  
  380.     return allow
  381. end
  382.  
  383.  
  384. function OnPlayerJoin(player)
  385.     local name = getname(player)
  386.     local hash = gethash(player)
  387.     local ip = getip(player)
  388.  
  389.     rtved[name] = false
  390.  
  391.     for x = 1,#bannedips do
  392.         if ip == bannedips[x][1] and bannedips[x][2] == true then
  393.             Ipban(player)
  394.         end
  395.     end
  396.  
  397.     for i = 0,15 do
  398.         if getplayer(i) ~= nil then
  399.             if not allow_ip_duplicates then
  400.                 if getip(i) == ip then
  401.                     kick(player)
  402.                 end
  403.             end
  404.         end
  405.     end
  406.  
  407.     if kills[name] then else kills[name] = 0 end
  408.     if deaths[name] then else deaths[name] = 0 end
  409.  
  410.     if unique_counter then
  411.         if not uniques[name] then
  412.             uniques[name] = 1
  413.             unique_count = tonumber(unique_count) + 1
  414.             say(name .. " is unique player #" .. unique_count)
  415.         else
  416.             if welcome_back_msg then
  417.                 uniques[name] = tonumber(uniques[name]) + 1
  418.                 privatesay(player, "Welcome back to the server " .. name .. "! You have been here " .. tonumber(uniques[name]) .. " times.")
  419.             end
  420.         end
  421.     end
  422. end
  423.  
  424. function tokenizestring(inputstr, sep)
  425.     if sep == nil then
  426.         sep = "%s"
  427.     end
  428.     local t={} ; i=1
  429.     for str in string.gmatch(inputstr, "([^"..sep.."]+)") do
  430.         t[i] = str
  431.         i = i + 1
  432.     end
  433.     return t
  434. end
  435.  
  436. function OnPlayerLeave(player)
  437. end
  438.  
  439. function OnVehicleEntry(player, vehiId, seat, mapId, voluntary)
  440.     if not voluntary then
  441.         forcedentry[player] = true
  442.     else
  443.         forcedentry[player] = false
  444.     end
  445. end
  446.  
  447. function OnVehicleEject(player, voluntary)
  448.     if forcedentry[player] then
  449.         destroyobject(getplayerobjectid(player)) -- Destroys vehicles spawned by phasor if a player decides to leave it (should prevent the server from crashing on maps that should not have vehicles.)
  450.         forcedentry[player] = false
  451.     end
  452. end
  453.  
  454. function OnDamageLookup(receiving, causing, tagid, tagdata)
  455.     if fall_damage == false then
  456.         local tagname = gettaginfo(tagid)
  457.         if (tagname == "globals\\falling" or tagname == "globals\\distance") then
  458.             odl_multiplier(0.001)
  459.         end
  460.     end
  461. end
  462.  
  463. function OnPlayerKill(killer, victim, mode)
  464.     if mode == 0 then
  465.         if victim then
  466.             local name = getname(victim)
  467.             if deaths[name] then
  468.                 deaths[name] = tonumber(deaths[name]) + 1
  469.             else
  470.                 deaths[name] = 1
  471.             end
  472.         end
  473.     elseif mode == 1 then
  474.         if victim then
  475.             local name = getname(victim)
  476.             if deaths[name] then
  477.                 deaths[name] = tonumber(deaths[name]) + 1
  478.             else
  479.                 deaths[name] = 1
  480.             end
  481.         end
  482.     elseif mode == 2 then
  483.         if victim then
  484.             local name = getname(victim)
  485.             if deaths[name] then
  486.                 deaths[name] = tonumber(deaths[name]) + 1
  487.             else
  488.                 deaths[name] = 1
  489.             end
  490.         end
  491.     elseif mode == 3 then
  492.         if victim then
  493.             local name = getname(victim)
  494.             if deaths[name] then
  495.                 deaths[name] = tonumber(deaths[name]) + 1
  496.             else
  497.                 deaths[name] = 1
  498.             end
  499.         end
  500.     elseif mode == 4 then
  501.         if victim then
  502.             local name = getname(victim)
  503.             local kname = getname(killer)
  504.             if kills[kname] then
  505.                 kills[kname] = tonumber(kills[kname]) + 1
  506.             else
  507.                 kills[kname] = 1
  508.             end
  509.             if deaths[name] then
  510.                 deaths[name] = tonumber(deaths[name]) + 1
  511.             else
  512.                 deaths[name] = 1
  513.             end
  514.         end
  515.     elseif mode == 5 then
  516.         if victim then
  517.             local name = getname(victim)
  518.             if deaths[name] then
  519.                 deaths[name] = tonumber(deaths[name]) + 1
  520.             else
  521.                 deaths[name] = 1
  522.             end
  523.         end
  524.     elseif mode == 6 then
  525.         if victim then
  526.             local name = getname(victim)
  527.             if deaths[name] then
  528.                 deaths[name] = tonumber(deaths[name]) + 1
  529.             else
  530.                 deaths[name] = 1
  531.             end
  532.         end
  533.     end
  534. end
  535.  
  536. function OnClientUpdate(player)
  537.     local m_player = getplayer(player)
  538.     if hidden[player] == true then
  539.         writefloat(m_player + 0x100, -1000)
  540.     end
  541. end
  542.  
  543. ------------------------------------------------------------------------------------------
  544. -------------------------------------- [[Commands]] --------------------------------------
  545. ------------------------------------------------------------------------------------------
  546.  
  547.  
  548. function newcommands(command, player)
  549.     local t = tokenizecmdstring(command)
  550.     if player ~= nil then
  551.         if t[1] == "\\e" or t[1] == "/e" then
  552.             if t[2] ~= nil then
  553.                 svcmd(command)
  554.             else
  555.                 sendconsoletext(player, "Incorrect usage! Syntax: e [command] {arguments}")
  556.             end
  557.         elseif t[1] == "\\b" or t[1] == "/b" then
  558.             if tonumber(t[2]) ~= nil then
  559.                 svcmd("sv_ban " .. t[2])
  560.             else
  561.                 sendconsoletext(player, "Incorrect usage! Syntax: b [number]")
  562.             end
  563.         elseif t[1] == "\\k" or t[1] == "/k" then
  564.             if tonumber(t[2]) ~= nil then
  565.                 svcmd("sv_kick " .. t[2])
  566.             else
  567.                 sendconsoletext(player, "Incorrect usage! Syntax: k [number]")
  568.             end
  569.         elseif t[1] == "\\setscore" or t[1] == "/setscore" or t[1] == "sv_setscore" then
  570.             if t[3] ~= nil then
  571.                 command_setscore(player, t[2], t[3])
  572.             else
  573.                 sendconsoletext(player, "Incorrect usage! Syntax: setscore [player] [amount]")
  574.             end
  575.         elseif t[1] == "\\setkills" or t[1] == "/setkills" or t[1] == "sv_setkills" then
  576.             if t[3] ~= nil then
  577.                 command_setkills(player, t[2], t[3])
  578.             else
  579.                 sendconsoletext(player, "Incorrect usage! Syntax: setkills [player] [amount]")
  580.             end
  581.         elseif t[1] == "\\setassists" or t[1] == "/setassists" or t[1] == "sv_setassists" then
  582.             if t[3] ~= nil then
  583.                 command_setassists(player, t[2], t[3])
  584.             else
  585.                 sendconsoletext(player, "Incorrect usage! Syntax: setassists [player] [amount]")
  586.             end
  587.         elseif t[1] == "\\setdeaths" or t[1] == "/setdeaths" or t[1] == "sv_setdeaths" then
  588.             if t[3] ~= nil then
  589.                 command_setdeaths(player, t[2], t[3])
  590.             else
  591.                 sendconsoletext(player, "Incorrect usage! Syntax: setdeaths [player] [amount]")
  592.             end
  593.         elseif t[1] == "\\setammo" or t[1] == "/setammo" or t[1] == "sv_setammo" then
  594.             if t[4] ~= nil then
  595.                 command_setdeaths(player, t[2], t[3], t[4])
  596.             else
  597.                 sendconsoletext(player, "Incorrect usage! Syntax: setammo [player] [type] [amount]")
  598.             end
  599.         elseif t[1] == "\\hide" or t[1] == "/hide" or t[1] == "sv_hide" then
  600.             if t[2] ~= nil then
  601.                 command_hide(player, t[2], 0)
  602.             else
  603.                 sendconsoletext(player, "Incorrect usage! Syntax: hide [player]")
  604.             end
  605.         elseif t[1] == "\\unhide" or t[1] == "/unhide" or t[1] == "sv_unhide" then
  606.             if t[2] ~= nil then
  607.                 command_hide(player, t[2], 1)
  608.             else
  609.                 sendconsoletext(player, "Incorrect usage! Syntax: unhide [player]")
  610.             end
  611.         elseif t[1] == "\\ghost" or t[1] == "/ghost" or t[1] == "sv_ghost" then
  612.             if t[2] ~= nil then
  613.                 command_ghost(player, t[2], 0)
  614.             else
  615.                 sendconsoletext(player, "Incorrect usage! Syntax: ghost [player]")
  616.             end
  617.         elseif t[1] == "\\unghost" or t[1] == "/unghost" or t[1] == "sv_unghost" then
  618.             if t[2] ~= nil then
  619.                 command_ghost(player, t[2], 1)
  620.             else
  621.                 sendconsoletext(player, "Incorrect usage! Syntax: unghost [player]")
  622.             end
  623.  
  624.         elseif t[1] == "\\god" or t[1] == "/god" or t[1] == "sv_god" then
  625.             if t[2] ~= nil then
  626.                 command_god(player, t[2], 0)
  627.             else
  628.                 sendconsoletext(player, "Incorrect usage! Syntax: god [player]")
  629.             end
  630.         elseif t[1] == "\\ungod" or t[1] == "/ungod" or t[1] == "sv_ungod" then
  631.             if t[2] ~= nil then
  632.                 command_god(player, t[2], 1)
  633.             else
  634.                 sendconsoletext(player, "Incorrect usage! Syntax: ungod [player]")
  635.             end
  636.         elseif t[1] == "\\spawn" or t[1] == "/spawn" or t[1] == "sv_spawn" then
  637.             if t[2] ~= nil and t[3] ~= nil then
  638.                 command_spawngiveenter(player, t[2], t[3], 0)
  639.             else
  640.                 sendconsoletext(player, "Incorrect usage! Syntax: spawn [object] [player]")
  641.             end
  642.         elseif t[1] == "\\enter" or t[1] == "/enter" or t[1] == "sv_enter" then
  643.             if t[2] ~= nil and t[3] ~= nil then
  644.                 command_spawngiveenter(player, t[2], t[3], 1)
  645.             else
  646.                 sendconsoletext(player, "Incorrect usage! Syntax: enter [vehicle] [player]")
  647.             end
  648.         elseif t[1] == "\\give" or t[1] == "/give" or t[1] == "sv_give" then
  649.             if t[2] ~= nil and t[3] ~= nil then
  650.                 command_spawngiveenter(player, t[2], t[3], 2)
  651.             else
  652.                 sendconsoletext(player, "Incorrect usage! Syntax: give [weapon or powerup] [player]")
  653.             end
  654.         elseif t[1] == "\\dyslexic" or t[1] == "/dyslexic" or t[1] == "sv_dyslexic" then
  655.             if t[2] ~= nil then
  656.                 command_dyslexic(player, t[2], 0)
  657.             else
  658.                 sendconsoletext(player, "Incorrect usage! Syntax: dyslexic [player]")
  659.             end
  660.         elseif t[1] == "\\undyslexic" or t[1] == "/undyslexic" or t[1] == "sv_undyslexic" then
  661.             if t[2] ~= nil then
  662.                 command_dyslexic(player, t[2], 1)
  663.             else
  664.                 sendconsoletext(player, "Incorrect usage! Syntax: undyslexic [player]")
  665.             end
  666.         elseif t[1] == "\\ipban" or t[1] == "/ipban" or t[1] == "sv_ipban" then
  667.             if t[2] ~= nil then
  668.                 command_ipban(player, t[2], t[3], 0)
  669.             else
  670.                 sendconsoletext(player, "Incorrect usage! Syntax: ipban [player] {Reason-Use-Dashes-Reason}")
  671.             end
  672.         elseif t[1] == "\\unipban" or t[1] == "/unipban" or t[1] == "sv_unipban" then
  673.             if t[2] ~= nil then
  674.                 command_ipban(player, t[2], 1)
  675.             else
  676.                 sendconsoletext(player, "Incorrect usage! Syntax: unipban [ip]")
  677.             end
  678.         elseif t[1] == "\\ipbanlist" or t[1] == "/ipbanlist" or t[1] == "sv_ipbanlist" then
  679.             if t[2] == nil then
  680.                 command_ipban(player, nil, 2)
  681.             else
  682.                 sendconsoletext(player, "Incorrect usage! Syntax: ipbanlist")
  683.             end
  684.         elseif t[1] == "\\ghost" or t[1] == "/ghost" or t[1] == "sv_ghost" then
  685.             if t[2] ~= nil then
  686.                 command_ghost(player, t[2], 0)
  687.             else
  688.                 sendconsoletext(player, "Incorrect usage! Syntax: ghost [player]")
  689.             end
  690.         elseif t[1] == "\\unghost" or t[1] == "/unghost" or t[1] == "sv_unghost" then
  691.             if t[2] ~= nil then
  692.                 command_ghost(player, t[2], 1)
  693.             else
  694.                 sendconsoletext(player, "Incorrect usage! Syntax: unghost [player]")
  695.             end
  696.         elseif t[1] == "\\falldamage" or t[1] == "/falldamage" or t[1] == "sv_falldamage" then
  697.             if t[2] ~= nil then
  698.                 local line = "(User: %s) (Command: %s) (Mode: %s)"
  699.                 local Line = string.format(line, getname(player),"falldamage", t[2])
  700.                 WriteLog(log_file, Line)
  701.                 if tonumber(t[2]) == 1 or t[2] == "true" then
  702.                     fall_damage = true
  703.                     sendconsoletext(player, "Fall damage = On")
  704.                 elseif tonumber(t[2]) == 0 or t[2] == "false" then
  705.                     fall_damage = false
  706.                     sendconsoletext(player, "Fall damage = Off")
  707.                 else
  708.                     sendconsoletext(player, "Invalid usage.")
  709.                 end
  710.             end
  711.         elseif t[1] == "\\ipadmin_add" or t[1] == "/ipadmin_add" or t[1] == "sv_ipadmin_add" then
  712.             if tonumber(t[2]) ~= nil then
  713.                 local line = "(User: %s) (Command: %s) (Player: %s)"
  714.                 local Line = string.format(line, getname(player),"ipadmin_add", t[2])
  715.                 WriteLog(log_file, Line)
  716.                 if getplayer(t[2]) ~= nil then
  717.                     local ip = getip(t[2])
  718.                     ipadmin[ip] = true
  719.                     sendconsoletext(player, getname(t[2]) .. " is now an ip admin.")
  720.                 else
  721.                     sendconsoletext(player, "Invalid Player.")
  722.                 end
  723.             else
  724.                 sendconsoletext(player, "You must use the players number.")
  725.             end
  726.         elseif t[1] == "\\ipadmin_del" or t[1] == "/ipadmin_del" or t[1] == "sv_ipadmin_del" then
  727.             if tonumber(t[2]) ~= nil then
  728.                 local line = "(User: %s) (Command: %s) (Player: %s)"
  729.                 local Line = string.format(line, getname(player),"ipadmin_del", t[2])
  730.                 WriteLog(log_file, Line)
  731.                 if getplayer(t[2]) ~= nil then
  732.                     local ip = getip(t[2])
  733.                     ipadmin[ip] = false
  734.                     sendconsoletext(player, getname(t[2]) .. " is no longer an ip admin.")
  735.                 else
  736.                     sendconsoletext(player, "Invalid Player.")
  737.                 end
  738.             else
  739.                 sendconsoletext(player, "You must use the players number.")
  740.             end
  741.         elseif t[1] == "\\pl" or t[1] == "/pl" or t[1] == "sv_pl" then
  742.             sendconsoletext(player, "Number - Name")
  743.             for i = 0,15 do
  744.                 if getplayer(i) ~= nil then
  745.                     sendconsoletext(player, resolveplayer(i) .. " - " .. getname(i))
  746.                 end
  747.             end
  748.         elseif t[1] == "\\spd" or t[1] == "/spd" then
  749.             if t[2] ~= nil then
  750.                 local players = getvalidplayers(t[2], player)
  751.                 if t[3] ~= nil then
  752.                     if players then
  753.                         for i = 1,#players do
  754.                             local line = "(User: %s) (Command: %s) (Player: %s) (Speed: %s)"
  755.                             local Line = string.format(line, getname(player),"spd", t[2], t[3])
  756.                             WriteLog(log_file, Line)
  757.                             svcmd("sv_setspeed " .. resolveplayer(players[i]) .. " " .. t[3])
  758.                             sendconsoletext(player, getname(players[i]) .. "'s speed has been set to " .. t[3])
  759.                         end
  760.                     else
  761.                         sendconsoletext(player, "Invlaid Player")
  762.                     end
  763.                 else
  764.                     sendconsoletext(player, "You must specify a new speed.")
  765.                 end
  766.             else
  767.                 sendconsoletext(user, "Invlaid Player")
  768.             end
  769.         elseif t[1] == "\\votekick_enbled" or t[1] == "/votekick_enabled" or t[1] == "sv_votekick_enabled" then
  770.             if t[2] ~= nil then
  771.                 local line = "(User: %s) (Command: %s) (Mode: %s)"
  772.                 local Line = string.format(line, getname(player),"votekick_enabled", t[2])
  773.                 WriteLog(log_file, Line)
  774.                 if tonumber(t[2]) == 1 or t[2] == "true" then
  775.                     votekick_enabled = true
  776.                     sendconsoletext(player, "Votekicking has been enabled.")
  777.                 elseif tonumber(t[2]) == 0 or t[2] == "false" then
  778.                     votekick_enabled = false
  779.                     sendconsoletext(player, "Votekicking has been disabled.")
  780.                 else
  781.                     sendconsoletext(player, "Invlaid option.")
  782.                 end
  783.                 sendconsoletext(player, "Invalid syntax: votekick_enabled [true or false]")
  784.             end
  785.         elseif t[1] == "\\votekick_needed" or t[1] == "/votekick_needed" or t[1] == "sv_votekick_needed" then
  786.             if t[2] ~= nil then
  787.                 local line = "(User: %s) (Command: %s) (amount: %s)"
  788.                 local Line = string.format(line, getname(player),"votekick_needed", t[2])
  789.                 WriteLog(log_file, Line)
  790.                 if tonumber(t[2]) == 1 then
  791.                     votekick_needed = t[2]
  792.                     votekick_enabled = true
  793.                     sendconsoletext(player, "Votekick needed has been set to " .. t[2] .. "% and enabled.")
  794.                 else
  795.                     sendconsoletext(player, "Invlaid option.")
  796.                 end
  797.                 sendconsoletext(player, "Invalid syntax: votekick_needed [number] Note: Use decimals Ex: 0.65 = 65%")
  798.             end
  799.         elseif t[1] == "\\votekick_timeout" or t[1] == "/votekick_timeout" or t[1] == "sv_votekick_timeout" then
  800.             if t[2] ~= nil then
  801.                 local line = "(User: %s) (Command: %s) (Time: %s)"
  802.                 local Line = string.format(line, getname(player),"votekick_needed", t[2])
  803.                 WriteLog(log_file, Line)
  804.                 if tonumber(t[2]) == 1 then
  805.                     votekick_timeout = t[2]
  806.                     sendconsoletext(player, "Votekick timeout has been set to " .. t[2] .. " minutes.")
  807.                 else
  808.                     sendconsoletext(player, "Invlaid option.")
  809.                 end
  810.                 sendconsoletext(player, "Invalid syntax: votekick_timeout [time(in minutes)]")
  811.             end
  812.         elseif t[1] == "\\rtv_enbled" or t[1] == "/rtv_enabled" or t[1] == "sv_rtv_enabled" then
  813.             if t[2] ~= nil then
  814.                 local line = "(User: %s) (Command: %s) (Mode: %s)"
  815.                 local Line = string.format(line, getname(player),"rtv_enabled", t[2])
  816.                 WriteLog(log_file, Line)
  817.                 if tonumber(t[2]) == 1 or t[2] == "true" then
  818.                     rtv_enabled = true
  819.                     sendconsoletext(player, "RTV / Map skipping has been enabled.")
  820.                 elseif tonumber(t[2]) == 0 or t[2] == "false" then
  821.                     rtv_enabled = false
  822.                     sendconsoletext(player, "RTV / Map skipping has been disabled.")
  823.                 else
  824.                     sendconsoletext(player, "Invlaid option.")
  825.                 end
  826.                 sendconsoletext(player, "Invalid syntax: rtv_enabled [true or false]")
  827.             end
  828.         elseif t[1] == "\\rtv_needed" or t[1] == "/rtv_needed" or t[1] == "sv_rtv_needed" or t[1] == "\\map_skip" or t[1] == "/map_skip" or t[1] == "sv_map_skip" then
  829.             if t[2] ~= nil then
  830.                 if tonumber(t[2]) == 1 then
  831.                     local line = "(User: %s) (Command: %s) (amount: %s)"
  832.                     local Line = string.format(line, getname(player),"rtv_needed", t[2])
  833.                     WriteLog(log_file, Line)
  834.                     rtv_needed = t[2]
  835.                     rtv_enabled = true
  836.                     sendconsoletext(player, "RTV / Map skipping has been set to " .. t[2] .. "% and enabled.")
  837.                 else
  838.                     sendconsoletext(player, "Invlaid option.")
  839.                 end
  840.                 sendconsoletext(player, "Invalid syntax: rtv_needed [number] Note: Use decimals Ex: 0.65 = 65%")
  841.             end
  842.         elseif t[1] == "\\kill" or t[1] == "/kill" or t[1] == "sv_kill"  then
  843.             if t[2] ~= nil then
  844.                 local players = getvalidplayers(t[2], player)
  845.                 if players then
  846.                     for i = 1,#players do
  847.                         local line = "(User: %s) (Command: %s) (Player: %s)"
  848.                         local Line = string.format(line, getname(player),"kill", t[2])
  849.                         WriteLog(log_file, Line)
  850.                         svcmd("sv_kill " .. resolveplayer(players[i]))
  851.                         sendconsoletext(player, getname(players[i]) .. " has been killed.")
  852.                     end
  853.                 else
  854.                     sendconsoletext(player, "Invlaid Player")
  855.                 end
  856.             else
  857.                 sendconsoletext(user, "Invlaid Player")
  858.             end
  859.         elseif t[1] == "\\hax" or t[1] == "/hax" or t[1] == "sv_hax" then
  860.             if t[2] ~= nil then
  861.                 command_hax(player, t[2], 0)
  862.             else
  863.                 sendconsoletext(player, "Incorrect usage! Syntax: hax [player]")
  864.             end
  865.         elseif t[1] == "\\unhax" or t[1] == "/unhax" or t[1] == "sv_unhax" then
  866.             if t[2] ~= nil then
  867.                 command_hax(player, t[2], 1)
  868.             else
  869.                 sendconsoletext(player, "Incorrect usage! Syntax: unhax [player]")
  870.             end
  871.         elseif t[1] == "\\teamswap" or t[1] == "/teamswap" or t[1] == "sv_teamswap" then
  872.             if t[2] ~= nil then
  873.                 command_teamswap(player, t[2])
  874.             else
  875.                 sendconsoletext(player, "Incorrect usage! Syntax: teamswap [player]")
  876.             end
  877.         elseif t[1] == "\\st" or t[1] == "/st" or t[1] == "sv_st" or t[1] == "/ts" or t[1] == "\\ts" or t[1] == "sv_ts" then
  878.             if t[2] ~= nil then
  879.  
  880.                 local line = "(User: %s) (Command: %s) (Player: %s)"
  881.                 local Line = string.format(line, getname(player),"st", recipient)
  882.                 WriteLog(log_file, Line)
  883.  
  884.                 local players = getvalidplayers(t[2], player)
  885.                 if players then
  886.                     for i = 1,#players do
  887.                         changeteam(players[i], true)
  888.                     end
  889.                 else
  890.                     sendconsoletext(player, "Invlaid Player")
  891.                 end
  892.             else
  893.                 sendconsoletext(player, "Incorrect usage! Syntax: st [player]")
  894.             end
  895.         elseif t[1] == "\\info" or t[1] == "/info" or t[1] == "\\stats" or t[1] == "/stats" or t[1] == "\\lead" or t[1] == "/lead" then
  896.         else
  897.             sendconsoletext(player, "Invlaid command")
  898.         end
  899.     end
  900. end
  901.  
  902. function command_teamswap(user, recipient)
  903.     if recipient ~= nil then else recipient = resolveplayer(user) end -- Just incase the script lets something through.
  904.  
  905.     local line = "(User: %s) (Command: %s) (Player: %s)"
  906.     local Line = string.format(line, getname(user),"teamswap", recipient)
  907.     WriteLog(log_file, Line)
  908.  
  909.     local players = getvalidplayers(recipient, user)
  910.     if players then
  911.         for i = 1,#players do
  912.             changeteam(players[i], false)
  913.             sendconsoletext(user, getname(players[i]) .. " team has been changed despite the color of his or her armor.")
  914.         end
  915.     else
  916.         sendconsoletext(user, "Invlaid Player")
  917.     end
  918. end
  919.  
  920. function command_hax(user, recipient, mode)
  921.     if recipient ~= nil then else recipient = resolveplayer(user) end -- Just incase the script lets something through.
  922.  
  923.     local line = "(User: %s) (Command: %s) (Player: %s) (Mode: %s)"
  924.     local Line = string.format(line, getname(user),"hax", recipient, mode)
  925.     WriteLog(log_file, Line)
  926.  
  927.     local players = getvalidplayers(recipient, user)
  928.     if players then
  929.         for i = 1,#players do
  930.             if mode == 0 then
  931.                 haxed[players[i]] = true
  932.                 sendconsoletext(user, getname(players[i]) .. " has been haxed!")
  933.                 if not haxedtimer then
  934.                     registertimer(250, "haxedplayer", players[i])
  935.                     haxedtimer = true
  936.                 end
  937.             elseif mode == 1 then
  938.                 local m_player = getplayer(players[i])
  939.                 setscore(players[i], 0)
  940.                 writeword(m_player + 0x9C, 0)
  941.                 writeword(m_player + 0xA4, 0)
  942.                 writeword(m_player + 0xAE, 0)
  943.                 haxed[players[i]] = false
  944.                 sendconsoletext(user, getname(players[i]) .. " has been unhaxed!")
  945.             end
  946.         end
  947.     else
  948.         sendconsoletext(user, "Invlaid Player")
  949.     end
  950. end
  951.  
  952. function haxedplayer(idk, idk1, player)
  953.     if player then
  954.         if haxed[player] == true then
  955.             local rand = getrandomnumber(100, 999)
  956.             local rand1 = getrandomnumber(100, 999)
  957.             local rand2 = getrandomnumber(100, 999)
  958.             local rand3 = getrandomnumber(100, 999)
  959.             local m_player = getplayer(player)
  960.             setscore(player, rand)
  961.             writeword(m_player + 0x9C, rand1)
  962.             writeword(m_player + 0xA4, rand2)
  963.             writeword(m_player + 0xAE, rand3)
  964.         end
  965.     end
  966.     if haxedtimer then
  967.         return true
  968.     else
  969.         return false
  970.     end
  971. end
  972.  
  973. function command_ipban(user, recipient, reason, mode)
  974.     if recipient ~= nil then else mode = 2 end
  975.  
  976.     local line = "(User: %s) (Command: %s) (Player: %s) (Mode: %s)"
  977.     local Line = string.format(line, getname(user),"ipban", recipient, reason, mode)
  978.     WriteLog(log_file, Line)
  979.  
  980.     local log_File = getprofilepath() .. "\\logs\\Ipbans.log" -- Secondary loging
  981.     local line = "(User: %s) (Command: %s) (Player: %s) (Mode: %s)"
  982.     local Line = string.format(line, getname(user),"ipban", recipient, reason, mode)
  983.     WriteLog(log_File, Line)
  984.  
  985.     if mode == 0 then
  986.         local players = getvalidplayers(recipient, user)
  987.         if players then
  988.             for i = 1,#players do
  989.                 local ip = getip(players[i])
  990.                 local name = getname(players[i])
  991.                 --if reason ~= nil then else reason = "None Given" end
  992.                 if not bannedips[ip] then
  993.                     bannedips[ip] = true
  994.                     say(name .. " has been ipbanned! Reason: " .. reason)
  995.                     sendconsoletext(user, name .. " has been ipbanned!")
  996.                 else
  997.                     say(name .. " has been ipbanned! Reason: " .. reason)
  998.                     sendconsoletext(user, name .. " has been ipbanned! Again...")
  999.                 end
  1000.             end
  1001.         else
  1002.             sendconsoletext(user, "Invlaid Player")
  1003.         end
  1004.     elseif mode == 1 then
  1005.         for i = 1,#bannedips do
  1006.             if recipient == bannedips[i][1] then
  1007.                 if bannedips[i][2] == true then
  1008.                     bannedips[i][2] = false
  1009.                     sendconsoletext(user, bannedips[i][1] .. "  has been unbanned.")
  1010.                 end
  1011.             else
  1012.                 sendconsoletext(user, "This ip does not appear to be banned. Please make sure you typed it in correctly")
  1013.             end
  1014.         end
  1015.     elseif mode == 2 then
  1016.         sendconsoletext(user, "Ip - Ban status")
  1017.         for i = 1,#bannedips do
  1018.             sendconsoletext(user, bannedips[i][1] .. " - " .. bannedips[i][2])
  1019.         end
  1020.     else
  1021.         sendconsoletext(user, "Error: Missing recipient or ip")
  1022.     end
  1023. end
  1024.  
  1025.  
  1026. function command_dyslexic(user, recipient, mode)
  1027.     if recipient ~= nil then else recipient = resolveplayer(user) end -- Just incase the script lets something through.
  1028.  
  1029.     local line = "(User: %s) (Command: %s) (Player: %s) (Mode: %s)"
  1030.     local Line = string.format(line, getname(user),"dyslexic", recipient, mode)
  1031.     WriteLog(log_file, Line)
  1032.  
  1033.     local players = getvalidplayers(recipient, user)
  1034.     if players then
  1035.         for i = 1,#players do
  1036.             if mode == 0 then
  1037.                 dyslexic[getname(players[i])] = true
  1038.             else
  1039.                 dyslexic[getname(players[i])] = false
  1040.             end
  1041.         end
  1042.     else
  1043.         sendconsoletext(user, "Invlaid Player")
  1044.     end
  1045. end
  1046.  
  1047. function command_spawngiveenter(user, object, recipient, mode)
  1048.     if recipient ~= nil then else recipient = resolveplayer(user) end -- Just incase the script lets something through.
  1049.  
  1050.     local players = getvalidplayers(recipient, user)
  1051.     if players then
  1052.         for i = 1,#players do
  1053.             if mode == 0 then
  1054.                 spawnobject(players[i], object, user)
  1055.             elseif mode == 1 then
  1056.                 enter(players[i], object, user)
  1057.             elseif mode == 2 then
  1058.                 giveweapon(players[i], object, user)
  1059.             end
  1060.         end
  1061.     else
  1062.         sendconsoletext(user, "Invlaid Player")
  1063.     end
  1064. end
  1065.  
  1066. function command_god(user, recipient, mode)
  1067.     if recipient ~= nil then else recipient = resolveplayer(user) end
  1068.  
  1069.     local line = "(User: %s) (Command: %s) (Player: %s) (Mode: %s)"
  1070.     local Line = string.format(line, getname(user),"God", recipient, mode)
  1071.     WriteLog(log_file, Line)
  1072.  
  1073.     local players = getvalidplayers(recipient, user)
  1074.     if players then
  1075.         for i = 1,#players do
  1076.             local m_object = getobject(getplayerobjectid(players[i]))
  1077.             if m_object then
  1078.                 if mode == 0 then
  1079.                     writefloat(m_object, 0xE0, 99999999)
  1080.                     writefloat(m_object, 0xE4, 99999999)
  1081.                     sendconsoletext(user, getname(players[i]) .. " now has godmode!")
  1082.                     privatesay(players[i], "You now have godmode!")
  1083.                 else
  1084.                     writefloat(m_object, 0xE0, 1)
  1085.                     writefloat(m_object, 0xE4, 1)
  1086.                     sendconsoletext(user, getname(players[i]) .. " no longer has godmode.")
  1087.                     privatesay(players[i], "You no longer have godmode.")
  1088.                 end
  1089.             end
  1090.         end
  1091.     else
  1092.         sendconsoletext(user, "Invlaid Player")
  1093.     end
  1094. end
  1095.  
  1096. function command_ghost(user, recipient, mode)
  1097.     if recipient ~= nil then else recipient = resolveplayer(user) end
  1098.  
  1099.     local line = "(User: %s) (Command: %s) (Player: %s) (Mode: %s)"
  1100.     local Line = string.format(line, getname(user),"Ghost", recipient, mode)
  1101.     WriteLog(log_file, Line)
  1102.  
  1103.     local players = getvalidplayers(recipient, user)
  1104.     if players then
  1105.         for i = 1,#players do
  1106.             local m_object = getobject(getplayerobjectid(players[i]))
  1107.             if m_object then
  1108.                 if mode == 0 then
  1109.                     writebit(m_object + 0x10, 7, 1)
  1110.                     sendconsoletext(user, getname(players[i]) .. " is now a ghost!")
  1111.                     privatesay(players[i], "You are now a ghost!")
  1112.                 else
  1113.                     writebit(m_object + 0x10, 7, 0)
  1114.                     sendconsoletext(user, getname(players[i]) .. " is no longer a ghost.")
  1115.                     privatesay(players[i], "You are no longer a ghost.")
  1116.                 end
  1117.             end
  1118.         end
  1119.     else
  1120.         sendconsoletext(user, "Invlaid Player")
  1121.     end
  1122. end
  1123.  
  1124. function command_hide(user, recipient, mode)
  1125.     if recipient ~= nil then else recipient = resolveplayer(user) end
  1126.  
  1127.     local line = "(User: %s) (Command: %s) (Player: %s) (Mode: %s)"
  1128.     local Line = string.format(line, getname(user),"Hide", recipient, mode)
  1129.     WriteLog(log_file, Line)
  1130.  
  1131.     local players = getvalidplayers(recipient, user)
  1132.     if players then
  1133.         for i = 1,#players do
  1134.             if tonumber(mode) == 0 then
  1135.                 sendconsoletext(user, getname(players[i]) .. " has been hidden!")
  1136.                 privatesay(players[i], "You have been hidden!")
  1137.                 hidden[players] = true
  1138.             else
  1139.                 sendconsoletext(user, getname(players[i]) .. " is no longer hidden.")
  1140.                 privatesay(players[i], "You are no longer hidden.")
  1141.                 hidden[players] = false
  1142.             end
  1143.         end
  1144.     else
  1145.         sendconsoletext(user, "Invlaid Player")
  1146.     end
  1147. end
  1148.  
  1149. function command_setammo(user, recipient, type, amount)
  1150.     if recipient ~= nil then else recipient = resolveplayer(user) end
  1151.  
  1152.     local line = "(User: %s) (Command: %s) (Player: %s) (amount: %s)"
  1153.     local Line = string.format(line, getname(user),"Setammo", recipient, amount)
  1154.     WriteLog(log_file, Line)
  1155.  
  1156.     local players = getvalidplayers(recipient, user)
  1157.     if players then
  1158.         for i = 1,#players do
  1159.             local m_objectId = getplayerobjectid(players[i]) or 0xFFFFFFFF
  1160.             local m_object = getobject(m_objectId)
  1161.             if m_object then
  1162.                 local m_weaponId = readdword(m_object + 0x118) or 0xFFFFFFFF
  1163.                 local m_weapon = getobject(m_weaponId)
  1164.                 if m_weapon then
  1165.                     if tonumber(amount) then
  1166.                         if type == "unloaded" or type == "1" then
  1167.                             writeword(m_weapon + 0x2B6, tonumber(ammo))
  1168.                             updateammo(m_weaponId)
  1169.                             sendconsoletext(user, getname(players[i]) .. " had their unloaded ammo changed to " .. amount)
  1170.                         elseif type == "2" or type == "loaded" then
  1171.                             writeword(m_weapon + 0x2B8, tonumber(ammo))
  1172.                             updateammo(m_weaponId)
  1173.                             sendconsoletext(user, getname(players[i]) .. " had their loaded ammo changed to " .. amount)
  1174.                         else
  1175.                             sendconsoletext(user, "Error: Type must be '1', 'unloaded', '2', 'loaded'")
  1176.                         end
  1177.                     else
  1178.                         sendconsoletext(user, "Error: You must use a number for the amount!")
  1179.                     end
  1180.                 end
  1181.             end
  1182.         end
  1183.     else
  1184.         sendconsoletext(user, "Invlaid Player")
  1185.     end
  1186. end
  1187.  
  1188. function command_setscore(user, recipient, amount)
  1189.     if recipient ~= nil then else recipient = resolveplayer(user) end
  1190.  
  1191.     local line = "(User: %s) (Command: %s) (Player: %s) (amount: %s)"
  1192.     local Line = string.format(line, getname(user),"Setscore", recipient, amount)
  1193.     WriteLog(log_file, Line)
  1194.  
  1195.     local players = getvalidplayers(recipient, user)
  1196.     if players then
  1197.         for i = 1,#players do
  1198.             local m_player = getplayer(players[i])
  1199.             if m_player then
  1200.                 if tonumber(amount) then
  1201.                     setscore(players[i], amount)
  1202.                     sendconsoletext(user, "Players score cannot be set right now.")
  1203.                 else
  1204.                     sendconsoletext(user, "Error: You must use a number for the amount!")
  1205.                 end
  1206.             end
  1207.         end
  1208.     else
  1209.         sendconsoletext(user, "Invlaid Player")
  1210.     end
  1211. end
  1212.  
  1213. function command_setkills(user, recipient, amount)
  1214.     if recipient ~= nil then else recipient = resolveplayer(user) end
  1215.  
  1216.     local line = "(User: %s) (Command: %s) (Player: %s)"
  1217.     local Line = string.format(line, getname(user),"Setkills", recipient)
  1218.     WriteLog(log_file, Line)
  1219.  
  1220.     local players = getvalidplayers(recipient, user)
  1221.     if players then
  1222.         for i = 1,#players do
  1223.             local m_player = getplayer(players[i])
  1224.             if m_player then
  1225.                 if tonumber(amount) then
  1226.                     writeshort(m_player + 0x9c, amount)
  1227.                     sendconsoletext(user, getname(players[i]) .. "'s kills has been set to " .. amount)
  1228.                 else
  1229.                     sendconsoletext(user, "Error: You must use a number for the amount!")
  1230.                 end
  1231.             end
  1232.         end
  1233.     else
  1234.         sendconsoletext(user, "Invlaid Player")
  1235.     end
  1236. end
  1237.  
  1238. function command_setassists(user, recipient, amount)
  1239.     if recipient ~= nil then else recipient = resolveplayer(user) end
  1240.  
  1241.     local line = "(User: %s) (Command: %s) (Player: %s)"
  1242.     local Line = string.format(line, getname(user),"Setassists", recipient)
  1243.     WriteLog(log_file, Line)
  1244.  
  1245.     local players = getvalidplayers(recipient, user)
  1246.     if players then
  1247.         for i = 1,#players do
  1248.             local m_player = getplayer(players[i])
  1249.             if m_player then
  1250.                 if tonumber(amount) then
  1251.                     writeshort(m_player + 0xA4, amount)
  1252.                     sendconsoletext(user, getname(players[i]) .. "'s assists has been set to " .. amount)
  1253.                 else
  1254.                     sendconsoletext(user, "Error: You must use a number for the amount!")
  1255.                 end
  1256.             end
  1257.         end
  1258.     else
  1259.         sendconsoletext(user, "Invlaid Player")
  1260.     end
  1261. end
  1262.  
  1263. function command_setdeaths(user, recipient, amount)
  1264.     if recipient ~= nil then else recipient = resolveplayer(user) end
  1265.  
  1266.     local line = "(User: %s) (Command: %s) (Player: %s)"
  1267.     local Line = string.format(line, getname(user),"Setdeaths", recipient)
  1268.     WriteLog(log_file, Line)
  1269.  
  1270.     local players = getvalidplayers(recipient, user)
  1271.     if players then
  1272.         for i = 1,#players do
  1273.             local m_player = getplayer(players[i])
  1274.             if m_player then
  1275.                     if tonumber(amount) then
  1276.                     writeshort(m_player + 0xAE, amount)
  1277.                     sendconsoletext(user, getname(players[i]) .. "'s deaths has been set to " .. amount)
  1278.                 else
  1279.                     sendconsoletext(user, "Error: You must use a number for the amount!")
  1280.                 end
  1281.             end
  1282.         end
  1283.     else
  1284.         sendconsoletext(user, "Invlaid Player")
  1285.     end
  1286. end
  1287.  
  1288.  
  1289. ------------------------------------------------------------------------------------------
  1290. ----------------------------------- [[Misc Function(s)]] -----------------------------------
  1291. ------------------------------------------------------------------------------------------
  1292.  
  1293. -- From AElites commands
  1294. function setscore(player, score)
  1295.     if tonumber(score) then
  1296.         local gametype = readbyte(gametype_base + 0x30)
  1297.         if gametype == 1 then
  1298.             local m_player = getplayer(player)
  1299.             writeword(m_player+0xC8, score)
  1300.         elseif gametype == 2 then
  1301.             writeword(slayer_globals + 0x40 + player*4, score)
  1302.         elseif gametype == 3 then
  1303.             local oddball_game = readbyte(gametype_base + 0x8C)
  1304.             local player = rresolveplayer(player)
  1305.             if oddball_game == 0 or oddball_game == 1 then
  1306.                 writeword(oddball_globals + 0x84 + player*4, score * 30)
  1307.             else
  1308.                 writeword(oddball_globals + 0x84 + player*4, score)
  1309.             end
  1310.         elseif gametype == 4 then
  1311.             local m_player = getplayer(player)
  1312.             writeword(m_player + 0xC4, score * 30)
  1313.         elseif gametype == 5 then
  1314.             local m_player = getplayer(player)
  1315.             writeword(m_player + 0xC6, score)
  1316.         end
  1317.     end
  1318. end
  1319.  
  1320. -- From Wiards comands
  1321. function getvalidplayers(expression, user)
  1322.     if cur_players ~= 0 and expression then
  1323.         local players = {}
  1324.         if expression == "*" then
  1325.             for i = 0,15 do
  1326.                 if getplayer(i) then
  1327.                     table.insert(players, i)
  1328.                 end
  1329.             end
  1330.         elseif expression == "me" then
  1331.             if user ~= nil and user ~= -1 and user then
  1332.                 table.insert(players, user)
  1333.             end
  1334.         elseif string.sub(expression, 1, 3) == "red" or string.sub(expression, 1, 2) == "rt" then
  1335.             for i = 0,15 do
  1336.                 if getplayer(i) and getteam(i) == 0 then
  1337.                     table.insert(players, i)
  1338.                 end
  1339.             end
  1340.         elseif string.sub(expression, 1, 4) == "blue" or string.sub(expression, 1, 2) == "bt" then
  1341.             for i = 0,15 do
  1342.                 if getplayer(i) and getteam(i) == 1 then
  1343.                     table.insert(players, i)
  1344.                 end
  1345.             end
  1346.         elseif (tonumber(expression) or 0) >= 1 and (tonumber(expression) or 0) <= 16 then
  1347.             local expression = tonumber(expression)
  1348.             if rresolveplayer(expression) then
  1349.                 table.insert(players, rresolveplayer(expression))
  1350.             end
  1351.         elseif expression == "random" or expression == "rand" then
  1352.             if cur_players == 1 and user ~= nil then
  1353.                 table.insert(players, user)
  1354.                 return players
  1355.             end
  1356.             while true do
  1357.                 num = math.random(0, 15)
  1358.                 if getplayer(num) and num ~= user then
  1359.                     break
  1360.                 end
  1361.             end
  1362.             table.insert(players, num)
  1363.         else
  1364.             for i = 0,15 do
  1365.                 if getplayer(i) then
  1366.                     if string.wild(getname(i), expression) then
  1367.                         table.insert(players, i)
  1368.                     end
  1369.                 end
  1370.             end
  1371.         end
  1372.         if players[1] then
  1373.             return players
  1374.         end
  1375.     end
  1376.     return false
  1377. end
  1378.  
  1379. function string.wild(match, wild, case_sensative)
  1380.     if not case_sensative then
  1381.         match, wild = string.lower(match), string.lower(wild)
  1382.     end
  1383.     if string.sub(wild, 1, 1) == "?" then wild = string.gsub(wild, "?", string.sub(match, 1, 1), 1) end
  1384.     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
  1385.     if not string.find(wild, "*") and not string.find(wild, "?") and wild ~= match then return false end
  1386.     if string.sub(wild, 1, 1) ~= string.sub(match, 1, 1) and string.sub(wild, 1, 1) ~= "*" then return false end
  1387.     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
  1388.     local substrings = string.split(wild, "*")
  1389.     local begin = 1
  1390.     for k,v in ipairs(substrings) do
  1391.         local sublength = string.len(v)
  1392.         local temp_begin = begin
  1393.         local temp_end = begin + sublength - 1
  1394.         local matchsub = string.sub(match, begin, temp_end)
  1395.         local bool
  1396.         repeat
  1397.             local wild = v
  1398.             local indexes = pack(string.findchar(wild, "?"))
  1399.             if #indexes > 0 then
  1400.                 for _,i in ipairs(indexes) do
  1401.                     wild = string.gsub(wild, "?", string.sub(matchsub, i, i), 1)
  1402.                 end
  1403.             end
  1404.             if matchsub == wild then
  1405.                 bool = true
  1406.                 break
  1407.             end
  1408.             matchsub = string.sub(match, temp_begin, temp_end)
  1409.             temp_begin = temp_begin + 1
  1410.             temp_end = temp_end + 1
  1411.         until temp_end >= string.len(match)
  1412.         if not bool then
  1413.             return false
  1414.         end
  1415.         begin = sublength + 1
  1416.     end
  1417.     return true
  1418. end
  1419.  
  1420. function SelectPlayer(team)
  1421.     local t = {}
  1422.     for i=0,15 do
  1423.         if getplayer(i) and getteam(i) == team then
  1424.             table.insert(t, i)
  1425.         end
  1426.     end
  1427.     if #t > 0 then
  1428.         return t[getrandomnumber(1, #t+1)]
  1429.     end
  1430.     return nil
  1431. end
  1432.  
  1433. function GetGameAddresses(game)
  1434.     if game == "PC" then
  1435.         ce = 0x0
  1436.         stats_header = 0x639720 -- Confirmed.
  1437.         stats_globals = 0x639898 -- Confirmed.
  1438.         ctf_globals = 0x639B98 -- Confirmed.
  1439.         slayer_globals = 0x63A0E8 -- Confirmed.
  1440.         oddball_globals = 0x639E58 -- Confirmed.
  1441.         koth_globals = 0x639BD0 -- Confirmed.
  1442.         race_globals = 0x639FA0 -- Confirmed.
  1443.         race_locs = 0x670F40 -- Confirmed.
  1444.         map_pointer = 0x63525c -- Confirmed.
  1445.         gametype_base = 0x671340 -- Confirmed.
  1446.         network_struct = 0x745BA0 -- Confirmed.
  1447.         camera_base = 0x69C2F8 -- Confirmed.
  1448.         player_header_pointer = 0x75ECE4 -- Confirmed.
  1449.         obj_header_pointer = 0x744C18 -- Confirmed.
  1450.         map_header_base = 0x630E74 -- Confirmed.
  1451.         banlist_header = 0x641280 -- Confirmed.
  1452.         --game_globals = "?" -- WTF IS THIS
  1453.         gameinfo_header = 0x671420 -- Confirmed.
  1454.         mapcycle_header = 0x614B4C -- Confirmed.
  1455.         network_server_globals = 0x69B934 -- Confirmed.
  1456.         flags_pointer = 0x6A590C -- Confirmed.
  1457.         hash_table_base = 0x6A2AE4 -- Confirmed.
  1458.         --Patches
  1459.         gametype_patch = 0x481F3C
  1460.         hashcheck_patch = 0x59c280 -- Confirmed.
  1461.         servername_patch = 0x517D6B -- Confirmed.
  1462.         versioncheck_patch = 0x5152E7 -- Confirmed.
  1463.         hash_duplicate_patch = 0x59C516 -- Confirmed
  1464.     else
  1465.         ce = 0x40
  1466.         stats_header = 0x5BD740 -- Confirmed.
  1467.         stats_globals = 0x5BD8B8 -- Confirmed.
  1468.         ctf_globals = 0x5BDBB8 -- Confirmed.
  1469.         slayer_globals = 0x5BE108 -- Confirmed.
  1470.         oddball_globals = 0x5BDE78 -- Confirmed.
  1471.         koth_globals = 0x5BDBF0 -- Confirmed.
  1472.         race_globals = 0x5BDFC0 -- Confirmed.
  1473.         race_locs = 0x5F5098 -- Confirmed.
  1474.         map_pointer = 0x5B927C -- Confirmed.
  1475.         gametype_base = 0x5F5498 -- Confirmed.
  1476.         network_struct = 0x6C7980 -- Confirmed.
  1477.         camera_base = 0x62075C -- Confirmed.
  1478.         player_globals = 0x6E1478 -- From OS.
  1479.         player_header_pointer = 0x6E1480 -- Confirmed.
  1480.         obj_header_pointer = 0x6C69F0 -- Confirmed.
  1481.         map_header_base = 0x6E2CA4 -- Confirmed.
  1482.         banlist_header = 0x5C52A0 -- Confirmed.
  1483.         game_globals = 0x61CFE0 -- Confirmed.
  1484.         gameinfo_header = 0x5F55BC -- Confirmed.
  1485.         mapcycle_header = 0x598A8C -- Confirmed.
  1486.         network_server_globals = 0x61FB64 -- Confirmed.
  1487.         hash_table_base = 0x5AFB34 -- Confirmed.
  1488.         --Patches
  1489.         hashcheck_patch = 0x530130 -- Confirmed.
  1490.         servername_patch = 0x4CE0CD -- Confirmed.
  1491.         versioncheck_patch = 0x4CB587 -- Confirmed.
  1492.         hash_duplicate_patch = 0x5302E6 -- Confirmed
  1493.     end
  1494. end
  1495.  
  1496.  
  1497. -- From Wizards commands
  1498. function Ipban(player)
  1499.     svcmd("sv_ban " .. resolveplayer(player))
  1500.     local banlist = io.open(getprofilepath() .. "\\banned.txt", "r")
  1501.     if banlist then
  1502.         local lines  = 0
  1503.         for line in banlist:lines() do
  1504.             lines = lines + 1
  1505.             if line and line ~= "" then
  1506.                 if string.find(line, gethash(player)) then
  1507.                     svcmd("sv_unban " .. lines - 2)
  1508.                 end
  1509.             end
  1510.         end
  1511.     end
  1512. end
  1513.  
  1514. -- Kennan's Function
  1515. function getplayerkdr(player)
  1516.  
  1517.     local kdr = nil
  1518.     if getplayer(player) then
  1519.         local name = getname(player)
  1520.         local kills = tonumber(kills[name])
  1521.         local deaths = tonumber(deaths[name])
  1522.         if kills ~= nil and deaths ~= nil then
  1523.             if kills ~= 0 then
  1524.                 if deaths ~= 0 then
  1525.                     local value = kills / deaths
  1526.                     kdr = math.round(value, 2)
  1527.                 else
  1528.                     kdr = tonumber(kills)
  1529.                 end
  1530.             else
  1531.                 kdr = "No Kills"
  1532.             end
  1533.         end
  1534.     end
  1535.  
  1536.     local s = tostring(kdr)
  1537.     if string.find(s, "#") then
  1538.         kdr = "0"
  1539.     end
  1540.     return kdr
  1541. end
  1542.  
  1543. -- Kennans's Function
  1544. function getnewmessage(msg)
  1545.  
  1546.     local t = {}
  1547.     t = tokenizestring(msg, " ")
  1548.     local str = ""
  1549.     local count = #t
  1550.     for i in irand(1, count) do
  1551.         str = str .. t[i] .. " "
  1552.     end
  1553.     return str
  1554. end
  1555.  
  1556. -- Kennans's Function
  1557. function irand(min, max)
  1558.  
  1559.     local u = {}
  1560.     for i = min,max do
  1561.         table.insert(u, i)
  1562.     end
  1563.     return function()
  1564.         if table.unpack(u) then
  1565.             local rand = getrandomnumber(1, #u + 1)
  1566.             local value = u[rand]
  1567.             table.remove(u, rand)
  1568.             return value
  1569.         end
  1570.     end
  1571. end
  1572.  
  1573. -- Nugget's Function
  1574. function math.round(input, precision)
  1575.     return math.floor(input * (10 ^ precision) + 0.5) / (10 ^ precision)
  1576. end
  1577.  
  1578.  
  1579. function giveweapon(player, weapon, user)
  1580.     if player then
  1581.  
  1582.         local line = "(User: %s) (Command: %s) (Object: %s)"
  1583.         local Line = string.format(line, getname(user),"Give", weapon)
  1584.         WriteLog(log_file, Line)
  1585.  
  1586.         local m_player = getplayer(player)
  1587.         local objId = readdword(m_player, 0x34)
  1588.         local m_object = getobject(objId)
  1589.         local m_weaponId = readdword(m_object + 0x118)
  1590.         local x, y, z = getobjectcoords(objId)
  1591.  
  1592.         if weapon == "camo" or object == "camouflage" then
  1593.             createobject(camouflage_tag_id, 0, 60, false, x, y, z+0.5)
  1594.         elseif weapon == "health" or object == "hp" then
  1595.             createobject(healthpack_tag_id, 0, 60, false, x, y, z+0.5)
  1596.         elseif weapon == "os" or object == "overshield" then
  1597.             createobject(overshield_tag_id, 0, 60, false, x, y, z+0.5)
  1598.         elseif weapon == "rifle" or object == "assaultrifle" then
  1599.             local rifleid = createobject(assaultrifle_tag_id, 0, 60, false, x, y, z+0.5)
  1600.             assignweapon(player, rifleid)
  1601.         elseif weapon == "flamethrower" or object == "flamer" or object == "flame" then
  1602.             local flameid = createobject(flamethrowerl_tag_id, 0, 60, false, x, y, z+0.5)
  1603.             assignweapon(player, flameid)
  1604.         elseif weapon == "ggun" or object == "gravitygun" or object == "gravityrifle" then
  1605.             local ggunid = createobject(gravityrifle_tag_id, 0, 60, false, x, y, z+0.5)
  1606.             assignweapon(player, ggunid)
  1607.         elseif weapon == "needler" then
  1608.             local needleid = createobject(needler_tag_id, 0, 60, false, x, y, z+0.5)
  1609.             assignweapon(player, needleid)
  1610.         elseif weapon == "pistol" then
  1611.             local pistolid = createobject(pistol_tag_id, 0, 60, false, x, y, z+0.5)
  1612.             assignweapon(player, pistolid)
  1613.         elseif weapon == "ppistol" or object == "plasmapistol" then
  1614.             local ppistolid = createobject(plasmapistol_tag_id, 0, 60, false, x, y, z+0.5)
  1615.             assignweapon(player, ppistolid)
  1616.         elseif weapon == "prifle" or object == "plasmarifle" then
  1617.             local prifleid = createobject(plasmarifle_tag_id, 0, 60, false, x, y, z+0.5)
  1618.             assignweapon(player, prifleid)
  1619.         elseif weapon == "rod" or object == "frod" or object == "fuelrod" then
  1620.             local rodid = createobject(plasmacannon_tag_id, 0, 60, false, x, y, z+0.5)
  1621.             assignweapon(player, rodid)
  1622.         elseif weapon == "rox" or object == "rocket" then
  1623.             local roxid createobject(rocketlauncher_tag_id, 0, 60, false, x, y, z+0.5)
  1624.             assignweapon(player, roxid)
  1625.         elseif weapon == "shotgun" or object == "shotty"  then
  1626.             local shotgunid = createobject(shotgun_tag_id, 0, 60, false, x, y, z+0.5)
  1627.             assignweapon(player, shotgunid)
  1628.         elseif weapon == "sniper" then
  1629.             local sniperid = createobject(sniper_tag_id, 0, 60, false, x, y, z+0.5)
  1630.             assignweapon(player, sniperid)
  1631.         else
  1632.             sendconsoletext(user, "Invalid Weapon or Powerup!")
  1633.         end
  1634.     end
  1635. end
  1636.  
  1637. function enter(player, vehicle, user)
  1638.     if player then
  1639.  
  1640.         local line = "(User: %s) (Command: %s) (Object: %s)"
  1641.         local Line = string.format(line, getname(user),"Enter", vehicle)
  1642.         WriteLog(log_file, Line)
  1643.  
  1644.         local m_player = getplayer(player)
  1645.         local objId = readdword(m_player, 0x34)
  1646.         local x, y, z = getobjectcoords(objId)
  1647.  
  1648.         if vehivle == "shee" or vehicle == "banshee" then
  1649.             local sheeid = createobject(banshee_tag_id, 0, 60, false, x, y, z+2)
  1650.             entervehicle(player, sheeid, 0)
  1651.         elseif vehicle == "turret" then
  1652.             local turretid = createobject(turret_tag_id, 0, 60, false, x, y, z+2)
  1653.             entervehicle(player, turretid, 0)
  1654.         elseif vehicle == "ghost" then
  1655.             local ghostid = createobject(ghost_tag_id, 0, 60, false, x, y, z+2)
  1656.             entervehicle(player, ghostid, 0)
  1657.         elseif vehicle == "rwarthog" or vehicle == "rockethog" or object == "rhog" then
  1658.             local rhogid = createobject(rwarthog_tag_id, 0, 60, false, x, y, z+2)
  1659.             entervehicle(player, rhogid, 0)
  1660.         elseif vehicle == "warthog" or vehicle == "hog" then
  1661.             local hogid = createobject(warthog_tag_id, 0, 60, false, x, y, z+2)
  1662.             entervehicle(player, hogid, 0)
  1663.         elseif vehicle == "tank" or vehicle == "scorpion" then
  1664.             local tankid = createobject(scorpiob_tag_id, 0, 60, false, x, y, z+2)
  1665.             entervehicle(player, tankid, 0)
  1666.         else
  1667.             sendconsoletext(user, "Invalid Vehicle!")
  1668.         end
  1669.     end
  1670. end
  1671.  
  1672. function spawnobject(player, object, user)
  1673.     if player then
  1674.  
  1675.         local line = "(User: %s) (Command: %s) (Object: %s)"
  1676.         local Line = string.format(line, getname(user),"Spawn", object)
  1677.         WriteLog(log_file, Line)
  1678.  
  1679.         local m_player = getplayer(player)
  1680.         local objId = readdword(m_player, 0x34)
  1681.         local x, y, z = getobjectcoords(objId)
  1682.  
  1683.         if object == "camo" or object == "camouflage" then
  1684.             createobject(camouflage_tag_id, 0, 60, false, x+1, y+1, z+1)
  1685.         elseif object == "health" or object == "hp" then
  1686.             createobject(healthpack_tag_id, 0, 60, false, x+1, y+1, z+1)
  1687.         elseif object == "os" or object == "overshield" then
  1688.             createobject(overshield_tag_id, 0, 60, false, x+1, y+1, z+1)
  1689.         elseif object == "rifle" or object == "assaultrifle" then
  1690.             createobject(assaultrifle_tag_id, 0, 60, false, x, y, z+0.5)
  1691.         elseif object == "flamethrower" or object == "flamer" or object == "flame" then
  1692.             createobject(flamethrower_tag_id, 0, 60, false, x, y, z+0.5)
  1693.         elseif object == "ggun" or object == "gravitygun" or object == "gravityrifle" then
  1694.             createobject(gravityrifle_tag_id, 0, 60, false, x, y, z+0.5)
  1695.         elseif object == "needler" then
  1696.             createobject(needler_tag_id, 0, 60, false, x, y, z+0.5)
  1697.         elseif object == "pistol" then
  1698.             createobject(pistol_tag_id, 0, 60, false, x, y, z+0.5)
  1699.         elseif object == "ppistol" or object == "plasmapistol" then
  1700.             createobject(plasmapistol_tag_id, 0, 60, false, x, y, z+0.5)
  1701.         elseif object == "prifle" or object == "plasmarifle" then
  1702.             createobject(plasmarifle_tag_id, 0, 60, false, x, y, z+0.5)
  1703.         elseif object == "rod" or object == "frod" or object == "fuelrod" then
  1704.             createobject(plasmacannon_tag_id, 0, 60, false, x, y, z+0.5)
  1705.         elseif object == "rox" or object == "rocket" then
  1706.             createobject(rocketlauncher_tag_id, 0, 60, false, x, y, z+0.5)
  1707.         elseif object == "shotgun" or object == "shotty"  then
  1708.             createobject(shotgun_tag_id, 0, 60, false, x, y, z+0.5)
  1709.         elseif object == "sniper" then
  1710.             createobject(sniper_tag_id, 0, 60, false, x, y, z+0.5)
  1711.         elseif object == "biped" or object == "cyborg" then
  1712.             createobject(cyborg_tag_id, 0, 60, false, x+1, y+1, z+1)
  1713.         elseif object == "shee" or object == "banshee" then
  1714.             createobject(banshee_tag_id, 0, 60, false, x+3, y+3, z+2)
  1715.         elseif object == "turret" then
  1716.             createobject(turret_tag_id, 0, 60, false, x+3, y+3, z+2)
  1717.         elseif object == "ghost" or object == "cyborg" then
  1718.             createobject(ghost_tag_id, 0, 60, false, x+3, y+3, z+2)
  1719.         elseif object == "rwarthog" or object == "rockethog" or object == "rhog" then
  1720.             createobject(rwarthog_tag_id, 0, 60, false, x+3, y+3, z+2)
  1721.         elseif object == "warthog" or object == "hog" then
  1722.             createobject(warthog_tag_id, 0, 60, false, x+3, y+3, z+2)
  1723.         elseif object == "tank" or object == "scorpion" then
  1724.             createobject(scorpiob_tag_id, 0, 60, false, x+3, y+3, z+2)
  1725.         else
  1726.             sendconsoletext(user, "Invalid Object!")
  1727.         end
  1728.     end
  1729. end
  1730.  
  1731. function getTagIds()
  1732.         -- Bipeds
  1733.     cyborg_tag_id = gettagid("bipd", "characters\\cyborg_mp\\cyborg_mp")
  1734.     captain_tag_id = gettagid("bipd", "characters\\captain\\captain")
  1735.     cortana_tag_id = gettagid("bipd", "characters\\cortana\\cortana")
  1736.     cortana2_tag_id = gettagid("bipd", "characters\\cortana\\halo_enhanced\\halo_enhanced")
  1737.     crewman_tag_id = gettagid("bipd", "characters\\crewman\\crewman")
  1738.     elite_tag_id = gettagid("bipd", "characters\\elite\\elite")
  1739.     elite2_tag_id = gettagid("bipd", "characters\\elite\\elite special")
  1740.     engineer_tag_id = gettagid("bipd", "characters\\engineer\\engineer")
  1741.     flood_tag_id = gettagid("bipd", "characters\\flood_captain\\flood_captain")
  1742.     flood2_tag_id = gettagid("bipd", "characters\\flood_infection\\flood_infection")
  1743.         -- Equipment
  1744.     camouflage_tag_id = gettagid("eqip", "powerups\\active camouflage")
  1745.     healthpack_tag_id = gettagid("eqip", "powerups\\health pack")
  1746.     overshield_tag_id = gettagid("eqip", "powerups\\over shield")
  1747.     doublespeed_tag_id = gettagid("eqip", "powerups\\double speed")
  1748.     fullspec_tag_id = gettagid("eqip", "powerups\\full-spectrum vision")
  1749.     fragnade_tag_id = gettagid("eqip", "weapons\\frag grenade\\frag grenade")
  1750.     plasmanade_tag_id = gettagid("eqip", "weapons\\plasma grenade\\plasma grenade")
  1751.     rifleammo_tag_id = gettagid("eqip", "powerups\\assault rifle ammo\\assault rifle ammo")
  1752.     needlerammo_tag_id = gettagid("eqip", "powerups\\needler ammo\\needler ammo")
  1753.     pistolammo_tag_id = gettagid("eqip", "powerups\\pistol ammo\\pistol ammo")
  1754.     rocketammo_tag_id = gettagid("eqip", "powerups\\rocket launcher ammo\\rocket launcher ammo")
  1755.     shotgunammo_tag_id = gettagid("eqip", "powerups\\shotgun ammo\\shotgun ammo")
  1756.     sniperammo_tag_id = gettagid("eqip", "powerups\\sniper rifle ammo\\sniper rifle ammo")
  1757.     flameammo_tag_id = gettagid("eqip", "powerups\\flamethrower ammo\\flamethrower ammo")
  1758.         -- Vehicles
  1759.     banshee_tag_id = gettagid("vehi", "vehicles\\banshee\\banshee_mp")
  1760.     turret_tag_id = gettagid("vehi", "vehicles\\c gun turret\\c gun turret_mp")
  1761.     ghost_tag_id = gettagid("vehi", "vehicles\\ghost\\ghost_mp")
  1762.     rwarthog_tag_id = gettagid("vehi", "vehicles\\rwarthog\\rwarthog")
  1763.     scorpion_tag_id = gettagid("vehi", "vehicles\\scorpion\\scorpion_mp")
  1764.     warthog_tag_id = gettagid("vehi", "vehicles\\warthog\\mp_warthog")
  1765.     wraith_tag_id = gettagid("vehi", "vehicles\\wraith\\wraith")
  1766.     pelican_tag_id = gettagid("vehi", "vehicles\\pelican\\pelican")
  1767.         -- Weapons
  1768.     assaultrifle_tag_id = gettagid("weap", "weapons\\assault rifle\\assault rifle")
  1769.     oddball_tag_id = gettagid("weap", "weapons\\ball\\ball")
  1770.     flag_tag_id = gettagid("weap", "weapons\\flag\\flag")
  1771.     flamethrower_tag_id = gettagid("weap", "weapons\\flamethrower\\flamethrower")
  1772.     gravityrifle_tag_id = gettagid("weap", "weapons\\gravity rifle\\gravity rifle")
  1773.     needler_tag_id = gettagid("weap", "weapons\\needler\\mp_needler")
  1774.     pistol_tag_id = gettagid("weap", "weapons\\pistol\\pistol")
  1775.     plasmapistol_tag_id = gettagid("weap", "weapons\\plasma pistol\\plasma pistol")
  1776.     plasmarifle_tag_id = gettagid("weap", "weapons\\plasma rifle\\plasma rifle")
  1777.     plasmacannon_tag_id = gettagid("weap", "weapons\\plasma_cannon\\plasma_cannon")
  1778.     rocketlauncher_tag_id = gettagid("weap", "weapons\\rocket launcher\\rocket launcher")
  1779.     shotgun_tag_id = gettagid("weap", "weapons\\shotgun\\shotgun")
  1780.     sniper_tag_id = gettagid("weap", "weapons\\sniper rifle\\sniper rifle")
  1781.     energysword_tag_id = gettagid("weap", "weapons\\energy sword\\energy sword")
  1782.         -- Projectiles
  1783.     bansheebolt_tag_id = gettagid("proj", "vehicles\\banshee\\banshee bolt")
  1784.     bansheeblast_tag_id = gettagid("proj", "vehicles\\banshee\\mp_banshee fuel rod")
  1785.     turretfire_tag_id = gettagid("proj", "vehicles\\c gun turret\\mp gun turret")
  1786.     ghostbolt_tag_id = gettagid("proj", "vehicles\\ghost\\ghost bolt")
  1787.     tankshot_tag_id = gettagid("proj", "vehicles\\scorpion\\bullet")
  1788.     tankblast_tag_id = gettagid("proj", "vehicles\\scorpion\\tank shell")
  1789.     warthogshot_tag_id = gettagid("proj", "vehicles\\warthog\\bullet")
  1790.     rifleshot_tag_id = gettagid("proj", "weapons\\assault rifle\\bullet")
  1791.     flame_tag_id = gettagid("proj", "weapons\\flamethrower\\flame")
  1792.     needlerfire_tag_id = gettagid("proj", "weapons\\needler\\mp_needle")
  1793.     pistolshot_tag_id = gettagid("proj", "weapons\\pistol\\bullet")
  1794.     plasmariflebolt_tag_id = gettagid("proj", "weapons\\plasma pistol\\bolt")
  1795.     plasmapistolbolt_tag_id = gettagid("proj", "weapons\\plasma rifle\\bolt")
  1796.     plasmapistolblast_tag_id = gettagid("proj", "weapons\\plasma rifle\\charged bolt")
  1797.     plasmacannonshot_tag_id = gettagid("proj", "weapons\\plasma_cannon\\plasma_cannon")
  1798.     rocket_tag_id = gettagid("proj", "weapons\\rocket launcher\\rocket")
  1799.     shotgunshot_tag_id = gettagid("proj", "weapons\\shotgun\\pellet")
  1800.     snipershot_tag_id = gettagid("proj", "weapons\\sniper rifle\\sniper bullet")
  1801. end
  1802.  
  1803. function WriteLog(filename, value)
  1804.     local File = io.open(filename, "a")
  1805.     if File then
  1806.         File:write( string.format("%s\t%s\n", os.date("!%m/%d/%Y %H:%M:%S"), tostring(value) ) )
  1807.         File:close()
  1808.     end
  1809. end
  1810.  
  1811. ------------------------------------------------------------------------------------------
  1812. -------------------------------- [[Nuggets table saving]] --------------------------------
  1813. ------------------------------------------------------------------------------------------
  1814.  
  1815. function table.save(t, filename)
  1816.     local dir = getprofilepath()
  1817.     local file = io.open(dir .. "\\data\\" .. filename, "w")
  1818.     local spaces = 0
  1819.  
  1820.     local function tab()
  1821.         local str = ""
  1822.         for i = 1,spaces do
  1823.             str = str .. " "
  1824.         end
  1825.         return str
  1826.     end
  1827.  
  1828.     local function format(t)
  1829.         spaces = spaces + 4
  1830.         local str = "{ "
  1831.         for k,v in opairs(t) do
  1832.             -- Key datatypes
  1833.             if type(k) == "string" then
  1834.                 k = string.format("%q", k)
  1835.             elseif k == math.inf then
  1836.                 k = "1 / 0"
  1837.             end
  1838.             k = tostring(k)
  1839.             -- Value datatypes
  1840.             if type(v) == "string" then
  1841.                 v = string.format("%q", v)
  1842.             elseif v == math.inf then
  1843.                 v = "1 / 0"
  1844.             end
  1845.             if type(v) == "table" then
  1846.                 if table.len(v) > 0 then
  1847.                     str = str .. "\n" .. tab() .. "[" .. k .. "] = " .. format(v) .. ","
  1848.                 else
  1849.                     str = str .. "\n" .. tab() .. "[" .. k .. "] = {},"
  1850.                 end
  1851.             else
  1852.                 str = str .. "\n" .. tab() .. "[" .. k .. "] = " .. tostring(v) .. ","
  1853.             end
  1854.         end
  1855.         spaces = spaces - 4
  1856.         return string.sub(str, 1, string.len(str) - 1) .. "\n" .. tab() .. "}"
  1857.     end
  1858.     file:write("return " .. format(t))
  1859.     file:close()
  1860. end
  1861.  
  1862. function table.load(filename)
  1863.     local dir = getprofilepath()
  1864.     local file = loadfile(dir .. "\\data\\" .. filename)
  1865.     if file then
  1866.         return file() or {}
  1867.     end
  1868.     return {}
  1869. end
  1870.  
  1871. function table.len(t)
  1872.     local count = 0
  1873.     for k,v in pairs(t) do
  1874.         count = count + 1
  1875.     end
  1876.     return count
  1877. end
  1878.  
  1879. function opairs(t)
  1880.     local keys = {}
  1881.     for k,v in pairs(t) do
  1882.         table.insert(keys, k)
  1883.     end
  1884.     table.sort(keys,
  1885.     function(a,b)
  1886.         if type(a) == "number" and type(b) == "number" then
  1887.             return a < b
  1888.         end
  1889.         an = string.lower(tostring(a))
  1890.         bn = string.lower(tostring(b))
  1891.         if an ~= bn then
  1892.             return an < bn
  1893.         else
  1894.             return tostring(a) < tostring(b)
  1895.         end
  1896.     end)
  1897.     local count = 1
  1898.     return function()
  1899.         if table.unpack(keys) then
  1900.             local key = keys[count]
  1901.             local value = t[key]
  1902.             count = count + 1
  1903.             return key,value
  1904.         end
  1905.     end
  1906. end
  1907.  
  1908. function spaces(n, delimiter)
  1909.     delimiter = delimiter or ""
  1910.     local str = ""
  1911.     for i = 1, n do
  1912.         if i == math.floor(n / 2) then
  1913.             str = str .. delimiter
  1914.         end
  1915.         str = str .. " "
  1916.     end
  1917.     return str
  1918. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement