Advertisement
HR_Shaft

Gunner-is-Driver v2 for Phasor v2

Jul 13th, 2014
271
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.89 KB | None | 0 0
  1. --[[ ###      Gunner-is-Driver v2    ###]]--
  2. --[[ ###  by H® Shaft for Phasor v2  ###]]--
  3.  
  4. -- edit --
  5. hog_limit = 15
  6.  
  7. -- don't edit --
  8. hogs = {}
  9. spawn_in_hog = {}
  10. compatible = {}
  11. game_started = false
  12.  
  13. -- ---- will player spawn in a vehicle? ----------
  14. --              Map:                    enable t/f:
  15. spawn_in_hog.   bloodgulch      =       true
  16. spawn_in_hog.   dangercanyon    =       true
  17. spawn_in_hog.   deathisland     =       true
  18. spawn_in_hog.   gephyrophobia   =       true
  19. spawn_in_hog.   icefields       =       true
  20. spawn_in_hog.   infinity        =       true       
  21. spawn_in_hog.   sidewinder      =       true   
  22. spawn_in_hog.   timberland      =       true
  23. spawn_in_hog.   beavercreek     =       false -- battle creek      
  24. spawn_in_hog.   boardingaction  =       false              
  25. spawn_in_hog.   carousel        =       false -- derelict
  26. spawn_in_hog.   chillout        =       false              
  27. spawn_in_hog.   damnation       =       false                      
  28. spawn_in_hog.   hangemhigh      =       false                  
  29. spawn_in_hog.   longest         =       false              
  30. spawn_in_hog.   prisoner        =       false              
  31. spawn_in_hog.   putput          =       false -- chiron tl34
  32. spawn_in_hog.   ratrace         =       false                  
  33. spawn_in_hog.   wizard          =       false
  34.  
  35. -- ----- is map compatible with calling a hog? ---------
  36. --              Map:                    compatible t/f:
  37. compatible.     bloodgulch      =       true
  38. compatible.     dangercanyon    =       true
  39. compatible.     deathisland     =       true
  40. compatible.     gephyrophobia   =       true
  41. compatible.     icefields       =       true
  42. compatible.     infinity        =       true       
  43. compatible.     sidewinder      =       true   
  44. compatible.     timberland      =       true
  45. compatible.     beavercreek     =       false -- battle creek      
  46. compatible.     boardingaction  =       false              
  47. compatible.     carousel        =       false -- derelict
  48. compatible.     chillout        =       false              
  49. compatible.     damnation       =       false                      
  50. compatible.     hangemhigh      =       false                  
  51. compatible.     longest         =       false              
  52. compatible.     prisoner        =       false              
  53. compatible.     putput          =       false -- chiron tl34
  54. compatible.     ratrace         =       false                      
  55. compatible.     wizard          =       false
  56.  
  57. function GetRequiredVersion()
  58.     return 200
  59. end
  60.  
  61. function OnScriptLoad(process, game, persistent)
  62.     if game == true or game == "PC" then
  63.         GAME = "PC"
  64.         gametype_base = 0x671340
  65.         map_name = readstring(0x698F21)
  66.     else
  67.         GAME = "CE"
  68.         gametype_base = 0x5F5498
  69.         map_name = readstring(0x61D151)
  70.     end
  71.     for i=0,15 do
  72.         if getplayer(i) then
  73.             hogs[i] = 0
  74.         end
  75.     end
  76. end
  77.  
  78. function OnNewGame(map)
  79.     if GAME == "PC" then
  80.         gametype_base = 0x671340
  81.         map_name = readstring(0x698F21)
  82.     elseif GAME == "CE" then
  83.         gametype_base = 0x5F5498
  84.         map_name = readstring(0x61D151)
  85.     end
  86.     for i=0,15 do
  87.         if getplayer(i) then
  88.             hogs[i] = 0
  89.         end
  90.     end
  91.     if not spawn_in_hog[map_name] and not compatible[map_name] then
  92.         log_msg(4, map_name .. " is NOT compatible with Gunner-Driver script, Large Maps only!")
  93.         log_msg(1, map_name .. " is NOT compatible with Gunner-Driver script, Large Maps only!")       
  94.     end
  95.     if spawn_in_hog[map_name] and compatible[map_name] then
  96.         notice = registertimer(180000, "timednotice") -- 180000 = 3 mins
  97.     end
  98.     game_started = true
  99. end
  100.  
  101. function OnPlayerJoin(player)
  102.     if getplayer(player) then
  103.         hogs[player] = 0
  104.     end
  105. end
  106.  
  107. function OnPlayerSpawnEnd(player, m_objectId)
  108.     if getplayer(player) then
  109.         if spawn_in_hog[map_name] and compatible[map_name] and game_started then
  110.             putinvehicle = registertimer(400, "PutInVehicle", player)
  111.         elseif not spawn_in_hog[map_name] and compatible[map_name] then
  112.             privatesay(player, "** Move away from small areas or bases, then")
  113.             privatesay(player, "** type HOG to get a vehicle.")
  114.         end
  115.     end
  116. end
  117.  
  118. function PutInVehicle(is, count, player)
  119.     if getplayer(player) and game_started then
  120.         local m_player = getplayerobjectid(player)
  121.         local x,y,z = getobjectcoords(m_player)
  122.         if m_player then
  123.             m_vehicleId = createobject(gettagid("vehi", "vehicles\\rwarthog\\rwarthog"), 0, 1, false, x,y,z+0.35)
  124.             entervehicle(player, m_vehicleId, 0)
  125.             entervehicle(player, m_vehicleId, 2)
  126.             privatesay(player, "** You are gunner AND driver.")
  127.         end
  128.     end
  129.     return false   
  130. end        
  131.  
  132. function OnServerChat(player, type, message)
  133.     local response = nil
  134.    
  135.     if player then
  136.    
  137.         if string.lower(message) == "hog" then
  138.             local m_player = getplayer(player)
  139.             if m_player then
  140.                 local response = false
  141.                 if game_started then
  142.                     if compatible[map_name] then
  143.                         if not isinvehicle(player) then
  144.                             local x,y,z = getobjectcoords(m_player)
  145.                             local m_player = getplayerobjectid(player)
  146.                             if not hog_limit or hogs[player] < hog_limit then
  147.                                 if m_player then   
  148.                                     local m_vehicleId = createobject(gettagid("vehi", "vehicles\\rwarthog\\rwarthog"), 0, 1, false, x,y,z+0.35)
  149.                                     entervehicle(player, m_vehicleId, 0)
  150.                                     entervehicle(player, m_vehicleId, 2)                                   
  151.                                     hogs[player] = hogs[player] + 1
  152.                                     privatesay(player, "** You are gunner AND driver.")                        
  153.                                     sendconsoletext(player, "**Hogs** You have " .. hog_limit - hogs[player] .. " hog calls remaining.")
  154.                                 else
  155.                                     sendconsoletext(player, "**Derp** You cannot spawn a vehicle while dead.")
  156.                                 end                            
  157.                             else
  158.                                 sendconsoletext(player, "**Hogs** You have reached the max amount of hog calls for this game.")
  159.                             end
  160.                         else
  161.                             sendconsoletext(player, "**Derp** You already have a vehicle.")
  162.                         end
  163.                     else
  164.                         sendconsoletext(player, "**Hogs** That feature has been disabled for this map.")
  165.                     end
  166.                 else
  167.                     sendconsoletext(player, "**Derp** You cannot spawn a hog after the game has ended.")
  168.                 end                
  169.             end
  170.             return response
  171.         end
  172.            
  173.     end
  174.    
  175.     return response
  176. end
  177.  
  178. function timednotice(id, count)
  179.     for i=0,15 do
  180.         if getplayer(i) then
  181.             privatesay(i, "** No vehicle?")
  182.             privatesay(i, "** Move away from small areas or bases, then")
  183.             privatesay(i, "** type HOG to get a vehicle. You are gunner AND driver.")                  
  184.         end
  185.     end
  186.     return true
  187. end
  188.  
  189. function OnGameEnd(stage)
  190.     if stage == 1 then
  191.         game_started = false
  192.         if notice then
  193.             notice = nil
  194.         end
  195.     end    
  196. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement