Advertisement
HR_Shaft

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

Jan 27th, 2015
259
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.23 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.     for i = 0,15 do
  36.         if getplayer(i) then
  37.             holders[i] = false
  38.         end
  39.     end
  40. end
  41.  
  42. function OnNewGame(map)
  43.     game_started = true
  44.     if not holdingtimer and game_started then
  45.         holdingtimer = registertimer(0, "holding")
  46.     end
  47.     for i = 0,15 do
  48.         if getplayer(i) then
  49.             holders[i] = false
  50.         end
  51.     end    
  52. end
  53.  
  54. function OnPlayerJoin(player)
  55.     if getplayer(player) then
  56.         holders[player] = false
  57.     end
  58. end
  59.  
  60. function OnPlayerLeave(player)
  61.     if getplayer(player) then
  62.         holders[player] = false
  63.     end
  64. end
  65.  
  66. function OnPlayerKill(killer, victim, mode)
  67.     if getplayer(victim) then
  68.         holders[victim] = false
  69.     end
  70. end        
  71.  
  72. function holding(id, count)
  73.     for i = 0, 15 do
  74.         if getplayer(i) then
  75.             local m_objectId = getplayerobjectid(i)
  76.             if m_objectId then
  77.                 local m_object = getobject(m_objectId)
  78.                 if m_object then
  79.                     local m_weaponId = readdword(m_object + 0x118)
  80.                     if m_weaponId then
  81.                         local m_weapon = getobject(m_weaponId)         
  82.                         if m_weapon then
  83.                             local weapname = gettaginfo(readdword(m_weapon))
  84.                             if weapname == ball_tag or weapname == flag_tag or weapname == ball_tag2 or weapname == flag_tag2 then
  85.                                 holders[i] = true
  86.                             else
  87.                                 holders[i] = false
  88.                             end
  89.                         end
  90.                     end
  91.                 end
  92.             end
  93.         end
  94.     end    
  95.     return true
  96. end
  97.  
  98. function OnServerChat(player, type, message)
  99.     local response = nil
  100.     if player then
  101.  
  102.         --will tell you the tagname of the primary weapon you are holding if you are not in a vehicle
  103.         if string.lower(message) == "weapon" and not isinvehicle(player) then
  104.             response = true
  105.             local m_objectId = getplayerobjectid(player)
  106.             if m_objectId then
  107.                 local m_object = getobject(m_objectId)
  108.                 if m_object then
  109.                     local m_weaponId = readdword(m_object + 0x118)
  110.                     if m_weaponId then
  111.                         local m_weapon = getobject(m_weaponId)         
  112.                         if m_weapon then
  113.                             local weapname = gettaginfo(readdword(m_weapon))
  114.                             privatesay(player, "Weapon tag name: " .. weapname)
  115.                         end    
  116.                     end
  117.                 end
  118.             end    
  119.         end
  120.        
  121.     end
  122.     return response
  123. end
  124.  
  125. function OnVehicleEntry(player, m_vehicleId, seat, mapId, relevant)
  126.     local response = nil
  127.     if getplayer(player) then
  128.         if holders[player] then
  129.             if seat ~= 1 then
  130.                 response = false
  131.                 privatesay(player, blocked_message)
  132.             else
  133.                 response = true
  134.             end
  135.         end
  136.     end
  137.     return response
  138. end
  139.  
  140. function OnGameEnd(stage)
  141.     if stage == 1 then
  142.         game_started = false
  143.         if delayholding then
  144.             delayholding = nil
  145.         end
  146.         if holdingtimer then
  147.             holdingtimer = nil
  148.         end
  149.         if holding then
  150.             holding = nil
  151.         end    
  152.     end    
  153. end
  154.  
  155. --[[ Created by H® Shaft.
  156. Thanks to Oxide, AelitePrime, Nugget & Wizard.
  157. Visit http://halorace.org/forum/index.php?topic=514.0 or
  158. Visit http://pastebin.com/u/HR_Shaft for more phasor scripts
  159. ]]--
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement