LUA 179
V2+ Tank Whores 1.0 By xdedeone on 26th February 2019 05:00:46 PM
  1. --[[ ###    Tank Whores    ###]]--
  2. --[[ ###        by H® Shaft    ###]]--
  3. --[[ ###   for Phasor v2    ###]]--
  4.  
  5. -- spawns players in tanks, (should not be used on indoor maps)
  6. -- should be used for large maps with outdoor player spawns
  7. -- player spawned vehicles respawn in 15 seconds after exit
  8. -- players can type 'tank' to spawn a new tank
  9.  
  10. -- optional: choose to have gametype spawned vehicles replaced by tanks, see below 'replace_vehicles'
  11. -- optional: choose to spawn players in vehicles (should be used only in large maps with outdoor player spawns)
  12.  
  13. -- edit --
  14. replace_vehicles = true                 -- change to true if you want all gametype spawned vehicles replaced by tanks
  15. spawn_in_vehicle = false                -- change to true if you want players to spawn in vehicles
  16.  
  17. -- don't edit --
  18. map_ids = {}
  19.  
  20. function GetRequiredVersion()
  21.         return 200
  22. end
  23.  
  24. function OnScriptLoad(process, game, persistent)
  25.         if game == "PC" then
  26.                 map_name = readstring(0x698F21)
  27.         else
  28.                 map_name = readstring(0x61D151)
  29.         end
  30.         LoadTags()
  31.         GAME = game
  32. end
  33.  
  34. function OnNewGame(map)
  35.         if GAME == "PC" then
  36.                 map_name = readstring(0x698F21)
  37.         else
  38.                 map_name = readstring(0x61D151)
  39.         end
  40.         LoadTags()
  41. end
  42.  
  43. function OnPlayerSpawnEnd(player, m_objectId)
  44.         local m_player = getplayerobjectid(player)
  45.         if m_player then
  46.                 if spawn_in_vehicle then
  47.                         putinvehicle = registertimer(300, "PutPlayerInVehicle", player)
  48.                 end    
  49.         end
  50. end
  51.  
  52. function PutPlayerInVehicle(id, count, player)
  53.         if count == 1 then
  54.                 local m_player = getplayerobjectid(player)
  55.                 local x,y,z = getobjectcoords(m_player)
  56.                 if map_ids[map_name] then
  57.                         if m_player then
  58.                                 local m_vehicleId = createobject(map_ids[map_name], 0, 15, false, x,y,z+0.4)
  59.                                 entervehicle(player, m_vehicleId, 0)
  60.                         end    
  61.                 end
  62.         end    
  63.         return true    
  64. end    
  65.  
  66. function OnGameEnd(stage)
  67.         if stage == 1 then     
  68.                 if putinvehicle then
  69.                         removetimer(putinvehicle)
  70.                         putinvehicle = nil
  71.                 end
  72.         end    
  73. end
  74.  
  75. function OnServerChat(player, type, message)
  76.         local response = nil
  77.         if player then
  78.                 if string.lower(message) == "tank" then
  79.                         local response = false
  80.                         local m_player = getplayer(player)
  81.                         if m_player then
  82.                                 if not isinvehicle(player) then
  83.                                         local m_player = getplayerobjectid(player)
  84.                                         if m_player then x,y,z = getobjectcoords(m_player) end
  85.                                         if map_ids[map_name] then
  86.                                                 local m_vehicleId = createobject(map_ids[map_name], 0, 15, false, x,y,z+1)
  87.                                                 entervehicle(player, m_vehicleId, 0)
  88.                                         end
  89.                                 else
  90.                                         sendconsoletext(player, "**Derp** You already have a vehicle.")
  91.                                 end
  92.                         end
  93.                         return response
  94.                 end
  95.         end
  96.         return response
  97. end    
  98.  
  99. function OnPlayerJoin(player)
  100.         registertimer(5000, "timedwelcome", player)
  101. end
  102.  
  103. function timedwelcome(id, count, player)
  104.         if count == 1 then
  105.                 if getplayer(player) then
  106.                         privatesay(player, "Welcome to Tank Whores: to spawn a tank, type TANK")
  107.                 end    
  108.         end    
  109.         return true    
  110. end
  111.  
  112. function LoadTags()
  113.         map_ids["beavercreek"] = gettagid("vehi", "vehicles\\scorpion\\scorpion_mp")
  114.         map_ids["bloodgulch"] = gettagid("vehi", "vehicles\\scorpion\\scorpion_mp")
  115.         map_ids["boardingaction"] = gettagid("vehi", "vehicles\\scorpion\\scorpion_mp")
  116.         map_ids["carousel"] = gettagid("vehi", "vehicles\\scorpion\\scorpion_mp")
  117.         map_ids["chillout"] = gettagid("vehi", "vehicles\\scorpion\\scorpion_mp")
  118.         map_ids["damnation"] = gettagid("vehi", "vehicles\\scorpion\\scorpion_mp")
  119.         map_ids["dangercanyon"] = gettagid("vehi", "vehicles\\scorpion\\scorpion_mp")
  120.         map_ids["deathisland"] = gettagid("vehi", "vehicles\\scorpion\\scorpion_mp")
  121.         map_ids["gephyrophobia"] = gettagid("vehi", "vehicles\\scorpion\\scorpion_mp")
  122.         map_ids["hangemhigh"] = gettagid("vehi", "vehicles\\scorpion\\scorpion_mp")
  123.         map_ids["icefields"] = gettagid("vehi", "vehicles\\scorpion\\scorpion_mp")
  124.         map_ids["infinity"] = gettagid("vehi", "vehicles\\scorpion\\scorpion_mp")
  125.         map_ids["longest"] = gettagid("vehi", "vehicles\\scorpion\\scorpion_mp")
  126.         map_ids["prisoner"] = gettagid("vehi", "vehicles\\scorpion\\scorpion_mp")
  127.         map_ids["putput"] = gettagid("vehi", "vehicles\\scorpion\\scorpion_mp")
  128.         map_ids["ratrace"] = gettagid("vehi", "vehicles\\scorpion\\scorpion_mp")
  129.         map_ids["sidewinder"] = gettagid("vehi", "vehicles\\scorpion\\scorpion_mp")
  130.         map_ids["timberland"] = gettagid("vehi", "vehicles\\scorpion\\scorpion_mp")
  131.         map_ids["wizard"] = gettagid("vehi", "vehicles\\scorpion\\scorpion_mp")
  132. end    
  133.  
  134. function OnObjectCreationAttempt(mapId, parentId, player)
  135.         if replace_vehicles then
  136.                 if mapId == gettagid("vehi", "vehicles\\rwarthog\\rwarthog") then
  137.                         return gettagid("vehi", "vehicles\\scorpion\\scorpion_mp")
  138.                 end
  139.                 if mapId == gettagid("vehi", "vehicles\\warthog\\mp_warthog") then
  140.                         return gettagid("vehi", "vehicles\\scorpion\\scorpion_mp")
  141.                 end
  142.                 if mapId == gettagid("vehi", "vehicles\\banshee\\banshee_mp") then
  143.                         return gettagid("vehi", "vehicles\\scorpion\\scorpion_mp")
  144.                 end
  145.                 if mapId == gettagid("vehi", "vehicles\\c gun turret\\c gun turret_mp") then
  146.                         return gettagid("vehi", "vehicles\\scorpion\\scorpion_mp")
  147.                 end
  148.                 if mapId == gettagid("vehi", "vehicles\\ghost\\ghost_mp") then
  149.                         return gettagid("vehi", "vehicles\\scorpion\\scorpion_mp")
  150.                 end            
  151.         end    
  152. end    
  153.  
  154. -- Created by H® Shaft thank you to Oxide, AelitePrime, Nugget & Wizard.
  155. -- Visit http://halorace.org/forum/index.php?topic=514.0 or
  156. -- Visit http://pastebin.com/u/HR_Shaft for more phasor scripts

HaloNet.Net is for source code and general debugging text.

Login or Register to edit, delete and keep track of your pastes and more.

Raw Paste

Login or Register to edit or fork this paste. It's free.