LUA 197
V2+ Pistol Vehicle Entry 6.0 By xdedeone on 26th February 2019 05:02:17 PM
  1. --[[ ###         Pistol Entry v6 Warthog Entry for Phasor v2        ###]]--
  2. --[[ ###             by H® Shaft, Elite Prime, H® BugZ             ###]]--
  3.  
  4. -- Update: When player shoots a hog with the pistol, and is inserted into the gunner seat, it will sometimes shoot the rocket
  5. -- added damage delay to prevent rocket hog gunners from accidentally betraying teammates on entry.
  6. -- Update 6: 9/19/2013 added ghost, tank & banshee entry, ghost specific entry
  7.  
  8. vehicles = {}
  9. delay = {}
  10. map_ids = {}
  11.  
  12. function GetRequiredVersion()
  13.         return 200
  14. end
  15.  
  16. function OnScriptLoad(process, game, persistent)
  17.         for i=0,15 do delay[i] = nil end
  18.         LoadTags()
  19. end
  20.  
  21. function OnNewGame(map)
  22.         for i=0,15 do delay[i] = nil end
  23.         LoadTags()
  24. end
  25.  
  26. function OnDamageLookup(receiving, causing, tagid, tagdata)
  27.         if receiving and causing and receiving ~= causing then
  28.                 local c_player = objectidtoplayer(causing)
  29.                 if delay[c_player] then
  30.                         return nil
  31.                 end
  32.                 if tagid == pistol_id then
  33.                         local bool, driver, passenger, gunner = false, false, false, false
  34.                         local mapId = readdword(getobject(receiving))
  35.                         if not bool and ghost_tag_id == mapId then
  36.                                 bool = true
  37.                                 passenger = true
  38.                                 gunner = true
  39.                         else
  40.                                 for k,v in pairs(map_ids) do
  41.                                         if mapId == v then
  42.                                                 bool = true
  43.                                                 break
  44.                                         end
  45.                                 end
  46.                         end
  47.                         if bool then
  48.                                 if c_player then
  49.                                         for k,v in pairs(vehicles) do
  50.                                                 if vehicles[k].vehiId == receiving and getplayer(k) and getteam(c_player) == getteam(k) then
  51.                                                         if vehicles[k].seat == 0 then
  52.                                                                 driver = true
  53.                                                         elseif vehicles[k].seat == 2 then
  54.                                                                 gunner = true
  55.                                                         elseif vehicles[k].seat == 1 then
  56.                                                                 passenger = true
  57.                                                         end
  58.                                                 end
  59.                                         end
  60.                                         if not isinvehicle(c_player) then
  61.                                                 if not driver then
  62.                                                         entervehicle(c_player, receiving, 0)
  63.                                                 elseif not gunner then
  64.                                                         delay[c_player] = registertimer(1000, "damagetimer", c_player)
  65.                                                         entervehicle(c_player, receiving, 2)
  66.                                                 elseif not passenger then
  67.                                                         delay[c_player] = registertimer(1000, "damagetimer", c_player)
  68.                                                         entervehicle(c_player, receiving, 1)
  69.                                                 end
  70.                                         end
  71.                                 end
  72.                         end
  73.                 end
  74.         end
  75.         return nil     
  76. end
  77.  
  78. function OnPlayerJoin(player)
  79.         vehicles[player] = {}
  80.         announce = registertimer(2001, "timedannounce", player)
  81. end
  82.  
  83. function timedannounce(id, count, player)
  84.         if getplayer(player) then sendconsoletext(player, "Pistol Entry is Enabled.") end
  85.         return false
  86. end
  87.  
  88. function OnVehicleEntry(player, veh_id, seat, mapId, relevant)
  89.         vehicles[player] = {}
  90.         vehicles[player].vehiId = veh_id
  91.         vehicles[player].seat = seat
  92.         return nil
  93. end
  94.  
  95. function OnVehicleEject(player, relevant)
  96.         vehicles[player] = nil
  97.         return nil
  98. end
  99.  
  100. function damagetimer(id, count, player)
  101.         delay[player] = nil
  102.         return false
  103. end
  104.  
  105. function LoadTags()
  106.         pistol_id = gettagid("jpt!", "weapons\\pistol\\bullet")
  107.         ghost_tag_id = gettagid("vehi", "vehicles\\ghost\\ghost_mp")
  108.         table.insert(map_ids, gettagid("vehi", "vehicles\\rwarthog\\rwarthog"))
  109.         table.insert(map_ids, gettagid("vehi", "vehicles\\warthog\\mp_warthog"))
  110.     table.insert(map_ids, gettagid("vehi", "vehicles\\banshee\\banshee_mp"))
  111.     table.insert(map_ids, gettagid("vehi", "vehicles\\scorpion\\scorpion_mp"))
  112. end
  113.  
  114. -- Created by H® Shaft thank you to Oxide, AelitePrime, Nugget & Wizard.
  115. -- Visit http://halorace.org/forum/index.php?topic=514.0 or
  116. -- 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.