Guest User

Commands

a guest
Jun 26th, 2011
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 26.60 KB | None | 0 0
  1. admin_table = {}
  2. mute_table = {}
  3.  
  4. function GetRequiredVersion()
  5.     return 3104
  6. end
  7.  
  8. function OnScriptLoad(process)
  9.  
  10.     local file = io.open("cg//admin.txt", "r")
  11.  
  12.     if (file ~= nil) then
  13.  
  14.         for line in file:lines() do
  15.  
  16.             local words = {}
  17.  
  18.             for word in line:gmatch("%w+") do
  19.                 table.insert(words, word)
  20.             end
  21.  
  22.             admin_table[words[2]] = words[3]
  23.  
  24.         end
  25.  
  26.         file:close()
  27.  
  28.     end
  29.  
  30. end
  31.  
  32. function OnScriptUnload()
  33. end
  34.  
  35. function OnNewGame(map)
  36. end
  37.  
  38. function OnGameEnd(mode)
  39. end
  40.  
  41. function OnServerChat(player, chattype, message)
  42.  
  43.     local AllowChat = 1
  44.     local count = gettokencount(message, " ")
  45.     local t = {}
  46.     local hash = gethash(player)
  47.     local access = nil
  48.  
  49.     for k,v in pairs(admin_table) do
  50.         if k == hash then
  51.             access = tonumber(v)
  52.             break
  53.         end
  54.     end
  55.  
  56.     for i=1,count do
  57.         local word = gettoken(message, " ", i - 1)
  58.         table.insert(t, word)
  59.     end
  60.  
  61.     if access ~= nil then
  62.  
  63.         local found2 = string.find(t[1], "/")
  64.         local found3 = string.find(t[1], "/", 2)
  65.         local found4 = string.find(t[1], "/info", -5)
  66.  
  67.         if found2 ~= nil and found3 == nil and found4 == nil then
  68.  
  69.             AllowChat = 0
  70.             local found5 = string.find(t[1], "/ban", -4)
  71.             local found6 = string.find(t[1], "/changeteam", -11)
  72.             local found7 = string.find(t[1], "/kick", -5)
  73.             local found8 = string.find(t[1], "/kill", -5)
  74.             local found9 = string.find(t[1], "/invis", -6)
  75.             local found10 = string.find(t[1], "/mute", -5)
  76.             local found11 = string.find(t[1], "/setspeed", -9)
  77.             local found12 = string.find(t[1], "/suspend", -8)
  78.             local found13 = string.find(t[1], "/teleport", -9)
  79.             local found14 = string.find(t[1], "/unmute", -7)
  80.             local found15 = string.find(t[1], "/unsuspend", -10)
  81.             local found16 = string.find(t[1], "/map_next", -9)
  82.             local found17 = string.find(t[1], "/map_reset", -10)
  83.  
  84.             if found5 == nil and found6 == nil and found7 == nil and found8 == nil and found9 == nil and found10 == nil and found11 == nil and found12 == nil and found13 == nil and found14 == nil and found15 == nil and found16 == nil and found17 == nil then
  85.                 privatesay(player, "Invalid Command")
  86.             else
  87.                 if count == 1 then
  88.                     if found16 ~= nil then
  89.                         if t[1] == "/map_next" then
  90.                             if access <= 2 then
  91.                                 if count == 1 then
  92.                                     svcmd("sv_map_next")
  93.                                 else
  94.                                     privatesay(player, "Invalid Syntax: /map_next")
  95.                                 end
  96.                             else
  97.                                 privatesay(player, "You cannot execute this command.")
  98.                             end
  99.                         end
  100.                     elseif found17 ~= nil then
  101.                         if t[1] == "/map_reset" then
  102.                             if access <= 2 then
  103.                                 if count == 1 then
  104.                                     svcmd("sv_map_reset")
  105.                                 else
  106.                                     privatesay(player, "Invalid Syntax: /map_reset")
  107.                                 end
  108.                             else
  109.                                 privatesay(player, "You cannot execute this command.")
  110.                             end
  111.                         end
  112.                     end
  113.                 elseif count >= 2 then
  114.  
  115.                     local hash2 = gethash(t[2] - 1)
  116.                     local name2 = getname(t[2] - 1)
  117.  
  118.                     if hash2 ~= 0 then
  119.                         if t[1] == "/ban" then
  120.                             if access <= 2 then
  121.                                 if count == 2 then
  122.                                     svcmd("sv_ban " .. t[2])
  123.                                 elseif count == 3 then
  124.                                     svcmd("sv_ban " .. t[2] .. " " .. t[3])
  125.                                 else
  126.                                     privatesay(player, "Invalid Syntax: /ban [player]")
  127.                                     privatesay(player, "Invalid Syntax: /ban [player] [time]")
  128.                                 end
  129.                             else
  130.                                 privatesay(player, "You cannot execute this command.")
  131.                             end
  132.                         elseif t[1] == "/changeteam" then
  133.                             if access <= 2 then
  134.                                 if count == 2 then
  135.                                     svcmd("sv_changeteam " .. t[2])
  136.                                 else
  137.                                     privatesay(player, "Invalid Syntax: /changeteam [player]")
  138.                                 end
  139.                             else
  140.                                 privatesay(player, "You cannot execute this command.")
  141.                             end
  142.                         elseif t[1] == "/kick" then
  143.                             if access <= 2 then
  144.                                 if count == 2 then
  145.                                     svcmd("sv_kick " .. t[2])
  146.                                 else
  147.                                     privatesay(player, "Invalid Syntax: /kick [player]")
  148.                                 end
  149.                             else
  150.                                 privatesay(player, "You cannot execute this command.")
  151.                             end
  152.                         elseif t[1] == "/kill" then
  153.                             if access <= 0 then
  154.                                 if count == 2 then
  155.                                     svcmd("sv_kill " .. t[2])
  156.                                 else
  157.                                     privatesay(player, "Invalid Syntax: /kill [player]")
  158.                                 end
  159.                             else
  160.                                 privatesay(player, "You cannot execute this command.")
  161.                             end
  162.                         elseif t[1] == "/invis" then
  163.                             if access <= 0 then
  164.                                 if count == 2 then
  165.                                     svcmd("sv_invis " .. t[2])
  166.                                 elseif count == 3 then
  167.                                     svcmd("sv_invis " .. t[2] .. " " .. t[3])
  168.                                 else
  169.                                     privatesay(player, "Invalid Syntax: /invis [player]")
  170.                                     privatesay(player, "Invalid Syntax: /invis [player] [time]")
  171.                                 end
  172.                             else
  173.                                 privatesay(player, "You cannot execute this command.")
  174.                             end
  175.                         elseif t[1] == "/mute" then
  176.                             if access <= 2 then
  177.                                 if count == 2 then
  178.  
  179.                                     local mute = nil
  180.  
  181.                                     for k,v in pairs(admin_table) do
  182.                                         if k == hash2 then
  183.                                             mute = 1
  184.                                             break
  185.                                         end
  186.                                     end
  187.  
  188.                                     if hash2 ~= 0 then
  189.                                         if mute == nil then
  190.                                             if mute_table[hash2] == nil then
  191.                                                 mute_table[hash2] = 1
  192.                                                 say(name2 .. " was muted by an admin!")
  193.                                             else
  194.                                                 privatesay(player, name2 .. " has already been muted.")
  195.                                             end
  196.                                         else
  197.                                             privatesay(player, "Admins cannot be muted.")
  198.                                         end
  199.                                     end
  200.  
  201.                                 else
  202.                                     privatesay(player, "Invalid Syntax: /mute [player]")
  203.                                 end
  204.                             else
  205.                                 privatesay(player, "You cannot execute this command.")
  206.                             end
  207.                         elseif t[1] == "/setammo" then
  208.                             if access <= 0 then
  209.                                 if count == 3 then
  210.                                     svcmd("sv_setammo " .. t[2] .. " " .. t[3])
  211.                                 else
  212.                                     privatesay(player, "Invalid Syntax: /setammo [player] [ammo]")
  213.                                 end
  214.                             else
  215.                                 privatesay(player, "You cannot execute this command.")
  216.                             end
  217.                         elseif t[1] == "/setspeed" then
  218.                             if access <= 0 then
  219.                                 if count == 3 then
  220.                                     svcmd("sv_setspeed " .. t[2] .. " " .. t[3])
  221.                                 else
  222.                                     privatesay(player, "Invalid Syntax: /setspeed [player] [speed]")
  223.                                 end
  224.                             else
  225.                                 privatesay(player, "You cannot execute this command.")
  226.                             end
  227.                         elseif t[1] == "/suspend" then
  228.                             if access <= 0 then
  229.                                 if count == 2 then
  230.  
  231.                                     local m_player = getplayer(t[2] - 1)
  232.                                     local player_respawn_time = readdword(m_player, 0x2C)
  233.  
  234.                                     if player_respawn_time == 0 then
  235.                                         svcmd("sv_kill " .. t[2])
  236.                                         writedword(m_player, 0x2C, 2592000)
  237.                                         say(name2 .. " was suspended by an admin!")
  238.                                     else
  239.                                         privatesay(player, name2 .. " has already been suspended.")
  240.                                     end
  241.  
  242.                                 else
  243.                                     privatesay(player, "Invalid Syntax: /suspend [player]")
  244.                                 end
  245.                             else
  246.                                 privatesay(player, "You cannot execute this command.")
  247.                             end
  248.                         elseif t[1] == "/teleport" then
  249.                             if access <= 0 then
  250.  
  251.                                 local name = getname(t[2] - 1)
  252.                                 local m_player = getplayer(t[2] - 1)
  253.                                 local player_respawn_time = readdword(m_player, 0x2C)
  254.                                 local m_playerObjId = readdword(m_player, 0x34)
  255.                                 local m_object = getobject(m_playerObjId)
  256.                                 local m_vehicle = getobject(readdword(m_object, 0x11C))
  257.  
  258.                                 if player_respawn_time == 0 then
  259.                                     if count == 3 then
  260.  
  261.                                         local hash3 = gethash(t[3] - 1)
  262.  
  263.                                         if t[3] ~= t[2] and hash3 ~= 0 then
  264.  
  265.                                             local t_player = getplayer(t[3] - 1)
  266.                                             local target_respawn_time = readdword(t_player, 0x2C)
  267.  
  268.                                             if player_respawn_time == 0 then
  269.  
  270.                                                 local t_playerObjId = readdword(t_player, 0x34)
  271.                                                 local t_object = getobject(t_playerObjId)
  272.                                                 local t_vehicle = getobject(readdword(t_object, 0x11C))
  273.  
  274.                                                 if t_vehicle ~= 0 then
  275.                                                     t_object = t_vehicle
  276.                                                 end
  277.  
  278.                                                 local obj_x_coord = readfloat(t_object, 0x5C)
  279.                                                 local obj_y_coord = readfloat(t_object, 0x60)
  280.                                                 local obj_z_coord = readfloat(t_object, 0x64)
  281.  
  282.                                                 if m_vehicle ~= 0 then
  283.                                                     writefloat(m_vehicle, 0x5C, obj_x_coord)
  284.                                                     writefloat(m_vehicle, 0x60, obj_y_coord)
  285.                                                     writefloat(m_vehicle, 0x64, obj_z_coord)
  286.                                                     say(name .. " was teleported by an admin!")
  287.                                                 else
  288.                                                     svcmd("sv_teleport " .. t[2] .. " " .. obj_x_coord .. ", " .. obj_y_coord .. ", " .. obj_z_coord + 0.5)
  289.                                                 end
  290.  
  291.                                             else
  292.                                                 privatesay(player, "Invalid Player")
  293.                                             end
  294.  
  295.                                         else
  296.                                             privatesay(player, "Invalid Player")
  297.                                         end
  298.  
  299.                                     elseif count == 5 then
  300.                                         if m_vehicle ~= 0 then
  301.                                             writefloat(m_vehicle, 0x5C, t[3])
  302.                                             writefloat(m_vehicle, 0x60, t[4])
  303.                                             writefloat(m_vehicle, 0x64, t[5])
  304.                                             say(name .. " was teleported by an admin!")
  305.                                         else
  306.                                             svcmd("sv_teleport " .. t[2] .. ", " .. t[3] .. ", " .. t[4] .. ", " .. t[5])
  307.                                         end
  308.                                     else
  309.                                         privatesay(player, "Invalid Syntax: /teleport [player] [player]")
  310.                                         privatesay(player, "Invalid Syntax: /teleport [player] [x] [y] [z]")
  311.                                     end
  312.                                 else
  313.                                     privatesay(player, "Invalid Player")
  314.                                 end
  315.  
  316.                             else
  317.                                 privatesay(player, "You cannot execute this command.")
  318.                             end
  319.                         elseif t[1] == "/unmute" then
  320.                             if access <= 2 then
  321.                                 if count == 2 then
  322.                                     if hash2 ~= 0 then
  323.                                         if mute_table[hash2] ~= nil then
  324.                                             mute_table[hash2] = nil
  325.                                             say(name2 .. " was unmuted by an admin!")
  326.                                         else
  327.                                             privatesay(player, name2 .. " has not been muted.")
  328.                                         end
  329.                                     end
  330.                                 else
  331.                                     privatesay(player, "Invalid Syntax: /unmute [player]")
  332.                                 end
  333.                             else
  334.                                 privatesay(player, "You cannot execute this command.")
  335.                             end
  336.                         elseif t[1] == "/unsuspend" then
  337.                             if access <= 0 then
  338.                                 if count == 2 then
  339.  
  340.                                     local m_player = getplayer(t[2] - 1)
  341.                                     local player_respawn_time = readdword(m_player, 0x2C)
  342.  
  343.                                     if player_respawn_time ~= 0 then
  344.                                         writedword(m_player, 0x2C, 0)
  345.                                         say(name2 .. " was unsuspended by an admin!")
  346.                                     else
  347.                                         privatesay(player, name2 .. " has not been suspended.")
  348.                                     end
  349.  
  350.                                 else
  351.                                     privatesay(player, "Invalid Syntax: /unsuspend [player]")
  352.                                 end
  353.                             else
  354.                                 privatesay(player, "You cannot execute this command.")
  355.                             end
  356.                         end
  357.                     else
  358.                         privatesay(player, "Invalid Player")
  359.                     end
  360.  
  361.                 end
  362.  
  363.             end
  364.  
  365.         end
  366.  
  367.     end
  368.  
  369.     if t[1] == "/info" then
  370.  
  371.         AllowChat = 0
  372.         local player_number = resolveplayer(player)
  373.         local m_player = getplayer(player)
  374.         local hash = gethash(player)
  375.         local display = 1
  376.  
  377.         if access ~= nil then
  378.             if count == 2 then
  379.  
  380.                 player_number = t[2]
  381.                 m_player = getplayer(player_number - 1)
  382.                 hash = gethash(player_number - 1)
  383.  
  384.                 if hash == 0 then
  385.                     privatesay(player, "Invalid Player")
  386.                     display = 0
  387.                 end
  388.  
  389.             elseif count > 2 then
  390.                 privatesay(player, "Invalid Syntax: /info")
  391.                 privatesay(player, "Invalid Syntax: /info [player]")
  392.                 display = 0
  393.             end
  394.         end
  395.  
  396.         if display == 1 then
  397.  
  398.             local m_playerObjId = readdword(m_player, 0x34)
  399.             local m_object = getobject(m_playerObjId)
  400.  
  401.             local player_name = readstring(m_player, 0x4, 0x14)
  402.             local player_team = readdword(m_player, 0x20)
  403.             local player_interaction_seat = readword(m_player, 0x2A)
  404.             local player_speed = readfloat(m_player, 0x6C)
  405.             local player_objective_mode = readbyte(m_player, 0x74)
  406.             local player_kills = readword(m_player, 0x9C)
  407.             local player_assists = readword(m_player, 0xA4)
  408.             local player_betrays = readword(m_player, 0xAC)
  409.             local player_deaths = readword(m_player, 0xAE)
  410.             local player_suicides = readword(m_player, 0xB0)
  411.             local player_ping = readword(m_player, 0xDC)
  412.             local player_weap_type = readword(m_player, 0x14C)
  413.             local player_nade_type = readword(m_player, 0x14E)
  414.  
  415.             local obj_max_health = readfloat(m_object, 0xD8)
  416.             local obj_max_shields = readfloat(m_object, 0xDC)
  417.             local obj_health = readfloat(m_object, 0xE0)
  418.             local obj_shields = readfloat(m_object, 0xE4)
  419.             local obj_invis_mode = readbyte(m_object, 0x204)
  420.             local obj_flashlight_mode = readbyte(m_object, 0x206)
  421.             local obj_crouch_mode = readbyte(m_object, 0x208)
  422.             local obj_primary_nades = readbyte(m_object, 0x31E)
  423.             local obj_secondary_nades = readbyte(m_object, 0x31F)
  424.             local obj_flashlight_level = readfloat(m_object, 0x344)
  425.             local obj_invis_scale = readfloat(m_object, 0x37C)
  426.  
  427.             local obj_primary_weap_id = readdword(m_object, 0x2F8)
  428.             local obj_secondary_weap_id = readdword(m_object, 0x2FC)
  429.             local primary_weap = getobject(obj_primary_weap_id)
  430.             local secondary_weap = getobject(obj_secondary_weap_id)
  431.  
  432.             local m_vehicle = getobject(readdword(m_object, 0x11C))
  433.  
  434.             if m_vehicle ~= 0 then
  435.  
  436.                 if player_interaction_seat ~= 1 then
  437.                     primary_weap = getobject(readdword(m_vehicle, 0x2F8))
  438.                     secondary_weap = getobject(readdword(m_vehicle, 0x2FC))
  439.                 end
  440.  
  441.                 m_object = m_vehicle
  442.  
  443.             end
  444.  
  445.             local obj_x_coord = readfloat(m_object, 0x5C)
  446.             local obj_y_coord = readfloat(m_object, 0x60)
  447.             local obj_z_coord = readfloat(m_object, 0x64)
  448.  
  449.             local primary_weap_heat = readfloat(primary_weap, 0x23C)
  450.             local primary_weap_age = readfloat(primary_weap, 0x240)
  451.             local primary_weap_ammo = readword(primary_weap, 0x2B6)
  452.             local primary_weap_clip = readword(primary_weap, 0x2B8)
  453.             local secondary_weap_heat = readfloat(secondary_weap, 0x23C)
  454.             local secondary_weap_age = readfloat(secondary_weap, 0x240)
  455.             local secondary_weap_ammo = readword(secondary_weap, 0x2B6)
  456.             local secondary_weap_clip = readword(secondary_weap, 0x2B8)
  457.  
  458.             local teamsize = getteamsize(player_team)
  459.  
  460.             if player_team == 0 then
  461.                 player_team = "Red"
  462.             elseif player_team == 1 then
  463.                 player_team = "Blue"
  464.             end
  465.  
  466.             if player_objective_mode == 0x22 then
  467.                 player_objective_mode = "Hill"
  468.             elseif player_objectivemode == 0x29 then
  469.                 player_objective_mode = "Ball"
  470.             else
  471.                 player_objective_mode = "None"
  472.             end
  473.  
  474.             if player_weap_type == 2 and player_objective_mode == "None" then
  475.                 player_objective_mode = "Flag"
  476.             end
  477.  
  478.             player_betrays = player_betrays - player_suicides
  479.  
  480.             obj_x_coord = round(obj_x_coord)
  481.             obj_y_coord = round(obj_y_coord)
  482.             obj_z_coord = round(obj_z_coord)
  483.             obj_max_health = round(obj_health * obj_max_health)
  484.             obj_max_shields = round(obj_shields * obj_max_shields)
  485.             obj_health = round(obj_health * 100)
  486.             obj_shields = round(obj_shields * 100)
  487.  
  488.             if obj_invis_mode == 0x51 then
  489.                 obj_invis_mode = "Yes"
  490.             else
  491.                 obj_invis_mode = "No"
  492.             end
  493.  
  494.             if obj_flashlight_mode == 8 then
  495.                 obj_flashlight_mode = "On"
  496.             else
  497.                 obj_flashlight_mode = "Off"
  498.             end
  499.  
  500.             obj_flashlight_level = round(obj_flashlight_level * 100)
  501.             obj_invis_scale = round(obj_invis_scale * 100)
  502.  
  503.             if obj_crouch_mode == 0 then
  504.                 obj_crouch_mode = "Standing"
  505.             elseif obj_crouch_mode == 1 then
  506.                 obj_crouch_mode = "Crouching"
  507.             elseif obj_crouch_mode == 2 then
  508.                 obj_crouch_mode = "Jumping"
  509.             end
  510.  
  511.  
  512.             if player_weap_type == 1 then
  513.                 primary_weap_heat = readfloat(secondary_weap, 0x23C)
  514.                 primary_weap_age = readfloat(secondary_weap, 0x240)
  515.                 primary_weap_ammo = readword(secondary_weap, 0x2B6)
  516.                 primary_weap_clip = readword(secondary_weap, 0x2B8)
  517.                 secondary_weap_heat = readfloat(primary_weap, 0x23C)
  518.                 secondary_weap_age = readfloat(primary_weap, 0x240)
  519.                 secondary_weap_ammo = readword(primary_weap, 0x2B6)
  520.                 secondary_weap_clip = readword(primary_weap, 0x2B8)
  521.             end
  522.  
  523.             primary_weap_heat = round(primary_weap_heat * 100)
  524.             primary_weap_age = round((1 - primary_weap_age) * 100)
  525.             secondary_weap_heat = round(secondary_weap_heat * 100)
  526.             secondary_weap_age = round((1 - secondary_weap_age) * 100)
  527.  
  528.             local primary_weap_info = "Primary Ammo: " .. primary_weap_clip .. " / " .. primary_weap_ammo
  529.             local secondary_weap_info = "Secondary Ammo: " .. secondary_weap_clip .. " / " .. secondary_weap_ammo
  530.  
  531.             if primary_weap_age >= 0 and primary_weap_ammo == 0 and primary_weap_clip == 0 then
  532.                 primary_weap_info = "Primary Battery: " .. primary_weap_heat .. "% / " .. primary_weap_age .. "%"
  533.             end
  534.  
  535.             if secondary_weap_age >= 0 and secondary_weap_ammo == 0 and secondary_weap_clip == 0 then
  536.                 secondary_weap_info = "Secondary Battery: " .. secondary_weap_heat .. "% / " .. secondary_weap_age .. "%"
  537.             end
  538.  
  539.             local nade_info = "Frag Grenades: " .. obj_primary_nades .. " | " .. "Plasma Grenades: " .. obj_secondary_nades
  540.  
  541.             if player_nade_type == 1 then
  542.                 nade_info = "Plasma Grenades: " .. obj_secondary_nades .. " | " .. "Frag Grenades: " .. obj_primary_nades
  543.             end
  544.  
  545.             privatesay(player, "----------")
  546.             privatesay(player, "Name: " .. player_name .. " (" .. player_number .. ") | " .. "Team: " .. player_team .. " (" .. teamsize .. ") | " .. "Speed: " .. player_speed .. " | " .. "Location: " .. obj_x_coord .. ", " .. obj_y_coord .. ", " .. obj_z_coord)
  547.             privatesay(player, "Hash: " .. hash .. " | " .. "Ping: " .. player_ping .. " | " .. "Stance: " .. obj_crouch_mode)
  548.             privatesay(player, "Kills: " .. player_kills .. " | " .. "Assists: " .. player_assists .. " | " .. "Betrays: " .. player_betrays .. " | " .. "Suicides: " .. player_suicides .. " | " .. "Deaths: " .. player_deaths .. " | " .. "Objective: " .. player_objective_mode)
  549.             privatesay(player, "Health: " .. obj_health .. "% (" .. obj_max_health .. ") | " .. "Shields: " .. obj_shields .. "% (" .. obj_max_shields .. ") | " .. "Invis: " .. obj_invis_mode .. " (" .. obj_invis_scale .. "%) | " .. "Light: " .. obj_flashlight_mode .. " (" .. obj_flashlight_level .. "%)")
  550.             privatesay(player, primary_weap_info .. " | " .. secondary_weap_info)
  551.             privatesay(player, nade_info)
  552.             privatesay(player, "----------")
  553.  
  554.         end
  555.  
  556.     end
  557.  
  558.     if mute_table[hash] ~= nil then
  559.         AllowChat = 0
  560.     end
  561.  
  562.     return AllowChat
  563.  
  564. end
  565.  
  566. function OnServerCommand(player, command)
  567.  
  568.     local fixed_command = string.gsub(command, "\"", "")
  569.  
  570.     if string.sub(command, 1, 7) == "sv_info" then
  571.  
  572.         local player_number = player + 1
  573.         local m_player = getplayer(player)
  574.         local hash = gethash(player)
  575.         local display = 1
  576.  
  577.         if gettokencount(fixed_command, " ") == 2 then
  578.  
  579.             player_number = tonumber(gettoken(fixed_command, " ", 1))
  580.             m_player = getplayer(player_number  - 1)
  581.             hash = gethash(player_number  - 1)
  582.  
  583.             if hash == 0 then
  584.                 hprintf("Invalid Player")
  585.                 display = 0
  586.             end
  587.  
  588.         elseif gettokencount(fixed_command, " ") > 2 then
  589.             hprintf("Invalid Syntax: sv_info [player]")
  590.             display = 0
  591.         end
  592.  
  593.         if display == 1 then
  594.  
  595.             local m_playerObjId = readdword(m_player, 0x34)
  596.             local m_object = getobject(m_playerObjId)
  597.  
  598.             local player_name = readstring(m_player, 0x4, 0x14)
  599.             local player_team = readdword(m_player, 0x20)
  600.             local player_interaction_seat = readword(m_player, 0x2A)
  601.             local player_speed = readfloat(m_player, 0x6C)
  602.             local player_objective_mode = readbyte(m_player, 0x74)
  603.             local player_kills = readword(m_player, 0x9C)
  604.             local player_assists = readword(m_player, 0xA4)
  605.             local player_betrays = readword(m_player, 0xAC)
  606.             local player_deaths = readword(m_player, 0xAE)
  607.             local player_suicides = readword(m_player, 0xB0)
  608.             local player_ping = readword(m_player, 0xDC)
  609.             local player_weap_type = readword(m_player, 0x14C)
  610.             local player_nade_type = readword(m_player, 0x14E)
  611.  
  612.             local obj_max_health = readfloat(m_object, 0xD8)
  613.             local obj_max_shields = readfloat(m_object, 0xDC)
  614.             local obj_health = readfloat(m_object, 0xE0)
  615.             local obj_shields = readfloat(m_object, 0xE4)
  616.             local obj_invis_mode = readbyte(m_object, 0x204)
  617.             local obj_flashlight_mode = readbyte(m_object, 0x206)
  618.             local obj_crouch_mode = readbyte(m_object, 0x208)
  619.             local obj_primary_nades = readbyte(m_object, 0x31E)
  620.             local obj_secondary_nades = readbyte(m_object, 0x31F)
  621.             local obj_flashlight_level = readfloat(m_object, 0x344)
  622.             local obj_invis_scale = readfloat(m_object, 0x37C)
  623.  
  624.             local obj_primary_weap_id = readdword(m_object, 0x2F8)
  625.             local obj_secondary_weap_id = readdword(m_object, 0x2FC)
  626.             local primary_weap = getobject(obj_primary_weap_id)
  627.             local secondary_weap = getobject(obj_secondary_weap_id)
  628.  
  629.             local m_vehicle = getobject(readdword(m_object, 0x11C))
  630.  
  631.             if m_vehicle ~= 0 then
  632.  
  633.                 if player_interaction_seat ~= 1 then
  634.                     primary_weap = getobject(readdword(m_vehicle, 0x2F8))
  635.                     secondary_weap = getobject(readdword(m_vehicle, 0x2FC))
  636.                 end
  637.  
  638.                 m_object = m_vehicle
  639.  
  640.             end
  641.  
  642.             local obj_x_coord = readfloat(m_object, 0x5C)
  643.             local obj_y_coord = readfloat(m_object, 0x60)
  644.             local obj_z_coord = readfloat(m_object, 0x64)
  645.  
  646.             local primary_weap_heat = readfloat(primary_weap, 0x23C)
  647.             local primary_weap_age = readfloat(primary_weap, 0x240)
  648.             local primary_weap_ammo = readword(primary_weap, 0x2B6)
  649.             local primary_weap_clip = readword(primary_weap, 0x2B8)
  650.             local secondary_weap_heat = readfloat(secondary_weap, 0x23C)
  651.             local secondary_weap_age = readfloat(secondary_weap, 0x240)
  652.             local secondary_weap_ammo = readword(secondary_weap, 0x2B6)
  653.             local secondary_weap_clip = readword(secondary_weap, 0x2B8)
  654.  
  655.             local teamsize = getteamsize(player_team)
  656.  
  657.             if player_team == 0 then
  658.                 player_team = "Red"
  659.             elseif player_team == 1 then
  660.                 player_team = "Blue"
  661.             end
  662.  
  663.             if player_objective_mode == 0x22 then
  664.                 player_objective_mode = "Hill"
  665.             elseif player_objectivemode == 0x29 then
  666.                 player_objective_mode = "Ball"
  667.             else
  668.                 player_objective_mode = "None"
  669.             end
  670.  
  671.             if player_weap_type == 2 and player_objective_mode == "None" then
  672.                 player_objective_mode = "Flag"
  673.             end
  674.  
  675.             player_betrays = player_betrays - player_suicides
  676.  
  677.             obj_x_coord = round(obj_x_coord)
  678.             obj_y_coord = round(obj_y_coord)
  679.             obj_z_coord = round(obj_z_coord)
  680.             obj_max_health = round(obj_health * obj_max_health)
  681.             obj_max_shields = round(obj_shields * obj_max_shields)
  682.             obj_health = round(obj_health * 100)
  683.             obj_shields = round(obj_shields * 100)
  684.  
  685.             if obj_invis_mode == 0x51 then
  686.                 obj_invis_mode = "Yes"
  687.             else
  688.                 obj_invis_mode = "No"
  689.             end
  690.  
  691.             if obj_flashlight_mode == 8 then
  692.                 obj_flashlight_mode = "On"
  693.             else
  694.                 obj_flashlight_mode = "Off"
  695.             end
  696.  
  697.             obj_flashlight_level = round(obj_flashlight_level * 100)
  698.             obj_invis_scale = round(obj_invis_scale * 100)
  699.  
  700.             if obj_crouch_mode == 0 then
  701.                 obj_crouch_mode = "Standing"
  702.             elseif obj_crouch_mode == 1 then
  703.                 obj_crouch_mode = "Crouching"
  704.             elseif obj_crouch_mode == 2 then
  705.                 obj_crouch_mode = "Jumping"
  706.             end
  707.  
  708.  
  709.             if player_weap_type == 1 then
  710.                 primary_weap_heat = readfloat(secondary_weap, 0x23C)
  711.                 primary_weap_age = readfloat(secondary_weap, 0x240)
  712.                 primary_weap_ammo = readword(secondary_weap, 0x2B6)
  713.                 primary_weap_clip = readword(secondary_weap, 0x2B8)
  714.                 secondary_weap_heat = readfloat(primary_weap, 0x23C)
  715.                 secondary_weap_age = readfloat(primary_weap, 0x240)
  716.                 secondary_weap_ammo = readword(primary_weap, 0x2B6)
  717.                 secondary_weap_clip = readword(primary_weap, 0x2B8)
  718.             end
  719.  
  720.             primary_weap_heat = round(primary_weap_heat * 100)
  721.             primary_weap_age = round((1 - primary_weap_age) * 100)
  722.             secondary_weap_heat = round(secondary_weap_heat * 100)
  723.             secondary_weap_age = round((1 - secondary_weap_age) * 100)
  724.  
  725.             local primary_weap_info = "Primary Ammo: " .. primary_weap_clip .. " / " .. primary_weap_ammo
  726.             local secondary_weap_info = "Secondary Ammo: " .. secondary_weap_clip .. " / " .. secondary_weap_ammo
  727.  
  728.             if primary_weap_age >= 0 and primary_weap_ammo == 0 and primary_weap_clip == 0 then
  729.                 primary_weap_info = "Primary Battery: " .. primary_weap_heat .. " / " .. primary_weap_age
  730.             end
  731.  
  732.             if secondary_weap_age >= 0 and secondary_weap_ammo == 0 and secondary_weap_clip == 0 then
  733.                 secondary_weap_info = "Secondary Battery: " .. secondary_weap_heat .. " / " .. secondary_weap_age
  734.             end
  735.  
  736.             local nade_info = "Frag Grenades: " .. obj_primary_nades .. " | " .. "Plasma Grenades: " .. obj_secondary_nades
  737.  
  738.             if player_nade_type == 1 then
  739.                 nade_info = "Plasma Grenades: " .. obj_secondary_nades .. " | " .. "Frag Grenades: " .. obj_primary_nades
  740.             end
  741.  
  742.             hprintf("----------")
  743.             hprintf("Name: " .. player_name .. " (" .. player_number .. ") | " .. "Team: " .. player_team .. " (" .. teamsize .. ") | " .. "Speed: " .. player_speed .. " | " .. "Location: " .. obj_x_coord .. ", " .. obj_y_coord .. ", " .. obj_z_coord)
  744.             hprintf("Hash: " .. hash .. " | " .. "Ping: " .. player_ping .. " | " .. "Stance: " .. obj_crouch_mode)
  745.             hprintf("Kills: " .. player_kills .. " | " .. "Assists: " .. player_assists .. " | " .. "Betrays: " .. player_betrays .. " | " .. "Suicides: " .. player_suicides .. " | " .. "Deaths: " .. player_deaths .. " | " .. "Objective: " .. player_objective_mode)
  746.             hprintf("Health: " .. obj_health .. " (" .. obj_max_health .. ") | " .. "Shields: " .. obj_shields .. " (" .. obj_max_shields .. ") | " .. "Invis: " .. obj_invis_mode .. " (" .. obj_invis_scale .. ") | " .. "Light: " .. obj_flashlight_mode .. " (" .. obj_flashlight_level .. ")")
  747.             hprintf(primary_weap_info .. " | " .. secondary_weap_info)
  748.             hprintf(nade_info)
  749.             hprintf("----------")
  750.  
  751.         end
  752.  
  753.     end
  754.  
  755.     return 1
  756.  
  757. end
  758.  
  759. function OnTeamDecision(cur_team)
  760.     return cur_team
  761. end
  762.  
  763. function OnPlayerJoin(player, team)
  764. end
  765.  
  766. function OnPlayerLeave(player, team)
  767. end
  768.  
  769. function OnPlayerKill(killer, victim, mode)
  770. end
  771.  
  772. function OnKillMultiplier(player, multiplier)
  773. end
  774.  
  775. function OnPlayerSpawn(player, m_objectId)
  776. end
  777.  
  778. function OnPlayerSpawnEnd(player, m_objectId)
  779. end
  780.  
  781. function OnTeamChange(relevant, player, team, dest_team)
  782.     return 1
  783. end
  784.  
  785. function OnObjectInteraction(player, m_ObjectId, tagType, tagName)
  786.     return 1
  787. end
  788.  
  789. function OnWeaponReload(player, weapon)
  790.     return 1
  791. end
  792.  
  793. function OnVehicleEntry(player)
  794.     return 1
  795. end
  796.  
  797. function OnDamageLookup(receiving_obj, causing_obj, tagdata, tagname)
  798. end
  799.  
  800. function OnWeaponAssignment(player, object, count, tag)
  801. end
  802.  
  803. function OnWeaponCreation(owningPlayer, owningObject, m_weapon, tag)
  804. end
  805.  
  806. function round(num)
  807.  
  808.     under = math.floor(num)
  809.     upper = math.floor(num) + 1
  810.     underV = -(under - num)
  811.     upperV = upper - num
  812.  
  813.     if (upperV > underV) then
  814.         return under
  815.     else
  816.         return upper
  817.     end
  818.  
  819. end
  820.  
  821. function readstring(address, offset, length)
  822.  
  823.     local char_table = {}
  824.     local string = ""
  825.  
  826.     for i=0,length do
  827.         if readbyte(address, (offset + (0x1 * i))) ~= 0 then
  828.             table.insert(char_table, string.char(readbyte(address, (offset + (0x1 * i)))))
  829.         end
  830.     end
  831.  
  832.     for k,v in pairs(char_table) do
  833.         string = string .. v
  834.     end
  835.  
  836.     return string
  837.  
  838. end
Advertisement
Add Comment
Please, Sign In to add comment