Advertisement
HR_Shaft

Taxi v5 for Phasor v2

May 15th, 2014
365
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 24.09 KB | None | 0 0
  1. --[[ ###            Taxi v5 for Phasor v2            ###]]--
  2. --[[ ###      by H® Shaft, AElitePrime & H® BugZ     ###]]--
  3.  
  4. -- Intended to be used as a Persistent Script
  5.  
  6. -- What does it do? If your team are in warthogs/tanks, taxi will insert you a seat into one of their vehicles by crouching or typing "taxi"
  7. -- type 'gun me' and pickup a gunner, type 'eject' to kick em out!
  8.  
  9. -- Version 4: Anti Hog Camping, Hog Spawn, Passenger Weapon, Show Players in Vehicle (type 'whois'), Per-Map Toggle Don't like this version? Use version 4: http://pastebin.com/EYqiMWU4
  10.  
  11. -- Version 5 Changelog:
  12. -- Added crouch detection that is does not accidentally activate on impact/falling crouch if crouch-to-taxi is enabled.
  13. -- Fine tuned some of the code to improve performance.
  14. -- Added CTF/Oddball compatibility so I removed automatic assignment of passenger heavy weapons that was in version 4
  15. -- Added driver activated passenger ejection seat: When driver types 'eject' passenger and/or gunner are both ejected from the hog.
  16. -- Added Aelite's 'Taxi-Teams' * - players in same hog are temporarily treated as a team, when one dies, they can call taxi and be put back into same hog - IF - there is still a teammate in it.
  17. -- Note: Taxi-Team assumes this is your preference rather than to be inserted into 'any' teammates hog - this is NOT editable, and comes after a year of testing player preferences in CTF/Race/Team King
  18. -- Added logging of taxi commands usage to Gamelog
  19.  
  20. -- Commands:
  21. -- Crouch key or type 'Taxi'    -- | Inserts you into a teammates hog or tank, if available. (if crouch-to-taxi/text-to-taxi is enabled)
  22. -- type 'Gun me' while in hog   -- | Inserts a walking teammate into your driver, gunner or passenger seat (if gunme is enabled)
  23. -- type 'who is' while in hog   -- | Shows you the driver/passenger/gunner names
  24. -- type 'hog' while walking     -- | spawns a hog and puts you into the drivers seat (if hog_spawn is enabled for the map)
  25. -- type 'eject' while driving   -- | Ejects any passenger or gunner from your vehicle
  26. -- type /taxi or @taxi          -- | See the above list
  27.  
  28. -- edit defaults--
  29. taxi_limit = 20             -- | Number of times a player can call taxi during one game.  You can go as high as you want, it won't affect gameplay or lag.
  30. hog_limit = 10              -- | Number of times a player can spawn a hog during one game. Should not be higher than 15 - ever! Spawning too many can cause lag and/or crash.
  31. crouch_to_taxi = true       -- | Toggle on/off the crouching taxi call. On = true, Off = false.
  32. text_to_taxi = true         -- | Toggle on/off the typed taxi call. On = true, Off = false.
  33. passenger_taxi = true       -- | Toggle on/off the passenger seat.  If off, the Taxi/Gun Me calls will not use passenger seats. On = true, Off = false.
  34. gunme_active = true         -- | Toggle on/off the typed 'gun me' call which when typed by a player in a vehicle, inserts gunners/passengers. On = true, Off = false.
  35. gunner_damage = true        -- | Toggle on/off damage from a vehicle gunner which has no driver (a.k.a. Hog Camper) If false, they cannot kill without a driver. This value should be opposite of rider_ejection value
  36. rider_ejection = false      -- | Toggle on/off anti-camping which ejects a player from a driverless vehicle. On = true, Off = false.  This value should be opposite of gunner_damage value
  37. max_time = 5                -- | amount of time in seconds before a hog turret camper or passenger is ejected (only valid if rider_ejection is true)           
  38.  
  39. -- don't edit --
  40. taxi, calls, crouch, hails, hogs, map_ids, vehicles, taxi_teams = {}, {}, {}, {}, {}, {}, {}, {}
  41. crouch_time = 2
  42. call_time = 0.1             -- | minimum of time in seconds before timer to rider ejection is initiated - value should be 0.1
  43.  
  44. -- | Toggle on/off script spawn hog on server chat - edit:
  45. -- | Small indoor maps should not use hog spawn, false to disable (spawning hogs in walls/below ground can cause crashes)
  46.  
  47. hog_spawn = {}
  48. --              Map:                        Boolean:
  49. hog_spawn.      beavercreek         =       false -- battle creek
  50. hog_spawn.      bloodgulch          =       true               
  51. hog_spawn.      boardingaction      =       true               
  52. hog_spawn.      carousel            =       false -- derelict
  53. hog_spawn.      chillout            =       false              
  54. hog_spawn.      damnation           =       false              
  55. hog_spawn.      dangercanyon        =       true               
  56. hog_spawn.      deathisland         =       true           
  57. hog_spawn.      gephyrophobia       =       true               
  58. hog_spawn.      hangemhigh          =       false              
  59. hog_spawn.      icefields           =       true               
  60. hog_spawn.      infinity            =       true               
  61. hog_spawn.      longest             =       false              
  62. hog_spawn.      prisoner            =       false              
  63. hog_spawn.      putput              =       false -- chiron tl34
  64. hog_spawn.      ratrace             =       false              
  65. hog_spawn.      sidewinder          =       true               
  66. hog_spawn.      timberland          =       true               
  67. hog_spawn.      wizard              =       false
  68.  
  69. function GetRequiredVersion()
  70.     return 200
  71. end
  72.  
  73. function OnScriptLoad(process, game, persistent)
  74.     if game == true or game == "PC" then
  75.         GAME = "PC"
  76.         map_name = readstring(0x698F21)
  77.     else
  78.         GAME = "CE"
  79.         map_name = readstring(0x61D151)
  80.     end
  81.     LoadTags()
  82.     for i=0,15 do
  83.         calls[i], hails[i], taxi[i], hogs[i] = 0, 0, {}, 0
  84.         if getplayer(i) then
  85.             local player_obj_id = getplayerobjectid(i)
  86.             if player_obj_id then
  87.                 local m_object = getobject(player_obj_id)
  88.                 if readbyte(m_object + 0x2A0) == 2 then
  89.                     taxi[i].seat = 1
  90.                     taxi[i].vehicle = getobject(readdword(m_object + 0x11C))
  91.                 end
  92.             end
  93.         end
  94.     end
  95.     Ejection = registertimer(call_time*1000, "ejection")
  96. end
  97.  
  98. function OnNewGame(map)
  99.     if GAME == "PC" then
  100.         map_name = readstring(0x698F21)
  101.     elseif GAME == "CE" then
  102.         map_name = readstring(0x61D151)
  103.     end
  104.     LoadTags() 
  105. end
  106.  
  107. function ejection(id, c)
  108.     if rider_ejection then
  109.         for k, v in pairs(vehicles) do
  110.             if vehicles[k] ~= {} then
  111.                 for key, value in pairs(vehicles[k]) do
  112.                     if vehicles[k].players and vehicles[k].players ~= {} then
  113.                         vehicles[k].count = (vehicles[k].count or 0) + call_time
  114.                         if vehicles[k].count >= max_time then
  115.                             for i=1, #vehicles[k].players do
  116.                                 local player = vehicles[k].players[i]
  117.                                 if player and getplayer(player) and isinvehicle(player) then
  118.                                     sendconsoletext(player, "**Taxi** Ejected! Please don't camp.")
  119.                                     log_msg(1, getname(player) .. " was force ejected from vehicle.")
  120.                                     exitvehicle(player)
  121.                                     if taxi[player].seat == 1 then resetpassenger(player, getobject(getplayerobjectid(player))) end
  122.                                 end
  123.                             end
  124.                             vehicles[k] = {}
  125.                         end
  126.                     else
  127.                         vehicles[k] = {}
  128.                     end
  129.                 end
  130.             end
  131.         end
  132.         return true
  133.     else   
  134.         return false
  135.     end
  136. end
  137.  
  138. function OnServerChat(player, type, message)
  139.     local response = nil
  140.     if player then
  141.    
  142.         if string.lower(message) == "taxi" then
  143.             if text_to_taxi then
  144.                 if not isinvehicle(player) then
  145.                     if taxi_limit == false or calls[player] < taxi_limit then
  146.                         if getplayerobjectid(player) then
  147.                             getTaxi(player)
  148.                             log_msg(1, getname(player) .. " used the taxi command.")
  149.                         else
  150.                             sendconsoletext(player, "**Taxi** You are dead. Try again after you respawn.")
  151.                         end
  152.                     else
  153.                         sendconsoletext(player, "**Taxi** You have reached the max amount of taxi calls for this game.")
  154.                     end
  155.                 else
  156.                     sendconsoletext(player, "**Taxi** You are already in a vehicle.")
  157.                 end
  158.             else
  159.                 sendconsoletext(player, "**Taxi** This feature is currently disabled.")
  160.             end
  161.         response = false
  162.            
  163.         elseif string.lower(message) == "gunme" or string.lower(message) == "gun me" then
  164.             if gunme_active then
  165.                 if isinvehicle(player) then
  166.                     getWalker(player)
  167.                     log_msg(1, getname(player) .. " used the gun me command.")
  168.                 else
  169.                     sendconsoletext(player, "**Gun Me** You must be in a vehicle to use this feature.")
  170.                 end
  171.             else
  172.                 sendconsoletext(player, "**Gun Me** This feature is currently disabled.")
  173.             end
  174.         response = false
  175.            
  176.         elseif string.lower(message) == "hog" then
  177.             local m_player = getplayer(player)
  178.             if m_player then
  179.                 if hog_spawn[map_name] then
  180.                     if not isinvehicle(player) then
  181.                         local m_player = getplayerobjectid(player)
  182.                         if m_player ~= nil then
  183.                             local x,y,z = getobjectcoords(m_player)
  184.                             if not hog_limit or hogs[player] < hog_limit then                      
  185.                                 local m_vehicleId = createobject(map_ids[map_name], 0, 15, false, x,y,z+0.4)
  186.                                 entervehicle(player, m_vehicleId, 0)
  187.                                 hogs[player] = hogs[player] + 1
  188.                                 sendconsoletext(player, "**Hogs** You have " .. hog_limit - hogs[player] .. " hog calls remaining.")
  189.                                 log_msg(1, getname(player) .. " spawned a hog.")
  190.                             else
  191.                                 sendconsoletext(player, "**Hogs** You have reached the max amount of hog calls for this game.")
  192.                             end
  193.                         else
  194.                             sendconsoletext(player, "**Hogs** Derp, you cannot spawn a hog while dead. ")
  195.                         end
  196.                     else
  197.                         sendconsoletext(player, "**Hogs** You already have a vehicle.")
  198.                     end
  199.                 else
  200.                     sendconsoletext(player, "**Hogs** That feature has been disabled for this map.")
  201.                 end
  202.             end
  203.         response = false
  204.            
  205.         elseif string.lower(message) == "whois" or string.lower(message) == "who is" then
  206.             local m_vehicleId = getplayervehicleid(player)
  207.             if isinvehicle(player) and m_vehicleId then
  208.                 local m_vehicle = getobject(m_vehicleId)
  209.                 local driver = getdriverplayer(m_vehicle)
  210.                 local gunner = getgunnerplayer(m_vehicle)
  211.                 local passenger = getpassengerplayer(m_vehicle)
  212.                 local driver = getdriverplayer(m_vehicle)
  213.                 local gunner = getgunnerplayer(m_vehicle)
  214.                 local passenger = getpassengerplayer(m_vehicle)
  215.                 message_players(driver, gunner, passenger)
  216.                 log_msg(1, getname(player) .. " used the whois command.")
  217.             else
  218.                 sendconsoletext(player, "**WhoIs** You must be in a vehicle to use this feature.")
  219.             end
  220.         response = false
  221.            
  222.         elseif string.lower(message) == "reject" or string.lower(message) == "eject" then
  223.             if isinvehicle(player) then
  224.                 local m_objectId = getplayervehicleid(player)
  225.                 local m_vehicle = getobject(m_objectId)
  226.                 if getdriverplayer(m_vehicle) == player then
  227.                     local drivername = getname(getdriverplayer(m_vehicle))
  228.                     local driver_veh = getplayervehicleid(player)
  229.                     local gunner = getgunnerplayer(m_vehicle)
  230.                     local passenger = getpassengerplayer(m_vehicle)
  231.                     if gunner and isinvehicle(gunner) and driver_veh == getplayervehicleid(gunner) then
  232.                         exitvehicle(gunner)
  233.                         sendconsoletext(gunner, "**Ejected!** " .. drivername .. " activated the ejection seat!")
  234.                         taxi[gunner].seat = nil
  235.                     end
  236.                     if passenger and isinvehicle(passenger) and driver_veh == getplayervehicleid(passenger) then
  237.                         exitvehicle(passenger)
  238.                         sendconsoletext(passenger, "**Ejected!** " .. drivername .. " activated the ejection seat!")
  239.                         taxi[passenger].seat = nil
  240.                     end
  241.                     log_msg(1, getname(player) .. " activated ejection seat.")
  242.                 end
  243.             end    
  244.         response = true
  245.            
  246.         elseif string.lower(message) == "/taxi" or string.lower(message) == "@taxi" then           
  247.             privatesay(player, "Crouch key or type 'Taxi' = Inserts you into a teammates hog or tank." )
  248.             privatesay(player, "type 'Gun me' while in hog = Inserts teammate into your driver, gunner or passenger seat." )
  249.             privatesay(player, "type 'who is' while in hog = Shows you the driver/passenger/gunner names." )
  250.             privatesay(player, "type 'hog' while walking = spawns a hog and puts you into the drivers seat." )
  251.             privatesay(player, "type 'eject' while driving = Ejects any passenger or gunner from your vehicle." )
  252.             log_msg(1, getname(player) .. " is reading taxi commands.")
  253.             response = false   
  254.         end
  255.        
  256.         return response
  257.        
  258.     end
  259.    
  260.     return response
  261. end
  262.  
  263. function OnPlayerJoin(player)
  264.     calls[player], hails[player], taxi[player], hogs[player] = 0, 0, {}, 0
  265.     announce = registertimer(4000, "timedannounce", player)
  266. end
  267.  
  268. function timedannounce(id, count, player)
  269.     if count == 1 then
  270.         if getplayer(player) then
  271.             if text_to_taxi then
  272.                 sendconsoletext(player, "Taxi is Enabled. Type @taxi to learn more.")
  273.             end        
  274.             if crouch_to_taxi and not text_to_taxi then
  275.                 sendconsoletext(player, "Crouch-to-Taxi is Enabled.  Type @taxi to learn more.")
  276.             end
  277.             if gunme_active and not text_to_taxi then
  278.                 sendconsoletext(player, "Gun Me is Enabled.  Type @taxi to learn more.")
  279.             end
  280.         end
  281.     end
  282.     return true
  283. end
  284.  
  285. function OnGameEnd(stage)
  286.     if stage == 1 then
  287.         if Ejection then
  288.             removetimer(Ejection)
  289.             Ejection = nil
  290.         end
  291.         if announce then
  292.             removetimer(announce)
  293.             announce = nil
  294.         end
  295.         if passenger then
  296.             removetimer(passenger)
  297.             passenger = nil
  298.         end
  299.         if settonil then
  300.             removetimer(settonil)
  301.             settonil = nil
  302.         end
  303.         if setupseat then
  304.             removetimer(setupseat)
  305.             setupseat = nil
  306.         end
  307.         if showplayers then
  308.             removetimer(showplayers)
  309.             showplayers = nil
  310.         end    
  311.     end
  312. end
  313.  
  314. function OnPlayerLeave(player)
  315.     if taxi[player].vehicle then
  316.         if taxi[player].seat == 1 then writedword(taxi[player].vehicle + 0x32C, 0xFFFFFFFF) end
  317.     end
  318.     taxi[player] = nil
  319. end
  320.  
  321. function OnPlayerKill(killer, victim, mode)
  322.     local m_vehicleId = getplayervehicleid(victim)
  323.     if taxi[victim].seat == 1 then resetpassenger(victim, getobject(getplayerobjectid(victim))) end
  324.     if victim and isinvehicle(victim) then checkplayer(victim) end
  325.     taxi[victim] = {}
  326. end
  327.  
  328. function OnVehicleEntry(player, m_vehicleId, seat, mapId, relevant)
  329.     taxi[player].seat = seat
  330.    
  331.     if seat == 1 then
  332.         local player_obj_id = getplayerobjectid(player)
  333.         local m_object = getobject(player_obj_id)
  334.         taxi[player].vehicle = getobject(readdword(m_object + 0x11C))
  335.         passenger = registertimer(0, "assignpassenger", {player_obj_id, getobject(m_vehicleId)})   
  336.     end
  337.    
  338.     if seat == 0 then
  339.         vehicles[m_vehicleId] = {}
  340.         settonil = registertimer(20, "setnil", m_vehicleId)
  341.     elseif not getdriverplayer(getobject(m_vehicleId)) then
  342.         setupseat = registertimer(0, "setupseattable", {m_vehicleId, player})
  343.     end
  344.    
  345.     local player_obj_id = getplayerobjectid(player)
  346.     if player_obj_id then
  347.         local m_object = getobject(player_obj_id)
  348.         taxi[player].vehicle = getobject(readdword(m_object + 0x11C))
  349.     end
  350.    
  351.     showplayers = registertimer(0, "showPlayers", getobject(m_vehicleId))
  352.    
  353.     return nil
  354. end
  355.  
  356. function OnVehicleEject(player, relevant)
  357.     local m_vehicleId = getplayervehicleid(player)
  358.     if taxi[player].seat == 1 then resetpassenger(player, getobject(getplayerobjectid(player))) end
  359.     checkplayer(player)
  360.     taxi[player] = {}
  361.     return nil
  362. end
  363.  
  364. function showPlayers(id, count, m_vehicle)
  365.     message_players(getdriverplayer(m_vehicle), getgunnerplayer(m_vehicle), getpassengerplayer(m_vehicle))
  366.     return false
  367. end
  368.  
  369. function checkplayer(player)
  370.     if taxi_teams[player] then
  371.         return player
  372.     end
  373.     for k,v in pairs(taxi_teams) do
  374.         if taxi_teams[k] ~= {} then
  375.             for key,value in pairs(taxi_teams[k]) do
  376.                 if value == player then
  377.                     return k
  378.                 end
  379.             end
  380.         end
  381.     end
  382.     return false
  383. end
  384.  
  385. function setupdrivertable(m_vehicleId, driver)
  386.     vehicles[m_vehicleId] = {}
  387.     vehicles[m_vehicleId].players = {}
  388.     vehicles[m_vehicleId].count = 0
  389.     local team = getteam(driver)
  390.     for player=0,15 do
  391.         if getplayer(player) and getteam(player) == team and isinvehicle(player) and getplayervehicleid(player) == m_vehicleId and driver ~= player then
  392.             table.insert(vehicles[m_vehicleId].players, player)
  393.         end
  394.     end
  395. end
  396.  
  397. function setupseattable(id, count, arg)
  398.     local m_vehicleId = arg[1]
  399.     vehicles[m_vehicleId] = {}
  400.     vehicles[m_vehicleId].players = {}
  401.     vehicles[m_vehicleId].count = 0
  402.     local driver = getdriverplayer(getobject(m_vehicleId))
  403.     local team = getteam(arg[2])
  404.     for player=0,15 do
  405.         if getplayer(player) and getteam(player) == team and isinvehicle(player) and getplayervehicleid(player) == m_vehicleId and driver ~= player then
  406.             table.insert(vehicles[m_vehicleId].players, player)
  407.         end
  408.     end
  409.     return false
  410. end
  411.  
  412. function setnil(id, count, m_vehicleId)
  413.     if count >= 20 then return false end
  414.     if vehicles[m_vehicleId] ~= {} then
  415.         vehicles[m_vehicleId] = {}
  416.     end
  417.     return true
  418. end
  419.  
  420. function getplayervehicleid(player)
  421.     local m_objectId = getplayerobjectid(player)
  422.     if m_objectId then return readdword(getobject(m_objectId) + 0x11C) end
  423. end
  424.  
  425. function getdriverobjid(m_vehicle)
  426.     return readdword(m_vehicle + 0x324)
  427. end
  428.  
  429. function getgunnerobjid(m_vehicle)
  430.     return readdword(m_vehicle + 0x328)
  431. end
  432.  
  433. function getpassengerobjid(m_vehicle)
  434.     return readdword(m_vehicle + 0x32C)
  435. end
  436.  
  437. function getdriverplayer(m_vehicle)
  438.     local obj_id = readdword(m_vehicle + 0x324)
  439.     if obj_id and obj_id ~= 0xFFFFFFFF then return objectidtoplayer(obj_id) end
  440. end
  441.  
  442. function getgunnerplayer(m_vehicle)
  443.     local obj_id = readdword(m_vehicle + 0x328)
  444.     if obj_id ~= 0xFFFFFFFF then return objectidtoplayer(obj_id) end
  445. end
  446. function getpassengerplayer(m_vehicle)
  447.     local obj_id = getpassengerobjid(m_vehicle)
  448.     if obj_id ~= 0xFFFFFFFF then return objectidtoplayer(obj_id) end
  449. end
  450.  
  451. function message_players(driver, gunner, passenger)
  452.     local t,n = {}, {}
  453.     if driver then
  454.         table.insert(t, driver)
  455.         table.insert(n, "Driver")
  456.     end
  457.     if gunner then
  458.         table.insert(t, gunner)
  459.         table.insert(n, "Gunner")
  460.     end
  461.     if passenger then
  462.         table.insert(t, passenger)
  463.         table.insert(n, "Passenger")
  464.     end
  465.     for k, v in pairs(t) do
  466.         for key, value in pairs(t) do
  467.             if v ~= value then
  468.                 sendconsoletext(v, n[key] .. " : " .. getname(value))
  469.             end
  470.         end
  471.     end
  472. end
  473.  
  474. function OnClientUpdate(player)
  475.     if hails[player] > 0 then hails[player] = hails[player] - 1 end
  476.     if crouch_to_taxi then
  477.         if not isinvehicle(player) then
  478.             local m_objectId = getplayerobjectid(player)
  479.             if m_objectId then
  480.                 local id = resolveplayer(player)
  481.                 if readbit(getobject(m_objectId) + 0x208, 0) and crouch[id] == nil then
  482.                     crouch[id] = OnPlayerCrouch(player)
  483.                 elseif readbyte(getobject(m_objectId) + 0x2A0) == 4 and crouch[id] ~= nil then
  484.                     crouch[id] = nil
  485.                 end
  486.             end
  487.         end
  488.     end
  489. end
  490.  
  491. function OnPlayerCrouch(player)
  492.     if hails[player] == 0 then
  493.         if taxi_limit == false or calls[player] < taxi_limit then
  494.             getTaxi(player)
  495.             hails[player] = (crouch_time*30)
  496.         else
  497.             sendconsoletext(player, "**Taxi** You have reached the max amount of taxi calls for this game.")
  498.         end
  499.     end
  500.     return true
  501. end
  502.  
  503. function assignpassenger(id, count, arg)
  504.     taxi[objectidtoplayer(arg[1])].vehicle = arg[2]
  505.     writedword(arg[2] + 0x32C, arg[1])
  506.     return false
  507. end
  508.  
  509. function checkSpaces(player, team, m_vehicleId)
  510.     local seats = getseats(m_vehicleId)
  511.     if seats > 0 and m_vehicleId then
  512.         for i=0,15 do
  513.             if player ~= i and getplayer(i) and getteam(i) == team and isinvehicle(i) then
  514.                 if getplayervehicleid(i) == m_vehicleId then
  515.                     seats = seats - 1
  516.                 end
  517.             end
  518.         end
  519.     end
  520.     return seats
  521. end
  522.  
  523. function getseats(m_vehicleId)
  524.     local name = gettaginfo(readdword(getobject(m_vehicleId)))
  525.     local seats = 0
  526.     if string.find(name, "ghost") or string.find(name, "banshee") or string.find(name, "turret") then
  527.         seats = 0
  528.     elseif string.find(name, "hog") then
  529.         seats = 2
  530.     elseif string.find(name, "scorpion") then
  531.         seats = 1
  532.     end
  533.     return seats
  534. end
  535.  
  536. function getTaxi(player)
  537.     local check = checkplayer(player)
  538.     local player2
  539.     if check then
  540.         for k,v in pairs(taxi_teams[check]) do
  541.             if isinvehicle(v) and checkSpaces(v, getteam(v), getplayervehicleid(v)) > 0 then
  542.                 player2 = v
  543.                 break
  544.             end
  545.         end
  546.     else
  547.         for i=0,15 do
  548.             if player ~= i and getplayer(i) and getteam(i) == getteam(player) and isinvehicle(i) and not checkplayer(i) and checkSpaces(i, getteam(i), getplayervehicleid(i)) > 0 then
  549.                 player2 = i
  550.                 break
  551.             end
  552.         end
  553.     end
  554.     if player2 then
  555.         InjectPlayer(player, getplayervehicleid(player2), true)
  556.     else
  557.         sendconsoletext(player, "**Taxi** Sorry no taxi is available at the moment. Please try again later.")
  558.     end
  559. end
  560.  
  561. function getWalker(player)
  562.     local m_vehicleId = getplayervehicleid(player)
  563.     if m_vehicleId then
  564.         if checkSpaces(player, getteam(player), m_vehicleId) > 0 then
  565.             local check = checkplayer(player)
  566.             local player2
  567.             if check then
  568.                 for k,v in pairs(taxi_teams[check]) do
  569.                     if not isinvehicle(v) then
  570.                         player2 = v
  571.                         break
  572.                     end
  573.                 end
  574.             else
  575.                 for i=0,15 do
  576.                     if player ~= i and getplayer(i) and getteam(i) == getteam(player) and not isinvehicle(i) and not checkplayer(i) and getplayerobjectid(i) then
  577.                         player2 = i
  578.                         break
  579.                     end
  580.                 end
  581.             end
  582.             if player2 then
  583.                 InjectPlayer(player2, m_vehicleId, false)
  584.             else
  585.                 sendconsoletext(player, "**Gun Me** No teammates, or no available teammates.")
  586.             end
  587.         else
  588.             sendconsoletext(player, "**Gun Me** No available seats in your vehicle.")
  589.         end
  590.     end
  591. end
  592.  
  593. function InjectPlayer(player, m_vehicleId, count)
  594.     local bool = false
  595.     if m_vehicleId then
  596.         local m_vehicle = getobject(m_vehicleId)
  597.         local driver = readdword(m_vehicle + 0x324)
  598.         local gunner = readdword(m_vehicle + 0x328)
  599.         local passenger = readdword(m_vehicle + 0x32C)
  600.         if driver == 0xFFFFFFFF then
  601.             entervehicle(player, m_vehicleId, 0)
  602.             bool = true
  603.         elseif gunner == 0xFFFFFFFF then
  604.             entervehicle(player, m_vehicleId, 2)
  605.             bool = true
  606.         elseif passenger_taxi and (passenger == 0xFFFFFFFF or passenger  == 0) then
  607.             entervehicle(player, m_vehicleId, 1)
  608.             bool = true
  609.         end
  610.         if bool and taxi_limit and count then
  611.             calls[player] = calls[player] + 1
  612.             sendconsoletext(player, "**Taxi** You have " .. taxi_limit - calls[player] .. " taxi calls left.")
  613.         elseif not count then
  614.             sendconsoletext(player, "**Gun Me** You have been put into the vehicle by a teammate.")
  615.         end
  616.     end
  617. end
  618.  
  619. function resetpassenger(player, m_object)
  620.     if player then
  621.         if taxi[player].vehicle then
  622.             writedword(taxi[player].vehicle + 0x32C, 0xFFFFFFFF)
  623.         end
  624.     end
  625. end
  626.  
  627. function OnDamageLookup(receiving, causing, tagid)
  628.     if causing then
  629.         local c_player = objectidtoplayer(causing)
  630.         if c_player and isinvehicle(c_player) then
  631.             local m_vehicleId = getplayervehicleid(c_player)
  632.             if m_vehicleId then
  633.                 local m_vehicle = getobject(m_vehicleId)
  634.                 local driver = readdword(m_vehicle + 0x324)
  635.                 local gunner = readdword(m_vehicle + 0x328)
  636.                 if not gunner_damage and (driver == 0xFFFFFFFF) and (gunner == causing) then
  637.                     return false
  638.                 end
  639.             end
  640.         end
  641.     end
  642. end
  643.  
  644. function LoadTags()
  645.     map_ids["beavercreek"] = gettagid("vehi", "vehicles\\rwarthog\\rwarthog")
  646.     map_ids["bloodgulch"] = gettagid("vehi", "vehicles\\rwarthog\\rwarthog")
  647.     map_ids["boardingaction"] = gettagid("vehi", "vehicles\\rwarthog\\rwarthog")
  648.     map_ids["carousel"] = gettagid("vehi", "vehicles\\rwarthog\\rwarthog")
  649.     map_ids["chillout"] = gettagid("vehi", "vehicles\\rwarthog\\rwarthog")
  650.     map_ids["damnation"] = gettagid("vehi", "vehicles\\rwarthog\\rwarthog")
  651.     map_ids["dangercanyon"] = gettagid("vehi", "vehicles\\rwarthog\\rwarthog")
  652.     map_ids["deathisland"] = gettagid("vehi", "vehicles\\rwarthog\\rwarthog")
  653.     map_ids["gephyrophobia"] = gettagid("vehi", "vehicles\\rwarthog\\rwarthog")
  654.     map_ids["hangemhigh"] = gettagid("vehi", "vehicles\\rwarthog\\rwarthog")
  655.     map_ids["icefields"] = gettagid("vehi", "vehicles\\rwarthog\\rwarthog")
  656.     map_ids["infinity"] = gettagid("vehi", "vehicles\\rwarthog\\rwarthog")
  657.     map_ids["longest"] = gettagid("vehi", "vehicles\\rwarthog\\rwarthog")
  658.     map_ids["prisoner"] = gettagid("vehi", "vehicles\\rwarthog\\rwarthog")
  659.     map_ids["putput"] = gettagid("vehi", "vehicles\\rwarthog\\rwarthog")
  660.     map_ids["ratrace"] = gettagid("vehi", "vehicles\\rwarthog\\rwarthog")
  661.     map_ids["sidewinder"] = gettagid("vehi", "vehicles\\rwarthog\\rwarthog")
  662.     map_ids["timberland"] = gettagid("vehi", "vehicles\\rwarthog\\rwarthog")
  663.     map_ids["wizard"] = gettagid("vehi", "vehicles\\rwarthog\\rwarthog")
  664.     -- if you prefer a chain hog for a specific map, replace above "vehicles\\rwarthog\\rwarthog" with "vehicles\\warthog\\mp_warthog" for that map.
  665. end
  666.  
  667. -- Created by H® Shaft thank you to Oxide, AelitePrime, Nugget & Wizard.
  668. -- Visit http://halorace.org/forum/index.php?topic=514.0 or
  669. -- Visit http://pastebin.com/u/HR_Shaft for more phasor scripts
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement