Advertisement
HR_Shaft

Custom Team and FFA Colors v2 for Phasor v2+

Nov 2nd, 2014
273
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.66 KB | None | 0 0
  1. --[[ ###  Custom Team and FFA Colors v2 ###]]--
  2. --[[ ###    by H® Shaft for Phasor v2+  ###]]--
  3.  
  4. -- Update 11/2/2014: random rgb values in previous version would sometimes error in FFA games. This version is error free.
  5.  
  6. -- Team Games: allows you to set custom colors for each team (see color table and selected team colors below)
  7. -- FFA games: each time a player spawns, they are given a new random color.
  8.  
  9. -- inspired by: AelitePrimes Colored Team Gametypes. Numerous rgb offsets published by Wizard,
  10. -- Correct rgb offsets found by 002 in his SAPP custom team color script: https://www.dropbox.com/s/91ksoqbsydi49nl/customteamcolors.lua
  11.  
  12. -- selected team colors - edit these --
  13. red_color = {}
  14. blue_color = {}
  15. red_color[1] = {0.67, 0.062, 0.956} --"Purple"
  16. blue_color[1] = {0, 1, 0.003} --"Green"
  17.  
  18. -- team color tables - don't edit --
  19. team_play = false
  20. color_table = {}
  21. color_table[1] = {0, 0, 0} --"Black"
  22. color_table[2] = {0.996, 0, 0} --"Red"
  23. color_table[3] = {0.007, 0.003, 0.890} --"Blue"
  24. color_table[4] = {0.439, 0.494, 0.443} --"Gray"
  25. color_table[5] = {1, 1, 0.003} --"Yellow"
  26. color_table[6] = {0, 1, 0.003} --"Green"
  27. color_table[7] = {1, 0.337, 0.725} --"Pink"
  28. color_table[8] = {0.67, 0.062, 0.956} --"Purple"
  29. color_table[9] = {0.003, 1, 1} --"Cyan"
  30. color_table[10] = {0.392, 0.576, 0.929} --"Cobalt"
  31. color_table[11] = {1, 0.498, 0} --"Orange"
  32. color_table[12] = {0.117, 0.80, 0.568} --"Teal"
  33. color_table[13] = {0, 0.392, 0.003} --"Sage"
  34. color_table[14] = {0.376, 0.217, 0.078} --"Brown"
  35. color_table[15] = {0.776, 0.6117, 0.423} --"Tan"
  36. color_table[16] = {0.615, 0.043, 0.054} --"Maroon"
  37. color_table[17] = {0.960, 0.6, 0.619} --"Salmon"
  38. color_table[18] = {1, 1, 1} -- "White"
  39.  
  40. function GetRequiredVersion()
  41.     return 200
  42. end
  43.  
  44. function OnScriptLoad(process, game, persistent)
  45.     GAME = game
  46.     GetGameAddresses(game)
  47. end
  48.  
  49. function OnNewGame(map)
  50.     team_play = getteamplay()
  51. end
  52.  
  53. function OnPlayerSpawn(player, m_objectId)
  54.     if getplayer(player) then
  55.         local m_objectId = getplayerobjectid(player)
  56.         if m_objectId then
  57.             local m_object = getobject(m_objectId)
  58.             if m_object then
  59.                 local m_player = getplayer(player)
  60.                 if m_player then
  61.                     if team_play then
  62.                         local team = readbyte(m_player + 0x66)
  63.                         if team == 0 then
  64.                             writefloat(m_object + 0x1A0, red_color[1][1])
  65.                             writefloat(m_object + 0x1A4, red_color[1][2])
  66.                             writefloat(m_object + 0x1A8, red_color[1][3])                          
  67.                             sendconsoletext(player, "Red Team")
  68.                         else
  69.                             writefloat(m_object + 0x1A0, blue_color[1][1])
  70.                             writefloat(m_object + 0x1A4, blue_color[1][2])
  71.                             writefloat(m_object + 0x1A8, blue_color[1][3])
  72.                             sendconsoletext(player, "Blue Team")
  73.                         end
  74.                     else
  75.                         ChangeFFAColor(player)     
  76.                     end
  77.                 end
  78.             end
  79.         end    
  80.     end
  81. end
  82.  
  83. function ChangeFFAColor(player)
  84.     if getplayer(player) then
  85.         local m_objectId = getplayerobjectid(player)
  86.         if m_objectId then
  87.             local m_object = getobject(m_objectId)
  88.             if m_object then
  89.                 local m_player = getplayer(player)
  90.                 local color = getrandomnumber(1, 18)
  91.                 writeword(m_player + 0x60, color)
  92.             end
  93.         end
  94.     end
  95. end
  96.  
  97. function GetGameAddresses(game)
  98.     if game == "PC" or GAME == "PC" then
  99.         map_name = readstring(0x698F21)
  100.         gametype_base = 0x671340       
  101.     else
  102.         map_name = readstring(0x61D151)
  103.         gametype_base = 0x5F5498   
  104.     end
  105. end
  106.  
  107. function getteamplay()
  108.     if readbyte(gametype_base + 0x34) == 1 then
  109.         return true
  110.     else
  111.         return false
  112.     end
  113. end
  114.  
  115. --[[ Created by H® Shaft.
  116. Thanks to Oxide, AelitePrime, Wizard -- and 002
  117. Visit http://halorace.org/forum/index.php?topic=514.0 or
  118. Visit http://pastebin.com/u/HR_Shaft for more phasor scripts
  119. ]]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement