Advertisement
HR_Shaft

Gunner-is-Driver v3 for Phasor v2+ *EDITED 8/7

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