Advertisement
it300

Sapp Functions & Other

Jan 6th, 2015
490
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 10.34 KB | None | 0 0
  1. -- Address for HaloCE only.
  2.  
  3. function adders() -- Some useful addresses.
  4.     network_struct = read_dword(sig_scan("F3ABA1????????BA????????C740??????????E8????????668B0D") + 3)
  5.     if halo_type == "CE" then
  6.         ce = 0x40
  7.         profilepath = read_string(0x5B9610)
  8.         banlistpath = read_string(0x61FB60)
  9.         hardwareinfo = read_string(0x5E6E3C)
  10.         gametype_base = 0x5F5478
  11.     end
  12. end
  13.  
  14. function get_game_type()
  15.     -- Gametype Name
  16.     local gametype_name = read_widestring(gametype_base, 0x2C) -- Custom name of gametype.
  17.     -- Gametype Options
  18.     local team_play = read_byte(gametype_base + 0X34) -- 0 = False | 1 = True
  19.     local gametype_game = read_byte(gametype_base + 0X30) -- Listed in order below with settings.
  20.     local gametype_timelimit = read_dword(gametype_base + 0x78) -- 1 Second = 30
  21.     local gametype_scorelimit = read_byte(gametype_base + 0x58) -- Number
  22.     -- 1 = CTF
  23.     local assualt = read_byte(gametype_base + 0x7C) -- 0 = False | 1 = True
  24.     local flag_must_reset = read_byte(gametype_base + 0x7E) -- 0 = False | 1 = True
  25.     local flag_at_home_to_score = read_byte(gametype_base + 0x7F) -- 0 = False | 1 = True
  26.     local single_flag_reset_time = read_dword(gametype_base + 0x80) -- 1 Second = 30
  27.     -- 2 = Slayer
  28.     local death_bonus = read_byte(gametype_base + 0x7C) -- 0 = False | 1 = True
  29.     local kill_penalty = read_byte(gametype_base + 0x7D) -- 0 = False | 1 = True
  30.     -- 3 = Oddball
  31.     local oddball_type = read_byte(gametype_base + 0x8C) -- 0 = Normal | 1 = Reverse Tag | 2 = Juggernaut
  32.     local speed_with_ball = read_byte(gametype_base + 0x80) -- 0 = Slow | 1 = Normal | 2 = Fast
  33.     local trait_with_ball = read_byte(gametype_base + 0x84) -- 0 = None | 1 = Invisable | 2 = Extra Damage | 3 = Damage Resistant
  34.     local trait_without_ball = read_byte(gametype_base + 0x88) -- Same as above.
  35.     local oddball_spawn_count = read_byte(gametype_base + 0x90) -- Unknown
  36.     -- 4 = King of the hill
  37.     local moving_hill = read_byte(gametype_base + 0x7C) -- 0 = False | 1 = True
  38.     -- 5 = Race
  39.     local race_type = read_byte(gametype_base + 0x7C) -- 0 = Normal | 1 = Any Order | 2 = Rally
  40.     local team_scoring = read_byte(gametype_base + 0x80) -- 0 = Min | 1 = Max | 2 = Sum
  41.     -- Player Options
  42.     local number_of_lives = read_byte(gametype_base + 0x50) -- 0 = Unlimited
  43.     local max_health = read_float(gametype_base + 0x54) -- Untested
  44.     local sheilds = read_bit(gametype_base + 0x38, 3) -- 0 = False | 1 = True
  45.     local respawn_time = read_byte(gametype_base + 0x48) -- 1 Second = 30
  46.     local respawn_time_growth = read_byte(gametype_base + 0x44) -- 1 Second = 30
  47.     local odd_man_out = read_byte(gametype_base + 0x40) -- 0 = False | 1 = True
  48.     local invisable_players = read_bit(gametype_base + 0x38, 4) -- 0 = False | 1 = True
  49.     local suicide_penalty = read_byte(gametype_base + 0x4C) -- 1 Second = 30
  50.     -- Item Options
  51.     local infite_grenades = read_bit(gametype_base + 0x38, 2) -- 0 = False | 1 = True
  52.     local weapon_set = read_byte(gametype_base + 0x5C) -- 0 = Normal | 1 = Pistols | 2 = Rifles | 3 = Plasma | 4 = Snipers | 5 = No Snipers | 6 = Rockets | 7 = Shotguns | 8 = Short Range | 9 = Human | 10 = Covenent | 11 = Classic | 12 = Heavy
  53.     local starting_equipment = read_bit(gametype_base + 0x38, 5) -- 0 = Custom | 1 = Generic
  54.     -- Vehicle Options
  55.     local red_vehicles = read_dword(gametype_base + 0x60) -- Unknown
  56.     local blue_vehicles = read_dword(gametype_base + 0x64) -- Unknown
  57.     local Vehicle_respawn_time = read_dword(gametype_base + 0x68) -- 1 Second = 30
  58.     -- Indicator Options
  59.     local gametype_indicator = read_byte(gametype_base + 0x3C) -- 0 = Motion Tracker | 1 = Nav Points | 2 = None
  60.     local only_friendlys_on_radar = read_bit(gametype_base + 0x38, 6) -- 0 = False | 1 = True
  61.     local all_players_on_radar = read_bit(gametype_base + 0x38, 0) -- 0 = False | 1 = True
  62.     local friendly_indicators = read_bit(gametype_base + 0x38, 1) -- 0 = False | 1 = True
  63.     -- Team Options
  64.     local friendly_fire = read_byte(gametype_base + 0x6C) -- 0 = False | 1 = True
  65.     local friendly_fire_penalty = read_byte(gametype_base + 0x70) -- 1 Second = 30
  66.     local auto_balance = read_byte(gametype_base + 0x74) -- 0 = False | 1 = True
  67. end
  68.  
  69. function NetworkStruct(PlayerIndex)
  70.     local client_machineinfo_struct = network_struct + 0x3B8+ce + to_real_index(PlayerIndex) * client_machineinfo_size
  71.     local crouch_key = read_bit(client_machineinfo_struct + 0x24, 0) -- Confirmed. (0 = False 1 = True)
  72.     local jump_key = read_bit(client_machineinfo_struct + 0x24, 1) -- Confirmed. (0 = False 1 = True)
  73.     --unknownbit(24, 2)(24, 3)
  74.     local flashlight_key = read_bit(client_machineinfo_struct + 0x24, 4) -- Confirmed. (0 = False 1 = True)
  75.     local action_key = read_bit(client_machineinfo_struct + 0x24, 6) -- Confirmed. (0 = False 1 = True) Excludes X (Swap weapon) & R (Reaload weapon)
  76.     local melee_key = read_bit(client_machineinfo_struct + 0x24, 7) -- Confirmed. (0 = False 1 = True)
  77.     --unknownbit(24, 8)(25, 0)(25, 1)
  78.     local reload_key = read_bit(client_machineinfo_struct + 0x25, 2) -- Confirmed. (0 = False 1 = True) Includes E (Action)
  79.     local primary_fire = read_bit(client_machineinfo_struct + 0x25, 3) -- Confirmed. (0 = False 1 = True)
  80.     local secondary_fire = read_bit(client_machineinfo_struct + 0x25, 4) -- Confirmed. (0 = False 1 = True)
  81.     local secondary_fire2 = read_bit(client_machineinfo_struct + 0x25, 5) -- Confirmed. (0 = False 1 = True)
  82.     local action_key2 = read_bit(client_machineinfo_struct + 0x25, 6) -- Confirmed. (0 = False 1 = True) Excludes X (Swap weapon) & R (Reaload weapon)
  83.     --unknownbit(25, 7)(25, 8)
  84. end
  85.  
  86. function driver(PlayerIndex)
  87.     local m_vehicle = toplayermvehicle(PlayerIndex)
  88.     local driver = read_dword(m_vehicle + 0x324) -- 0xFFFFFFFF if there is no driver to the vehicle
  89.     if driver then return driver end
  90.     return nil
  91. end
  92.  
  93. function get_random_player(New_Team, Kill)
  94.     local players, count = {}, 1
  95.     for i = 1,16 do
  96.         if player_present(i) then
  97.             if New_Team then
  98.                 if get_team(i) ~= New_Team then
  99.                     players[count], count = i, count + 1
  100.                 end
  101.             else
  102.                 players[count], count = i, count + 1
  103.     end end end
  104.     if #players > 1 then
  105.         local PlayerIndex = players(rand(1, #players))
  106.         set_team(PlayerIndex, New_Team, Kill)
  107.     end
  108. end
  109.  
  110. function get_tag(class, path) -- By 002
  111.     local tagarray = read_dword(0x40440000)
  112.     for i = 0,read_word(0x4044000C)-1 do
  113.         local tag = tagarray + i * 0x20
  114.         local tagclass = string.reverse(string.sub(read_string(tag),1,4))
  115.         if tagclass == class then
  116.             if(read_string(read_dword(tag + 0x10)) == path) then return read_dword(tag + 0xC) end
  117.         end
  118.     end
  119.     return nil
  120. end
  121.  
  122. function get_team(PlayerIndex)
  123.     local m_player = get_player(PlayerIndex)
  124.     if m_player then
  125.         return read_byte(m_player + 0x20)
  126.     end
  127.     return nil
  128. end
  129.  
  130. function get_name(PlayerIndex)
  131.     if player_present then
  132.         return get_var(PlayerIndex, "$name")
  133.     end
  134.     return nil
  135. end
  136.  
  137. function set_speed(PlayerIndex, Speed)
  138.     local m_player = get_player(PlayerIndex)
  139.     if m_player then
  140.         write_float(m_player + 0x6c, Speed)
  141.     end
  142. end
  143.  
  144. function set_spawn_time(PlayerIndex, Time)
  145.     local m_player = get_player(PlayerIndex)
  146.     if m_player then
  147.         write_dword(m_player + 0x2C, Time + 30)
  148.     end
  149. end
  150.  
  151. function set_color(PlayerIndex, Color)
  152.     local m_player = get_player(PlayerIndex)
  153.     if m_player then
  154.         write_word(m_player + 0x60, Color)
  155.     end
  156. end
  157.  
  158. function set_team(PlayerIndex, New_Team, Kill)
  159.     local m_player = get_player(PlayerIndex)
  160.     if m_player then
  161.         write_byte(m_player + 0x20, New_Team)
  162.         if Kill then kill(PlayerIndex) end
  163.     end
  164. end
  165.  
  166. function set_navs(PlayerIndex)
  167.     local Target = nil
  168.     for i = 1,16 do
  169.         local m_player = get_player(i)
  170.         if m_player then
  171.             if PlayerIndex == nil then
  172.                 Target = to_real_index(i)
  173.             else
  174.                 Target = to_real_index(PlayerIndex)
  175.             end
  176.             write_word(m_player + 0x88, Target)
  177.         end
  178.     end
  179. end
  180.  
  181. function rprintall_exclude(Message, PlayerIndex) -- Sends console text to every player except the one sent to the function.
  182.     for i = 1,16 do
  183.         if player_present(i) then
  184.             if i ~= PlayerIndex then
  185.                 rprint(i, "|c" .. Message)
  186.             end
  187.         end
  188.     end
  189. end
  190.  
  191. function tomplayerId(PlayerIndex)
  192.     local m_player = get_player(PlayerIndex)
  193.     if m_player then
  194.         local m_playerId = read_dword(m_player + 0x34)
  195.         return m_playerId
  196.     end
  197.     return nil
  198. end
  199.  
  200. function toplayermweaponid(PlayerIndex) -- Current weapon of the player.
  201.     local m_object = get_dynamic_player(PlayerIndex)
  202.     if m_object ~= 0 then
  203.         local m_weaponId = read_dword(m_object + 0x118)
  204.         return m_weaponId
  205.     end
  206.     return nil
  207. end
  208.  
  209. function toplayermvehicle(PlayerIndex) -- Just showing how to get m_vehicle of a player .
  210.     local m_object = get_dynamic_player(PlayerIndex)
  211.     if m_object then
  212.         local m_vehicleId = read_dword(m_object + 0x11C)
  213.         if m_vehicleId then
  214.             local m_vehicle = get_object_memory(m_vehicleId)
  215.             return m_vehicle
  216.         end
  217.     end
  218.     return nil
  219. end
  220.  
  221. function toplayermvehicleid(PlayerIndex) -- Current vehicle of the player.
  222.     local m_object = get_dynamic_player(PlayerIndex)
  223.     if m_object ~= 0 then
  224.         local m_vehicleId = read_dword(m_object + 0x11C)
  225.         return m_vehicleId
  226.     end
  227.     return nil
  228. end
  229.  
  230. function getplayercoords(PlayerIndex) -- Faster way to get the player coords
  231.     local m_object = get_dynamic_player(PlayerIndex)
  232.     if m_object ~= 0 then
  233.         local x, y, z = read_vector3d(m_object + 0x5c)
  234.         return x, y, z
  235.     end
  236.     return nil
  237. end
  238.  
  239. function getobjetinteractionid(PlayerIndex) -- Gets the ObjectId that is currently being interacted with
  240.     local m_player = get_player(PlayerIndex)
  241.     if m_player ~= 0 then
  242.         local ObjectId = read_dword(m_player + 0x24)
  243.         return ObjectId
  244.     end
  245.     return nil
  246. end
  247.  
  248. function write_widestring(address, str, len)
  249.     local Count = 0
  250.     for i = 1,len do -- Nuls out the old sting.
  251.         write_byte(address + Count, 0)
  252.         Count = Count + 2
  253.     end
  254.     local length = string.len(str)
  255.     local count = 0
  256.     for i = 1,length do -- Sets the new string
  257.         local newbyte = string.byte(string.sub(str,i,i))
  258.         write_byte(address + count, newbyte)
  259.         count = count + 2
  260.     end
  261. end
  262.  
  263. function read_widestring(address, length)
  264.     local count = 0
  265.     local byte_table = {}
  266.     for i = 1,length do -- reads the string.
  267.         byte_table[i] = string.char(read_byte(address + count))
  268.         count = count + 2
  269.     end
  270.     return table.concat(byte_table)
  271. end
  272.  
  273. function tokenizestring(inputstr, sep) -- I forgot how it got this but, to whoever made it, thank you.
  274.     if sep == nil then
  275.         sep = "%s"
  276.     end
  277.     local t={} ; i=1
  278.     for str in string.gmatch(inputstr, "([^"..sep.."]+)") do
  279.         t[i] = str
  280.         i = i + 1
  281.     end
  282.     return t
  283. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement