Advertisement
Guest User

Block flag/ball holders from driving/gunning Phasor v2+

a guest
Jan 27th, 2015
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 6.60 KB | None | 0 0
  1. --[[ ### Block flag/ball holders from driving/gunning ###]]--
  2. --[[ ###          for Phasor v2+ by H® Shaft          ###]]--
  3.  
  4. -- This script will prevent flag and ball holders from entering the driver or gunner seat of a vehicle (only passenger seats allowed)
  5.  
  6. -- Standard Ball and Flag tag names:
  7. ball_tag = "weapons\\ball\\ball"
  8. flag_tag = "weapons\\flag\\flag"
  9.  
  10. -- Enter custom tag names here (within quotes, see instructions)
  11. ball_tag2 = "weapons\\ball\\ball"
  12. flag_tag2 = "weapons\\ball\\ball"
  13.  
  14. -- Blocked gunner or driver seat message (you can edit):
  15. blocked_message = "BLOCKED! Ball and Flag holders cannot gun or drive!"
  16.  
  17. -- Instructions for retrieving the ball and flag tag names for unprotected custom maps:
  18. -- Ball and Flag tag names (above): You won't need to change this for all PC maps and MOST CE maps.  
  19. -- However, you can customize the script so it works for your custom map.
  20. -- Load the script and map, grab the flag or oddball, then type "weapon" it will tell you the tag name on the screen
  21. -- then enter that tag name above. Example: The tag name for the ball returned would be: weapons\ball\ball
  22. -- then scripted above as:  weapons\\ball\\ball, or - for the flag: weapons\\flag\\flag, etc. (add the additionional "\")
  23.  
  24. -- don't edit below --
  25. game_started = false
  26. holders = {}
  27.  
  28. function GetRequiredVersion()
  29.         return 200
  30. end
  31.  
  32. function OnScriptLoad(process, game, persistent)
  33.         game_started = true
  34.         holdingtimer = registertimer(0, "holding")
  35.         --[[
  36.         if not delayholding and game_started then
  37.                 delayholding = registertimer(2000, "delayholding")
  38.         end]]
  39.         for i = 0,15 do
  40.                 if getplayer(i) then
  41.                         holders[i] = false
  42.                 end
  43.         end    
  44. end
  45.  
  46. function OnNewGame(map)
  47.         game_started = true
  48.         if not holdingtimer and game_started then
  49.                 holdingtimer = registertimer(0, "holding")
  50.         end    
  51.         for i = 0,15 do
  52.                 if getplayer(i) then
  53.                         holders[i] = false
  54.                 end
  55.         end            
  56. end
  57.  
  58. function delayholding(id, count)
  59.         if not holdingtimer and game_started then
  60.                 holdingtimer = registertimer(0, "holding")
  61.         end    
  62.         return false
  63. end
  64.  
  65. function OnPlayerJoin(player)
  66.         if getplayer(player) then
  67.                 holders[player] = false
  68.         end
  69. end
  70.  
  71. function OnPlayerLeave(player)
  72.         if getplayer(player) then
  73.                 holders[player] = false
  74.         end
  75. end
  76.  
  77. function OnPlayerKill(killer, victim, mode)
  78.         if getplayer(victim) then
  79.                 holders[victim] = false
  80.         end
  81. end                    
  82.  
  83. function holding(id, count)
  84.         for i = 0, 15 do
  85.                 if getplayer(i) then
  86.                         local m_objectId = getplayerobjectid(i)
  87.                         if m_objectId then
  88.                                 local m_object = getobject(m_objectId)
  89.                                 if m_object then
  90.                                         local m_weaponId = readdword(m_object + 0x118)
  91.                                         if m_weaponId then
  92.                                                 local m_weapon = getobject(m_weaponId)                
  93.                                                 if m_weapon then
  94.                                                         local weapname = gettaginfo(readdword(m_weapon))
  95.                                                         if weapname == ball_tag or weapname == flag_tag or weapname == ball_tag2 or weapname == flag_tag2 then
  96.                                                                 holders[i] = true
  97.                                                         else
  98.                                                                 holders[i] = false
  99.                                                         end
  100.                                                 end
  101.                                         end
  102.                                 end
  103.                         end    
  104.                 end    
  105.         end            
  106.         return true
  107. end
  108.  
  109. function OnServerChat(player, type, message)
  110.         local response = nil
  111.         if player then
  112.  
  113.                 --will tell you the tagname of the primary weapon you are holding if you are not in a vehicle
  114.                 if string.lower(message) == "weapon" and not isinvehicle(player) then
  115.                         response = true
  116.                         local m_objectId = getplayerobjectid(player)
  117.                         if m_objectId then
  118.                                 local m_object = getobject(m_objectId)
  119.                                 if m_object then
  120.                                         local m_weaponId = readdword(m_object + 0x118)
  121.                                         if m_weaponId then
  122.                                                 local m_weapon = getobject(m_weaponId)                
  123.                                                 if m_weapon then
  124.                                                         local weapname = gettaginfo(readdword(m_weapon))
  125.                                                         privatesay(player, "Weapon tag name: " .. weapname)
  126.                                                 end            
  127.                                         end
  128.                                 end
  129.                         end            
  130.                 end
  131.                
  132.         end
  133.         return response
  134. end
  135.  
  136. function OnVehicleEntry(player, m_vehicleId, seat, mapId, relevant)
  137.         local response = nil
  138.         if getplayer(player) then
  139.                 if holders[player] then
  140.                         if seat ~= 1 then
  141.                                 response = false
  142.                                 privatesay(player, blocked_message)
  143.                         else
  144.                                 response = true
  145.                         end
  146.                 end
  147.         end
  148.         return response
  149. end    
  150.  
  151. function OnGameEnd(stage)
  152.         if stage == 1 then
  153.                 game_started = false
  154.                 if delayholding then
  155.                         delayholding = nil
  156.                 end
  157.                 if holdingtimer then
  158.                         holdingtimer = nil
  159.                 end
  160.                 if holding then
  161.                         holding = nil
  162.                 end            
  163.         end            
  164. end
  165.  
  166. --[[ Created by H® Shaft.
  167. Thanks to Oxide, AelitePrime, Nugget & Wizard.
  168. Visit http://halorace.org/forum/index.php?topic=514.0 or
  169. Visit http://pastebin.com/u/HR_Shaft for more phasor scripts
  170. ]]--
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement