Advertisement
it300

OnNameRequest

Jan 1st, 2016
286
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.63 KB | None | 0 0
  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, Size)
  42.     local str = ""
  43.     for i=0,Size-1 do
  44.         if read_byte(Address + i*2) ~= 00 then
  45.             str = str .. string.char(read_byte(Address + i*2))
  46.         end
  47.     end
  48.     if str ~= "" then return str end
  49.     return nil
  50. end
  51.  
  52. function OnScriptUnload() end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement