Advertisement
HR_Shaft

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

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