Advertisement
HR_Shaft

Gunner-is-Driver v3 Randomized Chain/Rhogs for Phasor v2+

Aug 7th, 2014
293
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.49 KB | None | 0 0
  1. --[[ ### Gunner-is-Driver v3  Randomized ###]]--
  2. --[[ ###    by H® Shaft for Phasor v2    ###]]--
  3.  
  4. -- This version: Rocket hogs and Chain hogs selected randomly
  5.  
  6. -- Best for Race gametypes on Bloodgulch, Sidewinder and Deathisland (large outside maps, players spawn outside)
  7. -- riders will not automatically eject if they roll upside down
  8. -- players will be put into a hog as gunner-driver automatically on spawn or ejecting from a hog
  9. -- In the event that players aren't put into a hog automatically, they can type 'hog' to get one
  10. -- If players get stuck anywhere on the map, they can type "kill me" or "suicide" to re-spawn
  11. -- Combine with my other script: 'Leap frog v5' (Makes the hog leap/jump when you press the brake) to increase player enjoyment:
  12. -- Leap frog v5:  http://pastebin.com/gJXFnJnE
  13.  
  14. -- don't edit --
  15. game_started = false
  16. notice = nil
  17.  
  18. function GetRequiredVersion()
  19.     return 200
  20. end
  21.  
  22. function OnScriptLoad(process, game, persistent)
  23.     if game == true or game == "PC" then
  24.         GAME = "PC"
  25.         devmode_patch1 = 0x4A4DBF
  26.         devmode_patch2 = 0x4A4E7F      
  27.     else
  28.         GAME = "CE"
  29.         devmode_patch1 = 0x47DF0C
  30.         devmode_patch2 = 0x47DFBC      
  31.     end
  32.     writeword(devmode_patch1, 0x9090)
  33.     writeword(devmode_patch2, 0x9090)
  34.     if not game_started then game_started = true end
  35.     if notice == nil then
  36.         notice = registertimer(180000, "timednotice") -- every 3 minutes
  37.     end
  38. end
  39.  
  40. function OnNewGame(map)
  41.     if GAME == "PC" then
  42.         devmode_patch1 = 0x4A4DBF
  43.         devmode_patch2 = 0x4A4E7F      
  44.     elseif GAME == "CE" then
  45.         devmode_patch1 = 0x47DF0C
  46.         devmode_patch2 = 0x47DFBC      
  47.     end
  48.     writeword(devmode_patch1, 0x9090)
  49.     writeword(devmode_patch2, 0x9090)
  50.     if not game_started then game_started = true end
  51.     if notice == nil then
  52.         notice = registertimer(180000, "timednotice") -- every 3 minutes
  53.     end    
  54. end
  55.  
  56. function OnPlayerJoin(player)
  57.     if getplayer(player) then
  58.         privatesay(player, "You are both gunner and driver!")
  59.         privatesay(player, "If you get stuck anywhere type \"kill me\" to re-spawn yourself.")
  60.         privatesay(player, "If you aren't automatically put into a hog, type \"hog\" to get a new one.")
  61.     end
  62. end
  63.  
  64. function timednotice(id, count)
  65.     if game_started then
  66.         for i=0,15 do
  67.             if getplayer(i) then
  68.                 privatesay(i, "You are both gunner and driver!")
  69.                 privatesay(i, "If you get stuck anywhere type \"kill me\" to re-spawn yourself.")
  70.                 privatesay(i, "If you aren't automatically put into a hog, type \"hog\" to get a new one.")
  71.             end
  72.         end
  73.     end
  74.     return true
  75. end
  76.  
  77. function OnPlayerSpawnEnd(player, m_objectId)
  78.     if getplayer(player) then
  79.         if game_started then
  80.             putinvehicle = registertimer(400, "PutInVehicle", player)
  81.         end
  82.     end
  83. end
  84.  
  85. function OnVehicleEject(player, relevant)
  86.     if getplayer(player) and game_started then
  87.         putinvehicle = registertimer(1200, "PutInVehicle", player) -- 1200ms gives previous hog time to be destroyed/disappear
  88.     end
  89. end
  90.  
  91. function PutInVehicle(id, count, player)
  92.     if getplayer(player) and game_started then
  93.         local m_objectId = getplayerobjectid(player)
  94.         if m_objectId then
  95.             local m_object = getobject(m_objectId)
  96.             local x,y,z = getobjectcoords(m_objectId)
  97.             if m_object and not isinvehicle(player) then
  98.                 local randomize = getrandomnumber(1, 11)
  99.                 if randomize >= 5 then
  100.                     m_vehicleId = createobject(gettagid("vehi", "vehicles\\rwarthog\\rwarthog"), 0, 1, false, x,y,z+0.45)
  101.                     entervehicle(player, m_vehicleId, 0)
  102.                     entervehicle(player, m_vehicleId, 2)
  103.                     svcmd("set rider_ejection false")
  104.                 else
  105.                     m_vehicleId = createobject(gettagid("vehi", "vehicles\\warthog\\mp_warthog"), 0, 1, false, x,y,z+0.45)
  106.                     entervehicle(player, m_vehicleId, 0)
  107.                     entervehicle(player, m_vehicleId, 2)
  108.                     svcmd("set rider_ejection false")
  109.                 end    
  110.             end
  111.         end
  112.     end
  113.     return false   
  114. end        
  115.  
  116. function OnServerChat(player, type, message)
  117.     local response = nil
  118.     if player then
  119.    
  120.         if string.lower(message) == "hog" then
  121.             response = false
  122.             if game_started then
  123.                 if not isinvehicle(player) then
  124.                     local m_objectId = getplayerobjectid(player)
  125.                     if m_objectId then
  126.                         local x,y,z = getobjectcoords(m_objectId)  
  127.                         local m_object = getobject(m_objectId)
  128.                         if m_object then
  129.                             local randomize = getrandomnumber(1, 11)
  130.                             if randomize >= 5 then
  131.                                 m_vehicleId = createobject(gettagid("vehi", "vehicles\\rwarthog\\rwarthog"), 0, 1, false, x,y,z+0.45)
  132.                                 entervehicle(player, m_vehicleId, 0)
  133.                                 entervehicle(player, m_vehicleId, 2)
  134.                                 svcmd("set rider_ejection false")
  135.                             else
  136.                                 m_vehicleId = createobject(gettagid("vehi", "vehicles\\warthog\\mp_warthog"), 0, 1, false, x,y,z+0.45)
  137.                                 entervehicle(player, m_vehicleId, 0)
  138.                                 entervehicle(player, m_vehicleId, 2)
  139.                                 svcmd("set rider_ejection false")
  140.                             end                    
  141.                         else
  142.                             sendconsoletext(player, "**Derp** You cannot spawn a vehicle while dead.")
  143.                         end
  144.                     end    
  145.                 else
  146.                     sendconsoletext(player, "**Derp** You already have a vehicle.")
  147.                 end
  148.             else
  149.                 sendconsoletext(player, "**Derp** You cannot spawn a hog after the game has ended.")
  150.             end                    
  151.         end
  152.        
  153.         if string.lower(message) == "killme" or string.lower(message) == "kill me" or string.lower(message) == "suicide" then
  154.             response = false
  155.             if game_started then
  156.                 kill(player)
  157.             end
  158.         end    
  159.        
  160.     end
  161.     return response
  162. end
  163.  
  164. function OnGameEnd(stage)
  165.     game_started = false
  166.     if stage == 1 then
  167.         if putinvehicle then
  168.             putinvehicle = nil
  169.         end
  170.         if notice then
  171.             notice = nil
  172.         end    
  173.     end
  174.    
  175. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement