SHARE
TWEET

OnNameRequest

it300 Jan 1st, 2016 (edited) 146 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- OnNameRequest script for Sapp
  2. -- By: Devieth
  3.  
  4. api_version = "1.9.0.0"
  5.  
  6. function OnScriptLoad()
  7.     register_callback(cb['EVENT_PREJOIN'], "OnPlayerPrejoin")
  8.     if halo_type == "PC" then ce = 0x0 else ce = 0x40 end
  9. end
  10.  
  11. function OnPlayerPrejoin(PlayerIndex)
  12.     local network_struct = read_dword(sig_scan("F3ABA1????????BA????????C740??????????E8????????668B0D") + 3)
  13.     local client_network_struct = network_struct + 0x1AA + ce + to_real_index(PlayerIndex) * 0x20
  14.     local name = read_widestring(client_network_struct, 12)
  15.     local new_name = OnNameRequest(PlayerIndex, name)
  16.     if name ~= new_name then -- Check if the new name is different from the players orignal name.
  17.         write_widestring(client_network_struct, string.sub(new_name,1,11), 12) -- Set the new name if its different from the orignal.
  18.     end
  19. end
  20.  
  21. function OnNameRequest(PlayerIndex, Name)
  22.     return Name -- Send back the decidred name.
  23. end
  24.  
  25. -- Don't touch these...
  26. function write_widestring(address, str, len)
  27.     local Count = 0
  28.     for i = 1,len do -- Nuls out the old sting.
  29.         write_byte(address + Count, 0)
  30.         Count = Count + 2
  31.     end
  32.     local length = string.len(str)
  33.     local count = 0
  34.     for i = 1,length do -- Sets the new string.
  35.         local newbyte = string.byte(string.sub(str,i,i))
  36.         write_byte(address + count, newbyte)
  37.         count = count + 2
  38.     end
  39. end
  40.  
  41. function read_widestring(address, length)
  42.     local count = 0
  43.     local byte_table = {}
  44.     for i = 1,length do -- Reads the string.
  45.         if read_byte(address + count) ~= 0 then
  46.             byte_table[i] = string.char(read_byte(address + count))
  47.         end
  48.         count = count + 2
  49.     end
  50.     return table.concat(byte_table)
  51. end
  52.  
  53. function OnScriptUnload() end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top