Advertisement
HR_Shaft

Replace Player Names v1 for Phasor v2+

Dec 13th, 2014
304
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.60 KB | None | 0 0
  1. --[[ ### Replace Player Names v1.0  ###]]--
  2. --[[ ### by H® Shaft for Phasor v2+ ###]]--
  3.  
  4. -- This will replace unwanted player names with the "replacement_name" you specify (below) and also log the name change in the game log.  
  5. -- You can add names to the table (replace_table) with the name you want replaced in quotes separated by comma between names. (case sensitive)
  6. -- If a player joins with a name that is in the table, it will be replaced with the new name, and number.
  7. -- All random names built into halo (profile name "+%+") are already in the list, as well as "vehicle", "your mom", etc.
  8. -- Inappropriate names can be added to this table as well, rather than blocking entry or banning.
  9. -- If there is interest, I will re-write this to read-from and write-to files on the host server, along with adding admin function to add/remove names.
  10. -- NOTE: failing to put names in quotes, or failing to separate names with comma's will result in an error.
  11.  
  12. replacement_name = "GUEST" -- | Edit this name, no more than 6 characters, it will generate a new name: "GUEST_1", "GUEST_2", etc.
  13.  
  14. replace_table = {"+%+", "Donut", "Penguin", "Stumpy", "Whicker", "Shadow", "Howard", "Wilshire", "Darling", "Disco", "Jack", "The Bear", "Sneak", "The Big L", "Whisp",  
  15.                 "Wheezy", "Crazy", "Goat", "Pirate", "Saucy", "Hambone", "Butcher", "Walla Walla", "Snake", "Caboose", "Sleepy", "Killer", "Stompy", "Mopey",  
  16.                 "Dopey", "Weasel", "Ghost", "Dasher", "Grumpy", "Hollywood", "Tooth", "Noodle", "King", "Cupid", "Prancer", "New001", "new001", "Nuevo001",
  17.                 "Vehicle", "vehicle", "Your Mom", "your mom"
  18.                 }
  19.  
  20. newnames = {}              
  21.                                
  22. function GetRequiredVersion()
  23.     return 200
  24. end
  25.  
  26. function OnScriptLoad(process, game, persistent)
  27.     namenumber = 0
  28.     for i=0,15 do
  29.         if getplayer(i) then
  30.             newnames[gethash(i)] = false
  31.         end
  32.     end
  33. end
  34.  
  35. function OnPlayerJoin(player)
  36.     if getplayer(player) then
  37.         if newnames[gethash(player)] then
  38.             privatesay(player, "The server has replaced your name.  Your new name is: " .. getname(player))
  39.         end
  40.     end
  41. end
  42.  
  43. function OnPlayerLeave(player)
  44.     if getplayer(player) then
  45.         newnames[gethash(player)] = nil
  46.     end
  47. end
  48.  
  49. function OnNameRequest(hash, name, new_name)
  50.     namenumber = namenumber + 1
  51.     hprintf(name .. " is attempting to join the server.")
  52.     for k,v in pairs(replace_table) do
  53.         if v == name then
  54.             new_name = (replacement_name .. "_" .. namenumber)
  55.             log_msg(1, name .. " was given the new name of " .. new_name .. " hash: " .. hash)
  56.             newnames[hash] = true
  57.             return true, new_name
  58.         else
  59.             new_name = name
  60.         end
  61.     end
  62.     return true, new_name                  
  63. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement