HR_Shaft

Gun-Game/Arms Race v5 'DOWN' for Phasor v2+

Jul 30th, 2014
304
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 60.33 KB | None | 0 0
  1. --[[ ### Gun-Game/Arms Race v5 'DOWN' ###]]--
  2. --[[ ###  by H® Shaft for Phasor v2   ###]]--
  3.  
  4. -- GUN GAME: Based on the Counter Strike game called 'Gun Game.' Also, derivatives known as 'Global Offensive' & 'Arsenal: Arms Race' by Valve
  5. -- UP VERSION: Work your way up from weakest to strongest weapons.  Link: http://pastebin.com/NerBUTVk
  6. -- DOWN VERSION: Work your way down from strongest to weakest weapons. Link: http://pastebin.com/9FFkFhZi
  7. -- Compatible with CTF & Slayer gametypes only! Pre-fabricated gametypes for both PC and CE: http://www.mediafire.com/download/2jtch51nba7cmcs/gungame_gametypes.zip
  8.  
  9. -- GAME PLAY:
  10. -- Each time you kill with a weapon, you will be given a new weapon. (oddball and flag: excluded weapons)
  11. -- The first person to kill with each weapon in the game - wins!
  12. -- There are 10 weapons. You can only use the weapon you are given. All weapons have infinite ammo.
  13. -- When you kill another player, you will only advance if you survive the kill.  If you die during the kill, you don't advance.
  14. -- Melee is instant kill and will advance your level.
  15. -- If you are on level 10 (final level), and get killed by another player, betray or suicide, you are demoted one level.
  16. -- Beserk Mode: When reaching level 10, you activate 'Beserk Mode' which temporarily speeds up all other players and heals the injured.
  17. -- Your player speed is based on your weapon: With a strong weapon, you move slower than you will with a weaker weapon.
  18.  
  19. -- SERVER SETUP - USAGE: --- scroll to very bottom for additional info
  20.  
  21. -- edit --
  22. logging = false         -- | true enable full script game logging: false = disable, true = enable, see also line 91 - can be spammy to the log, best used for tournaments/scrims/debugging
  23. autobal_delay = 15      -- | Time in seconds to delay balancing teams during the game and when players join or leave, you should not go lower than 10 seconds
  24. -- don't edit --
  25. team_play = false
  26. map_reset = false
  27. beserk = false
  28. weapons = {}
  29. level = {}
  30. last_damage = {}
  31. team_change = {}
  32. mybattery = {}
  33. playerscore = {}
  34. teamscore = {}
  35. needler_clip = 20
  36. shotgun_clip = 12
  37. assault_clip = 60
  38. flame_clip = 100
  39. pistol_clip = 12
  40. rocket_clip = 2
  41. sniper_clip = 4
  42. battery = 0
  43. cur_players = 0
  44. game_autobal = nil
  45.  
  46. -- prefix globals
  47. default_script_prefix = "\171GunGame\187  "
  48. phasor_privatesay = privatesay
  49. phasor_say = say
  50.  
  51. function GetRequiredVersion()
  52.     return 200
  53. end
  54.  
  55. function OnScriptLoad(process, game, persistent)
  56.     GAME = game
  57.     GetGameAddresses(game)
  58.     processid = process
  59.     Persistent = persistent
  60.     ScriptLoad()
  61. end
  62.  
  63. function OnScriptUnload()
  64.     writedword(ctf_score_patch, 0xFFFDE9E8)
  65.     writebyte(ctf_score_patch1, 0xFF)
  66.     writebyte(slayer_score_patch, 0x74)
  67.     writebyte(slayer_score_patch2, 0x75)
  68. end
  69.  
  70. function OnNewGame(map)
  71.     ScriptLoad()   
  72.     team_play = getteamplay()
  73.     gametype = readbyte(gametype_base + 0x30)
  74.     game_started = false
  75.    
  76.     if not new_game_timer then
  77.         new_game_timer = registertimer(0, "NewGameTimer")
  78.     end
  79. end
  80.  
  81. function ApplyPatches()
  82.     writedword(ctf_score_patch, 0x90909090)
  83.     writebyte(ctf_score_patch1, 0x90)
  84.     writebyte(slayer_score_patch, 0xEB)
  85.     writebyte(slayer_score_patch2, 0xEB)   
  86. end    
  87.  
  88. function ScriptLoad()
  89.     if Persistent then
  90.         -- edit --
  91.         logging = false         -- | true enable full script game logging: false = disable, true = enable, see also line 22 - can be spammy to the log, best used for tournaments/scrims/debugging
  92.         autobal_delay = 15      -- | Time in seconds to delay balancing teams during the game and when players join or leave, you should not go lower than 10 seconds
  93.         -- don't edit --
  94.         game_started = false
  95.         team_play = false
  96.         beserk = false     
  97.         weapons = {}
  98.         level = {}
  99.         last_damage = {}
  100.         team_change = {}
  101.         mybattery = {}
  102.         playerscore = {}
  103.         teamscore = {}
  104.         needler_clip = 20
  105.         shotgun_clip = 12
  106.         assault_clip = 60
  107.         flame_clip = 100
  108.         pistol_clip = 12
  109.         rocket_clip = 2
  110.         sniper_clip = 4
  111.         battery = 0
  112.         game_autobal = nil     
  113.  
  114.         if new_game_timer == nil then
  115.             new_game_timer = registertimer(0, "NewGameTimer")
  116.         end        
  117.     end
  118.    
  119.     GetGameAddresses(game)
  120.     ApplyPatches()
  121.     game_started = false
  122.     team_play = false  
  123.     team_play = getteamplay()
  124.     beserk = false
  125.     gametype = readbyte(gametype_base + 0x30)
  126.     cur_players = readword(network_base, 0x1A0)
  127.    
  128.     for i = 0,15 do
  129.         if getplayer(i) then
  130.             local ip = getip(i)
  131.             last_damage[ip] = nil
  132.             mybattery[i] = 1
  133.             weapons[i] = "weapons\\plasma_cannon\\plasma_cannon"
  134.             level[i] = 1
  135.             playerscore[i] = 0
  136.             team_change[i] = false
  137.             cur_players = cur_players + 1
  138.         end
  139.     end    
  140.  
  141.     if team_play and game_autobal == nil then
  142.         game_autobal = registertimer(autobal_delay * 1000, "AutoBalance")
  143.     end
  144.    
  145.     if gametype == 3 or gametype == 4 or gametype == 5 then
  146.         for i=0,15 do
  147.             if getplayer(i) then
  148.                 privatesay(i, "KOTH, Oddball & Race gametypes are not compatible with Gun-Game. ", false)
  149.             end
  150.         end    
  151.         log_msg(4, "#GUN-GAME# KOTH, Oddball & Race gametypes are NOT compatible with Gun-Game: try CTF or Slayer.") -- log in scripts log
  152.         log_msg(1, "#GUN-GAME# KOTH, Oddball & Race gametypes are NOT compatible with Gun-Game: try CTF or Slayer.") -- log in game log
  153.     else
  154.         game_started = false
  155.         if new_game_timer == nil then
  156.             new_game_timer = registertimer(0, "NewGameTimer")
  157.         end    
  158.     end
  159.        
  160. end
  161.  
  162. function OnPlayerJoin(player)
  163.     if getplayer(player) then
  164.         local name = getname(player)
  165.         cur_players = cur_players + 1
  166.         mybattery[player] = 1
  167.         weapons[player] = "weapons\\plasma_cannon\\plasma_cannon"
  168.         level[player] = 1
  169.         playerscore[player] = 0
  170.         team_change[player] = false
  171.         welcome = registertimer(9000, "Welcome", player)
  172.         if game_started and team_play and cur_players > 3 then
  173.             join_autobal = registertimer(autobal_delay * 1000, "AutoBalance")
  174.         end
  175.         if team_play and cur_players > 3 and not game_autobal then
  176.             game_autobal = registertimer(autobal_delay * 1000, "AutoBalance")
  177.         end
  178.         if logging then log_msg(1, name .. " given plasma pistol on spawn.") end   
  179.     end
  180. end
  181.  
  182. function Welcome(id, count, player)
  183.     if count == 1 then
  184.         if getplayer(player) then
  185.             privatesay(player, "Welcome to Gun-Game Arms Race!")
  186.             privatesay(player, "Each time you kill with a weapon, you will be given a new weapon.")
  187.             privatesay(player, "The first person to kill with every weapon in the game - wins!")
  188.             privatesay(player, "This version is 'DOWN': Start with Plasma Cannon, end with Plasma Pistol.")
  189.             privatesay(player, "type @help for more info.")
  190.         end
  191.     end
  192.     return false   
  193. end
  194.  
  195. function OnPlayerLeave(player)
  196.     if getplayer(player) then
  197.         cur_players = cur_players - 1
  198.         if level[player] == 10 then
  199.             beserk = false
  200.         end
  201.         mybattery[player] = {}
  202.         team_change[player] = {}
  203.         weapons[player] = {}
  204.         level[player] = {}
  205.         playerscore[player] = 0
  206.         if game_started and team_play and cur_players > 3 then
  207.             leave_autobal = registertimer(autobal_delay * 1000, "AutoBalance")
  208.         end    
  209.         if team_play and cur_players < 4 and game_autobal then
  210.             game_autobal = nil
  211.         elseif team_play and cur_players > 3 and not game_autobal then 
  212.             game_autobal = registertimer(autobal_delay * 1000, "AutoBalance")
  213.         end
  214.     end
  215. end
  216.  
  217. function OnPlayerSpawn(player, m_objectId)
  218.     if getplayer(player) then
  219.         local ip = getip(player)
  220.         last_damage[ip] = nil
  221.         team_change[player] = false
  222.         if game_started then
  223.             gameweap = registertimer(0, "AssignGameWeapons", player)
  224.         end    
  225.     end
  226. end
  227.  
  228. function OnServerCommand(player, command)
  229.     local allow = nil
  230.     local cmd = tokenizecmdstring(command)
  231.     local tokencount = #cmd
  232.     if tokencount > 0 then
  233.    
  234.         if cmd[1] == "sv_map_reset" then
  235.             map_reset = true   
  236.             ScriptLoad()
  237.             privatesay(player, "**RESET** The game has been reset and scripts reloaded. ")
  238.             if logging then log_msg(1, getname(player) .. " used sv_map_reset command.") end           
  239.             for i=0,15 do  
  240.                 if getplayer(i) then
  241.                     privatesay(i, "The game has been reset. ")
  242.                 end
  243.             end        
  244.             allow = true
  245.            
  246.         elseif cmd[1] == "sv_script_reload" then
  247.             map_reset = true
  248.             writedword(gametime_base + 0x10, 0)
  249.             ScriptLoad()
  250.             privatesay(player, "**RELOAD** The game has been reset and scripts reloaded. ")
  251.             if logging then log_msg(1, getname(player) .. " used sv_script_reload command.") end
  252.             for i=0,15 do  
  253.                 if getplayer(i) then
  254.                     kill(i)
  255.                     privatesay(i, "The game has been reset. ")
  256.                 end
  257.             end        
  258.             allow = true
  259.         end
  260.        
  261.     end
  262.     return allow
  263. end
  264.  
  265. function NewGameTimer(id, count)
  266.     if map_reset == true then
  267.         if team_play and cur_players > 3 then Balance_Teams() end
  268.         map_reset = false
  269.     end
  270.    
  271.     game_started = true
  272.     team_play = getteamplay()
  273.     cur_players = readword(network_base, 0x1A0)
  274.    
  275.     if team_play then
  276.         teamscore[0] = 0
  277.         teamscore[1] = 0
  278.         if not game_autobal and game_started and cur_players > 3 then
  279.             game_autobal = registertimer(autobal_delay * 1000, "AutoBalance")
  280.         end        
  281.     end
  282.    
  283.     if Persistent then
  284.         if logging then log_msg(1, "Gun-Game has begun on " .. map_name .. " and running as a persistent script.") end
  285.     else
  286.         if logging then log_msg(1, "Gun-Game has begun on " .. map_name .. " and running as a non-persistent script.") end
  287.     end
  288.    
  289.     for x = 0,15 do
  290.         if getplayer(x) then
  291.             local ip = getip(x)
  292.             local name = getname(x)
  293.             local m_objectId = getplayerobjectid(x)
  294.             last_damage[ip] = nil
  295.             team_change[x] = false
  296.             beserk = false
  297.             mybattery[x] = 0   
  298.             weapons[x] = "weapons\\plasma_cannon\\plasma_cannon"
  299.             level[x] = 1
  300.             playerscore[x] = 0
  301.             speedtimer = registertimer(0, "SpeedTimer", x)
  302.            
  303.             if m_objectId ~= nil then
  304.                 local m_object = getobject(m_objectId)
  305.                 if m_object then
  306.                     for i = 0,3 do
  307.                         local weapID = readdword(getobject(m_objectId), 0x2F8 + i*4)
  308.                         if weapID ~= 0xFFFFFFFF then
  309.                             destroyobject(weapID)
  310.                         end
  311.                     end
  312.                     writebyte(m_object + 0x31E, 0)
  313.                     writebyte(m_object + 0x31F, 0) 
  314.                 end
  315.                
  316.                 if level[x] == 1 then
  317.                     battery = 0
  318.                     weapons[x] = "weapons\\plasma_cannon\\plasma_cannon"
  319.                     sendconsoletext(x, "Level 1:   Plasma Cannon", 4, 0)
  320.                     if m_object then
  321.                         writebyte(m_object + 0x31E, 0)
  322.                         writebyte(m_object + 0x31F, 0) 
  323.                     end
  324.                 end
  325.                
  326.                 local m_weaponId = createobject(gettagid("weap", weapons[x]), 0, 20, false, 0, 0, 0)
  327.                
  328.                 if m_weaponId then
  329.                     local m_weapon = getobject(m_weaponId)
  330.                     if m_weapon then
  331.                         assignweapon(x, m_weaponId)
  332.                         if logging then log_msg(1, name .. " given plasma cannon on new game.") end
  333.                         if m_weapon then
  334.                             mybattery[x] = 1
  335.                         end
  336.                     end    
  337.                 end
  338.                
  339.             end
  340.         end
  341.     end
  342.    
  343.     if updatescores == nil and game_started then
  344.         updatescores = registertimer(500, "Update_Scores")
  345.     end
  346.    
  347.     if checkbattery == nil and game_started then
  348.         checkbattery = registertimer(1000, "CheckBattery") 
  349.     end
  350.    
  351.     new_game_timer = nil   
  352.     return false
  353. end
  354.  
  355. function AssignGameWeapons(id, count, player)
  356.     if map_reset == true then
  357.         map_reset = false
  358.     end
  359.    
  360.     local clip = 0
  361.     local ammo = 9999
  362.    
  363.     if game_started then   
  364.         if getplayer(player) then      
  365.             local m_objectId = getplayerobjectid(player)
  366.             local name = getname(player)
  367.             local lvl = level[player]
  368.             local team = getteam(player)
  369.            
  370.             if m_objectId ~= nil then
  371.                 if gametype == 1 or gametype == 2 then
  372.                     speedtimer = registertimer(0, "SpeedTimer", player)
  373.                 end
  374.                
  375.                 local m_object = getobject(m_objectId)
  376.                 if m_object then
  377.                     for i = 0,3 do
  378.                         local weapID = readdword(getobject(m_objectId), 0x2F8 + i*4)
  379.                         if weapID ~= 0xFFFFFFFF then
  380.                             destroyobject(weapID)
  381.                         end
  382.                     end
  383.                     writebyte(m_object + 0x31E, 0)
  384.                     writebyte(m_object + 0x31F, 0) 
  385.                 end
  386.                
  387.                 if logging then log_msg(1, name .. " weapon assignment initiated - weapons & nades removed. Is level: " .. lvl) end
  388.                
  389.                 if level[player] == nil then
  390.                     level[player] = 1
  391.                     weapons[player] = "weapons\\plasma_cannon\\plasma_cannon"
  392.                     sendconsoletext(player, "Level 1:   Plasma Cannon", 4, 0)  
  393.                     if logging then log_msg(1, name .. " given plasma cannon. Is level: " .. lvl) end
  394.                    
  395.                 elseif level[player] == 1 then
  396.                     weapons[player] = "weapons\\plasma_cannon\\plasma_cannon"
  397.                     sendconsoletext(player, "Level 1:   Plasma Cannon", 4, 0)
  398.                     if logging then log_msg(1, name .. " given plasma cannon. Is level: " .. lvl) end  
  399.                    
  400.                 elseif level[player] == 2 then
  401.                     clip = sniper_clip
  402.                     weapons[player] = "weapons\\sniper rifle\\sniper rifle"
  403.                     sendconsoletext(player, "Level 2:   Sniper Rifle", 4, 0)
  404.                     if logging then log_msg(1, name .. " given sniper rifle. Is level: " .. lvl) end   
  405.                    
  406.                 elseif level[player] == 3 then
  407.                     clip = rocket_clip
  408.                     weapons[player] = "weapons\\rocket launcher\\rocket launcher"
  409.                     sendconsoletext(player, "Level 3:   Rocket Launcher", 4, 0)
  410.                     health = registertimer(0, "ApplyHP", player)                   
  411.                     if logging then log_msg(1, name .. " given rocket launcher. Is level: " .. lvl) end
  412.                    
  413.                 elseif level[player] == 4 then
  414.                     clip = pistol_clip
  415.                     weapons[player] = "weapons\\pistol\\pistol"
  416.                     sendconsoletext(player, "Level 4:   Pistol", 4, 0)
  417.                     if logging then log_msg(1, name .. " given pistol. Is level: " .. lvl)  end
  418.                    
  419.                 elseif level[player] == 5 then
  420.                     clip = flame_clip
  421.                     weapons[player] = "weapons\\flamethrower\\flamethrower"
  422.                     sendconsoletext(player, "Level 5:   Flamethrower", 4, 0)                   
  423.                     if logging then log_msg(1, name .. " given flamethrower. Is level: " .. lvl) end
  424.                    
  425.                 elseif level[player] == 6 then
  426.                     clip = assault_clip
  427.                     weapons[player] = "weapons\\assault rifle\\assault rifle"
  428.                     sendconsoletext(player, "Level 6: Assault Rifle", 4, 0)
  429.                     if m_object then
  430.                         writebyte(m_object + 0x31E, 1)
  431.                         writebyte(m_object + 0x31F, 0)
  432.                     end                
  433.                     if logging then log_msg(1, name .. " given assault rifle, 1 frag. Is level: " .. lvl) end  
  434.                    
  435.                 elseif level[player] == 7 then
  436.                     weapons[player] = "weapons\\plasma rifle\\plasma rifle"
  437.                     sendconsoletext(player, "Level 7:   Plasma Rifle", 4, 0)
  438.                     if m_object then
  439.                         writebyte(m_object + 0x31E, 0)
  440.                         writebyte(m_object + 0x31F, 2)
  441.                     end                
  442.                     if logging then log_msg(1, name .. " given plasma rifle, 2 plasmas. Is level: " .. lvl) end
  443.                    
  444.                 elseif level[player] == 8 then
  445.                     clip = shotgun_clip
  446.                     weapons[player] = "weapons\\shotgun\\shotgun"
  447.                     sendconsoletext(player, "Level 8:   Shotgun", 4, 0)
  448.                     health = registertimer(0, "ApplyHP", player)
  449.                     if m_object then
  450.                         writebyte(m_object + 0x31E, 1)
  451.                         writebyte(m_object + 0x31F, 0)
  452.                     end                
  453.                     if logging then log_msg(1, name .. " given shotgun, 1 frag. Is level: " .. lvl) end
  454.                    
  455.                 elseif level[player] == 9 then
  456.                     clip = needler_clip
  457.                     weapons[player] = "weapons\\needler\\mp_needler"
  458.                     sendconsoletext(player, "Level 9:   Needler", 4, 0)
  459.                     if m_object then
  460.                         writebyte(m_object + 0x31E, 0)
  461.                         writebyte(m_object + 0x31F, 2)
  462.                     end                
  463.                     if logging then log_msg(1, name .. " given needler, 2 plasmas and active camouflage. Is level: " .. lvl) end   
  464.                    
  465.                 elseif level[player] == 10 then
  466.                     weapons[player] = "weapons\\plasma pistol\\plasma pistol"
  467.                     beserk = true
  468.                     sendconsoletext(player, "Level 10:   Plasma Pistol --- FINAL LEVEL! ---", 4, 0)
  469.                     if m_object then
  470.                         writebyte(m_object + 0x31E, 1)
  471.                         writebyte(m_object + 0x31F, 1) 
  472.                     end
  473.                     local team = getteam(player)   
  474.                     say(name .. " has reached level 10! Beserk mode activated! Kill 'em!")
  475.                     if logging then log_msg(1, name .. " given plasma pistol, 1 frag, 1 plasma, active camouflage removed and booster function called. Is level: " .. lvl) end
  476.                    
  477.                     --Health Booster call for all but level 10
  478.                     for i=0,15 do
  479.                         if getplayer(i) then
  480.                             local name = getname(i)
  481.                             local lvl = level[i]
  482.                             local p_objectId = getplayerobjectid(i)
  483.                             if p_objectId ~= nil then
  484.                                 if lvl <= 9 then
  485.                                     local p_object = getobject(p_objectId)
  486.                                     local obj_health = readfloat(p_object + 0xE0)
  487.                                     if obj_health < 1 then
  488.                                         p_objectId = registertimer(6000, "Booster", {i, m_objectId})
  489.                                     end
  490.                                 end
  491.                             end
  492.                         end
  493.                     end
  494.                    
  495.                 end
  496.                
  497.                 local m_weaponId = createobject(gettagid("weap", weapons[player]), 0, 20, false, 0, 0, 0)
  498.                
  499.                 if m_weaponId then
  500.                     local m_weapon = getobject(m_weaponId)
  501.                     assignweapon(player, m_weaponId)
  502.                     if m_weapon then
  503.                         if (level[player] == 1) or (level[player] == 7) or (level[player] == 10) then
  504.                             mybattery[player] = 1
  505.                         else
  506.                             mybattery[player] = 0
  507.                             writeword(m_weapon + 0x2B6, ammo)
  508.                             writeword(m_weapon + 0x2B8, clip)
  509.                             updateammo(m_weaponId)
  510.                         end
  511.                     end
  512.                 end
  513.                
  514.             end
  515.         end
  516.     end    
  517.     return false
  518. end
  519.  
  520. function CheckBattery(id, count, player)
  521.     -- checks battery level for plasma weapons and assigns replacement if low battery: plasma pistol, plasma rifle and plasma cannon
  522.     for i = 0,15 do
  523.         if getplayer(i) then
  524.             if mybattery[i] == 1 then
  525.                 local name = getname(i)
  526.                 local lvl = level[i]
  527.                 local m_objectId = getplayerobjectid(i)
  528.                 if m_objectId ~= nil then
  529.                     local m_object = getobject(m_objectId)
  530.                     if m_object then
  531.                         local m_weaponId = readdword(m_object + 0x118)
  532.                         if m_weaponId then
  533.                             local m_weapon = getobject(m_weaponId)
  534.                             if m_weapon then   
  535.                                 if readfloat(m_weapon + 0x240) >= 0.84 then
  536.                                     destroyplayerweaps(i)
  537.                                     replaceplasmaweap = registertimer(0, "ReplacePlasmaWeap", i)
  538.                                     if logging then log_msg(1, name .. " has a low battery on battery check. Is level: " .. lvl) end
  539.                                 end
  540.                             end
  541.                         end
  542.                     end
  543.                 end
  544.             end
  545.         end
  546.     end
  547.     return true
  548. end
  549.  
  550. function ReplacePlasmaWeap(id, count, player)
  551.     -- replaces low battery plasma weapons
  552.     if count == 1 then 
  553.         if player ~= nil and game_started then
  554.             local name = getname(player)
  555.             local lvl = level[player]  
  556.             if mybattery[player] == 1 then
  557.                 local m_weaponId = registertimer(0, "AssignGameWeapons", player)
  558.                 if logging then log_msg(1, name .. " was given assigment to replace plasma weapon. Is level: " .. lvl) end
  559.                 privatesay(player, "Battery recharged.")
  560.                 mybattery[player] = 0  
  561.             end    
  562.         end
  563.     end
  564.     return false
  565. end
  566.  
  567. function Update_Scores(id, count)
  568.     -- continuous score updating, not conditioned to game_started, updates negative values to 0 to prevent sabotage
  569.     if not team_play then
  570.         for i = 0,15 do
  571.             if getplayer(i) then
  572.                 if playerscore[i] == nil or playerscore[i] < 0 then playerscore[i] = 0 end
  573.                 Write_Player_Score(i, playerscore[i])
  574.             end
  575.         end    
  576.     else
  577.         for i = 0,15 do
  578.             if getplayer(i) then
  579.                 if playerscore[i] == nil or playerscore[i] < 0 then playerscore[i] = 0 end
  580.                 Write_Player_Score(i, playerscore[i])
  581.             end
  582.         end
  583.         if teamscore[0] == nil or teamscore[0] < 0 then teamscore[0] = 0 end
  584.         if teamscore[1] == nil or teamscore[1] < 0 then teamscore[1] = 0 end
  585.         Write_Team_Score(0, teamscore[0])
  586.         Write_Team_Score(1, teamscore[1])
  587.     end
  588.     return true
  589. end                
  590.  
  591. function Write_Player_Score(player, score)
  592.     -- writes the players score
  593.     if gametype == 1 then
  594.         if player then
  595.             local m_player = getplayer(player)
  596.             writeword(m_player + 0xC8, score)
  597.         end
  598.     elseif gametype == 2 then
  599.         if player then
  600.             writedword(slayer_globals + 0x40 + player*4, score)
  601.         end
  602.     end
  603. end
  604.  
  605. function Write_Team_Score(team, score)
  606.     -- writes the team score
  607.     if gametype == 1 then
  608.         writedword(ctf_globals + team*4 + 0x10, score)
  609.     elseif gametype == 2 then
  610.         writedword(slayer_globals + team*4, score)
  611.     end
  612. end
  613.  
  614. function GetGameAddresses(game)
  615.     if game == "PC" or GAME == "PC" then
  616.         map_name = readstring(0x698F21)
  617.         gametype_base = 0x671340
  618.         ctf_globals = 0x639B98
  619.         ctf_score_patch = 0x488602
  620.         ctf_score_patch1 = 0x488606    
  621.         slayer_globals = 0x63A0E8
  622.         slayer_score_patch = 0x48F428
  623.         slayer_score_patch2 = 0x48F23E
  624.         network_base = 0x745BA8
  625.         gametime_base = 0x671420       
  626.     else
  627.         map_name = readstring(0x61D151)
  628.         gametype_base = 0x5F5498
  629.         ctf_globals = 0x5BDBB8
  630.         ctf_score_patch = 0x463472
  631.         ctf_score_patch1 = 0x463476
  632.         slayer_globals = 0x5BE108
  633.         slayer_score_patch = 0x469CF8
  634.         slayer_score_patch2 = 0x4691CE
  635.         network_base = 0x6C7988
  636.         gametime_base = 0x5F55BC       
  637.     end
  638. end
  639.  
  640. function getteamplay()
  641.     if readbyte(gametype_base + 0x34) == 1 then
  642.         return true
  643.     else
  644.         return false
  645.     end
  646. end
  647.  
  648. function privatesay(player, message, script_prefix)
  649.     if GAME == "PC" then
  650.         phasor_privatesay(player, (script_prefix or default_script_prefix) .. " " .. message, false)
  651.     else
  652.         phasor_privatesay(player, message, false)
  653.     end
  654. end
  655.  
  656. function say(message, script_prefix)
  657.     if GAME == "PC" then
  658.         phasor_say((script_prefix or default_script_prefix) .. " " .. message, false)
  659.     else
  660.         phasor_say(message, false)
  661.     end
  662. end
  663.  
  664. function getweaponobjectid(player, slot)
  665.     local m_objectId = getplayerobjectid(player)
  666.     if m_objectId then return readdword(getobject(m_objectId) + 0x2F8 + slot*4) end
  667. end
  668.  
  669. function destroyplayerweaps(player)
  670.     for i=0,3 do
  671.         local weap_id = getweaponobjectid(player, i)
  672.         if weap_id ~= 0xFFFFFFFF then destroyobject(weap_id) end
  673.     end
  674. end
  675.  
  676. function Booster(id, count, arg)
  677.     -- heals all players level 9 and below when any other player reaches level 10
  678.     if count == 1 and game_started then
  679.         local player = arg[1]
  680.         if getplayer(player) then
  681.             local name = getname(player)
  682.             local lvl = level[player]      
  683.             local m_playerObjId = getplayerobjectid(player)
  684.             if m_playerObjId ~= nil and lvl <= 9 then
  685.                 local m_object = getobject(m_playerObjId)
  686.                 local obj_health = readfloat(m_object + 0xE0)
  687.                 if obj_health < 1 then
  688.                     writefloat(m_object + 0xE0, 1)
  689.                     sendconsoletext(player, "Bonus! Health restored!", 4, 0)
  690.                     if logging then log_msg(1, name .. " health restored from booster function. Is level: " .. lvl) end
  691.                 end
  692.             end
  693.         end
  694.     end
  695.     return false
  696. end
  697.  
  698. function SpeedTimer(id, count, player)
  699.     -- monitors player levels, and sets player speed accordingly. Also sets Beserk Mode speed.
  700.     if player then
  701.         local name = getname(player)
  702.         local lvl = level[player]  
  703.         if level[player] == 1 then
  704.             if beserk then
  705.                 setspeed(player, 1.5)
  706.                 sendconsoletext(player, "BESERK MODE!", 4, 1)
  707.             else   
  708.                 setspeed(player, 0.65) -- plasma cannon 0.65
  709.             end
  710.             if logging then log_msg(1, name .. " speed set at 0.65. Is level: " .. lvl) end
  711.         elseif level[player] == 2 then
  712.             if beserk then
  713.                 setspeed(player, 1.5)
  714.                 sendconsoletext(player, "BESERK MODE!", 4, 1)
  715.             else       
  716.                 setspeed(player, 0.75) -- sniper rifle 0.75
  717.             end
  718.             if logging then log_msg(1, name .. " speed set at 0.75. Is level: " .. lvl) end
  719.         elseif level[player] == 3 then
  720.             if beserk then
  721.                 setspeed(player, 1.5)
  722.                 sendconsoletext(player, "BESERK MODE!", 4, 1)
  723.             else
  724.                 setspeed(player, 0.65) -- rocket launcher 0.65
  725.             end
  726.             if logging then log_msg(1, name .. " speed set at 0.65. Is level: " .. lvl) end
  727.         elseif level[player] == 4 then
  728.             if beserk then
  729.                 setspeed(player, 1.5)
  730.                 sendconsoletext(player, "BESERK MODE!", 4, 1)
  731.             else       
  732.                 setspeed(player, 0.85) -- pistol 0.85
  733.             end
  734.             if logging then log_msg(1, name .. " speed set at 0.85. Is level: " .. lvl) end
  735.         elseif level[player] == 5 then
  736.             if beserk then
  737.                 setspeed(player, 1.5)
  738.                 sendconsoletext(player, "BESERK MODE!", 4, 1)
  739.             else       
  740.                 setspeed(player, 1) -- flamethrower 1
  741.             end
  742.             if logging then log_msg(1, name .. " speed set at 1. Is level: " .. lvl) end
  743.         elseif level[player] == 6 then
  744.             if beserk then
  745.                 setspeed(player, 1.5)
  746.                 sendconsoletext(player, "BESERK MODE!", 4, 1)
  747.             else       
  748.                 setspeed(player, 1.15) -- assault rifle 1.15
  749.             end
  750.             if logging then log_msg(1, name .. " speed set at 1.15. Is level: " .. lvl) end
  751.         elseif level[player] == 7 then
  752.             if beserk then
  753.                 setspeed(player, 1.5)
  754.                 sendconsoletext(player, "BESERK MODE!", 4, 1)
  755.             else       
  756.                 setspeed(player, 1.15) -- plasma rifle 1.15
  757.             end
  758.             if logging then log_msg(1, name .. " speed set at 1.15. Is level: " .. lvl) end
  759.         elseif level[player] == 8 then
  760.             if beserk then
  761.                 setspeed(player, 1.5)
  762.                 sendconsoletext(player, "BESERK MODE!", 4, 1)
  763.             else       
  764.                 setspeed(player, 1.25) -- shotgun 1.25
  765.             end
  766.             if logging then log_msg(1, name .. " speed set at 1.25. Is level: " .. lvl) end
  767.         elseif level[player] == 9 then
  768.             if beserk then
  769.                 setspeed(player, 1.5)
  770.                 sendconsoletext(player, "BESERK MODE!", 4, 1)
  771.             else       
  772.                 setspeed(player, 1.35) -- needler 1.35
  773.             end
  774.             if logging then log_msg(1, name .. " speed set at 1.35. Is level: " .. lvl) end
  775.         elseif level[player] == 10 then
  776.             setspeed(player, 1.45) -- plasma pistol 1.45
  777.             if logging then log_msg(1, name .. " speed set at 1.45. Is level: " .. lvl) end
  778.         end
  779.     end
  780.     return false
  781. end
  782.  
  783. function OnServerChat(player, type, message)
  784.     local response = nil
  785.    
  786.     if player then
  787.         local name = getname(player)
  788.        
  789.         if string.lower(message) == "help" or string.lower(message) == "@help" or string.lower(message) == "/help" then
  790.             local response = false
  791.             privatesay(player, "Each time you kill with a weapon, you will be given a new weapon.")
  792.             privatesay(player, "The first person to kill with each weapon in the game - wins!")
  793.             privatesay(player, "There are 10 weapons. Starting with plasma cannon and ending with plasma pistol.")
  794.             privatesay(player, "Other weapons, grenades & powerups are blocked. Killing with vehicles blocked.")
  795.             privatesay(player, "If you are on level 10, and get killed, suicide or betray you're demoted one level.")
  796.             say(name .. " is reading the @help menu. ")
  797.             return response        
  798.         end
  799.        
  800.         if string.lower(message) == "balance" then
  801.             Balance_Teams()
  802.             response = false           
  803.         end    
  804.                
  805.     end
  806.     return response
  807. end
  808.  
  809. function OnPlayerKill(killer, victim, mode)
  810.     local response = false
  811.        
  812.     if game_started then
  813.         mybattery[victim] = 0
  814.        
  815.         if mode == 0 then -- player was killed by server
  816.             if getplayer(victim) then
  817.                 if team_change[victim] then
  818.                     response = false   
  819.                 else
  820.                     vlvl = level[victim]
  821.                     vname = getname(victim)
  822.                     vip = getip(victim)
  823.                     privatesay(victim, vname .. " - you were killed by the server.")
  824.                     if logging then log_msg(1, vname .. " was killed by the server. Is level: " .. vlvl) end
  825.                     response = false                       
  826.                 end
  827.                 response = false
  828.             end
  829.            
  830.         elseif mode == 1 then -- player was killed by falling or team-change
  831.                 if getplayer(victim) then
  832.                     vlvl = level[victim]
  833.                     vname = getname(victim)
  834.                     vip = getip(victim)
  835.                     if not team_change[victim] and not map_reset then
  836.                         if last_damage[vip] == "globals\\distance" or last_damage[vip] == "globals\\falling" then
  837.                             say(vname .. " fell and died.")
  838.                             if logging then log_msg(1, vname .. " was killed by fall damage. Is level: " .. vlvl) end
  839.                             response = false
  840.                         end
  841.                     elseif team_change[victim] and map_reset then
  842.                         team_change[victim] = false
  843.                         if logging then log_msg(1, vname .. " was killed by team change. Is level: " .. vlvl) end
  844.                         response = false                       
  845.                     end
  846.                 end
  847.            
  848.         elseif mode == 2 then -- player was killed by the guardians
  849.             if getplayer(victim) then
  850.                 vlvl = level[victim]
  851.                 vname = getname(victim)
  852.                 vip = getip(victim)
  853.                 say(vname .. " was killed by the guardians. ", false)
  854.                 if logging then log_msg(1, vname .. " was killed by guardians. Is level: " .. vlvl) end
  855.                 response = false
  856.             end
  857.            
  858.         elseif mode == 3 then -- player was killed by vehicle
  859.             if getplayer(victim) then
  860.                 vlvl = level[victim]
  861.                 vname = getname(victim)
  862.                 vip = getip(victim)
  863.                 say(vname .. " was killed by a vehicle. ")
  864.                 if logging then log_msg(1, vname .. " was killed by a vehicle. Is level: " .. vlvl) end
  865.                 response = false
  866.             end
  867.            
  868.         elseif mode == 4 then -- player was killed by another player
  869.             -- killer is not always valid, setup values to prevent error
  870.             if getplayer(killer) then
  871.                 klvl = level[killer]
  872.                 kname = getname(killer)
  873.                 kip = getip(killer)
  874.                 kteam = getteam(killer)
  875.             else   
  876.                 kname = "NULL"
  877.                 klvl = NULL
  878.                 kteam = -1
  879.             end
  880.            
  881.             if getplayer(victim) then
  882.                 vlvl = level[victim]
  883.                 vname = getname(victim)
  884.                 vip = getip(victim)
  885.                 vteam = getteam(victim)
  886.                 if vlvl == 10 then
  887.                     beserk = false
  888.                     sendconsoletext(victim, "Demoted to Level 9! Ain't that a bitch?!", 4, 0)
  889.                     say(vname .. " demoted to Level 9 for getting killed.")
  890.                     weapons[victim] = "weapons\\needler\\mp_needler"
  891.                     level[victim] = 9
  892.                     playerscore[victim] = 8
  893.                     if team_play then if (teamscore[vteam] - 1) >= 0 then teamscore[vteam] = teamscore[vteam] - 1 end end
  894.                     if logging then log_msg(1, vname .. " level 10 demoted to 9 for being killed by another player.") end
  895.                     response = false
  896.                 end
  897.  
  898.                 if last_damage[vip] then
  899.                     if getplayer(killer) then
  900.                         klvl = level[killer]
  901.                         kname = getname(killer)
  902.                         kip = getip(killer)
  903.                         kteam = getteam(killer)                    
  904.                         local k_objectId = getplayerobjectid(killer)
  905.                         if k_objectId ~= nil then -- sets condition that killer must be alive for the following
  906.                             if team_play then kteam = getteam(killer) teamscore[kteam] = teamscore[kteam] + 1 end
  907.                                    
  908.                             if last_damage[vip] == "weapons\\plasma_cannon\\effects\\plasma_cannon_explosion" or last_damage[vip] == "weapons\\plasma_cannon\\effects\\plasma_cannon_melee" then
  909.                                 if weapons[killer] == "weapons\\plasma_cannon\\plasma_cannon" then
  910.                                     level[killer] = 2
  911.                                     playerscore[killer] = 1
  912.                                     if string.find(last_damage[vip], "melee") then
  913.                                         say(kname .. " melee'd " .. vname .. " with a plasma cannon")
  914.                                         if logging then log_msg(1, vname .. " was killed by " .. kname .. "'s melee who is level: " .. klvl) end
  915.                                     else                                   
  916.                                         say(kname .. " killed " .. vname .. " with a plasma cannon")
  917.                                         if logging then log_msg(1, vname .. " was killed by " .. kname .. " who is level: " .. klvl) end
  918.                                     end
  919.                                     gameweap = registertimer(0, "AssignGameWeapons", killer)
  920.                                     response = false
  921.                                 end
  922.  
  923.                             elseif last_damage[vip] == "weapons\\sniper rifle\\sniper bullet" or last_damage[vip] == "weapons\\sniper rifle\\melee" then
  924.                                 if weapons[killer] == "weapons\\sniper rifle\\sniper rifle" then
  925.                                     level[killer] = 3
  926.                                     playerscore[killer] = 2
  927.                                     for i=0,15 do
  928.                                         if getplayer(i) then
  929.                                             speedtimer = registertimer(0, "SpeedTimer", i)
  930.                                         end
  931.                                     end    
  932.                                     if string.find(last_damage[vip], "melee") then
  933.                                         say(kname .. " melee'd " .. vname .. " with a sniper rifle")
  934.                                         if logging then log_msg(1, vname .. " was killed by " .. kname .. "'s melee who is level: " .. klvl) end
  935.                                     else                                   
  936.                                         say(kname .. " killed " .. vname .. " with a sniper rifle")
  937.                                         if logging then log_msg(1, vname .. " was killed by " .. kname .. " who is level: " .. klvl) end
  938.                                     end
  939.                                     gameweap = registertimer(0, "AssignGameWeapons", killer)
  940.                                     response = false                               
  941.                                 end                            
  942.                                
  943.                             elseif last_damage[vip] == "weapons\\rocket launcher\\explosion" or last_damage[vip] == "weapons\\rocket launcher\\melee" then
  944.                                 if weapons[killer] == "weapons\\rocket launcher\\rocket launcher" then
  945.                                     if isinvehicle(killer) then
  946.                                         say(kname .. " killed " .. vname .. " with a warthog rocket")
  947.                                         if logging then log_msg(1, vname .. " was killed by " .. kname .. " who is level: " .. klvl .. " was vehicle rocket, no advance.") end
  948.                                     else
  949.                                         level[killer] = 4
  950.                                         playerscore[killer] = 3
  951.                                         if string.find(last_damage[vip], "melee") then
  952.                                             say(kname .. " melee'd " .. vname .. " with a rocket launcher")
  953.                                             if logging then log_msg(1, vname .. " was killed by " .. kname .. "'s melee who is level: " .. klvl) end
  954.                                         else                                       
  955.                                             say(kname .. " killed " .. vname .. " with a rocket launcher")
  956.                                             if logging then log_msg(1, vname .. " was killed by " .. kname .. " who is level: " .. klvl) end
  957.                                         end
  958.                                         gameweap = registertimer(0, "AssignGameWeapons", killer)
  959.                                         response = false
  960.                                     end
  961.                                 end
  962.  
  963.                             elseif last_damage[vip] == "weapons\\pistol\\bullet" or last_damage[vip] == "weapons\\pistol\\melee" then
  964.                                 if weapons[killer] == "weapons\\pistol\\pistol" then
  965.                                     level[killer] = 5
  966.                                     playerscore[killer] = 4
  967.                                     if string.find(last_damage[vip], "melee") then
  968.                                         say(kname .. " melee'd " .. vname .. " with a pistol")
  969.                                         if logging then log_msg(1, vname .. " was killed by " .. kname .. "'s melee who is level: " .. klvl) end
  970.                                     else                                   
  971.                                         say(kname .. " killed " .. vname .. " with a pistol")
  972.                                         if logging then log_msg(1, vname .. " was killed by " .. kname .. " who is level: " .. klvl) end
  973.                                     end
  974.                                     gameweap = registertimer(0, "AssignGameWeapons", killer)
  975.                                     response = false
  976.                                 end                            
  977.                                
  978.                             elseif last_damage[vip] == "weapons\\flamethrower\\burning" or last_damage[vip] == "weapons\\flamethrower\\explosion" or last_damage[vip] == "weapons\\flamethrower\\impact damage" or last_damage[vip] == "weapons\\flamethrower\\melee" then
  979.                                 if weapons[killer] == "weapons\\flamethrower\\flamethrower" then
  980.                                     level[killer] = 6
  981.                                     playerscore[killer] = 5
  982.                                     if string.find(last_damage[vip], "melee") then
  983.                                         say(kname .. " melee'd " .. vname .. " with a flamethrower")
  984.                                         if logging then log_msg(1, vname .. " was killed by " .. kname .. "'s melee who is level: " .. klvl) end
  985.                                     else                                   
  986.                                         say(kname .. " killed " .. vname .. " with a flamethrower")
  987.                                         if logging then log_msg(1, vname .. " was killed by " .. kname .. " who is level: " .. klvl) end
  988.                                     end
  989.                                     gameweap = registertimer(0, "AssignGameWeapons", killer)
  990.                                     response = false
  991.                                 end
  992.                                
  993.                             elseif last_damage[vip] == "weapons\\assault rifle\\bullet" or last_damage[vip] == "weapons\\assault rifle\\melee" then
  994.                                 if weapons[killer] == "weapons\\assault rifle\\assault rifle" then
  995.                                     level[killer] = 7
  996.                                     playerscore[killer] = 6
  997.                                     if string.find(last_damage[vip], "melee") then
  998.                                         say(kname .. " melee'd " .. vname .. " with an assault rifle")
  999.                                         if logging then log_msg(1, vname .. " was killed by " .. kname .. "'s melee who is level: " .. klvl) end
  1000.                                     else                                   
  1001.                                         say(kname .. " killed " .. vname .. " with an assault rifle")
  1002.                                         if logging then log_msg(1, vname .. " was killed by " .. kname .. " who is level: " .. klvl) end
  1003.                                     end
  1004.                                     gameweap = registertimer(0, "AssignGameWeapons", killer)
  1005.                                     response = false
  1006.                                 end                            
  1007.                                
  1008.                             elseif last_damage[vip] == "weapons\\plasma rifle\\bolt" or last_damage[vip] == "weapons\\plasma rifle\\melee" then                            
  1009.                                 if weapons[killer] == "weapons\\plasma rifle\\plasma rifle" then
  1010.                                     level[killer] = 8
  1011.                                     playerscore[killer] = 7
  1012.                                     if string.find(last_damage[vip], "melee") then
  1013.                                         say(kname .. " melee'd " .. vname .. " with a plasma rifle")
  1014.                                         if logging then log_msg(1, vname .. " was killed by " .. kname .. "'s melee who is level: " .. klvl) end
  1015.                                     else                                   
  1016.                                         say(kname .. " killed " .. vname .. " with a plasma rifle")
  1017.                                         if logging then log_msg(1, vname .. " was killed by " .. kname .. " who is level: " .. klvl) end
  1018.                                     end
  1019.                                     gameweap = registertimer(0, "AssignGameWeapons", killer)
  1020.                                     response = false
  1021.                                 end
  1022.                                
  1023.                             elseif last_damage[vip] == "weapons\\shotgun\\pellet" or last_damage[vip] == "weapons\\shotgun\\melee" then
  1024.                                 if weapons[killer] == "weapons\\shotgun\\shotgun" then
  1025.                                     level[killer] = 9
  1026.                                     playerscore[killer] = 8
  1027.                                     if string.find(last_damage[vip], "melee") then
  1028.                                         say(kname .. " melee'd " .. vname .. " with a shotgun")
  1029.                                         if logging then log_msg(1, vname .. " was killed by " .. kname .. "'s melee who is level: " .. klvl) end
  1030.                                     else
  1031.                                         say(kname .. " killed " .. vname .. " with a shotgun")
  1032.                                         if logging then log_msg(1, vname .. " was killed by " .. kname .. " who is level: " .. klvl) end
  1033.                                     end
  1034.                                     gameweap = registertimer(0, "AssignGameWeapons", killer)
  1035.                                     response = false
  1036.                                 end                            
  1037.                                
  1038.                             elseif last_damage[vip] == "weapons\\needler\\detonation damage" or last_damage[vip] == "weapons\\needler\\explosion" or last_damage[vip] == "weapons\\needler\\impact damage" or last_damage[vip] == "weapons\\needler\\melee" then
  1039.                                 if weapons[killer] == "weapons\\needler\\mp_needler" then
  1040.                                     level[killer] = 10
  1041.                                     playerscore[killer] = 9
  1042.                                     beserk = true
  1043.                                     if string.find(last_damage[vip], "melee") then
  1044.                                         say(kname .. " melee'd " .. vname .. " with a needler, advanced to Level 10!")
  1045.                                         if logging then log_msg(1, vname .. " was killed by " .. kname .. "'s melee who is level: " .. klvl) end
  1046.                                     else
  1047.                                         say(kname .. " killed " .. vname .. " with a needler, advanced to Level 10!")
  1048.                                         if logging then log_msg(1, vname .. " was killed by " .. kname .. " who is level: " .. klvl) end
  1049.                                     end
  1050.                                     gameweap = registertimer(0, "AssignGameWeapons", killer)
  1051.                                     response = false
  1052.                                 end                                                
  1053.                                
  1054.                             elseif last_damage[vip] == "weapons\\plasma pistol\\bolt" or last_damage[vip] == "weapons\\plasma rifle\\charged bolt" or last_damage[vip] == "weapons\\plasma pistol\\melee" then
  1055.                                 if weapons[killer] == "weapons\\plasma pistol\\plasma pistol" then
  1056.                                     level[killer] = 11
  1057.                                     playerscore[killer] = playerscore[killer] + 11
  1058.                                     if team_play then kteam = getteam(killer) teamscore[kteam] = teamscore[kteam] + 11 end
  1059.                                     beserk = false
  1060.                                     if string.find(last_damage[vip], "melee") then
  1061.                                         say(kname .. " melee'd " .. vname .. " with a plasma pistol, advanced to WIN! +10 Points")
  1062.                                         if logging then log_msg(1, vname .. " was killed by " .. kname .. "'s melee who is level: " .. klvl) end
  1063.                                     else
  1064.                                         say(kname .. " killed " .. vname .. " with a plasma pistol, advanced to WIN! +10 Points")
  1065.                                         if logging then log_msg(1, vname .. " was killed by " .. kname .. " who is level: " .. klvl) end
  1066.                                     end
  1067.                                     response = false
  1068.                                 end                            
  1069.                                
  1070.                             elseif last_damage[vip] == "weapons\\plasma grenade\\explosion" or last_damage[vip] == "weapons\\frag grenade\\explosion" then
  1071.                                 say(kname .. " killed " .. vname .. " with a grenade, no level advancement.")
  1072.                                 sendconsoletext(killer, "No level advancement for grenade kills.", 4, 0)
  1073.                                 if logging then log_msg(1, vname .. " was killed by " .. kname .. "'s grenade who is level: " .. klvl) end
  1074.                                 response = false                           
  1075.                             end
  1076.                         else
  1077.                             response = false
  1078.                         end
  1079.                     end
  1080.                 end
  1081.             end
  1082.            
  1083.         elseif mode == 5 then -- player was killed/betrayed by teammate
  1084.             if getplayer(killer) then
  1085.                 klvl = level[killer]
  1086.                 kname = getname(killer)
  1087.                 kip = getip(killer)
  1088.                 kteam = getteam(killer)                
  1089.             else   
  1090.                 kname = "NULL"
  1091.                 klvl = NULL
  1092.                 kteam = -1 
  1093.             end
  1094.            
  1095.             if getplayer(victim) then
  1096.                 vlvl = level[victim]
  1097.                 vname = getname(victim)
  1098.                 vip = getip(victim)
  1099.                 vteam = getteam(victim)
  1100.                 if getplayer(killer) then
  1101.                     klvl = level[killer]
  1102.                     kname = getname(killer)
  1103.                     kip = getip(killer)
  1104.                     kteam = getteam(killer)  
  1105.                     mybattery[killer] = 0
  1106.                     if level[killer] ~= nil and level[killer] > 1 then
  1107.                         if (level[killer] - 1) >= 1 then level[killer] = level[killer] - 1 end
  1108.                         if (playerscore[killer] - 1) >= 0 then playerscore[killer] = playerscore[killer] - 1 end
  1109.                         if team_play then if (teamscore[kteam] - 1) >= 0 then teamscore[kteam] = teamscore[kteam] - 1 end end
  1110.                         mybattery[killer] = 0
  1111.                         kill(killer)
  1112.                         say(kname .. " was demoted one level and killed for betraying " .. vname)
  1113.                         if logging then log_msg(1, kname .. " was killed by server for betrayal of " .. vname) end
  1114.                         response = false
  1115.                     else
  1116.                         kill(killer)
  1117.                         say(kname .. " was killed for betraying " .. vname)
  1118.                         if logging then log_msg(1, kname .. " was killed by server for betrayal of " .. vname) end
  1119.                         response = false
  1120.                     end
  1121.                     response = false       
  1122.                 end
  1123.                 response = false   
  1124.             end    
  1125.            
  1126.         elseif mode == 6 then --suicides - killer is self/victim
  1127.             if getplayer(victim) then
  1128.                 vlvl = level[victim]
  1129.                 vname = getname(victim)
  1130.                 vip = getip(victim)
  1131.                 vteam = getteam(victim)
  1132.                 if vlvl == 10 then
  1133.                     level[victim] = 9
  1134.                     playerscore[victim] = 8
  1135.                     beserk = false
  1136.                     weapons[victim] = "weapons\\needler\\mp_needler"
  1137.                     sendconsoletext(victim, "Demoted to Level 9! Ain't that a bitch?!", 4, 0)
  1138.                     say(vname .. " demoted to Level 9 for suicide.")
  1139.                     if logging then log_msg(1, vname .. " demoted from level 10 to 9 for suicide. Is level: " .. vlvl) end
  1140.                     response = false
  1141.                 end
  1142.                 if level[victim] ~= nil and level[victim] > 1 then
  1143.                     if (level[victim] - 1) >= 1 then level[victim] = level[victim] - 1 end
  1144.                     if (playerscore[victim] - 1) >= 0 then playerscore[victim] = playerscore[victim] - 1 end
  1145.                     if team_play then if (teamscore[vteam] - 1) >= 0 then teamscore[vteam] = teamscore[vteam] - 1 end end
  1146.                     say(vname .. " committed suicide and was demoted one level.")
  1147.                     if logging then log_msg(1, vname .. " demoted one level for suicide. Is level: " .. vlvl) end
  1148.                     response = false
  1149.                 else
  1150.                     say(vname .. " committed suicide.")
  1151.                     response = false
  1152.                 end
  1153.                 response = false
  1154.             end
  1155.         end
  1156.     end
  1157.    
  1158.     return response
  1159. end
  1160.  
  1161. function OnVehicleEntry(player, veh_id, seat, mapid, relevant)
  1162.     if getplayer(player) then
  1163.         privatesay(player, getname(player) .. " NOTE: You can't kill players with vehicle or vehicle guns.")
  1164.     end
  1165.     return nil
  1166. end
  1167.  
  1168. function OnDamageApplication(receiving, causing, tagid, hit, backtap)
  1169.     -- sets the last damage value for all players, used to determine how a player was damaged and with which weapon
  1170.     if receiving then
  1171.         local r_object = getobject(receiving)
  1172.         if r_object then
  1173.             local receiver = objectaddrtoplayer(r_object)
  1174.             if receiver then
  1175.                 local rip = getip(receiver)
  1176.                 local tagname,tagtype = gettaginfo(tagid)
  1177.                 last_damage[rip] = tagname
  1178.             end
  1179.         end
  1180.     end
  1181.     return nil
  1182. end
  1183.  
  1184. function OnDamageLookup(receiving, causing, tagid)
  1185.     -- looks up and sets damage variables
  1186.     if receiving and causing and receiving ~= causing then
  1187.         local tagname, tagtype = gettaginfo(tagid)
  1188.         local melee = string.find(tagname, "melee")
  1189.         local ppistolc = string.find(tagname, "weapons\\plasma rifle\\charged bolt")
  1190.         local ppistolb = string.find(tagname, "weapons\\plasma pistol\\bolt")
  1191.         local needlerd = string.find(tagname, "weapons\\needler\\detonation damage")
  1192.         local plasrifle = string.find(tagname, "weapons\\plasma rifle\\bolt")
  1193.         local c_player = objectidtoplayer(causing)
  1194.         local r_player = objectidtoplayer(receiving)
  1195.         -- block vehicle and vehicle gun damage
  1196.         if c_player and isinvehicle(c_player) then
  1197.             local m_vehicleId = getplayervehicleid(c_player)
  1198.             if m_vehicleId then
  1199.                 local m_vehicle = getobject(m_vehicleId)
  1200.                 local gunner = readdword(m_vehicle + 0x328)
  1201.                 local driver = readdword(m_vehicle + 0x324)
  1202.                 if gunner == causing then
  1203.                     return false
  1204.                 elseif driver == causing then
  1205.                     return false
  1206.                 end            
  1207.             end
  1208.         end
  1209.         -- increase damage of melee to instant kill, increase plasma pistol, needler and plasma rifle to balance game play
  1210.         if c_player and r_player then
  1211.             if melee then odl_multiplier(9999) end
  1212.             if ppistolc then odl_multiplier(1.85) end
  1213.             if ppistolb then odl_multiplier(1.85) end
  1214.             if needlerd then odl_multiplier(1.75) end
  1215.             if plasrifle then odl_multiplier(1.35) end         
  1216.         end
  1217.     end
  1218.     return nil
  1219. end
  1220.    
  1221. function getplayervehicleid(player)
  1222.     local m_objectId = getplayerobjectid(player)
  1223.     if m_objectId then return readdword(getobject(m_objectId) + 0x11C) end
  1224. end
  1225.    
  1226. function OnObjectInteraction(player, objId, mapId)
  1227.     -- blocks players from picking up weapons and nades
  1228.     local Pass = nil
  1229.     local name, type = gettaginfo(mapId)
  1230.     if type == "weap" then
  1231.         if weapons[player] ~= nil then
  1232.             if name ~= weapons[player] then
  1233.                 Pass = false
  1234.             end
  1235.         end
  1236.     elseif type == "eqip" then
  1237.         if name == "powerups\\over shield" or name == "powerups\\health pack" then
  1238.             Pass = true
  1239.         else   
  1240.             Pass = false
  1241.         end
  1242.     end
  1243.     return Pass
  1244. end
  1245.  
  1246. function ApplyHP(id, count, player)
  1247.     -- restores players health, called when a player reaches levels 3 and 8
  1248.     if count == 1 then
  1249.         if player and game_started then
  1250.             local name = getname(player)
  1251.             local lvl = level[player]  
  1252.             local m_playerObjId = getplayerobjectid(player)
  1253.             if m_playerObjId ~= nil then
  1254.                 local m_object = getobject(m_playerObjId)
  1255.                 local obj_health = readfloat(m_object + 0xE0)
  1256.                 if obj_health < 1 then
  1257.                     writefloat(m_object + 0xE0, 1)
  1258.                     sendconsoletext(player, "Bonus: Your health has been restored.", 4, 0)
  1259.                     if logging then log_msg(1, name .. " Health Bonus applied. Is Level: " .. lvl) end
  1260.                 end
  1261.             end
  1262.         end
  1263.     end
  1264.     return false
  1265. end
  1266.  
  1267. function OnObjectCreationAttempt(mapId, parentId, player)
  1268.     local response = nil
  1269.     if game_started then
  1270.         -- blocks creation of these items when game starts, only if game_started is valid (after script load, after new game)
  1271.         if mapId == gettagid("weap", "weapons\\ball\\ball") or
  1272.             mapId == gettagid("eqip", "weapons\\frag grenade\\frag grenade") or
  1273.             mapId == gettagid("eqip", "weapons\\plasma grenade\\plasma grenade") then
  1274.             response = false
  1275.         end
  1276.         if mapId == gettagid("weap", "weapons\\flag\\flag") then
  1277.             return gettagid("weap", "weapons\\plasma pistol\\plasma pistol")
  1278.         end        
  1279.         if mapId == gettagid("eqip", "powerups\\active camouflage") then
  1280.             return gettagid("eqip", "powerups\\over shield")
  1281.         end        
  1282.     elseif not game_started then
  1283.         -- allows creation of these items when game starts or on script load
  1284.         if mapId == gettagid("eqip", "powerups\\full-spectrum vision") or
  1285.             mapId == gettagid("eqip", "powerups\\health pack") or
  1286.             mapId == gettagid("bipd", "characters\\cyborg_mp\\cyborg_mp") or
  1287.             mapId == gettagid("vehi", "vehicles\\warthog\\mp_warthog") or
  1288.             mapId == gettagid("vehi", "vehicles\\rwarthog\\rwarthog") or
  1289.             mapId == gettagid("vehi", "vehicles\\ghost\\ghost_mp") or
  1290.             mapId == gettagid("vehi", "vehicles\\c gun turret\\c gun turret_mp") or
  1291.             mapId == gettagid("vehi", "vehicles\\scorpion\\scorpion_mp") then
  1292.             response = true
  1293.         end
  1294.         -- blocks creation of these items when game starts, when game is restarted, or scripts reloaded
  1295.         if mapId == gettagid("weap", "weapons\\ball\\ball") or
  1296.             mapId == gettagid("eqip", "weapons\\frag grenade\\frag grenade") or
  1297.             mapId == gettagid("eqip", "weapons\\plasma grenade\\plasma grenade") then
  1298.             response = false
  1299.         end
  1300.         if mapId == gettagid("weap", "weapons\\flag\\flag") then
  1301.             return gettagid("weap", "weapons\\plasma pistol\\plasma pistol")
  1302.         end        
  1303.         if mapId == gettagid("eqip", "powerups\\active camouflage") then
  1304.             return gettagid("eqip", "powerups\\over shield")
  1305.         end
  1306.     else
  1307.         response = false
  1308.     end
  1309.     return response
  1310. end
  1311.  
  1312. function OnClientUpdate(player)
  1313.     if getplayer(player) then
  1314.         local lvl = level[player]
  1315.         if lvl ~= nil then
  1316.             -- monitors and initiates game win announcement
  1317.             if lvl == 11 and game_started then
  1318.                 game_started = false
  1319.                 announcewin = registertimer(0, "AnnounceWin", player)
  1320.                 if logging then log_msg(1, "Game win detected - Announcement called.") end
  1321.             end
  1322.         end
  1323.     end
  1324. end
  1325.  
  1326. function AnnounceWin(id, count, player)
  1327.     -- announces game winner
  1328.     if player and game_started == false then
  1329.         local name = getname(player)   
  1330.         svcmd("sv_map_next")
  1331.         if not team_play then
  1332.             say(name .. " WINS THE GAME! ")
  1333.         else   
  1334.             local team = getteam(player)
  1335.             if team == 0 then team = "RED TEAM" elseif team == 1 then team = "BLUE TEAM" end
  1336.             say(name .. " OF " .. team .. " WINS THE GAME! ")
  1337.         end    
  1338.         log_msg(1, name .. " has won the Gun-Game on " .. map_name .. "!")
  1339.     end    
  1340.     return false
  1341. end
  1342.  
  1343. function OnTeamChange(player, old_team, new_team, relevant)
  1344.     -- prevent unbalancing teams by team change
  1345.     local response = nil
  1346.     if getplayer(player) then
  1347.    
  1348.         local newteam = "New Team"
  1349.         local oldteam = "Old Team"
  1350.        
  1351.         if not team_play then response = false return response end
  1352.        
  1353.         if new_team == 0 then
  1354.             oldteam = "Blue Team"
  1355.             newteam = "Red Team"       
  1356.         elseif new_team == 1 then
  1357.             oldteam = "Red Team"
  1358.             newteam = "Blue Team"      
  1359.         end        
  1360.        
  1361.         if relevant == true or relevant == 1 then
  1362.             if getteamsize(old_team) == getteamsize(new_team) then
  1363.                 privatesay(player, "You cannot change teams.")
  1364.                 response = false
  1365.             elseif getteamsize(old_team) + 1 == getteamsize(new_team) then
  1366.                 privatesay(player, "You cannot change teams.")
  1367.                 response = false
  1368.             elseif getteamsize(old_team) == getteamsize(new_team) + 1 then
  1369.                 privatesay(player, "You cannot change teams.")
  1370.                 response = false
  1371.             elseif getteamsize(old_team) > getteamsize(new_team) then
  1372.                 team_change[player] = true
  1373.                 -- transfer player score to new team score, and deduct new player score from old team score
  1374.                 if team_play then
  1375.                     teamscore[new_team] = teamscore[new_team] + playerscore[player]
  1376.                     teamscore[old_team] = teamscore[old_team] - playerscore[player]
  1377.                 end
  1378.                 mybattery[player] = 0
  1379.                 say(getname(player) .. " switched to the "  .. newteam)
  1380.                 response = true
  1381.             elseif getteamsize(old_team) < getteamsize(new_team) then
  1382.                 team_change[player] = true
  1383.                 -- transfer player score to new team score, and deduct new player score from old team score
  1384.                 if team_play then
  1385.                     teamscore[new_team] = teamscore[new_team] + playerscore[player]
  1386.                     teamscore[old_team] = teamscore[old_team] - playerscore[player]
  1387.                 end                            
  1388.                 mybattery[player] = 0
  1389.                 say(getname(player) .. " switched to the "  .. newteam)
  1390.                 response = true
  1391.             end
  1392.         elseif relevant == false or relevant == 0 then
  1393.             team_change[player] = true
  1394.             -- transfer player score to new team score, and deduct new player score from old team score
  1395.             if team_play then
  1396.                 teamscore[new_team] = teamscore[new_team] + playerscore[player]
  1397.                 teamscore[old_team] = teamscore[old_team] - playerscore[player]
  1398.             end        
  1399.             mybattery[player] = 0
  1400.             say(getname(player) .. " was team-switched to balance the teams.")
  1401.             response = true
  1402.         end
  1403.        
  1404.     end
  1405.     return response
  1406. end
  1407.  
  1408. function AutoBalance(id, count)
  1409.     if game_started and team_play and cur_players > 3 then
  1410.         Balance_Teams()
  1411.         if join_autobal then join_autobal = nil end
  1412.         if leave_autobal then leave_autobal = nil end
  1413.         return true
  1414.     elseif game_started and team_play and cur_players < 4 then 
  1415.         return false
  1416.     else
  1417.         return false
  1418.     end
  1419. end
  1420.  
  1421. -- inspired by 002's team balance for Sapp
  1422. function Balance_Teams()
  1423.     if game_started and team_play then
  1424.         local redteam = getteamsize(0)
  1425.         local blueteam = getteamsize(1)
  1426.         if redteam > blueteam then
  1427.             while TeamsAreUneven() do
  1428.                 while (getteamsize(0) > getteamsize(1)+1) do
  1429.                     local randomred = SelectPlayer(0)
  1430.                     if randomred ~= nil then
  1431.                         changeteam(randomred, true)
  1432.                     end
  1433.                 end
  1434.             end
  1435.         elseif blueteam > redteam then
  1436.             while TeamsAreUneven() do
  1437.                 while (getteamsize(1) > getteamsize(0)+1) do
  1438.                     local randomblu = SelectPlayer(1)
  1439.                     if randomblu ~= nil then                           
  1440.                         changeteam(randomblu, true)
  1441.                     end
  1442.                 end
  1443.             end    
  1444.         end
  1445.     end
  1446. end
  1447.  
  1448. -- inspired by 002's team balance for Sapp
  1449. function TeamsAreUneven()
  1450.     local red = getteamsize(0)
  1451.     local blue = getteamsize(1)
  1452.     if (red > blue + 1 or blue > red + 1) then return true end
  1453.     return false
  1454. end
  1455.  
  1456. function SelectPlayer(team)
  1457.     local t = {}
  1458.     for i=0,15 do
  1459.         if getplayer(i) and getteam(i) == team then
  1460.             table.insert(t, i)
  1461.         end
  1462.     end
  1463.     if #t > 0 then
  1464.         local r = getrandomnumber(1, #t+1)
  1465.         return t[r]
  1466.     end
  1467.     return nil
  1468. end
  1469.  
  1470. function OnGameEnd(stage)
  1471.     -- terminate or nil timers, set game values.  Some timers cannot be removed, instead they are nil'd
  1472.     if stage == 1 then
  1473.         game_started = false
  1474.         beserk = false 
  1475.         if gameweap then
  1476.             gameweap = nil
  1477.         end
  1478.         if announcewin then
  1479.             announcewin = nil
  1480.         end
  1481.         if m_weaponId then
  1482.             m_weaponId = nil
  1483.         end
  1484.         if replaceplasmaweap then
  1485.             replaceplasmaweap = nil
  1486.         end
  1487.         if p_objectId then
  1488.             p_objectId = nil
  1489.         end
  1490.         if health then
  1491.             health = nil
  1492.         end
  1493.         if welcome then
  1494.             welcome = nil
  1495.         end
  1496.         if speedtimer then
  1497.             speedtimer = nil
  1498.         end
  1499.         if checkbattery then
  1500.             checkbattery = nil
  1501.         end
  1502.         if updatescores then
  1503.             updatescores = nil
  1504.         end
  1505.         if game_autobal then
  1506.             game_autobal = nil
  1507.         end
  1508.         if join_autobal then
  1509.             join_autobal = nil
  1510.         end
  1511.         if leave_autobal then
  1512.             leave_autobal = nil
  1513.         end
  1514.         if consoletimer then
  1515.             consoletimer = nil
  1516.         end
  1517.     elseif stage == 3 then
  1518.         for i = 0, 15 do
  1519.             if getplayer(i) then
  1520.                 privatesay(i, "Thank you for playing the Gun-Game Arms Race!")
  1521.                 privatesay(i, "This and other scripts available on HaloRace.org")
  1522.             end
  1523.         end    
  1524.     end
  1525. end
  1526.  
  1527. -- -------------------------------------------------------------------------
  1528. -- Start sendconsoletext overloaded by Nugget
  1529. console = {}
  1530. console.__index = console
  1531. consoletimer = registertimer(100, "ConsoleTimer")
  1532. phasor_sendconsoletext = sendconsoletext
  1533.  
  1534. function sendconsoletext(player, message, time, order, align, height, func)
  1535.     if player then
  1536.         console[player] = console[player] or {}
  1537.         local temp = {}
  1538.         temp.player = player
  1539.         temp.id = nextid(player, order)
  1540.         temp.message = message or ""
  1541.         temp.time = time or 0.7
  1542.         temp.remain = temp.time
  1543.         temp.align = align or "left"
  1544.         temp.height = height or 0
  1545.         if type(func) == "function" then
  1546.             temp.func = func
  1547.         elseif type(func) == "string" then
  1548.             temp.func = _G[func]
  1549.         end
  1550.         console[player][temp.id] = temp
  1551.         setmetatable(console[player][temp.id], console)
  1552.         return console[player][temp.id]
  1553.     end
  1554. end
  1555.  
  1556. function nextid(player, order)
  1557.     if not order then
  1558.         local x = 0
  1559.         for k,v in pairs(console[player]) do
  1560.             if k > x + 1 then
  1561.                 return x + 1
  1562.             end
  1563.            
  1564.             x = x + 1
  1565.         end
  1566.         return x + 1
  1567.     else
  1568.         local original = order
  1569.         while console[player][order] do
  1570.             order = order + 0.001
  1571.             if order == original + 0.999 then break end
  1572.         end
  1573.         return order
  1574.     end
  1575. end
  1576.  
  1577. function getmessage(player, order)
  1578.     if console[player] then
  1579.         if order then
  1580.             return console[player][order]
  1581.         end
  1582.     end
  1583. end
  1584.  
  1585. function getmessages(player)
  1586.     return console[player]
  1587. end
  1588.  
  1589. function getmessageblock(player, order)
  1590.     local temp = {}
  1591.     for k,v in opairs(console[player]) do
  1592.         if k >= order and k < order + 1 then
  1593.             table.insert(temp, console[player][k])
  1594.         end
  1595.     end
  1596.     return temp
  1597. end
  1598.  
  1599. function console:getmessage()
  1600.     return self.message
  1601. end
  1602.  
  1603. function console:append(message, reset)
  1604.     if console[self.player] then
  1605.         if console[self.player][self.id] then
  1606.             if getplayer(self.player) then
  1607.                 if reset then
  1608.                     if reset == true then
  1609.                         console[self.player][self.id].remain = console[self.player][self.id].time
  1610.                     elseif tonumber(reset) then
  1611.                         console[self.player][self.id].time = tonumber(reset)
  1612.                         console[self.player][self.id].remain = tonumber(reset)
  1613.                     end
  1614.                 end
  1615.                
  1616.                 console[self.player][self.id].message = message or ""
  1617.                 return true
  1618.             end
  1619.         end
  1620.     end
  1621. end
  1622.  
  1623. function console:shift(order)
  1624.     local temp = console[self.player][self.id]
  1625.     console[self.player][self.id] = console[self.player][order]
  1626.     console[self.player][order] = temp
  1627. end
  1628.  
  1629. function console:pause(time)
  1630.     console[self.player][self.id].pausetime = time or 5
  1631. end
  1632.  
  1633. function console:delete()
  1634.     console[self.player][self.id] = nil
  1635. end
  1636.  
  1637. function ConsoleTimer(id, count)
  1638.     for i,_ in opairs(console) do
  1639.         if tonumber(i) then
  1640.             if getplayer(i) then
  1641.                 for k,v in opairs(console[i]) do
  1642.                     if console[i][k].pausetime then
  1643.                         console[i][k].pausetime = console[i][k].pausetime - 0.1
  1644.                         if console[i][k].pausetime <= 0 then
  1645.                             console[i][k].pausetime = nil
  1646.                         end
  1647.                     else
  1648.                         if console[i][k].func then
  1649.                             if not console[i][k].func(i) then
  1650.                                 console[i][k] = nil
  1651.                             end
  1652.                         end
  1653.                         if console[i][k] then
  1654.                             console[i][k].remain = console[i][k].remain - 0.1
  1655.                             if console[i][k].remain <= 0 then
  1656.                                 console[i][k] = nil
  1657.                             end
  1658.                         end
  1659.                     end
  1660.                 end
  1661.                 if table.len(console[i]) > 0 then
  1662.                     local paused = 0
  1663.                     for k,v in pairs(console[i]) do
  1664.                         if console[i][k].pausetime then
  1665.                             paused = paused + 1
  1666.                         end
  1667.                     end
  1668.                     if paused < table.len(console[i]) then
  1669.                         local str = ""
  1670.                         for i = 0,30 do
  1671.                             str = str .. " \n"
  1672.                         end
  1673.                         phasor_sendconsoletext(i, str)
  1674.                         for k,v in opairs(console[i]) do
  1675.                             if not console[i][k].pausetime then
  1676.                                 if console[i][k].align == "right" or console[i][k].align == "center" then
  1677.                                     phasor_sendconsoletext(i, consolecenter(string.sub(console[i][k].message, 1, 78)))
  1678.                                 else
  1679.                                     phasor_sendconsoletext(i, string.sub(console[i][k].message, 1, 78))
  1680.                                 end
  1681.                             end
  1682.                         end
  1683.                     end
  1684.                 end
  1685.             else
  1686.                 console[i] = nil
  1687.             end
  1688.         end
  1689.     end
  1690.     return true
  1691. end
  1692.  
  1693. function consolecenter(text)
  1694.     if text then
  1695.         local len = string.len(text)
  1696.         for i = len + 1, 78 do
  1697.             text = " " .. text
  1698.         end
  1699.         return text
  1700.     end
  1701. end
  1702.  
  1703. function opairs(t)
  1704.     local keys = {}
  1705.     for k,v in pairs(t) do
  1706.         table.insert(keys, k)
  1707.     end    
  1708.     table.sort(keys,
  1709.     function(a,b)
  1710.         if type(a) == "number" and type(b) == "number" then
  1711.             return a < b
  1712.         end
  1713.         an = string.lower(tostring(a))
  1714.         bn = string.lower(tostring(b))
  1715.         if an ~= bn then
  1716.             return an < bn
  1717.         else
  1718.             return tostring(a) < tostring(b)
  1719.         end
  1720.     end)
  1721.     local count = 1
  1722.     return function()
  1723.         if table.unpack(keys) then
  1724.             local key = keys[count]
  1725.             local value = t[key]
  1726.             count = count + 1
  1727.             return key,value
  1728.         end
  1729.     end
  1730. end
  1731.  
  1732. function table.len(t)
  1733.     local count = 0
  1734.     for k,v in pairs(t) do
  1735.         count = count + 1
  1736.     end
  1737.     return count
  1738. end
  1739.  
  1740. --[[ Created by H® Shaft.
  1741. Thanks to Oxide, AelitePrime, Nugget & Wizard.
  1742. Visit http://halorace.org/forum/index.php?topic=514.0 or
  1743. Visit http://pastebin.com/u/HR_Shaft for more phasor scripts
  1744. Special thanks to AelitePrime, as this was an attempt to script patterned after his style similar to his Zombie script 4.1, and other scripts we have mutually developed.
  1745. Note: This was written and developed by H® Shaft prior to the release of any other similar script with similar names. Any claims of duplication of concept/script are 100% bullpucky.
  1746.  
  1747. Special thanks to our beta testers, server hosts & contributors:
  1748. H® HUMMER, H® BugZ, H® Monkey, H® Wingnut, H® LoLLi, H® Stone, H® RUDE, H® Outage, H® Griff, -JR- Mumbler, -JR- RAVIN,
  1749. -JR-Hollypaw, -JR- Slayer, -JR- Falx, -JR- Spec4, -JR- Slayer, -JR-wraith, AR~Dvs_One, -JR-ÄÐhè®é,  AR~Hazy,
  1750. AR~Un¡t»Zero, AR~Hanabal, AR~DSPFlag, AR~HiroP, AR~Archon, Forseti, Mastermind, [x] fisk, ²MõD²Wrath, ²MõD²Corvair,
  1751. ²MõD²Bear, ²MõD²Buster, «§H»Kennan, Telyx, Lobo, Awesome, Nugget, Wizard, particleboy, PÕQ clan, {ØZ} clan, Skylace,
  1752. A§H» clan, Ponyboy and the Ousiders, PÕQ~Technut, smiley, Btcc22, Roger W, sehé°°, kornman00, Geomitar]]
  1753.  
  1754. --[[ SERVER SETUP - USAGE:
  1755. Compatible with CTF & Slayer gametypes only - 'Standard' PC & CE Maps and custom maps with classic weapon sets. Not compatible with race, oddball or koth gametypes, or custom named weapons CE maps.
  1756. Gametype should set weapons to normal/generic, infinite nades off.
  1757. Place in your cg/scripts/persistent folder.  Intended to be used as a persisitent script, but not required.
  1758. DO NOT combine with other death message/player kill scripts during this game.
  1759. Use of server rcon commands sv_map_reset and sv_script_reload are allowed, and function well with no errors.  Reloading will behave similar to resetting.
  1760. Extended game logging best used for tournaments/scrims/ or debugging.  If you choose to customize this script, set logging to true to help you.
  1761. This script has been rigorously tested and believed to be error free. If you get errors, try running the script by itself, it could conflict with other scripts. Set logging to true on lines 29 and 98 to help you debug then read the logs
  1762. If help is needed, message me on phasor.proboards.com, or on www.HaloRace.org, or xfire: nervebooger2012
  1763. Thank you, I hope you enjoy this as much as we have on our PC and CE servers.
  1764. Visit us at http://halorace.org/forum/index.php
  1765. Jicelle, Mandy Lynn, Misty Rain, Amaleen, Baylie & Brittney - and -jr- Chaos for spooning with all -db- members.]]
Advertisement
Add Comment
Please, Sign In to add comment