Advertisement
HR_Shaft

Slaughterhouse - a Mini-Game for Halo PC/CE and Sapp

May 27th, 2017
278
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 36.08 KB | None | 0 0
  1. -- Slaughterhouse - a Mini-Game - All Players will get 'slaughtered' - not intended for pussies.
  2.  
  3. -- Players spawn at random locations
  4. -- When a player spawns they will spawn in a rocket hog, in the gunner seat, and will also be the driver
  5. -- If a player tips over/crashes - they will be auto-flipped to keep drivers on their tires (Thanks to Giraffe)
  6. -- to get a new warthog, players should type: HOG or /HOG
  7. -- If Teamkill is on and a player betrays a teammate, they too will be killed.
  8. -- Various areas on maps are blocked from entering with a vehicle - so you can't hide like a momma's boy.
  9.  
  10. -- Supports: bloodgulch, sidewinder, deathisland, dangercanyon, (and boardingaction - on top of map)
  11. -- Suggested Gametypes: FFA/Team/Rally Race, FFA/Team Slayer, CTF, FFA/Team King of the Hill
  12. -- Suggested Maps: bloodgulch, danger canyon and boardingaction
  13.  
  14. -- ===== Gametypes should NOT spawn vehicles! This script creates them ==========
  15.  
  16. -- NOTE: boardingaction:
  17. -- I suggest FFA/Team Slayer ONLY: - it is NOT compatible with CTF as this script disables picking up the flag,
  18. -- and players spawn ON TOP of map: so no King, no CTF, no SKULL oddball, but can be juggernaught-oddball type (fun!)
  19.  
  20.  
  21. -- Amount of time in seconds before a spawned hog is destroyed after players leave it, and if it has 'no driver'.
  22. destroy_time = 2
  23.  
  24. -- Amount of time in seconds to add to a players respawn time for betrays
  25. respawn_time = 10
  26.  
  27. -- message given to vehicle drivers when they attempt to enter a blocked area
  28. blocked_message = "**BLOCKED!** Vehicles prohibited! ~~ Prohibe los vehiculos!"
  29.  
  30.  
  31. -- sapp api version
  32. api_version = "1.9.0.0"
  33. team_play = false
  34. loop_end = 8
  35. vehicles = {}
  36. cont_check = nil
  37. destroyvehicle = nil
  38.  
  39. function OnScriptLoad()
  40.     register_callback(cb['EVENT_GAME_START'], "OnNewGame")
  41.     register_callback(cb['EVENT_GAME_END'], "OnGameEnd")
  42.     register_callback(cb['EVENT_PRESPAWN'], "OnPlayerPrespawn")
  43.     register_callback(cb['EVENT_SPAWN'], "OnPlayerSpawn")
  44.     register_callback(cb['EVENT_VEHICLE_ENTER'], "OnVehicleEntry")
  45.     register_callback(cb['EVENT_VEHICLE_EXIT'], "OnVehicleExit")
  46.     register_callback(cb['EVENT_TICK'], "OnTick")
  47.     register_callback(cb['EVENT_TEAM_SWITCH'], "ChangeColor")
  48.     register_callback(cb['EVENT_DIE'], "ChangeColor")
  49.     register_callback(cb['EVENT_JOIN'], "OnPlayerJoin")
  50.     register_callback(cb['EVENT_BETRAY'], "OnPlayerBetray")
  51.     register_callback(cb['EVENT_CHAT'], "OnPlayerChat")
  52.     -- begin color
  53.     location_store = sig_scan("741F8B482085C9750C")
  54.     if(location_store == 0) then
  55.         location_store = sig_scan("EB1F8B482085C9750C")
  56.         if(location_store == 0) then
  57.             cprint("Failed to find color assignment signature")
  58.         end
  59.     end
  60.     safe_write(true)
  61.     write_char(location_store,235)
  62.     safe_write(false)
  63.     -- end color   
  64.     if get_var(0, "$gt") ~= "n/a" then
  65.         game_started = true
  66.         map_name = get_var(0,"$map")
  67.         game_type = get_var(0,"$gt")
  68.         team_play = getteamplay()
  69.         Load_Tables()
  70.         execute_command("rider_ejection 0")
  71.         if cont_check == nil then
  72.             cont_check = timer(1000, "continuous_vehicle_check")
  73.         end
  74.     end
  75. end
  76.  
  77. function OnScriptUnload()
  78.     execute_command("rider_ejection 1")
  79. end
  80.  
  81. function OnNewGame()
  82.     game_started = true
  83.     map_name = get_var(0,"$map")
  84.     game_type = get_var(0,"$gt")
  85.     team_play = getteamplay()
  86.     execute_command("rider_ejection 0")
  87.     Load_Tables()
  88.     if team_play then loop_end = 8 else loop_end = 16 end -- default number of spawns for duplicate spawn check
  89.     if cont_check == nil then
  90.         cont_check = timer(1000, "continuous_vehicle_check")
  91.     end
  92.  
  93.     if map_name == "boardingaction" then
  94.         placemarkers = timer(100, "Place_Markers")
  95.         execute_command('disable_object "weapons\\flag\\flag" 0')      
  96.     end
  97.    
  98. end
  99.  
  100. function OnGameEnd()
  101.     game_started = false
  102.     execute_command("rider_ejection 1")
  103.     destroyvehicle = nil   
  104. end
  105.  
  106. function OnPlayerJoin(PlayerIndex)
  107.     ChangeColor(PlayerIndex)
  108.     timedwelcome = timer(7000, "TimedWelcome", PlayerIndex)
  109. end
  110.  
  111. function TimedWelcome(PlayerIndex)
  112.     if player_present(PlayerIndex) and game_started then
  113.         local welcome1 = "~~~~ Welcome to the Driver-Gunner Slaughterhouse! ~~~~"
  114.         rprint(PlayerIndex, "|c " .. welcome1)
  115.         rprint(PlayerIndex,"|n ")
  116.         rprint(PlayerIndex,"|n ")  
  117.         rprint(PlayerIndex,"|n ")
  118.         rprint(PlayerIndex,"|n ")
  119.         rprint(PlayerIndex,"|n ")
  120.         rprint(PlayerIndex,"|n ")
  121.     end
  122.     return false   
  123. end
  124.  
  125. function Place_Markers()
  126.     if game_started then
  127.         if map_name == "boardingaction" then
  128.             spawn_object("weap", "weapons\\flag\\flag", 56.332, -5.123, 63.328) -- center
  129.             spawn_object("weap", "weapons\\flag\\flag", 56.764, -62.689, 47.539) -- below      
  130.             spawn_object("weap", "weapons\\flag\\flag", 55.827, 28.029, 63.338) -- near
  131.             spawn_object("weap", "weapons\\flag\\flag", 55.339, -39.422, 63.328) -- far
  132.             spawn_object("vehi", "vehicles\\c gun turret\\c gun turret_mp", 35.151, -4.693, 63.251, 6.25) -- center left
  133.             spawn_object("vehi", "vehicles\\c gun turret\\c gun turret_mp", 75.993, -5.240, 63.251, 3.11) -- center right          
  134.         end
  135.     end
  136.     return false
  137. end
  138.  
  139. function OnPlayerSpawn(PlayerIndex)
  140.     ChangeColor(PlayerIndex)
  141.     -- execute_command_sequence("ammo me 0 5;mag me 0 5;nades me 0", PlayerIndex)
  142.     local Deaths = tonumber(get_var(PlayerIndex, "$deaths"))
  143.     if player_alive(PlayerIndex) and (game_started == true) then
  144.         timer(1100, "PutInVehicle", PlayerIndex)
  145.         if Deaths > 15 then
  146.             overshield = timer(6000, "GiveOverShield", PlayerIndex)
  147.         end    
  148.     end
  149. end
  150.  
  151. function OnPlayerChat(PlayerIndex, Message)
  152.     local response = nil
  153.     local Message = string.lower(Message)
  154.     local name = get_var(PlayerIndex,"$name")
  155.     if (Message == "help") then
  156.         response = false
  157.         say(PlayerIndex, "~~~~~~~Driver-Gunner Help~~~~~~~")
  158.         say(PlayerIndex, "You will drive from the gunner seat.")
  159.         say(PlayerIndex, "Sometimes you will wreck, if so, we will help")
  160.         say(PlayerIndex, "if you need a warthog, type HOG")
  161.         say_all(string.format("%s is reading HELP. ", tostring(name)))
  162.     elseif (Message == "hog") or (Message == "/hog") or (Message == "/v") then
  163.         response = false
  164.         if isinvehicle(PlayerIndex) then
  165.             say(PlayerIndex, "You already have a hog, DUH!")
  166.         else   
  167.             timer(400, "PutInVehicle", PlayerIndex)
  168.         end
  169.         say_all(string.format("%s requested a HOG. ", tostring(name))) 
  170.     elseif (Message == "coord") then
  171.         response = false
  172.         local player_static = get_player(PlayerIndex)
  173.         local x,y,z = GetPlayerCoords(PlayerIndex)
  174.         local Z = z+0.3
  175.         local rotation = read_float(player_static + 0x138)
  176.         local map_name = get_var(0,"$map")
  177.         local data = string.format("%s, %s, %s, %s, %s", tostring(map_name),tostring(x),tostring(y),tostring(Z),tostring(math.round(rotation, 2)))
  178.         execute_command("log_note \""..data.."\"") 
  179.         say(PlayerIndex, "XYZR: " .. x .. ", " .. y .. ", " .. Z .. ", " .. math.round(rotation, 2))   
  180.     else
  181.         response = true
  182.     end
  183.     return response
  184. end
  185.  
  186. function OnPlayerBetray(PlayerIndex, VictimIndex)
  187.     if not team_play then return end
  188.     if not player_present(PlayerIndex) then return end
  189.     local name = get_var(PlayerIndex,"$name")
  190.     if player_alive(PlayerIndex) and game_started then
  191.         local respawn_time_old = read_dword(get_player(PlayerIndex) + 0x30)
  192.         write_dword(get_player(PlayerIndex) + 0x30, respawn_time_old + 30 * respawn_time)
  193.         kill(PlayerIndex)
  194.         write_dword(get_player(PlayerIndex) + 0x30, respawn_time_old)
  195.         say(PlayerIndex, name .. "PLEASE AVOID TEAMKILLS, AIM CAREFULLY! NOW =YOU= DIE!")
  196.         say(PlayerIndex, name .. "NO MATAR A COMPANEROS DE EQUIPO, APUNTAR CON CUIDADO ! AHORA SE MUERE!")
  197.         say(PlayerIndex, respawn_time .. " seconds added respawn time! ~~ ".. respawn_time .. " segundos anadidos a su tiempo de desove!")
  198.     end
  199. end
  200.  
  201. function OnVehicleEntry(PlayerIndex, Seat)
  202.     if (game_started == true) then 
  203.         execute_command("rider_ejection 0", PlayerIndex)
  204.         if Seat == "0" then
  205.             say(PlayerIndex, "You are driver and gunner! Go! ~~ Estas conductor y artillero! Conduce!")
  206.         end
  207.     end
  208. end
  209.  
  210. function OnVehicleExit(PlayerIndex)
  211.     if player_alive(PlayerIndex) and (game_started == true) then
  212.         rprint(PlayerIndex, "|cPlease STAY in your vehicle! ~~ Por favor, PERMANEZCA en su vehiculo!")
  213.         rprint(PlayerIndex, "|cType HOG to get a vehicle ~~ Escriba HOG para conseguir un vehiculo.")
  214.         rprint(PlayerIndex,"|n ")  
  215.         rprint(PlayerIndex,"|n ")
  216.         rprint(PlayerIndex,"|n ")
  217.         rprint(PlayerIndex,"|n ")
  218.         rprint(PlayerIndex,"|n ")      
  219.     end
  220. end
  221.  
  222. function Punish(PlayerIndex)
  223.     if player_alive(PlayerIndex) and (game_started == true) then
  224.         local respawn_time_old = read_dword(get_player(PlayerIndex) + 0x30)
  225.         write_dword(get_player(PlayerIndex) + 0x30, respawn_time_old + 30 * respawn_time)
  226.         kill(PlayerIndex)
  227.         write_dword(get_player(PlayerIndex) + 0x30, respawn_time_old)
  228.     else
  229.         return false
  230.     end
  231.     return false   
  232. end    
  233.  
  234. function GiveOverShield(PlayerIndex)
  235.     if (game_started == true) then
  236.         if player_alive(PlayerIndex) then
  237.             local name = get_var(PlayerIndex,"$name")
  238.             say(PlayerIndex, "** " .. name .. " ** You're gettin your ass kicked, here's an over-shield, cupcake.")
  239.             local ObjectID = spawn_object("eqip", "powerups\\over shield") 
  240.             powerup_interact(ObjectID, PlayerIndex)
  241.         end
  242.     end
  243.     return false
  244. end
  245.  
  246. function PutInVehicle(PlayerIndex)
  247.     if (game_started == true) then
  248.         if not isinvehicle(PlayerIndex) then
  249.             local player_object = get_dynamic_player(PlayerIndex)
  250.             if (player_object ~= 0) then
  251.                 local player_static = get_player(PlayerIndex)
  252.                 local x,y,z = read_vector3d(player_object + 0x5C)
  253.                 local rotation = read_float(player_static + 0x138)
  254.                 local vehicleId = spawn_object("vehi", "vehicles\\rwarthog\\rwarthog", x, y, z+0.5, rotation)
  255.                 if vehicleId then
  256.                     table.insert(vehicles, {vehicleId, tonumber(destroy_time)})                        
  257.                     enter_vehicle(vehicleId, PlayerIndex, 0)
  258.                     enter_vehicle(vehicleId, PlayerIndex, 2)
  259.                 end
  260.             end
  261.         end
  262.     end
  263.     return false
  264. end
  265.  
  266. function OnTick()
  267.     if (game_started == true) then
  268.         for PlayerIndex=1,16 do
  269.             if player_alive(PlayerIndex) then
  270.                 local player_object = get_dynamic_player(PlayerIndex)
  271.                 local player_obj_id = read_dword(get_player(PlayerIndex) + 0x34)
  272.                 local x,y,z = read_vector3d(player_object + 0x5C)
  273.                 local vehicleId = read_dword(player_object + 0x11C)
  274.                 local vehicle_object = get_object_memory(vehicleId)
  275.                 local obj_health = tonumber(get_var(PlayerIndex, "$hp"))
  276.                 if (vehicleId ~= 0xFFFFFFFF) then
  277.                     flip_vehicle(vehicle_object)
  278.                 end            
  279.                 if (player_object ~= 0) then
  280.                     -- vehicle blocked areas per map
  281.                     if map_name == "bloodgulch" then
  282.                         local health_lapnav = inSphere(player_obj_id, 60.987, -121.606, 0.274, 1)
  283.                         if health_lapnav then
  284.                             if (obj_health < 1) then
  285.                                 bonushealth = timer(3000, "Bonus_HP", PlayerIndex)
  286.                             end
  287.                         end                
  288.                         local block1 = inSphere(player_obj_id, 95.64, -155.22, -0.07, 2)
  289.                         local block2 = inSphere(player_obj_id, 95.49, -164.05, -0.03, 2)
  290.                         local block3 = inSphere(player_obj_id, 95.63, -159.42, -0.2, 2)
  291.                         local block4 = inSphere(player_obj_id, 96.65, -115.62, 3.79, 2)
  292.                         local block5 = inSphere(player_obj_id, 99.07, -100.57, 4.24, 2)
  293.                         local block6 = inSphere(player_obj_id, 69.05, -92.24, 4.71, 2) -- cave/4th nav
  294.                         local block7 = inSphere(player_obj_id, 71.30, -85.51, 5.66, 2) -- cave/4th nav
  295.                         local block8 = inSphere(player_obj_id, 40.06, -83.70, -0.01, 2)
  296.                         local block9 = inSphere(player_obj_id, 40.19, -74.59, 0.03, 2)
  297.                         local block10 = inSphere(player_obj_id, 40.17, -79.10, -0.88, 2)
  298.                         if isinvehicle(PlayerIndex) then
  299.                             if block1 then moveobject(player_obj_id, 95.79, -150.45, 0.06+0.3) say(PlayerIndex, blocked_message) end               
  300.                             if block2 then moveobject(player_obj_id, 95.92, -168.40, 0.18+0.3) say(PlayerIndex, blocked_message) end               
  301.                             if block3 then moveobject(player_obj_id, 95.79, -150.45, 0.06+0.3) say(PlayerIndex, blocked_message) end
  302.                             if block4 then moveobject(player_obj_id, 91.85, -121.03, 2.45+0.3) say(PlayerIndex, blocked_message) end               
  303.                             if block5 then moveobject(player_obj_id, 97.15, -96.86, 4.40+0.3) say(PlayerIndex, blocked_message) end                
  304.                             --if block6 then moveobject(player_obj_id, 73.42, -92.75, 4.68+0.3) say(PlayerIndex, blocked_message) end                  
  305.                             --if block7 then moveobject(player_obj_id, 66.03, -81.32, 1.14+0.3) say(PlayerIndex, blocked_message) end              
  306.                             if block8 then moveobject(player_obj_id, 40.40, -88.23, 0.10+0.3) say(PlayerIndex, blocked_message) end
  307.                             if block9 then moveobject(player_obj_id, 39.91, -70.12, 0.28+0.3) say(PlayerIndex, blocked_message) end
  308.                             if block10 then moveobject(player_obj_id, 39.91, -70.12, 0.28+0.3) say(PlayerIndex, blocked_message) end
  309.                         end
  310.                        
  311.                     elseif map_name == "boardingaction" then
  312.                    
  313.                         local health_lapnav = inSphere(player_obj_id, 35.151, -4.693, 63.251, 1)
  314.                         if health_lapnav then
  315.                             if (obj_health < 1) then
  316.                                 bonushealth = timer(3000, "Bonus_HP", PlayerIndex)
  317.                             end
  318.                         end
  319.                         local near = inSphere(player_obj_id, 55.827, 28.029, 63.338, 1.5)
  320.                         local far = inSphere(player_obj_id, 55.339, -39.422, 63.328, 1.5)          
  321.                         local center = inSphere(player_obj_id, 56.332, -5.123, 63.242, 1.5)
  322.                         local below = inSphere(player_obj_id, 56.764, -62.689, 47.539, 1.5)
  323.                         if below then
  324.                             moveobject(player_obj_id, 56.332, -5.123, 63.242)  
  325.                         end
  326.                         if near and isinvehicle(PlayerIndex) then
  327.                             moveobject(player_obj_id, 56.332, -5.123, 63.242)
  328.                         end
  329.                         if far and isinvehicle(PlayerIndex) then
  330.                             moveobject(player_obj_id, 56.332, -5.123, 63.242)
  331.                         end
  332.                         if center and isinvehicle(PlayerIndex) then                
  333.                             local rspin = rand(1,11)
  334.                             if rspin >=6 then
  335.                                 rspin = -0.6
  336.                             else
  337.                                 rspin = 0.6
  338.                             end
  339.                             moveobject(player_obj_id, 56.332, -5.123, 66.978)
  340.                             write_float(vehicle_object + 0x70, 0.25)   
  341.                             write_float(vehicle_object + 0x94, rspin)
  342.                             rprint(PlayerIndex, "|c~~ Whoa! ~~ Ay Caramba! ~~")                        
  343.                         end
  344.  
  345.                     elseif map_name == "sidewinder" then
  346.                    
  347.                         local health_lapnav = inSphere(player_obj_id, 1.984, 54.499, -2.801, 1)
  348.                         if health_lapnav then
  349.                             if (obj_health < 1) then
  350.                                 bonushealth = timer(3000, "Bonus_HP", PlayerIndex)
  351.                             end
  352.                         end
  353.                         local red_tun = inSphere(player_obj_id, -18.892, -35.596, -3.551, 1.5)
  354.                         local blu_tun = inSphere(player_obj_id, 17.511, -29.548, -3.611, 1.5)              
  355.                         if red_tun and isinvehicle(PlayerIndex) then
  356.                             moveobject(player_obj_id, -20.456, -33.856, -3.551)
  357.                             say(PlayerIndex, blocked_message)                          
  358.                         end
  359.                         if blu_tun and isinvehicle(PlayerIndex) then
  360.                             moveobject(player_obj_id, 18.968, -28.187, -3.611)
  361.                             say(PlayerIndex, blocked_message)
  362.                         end
  363.  
  364.                     elseif map_name == "deathisland" then
  365.                    
  366.                         local health_lapnav1 = inSphere(player_obj_id, 1.499, -55.629, 1.645, 1) -- lap nav
  367.                         local health_lapnav2 = inSphere(player_obj_id, -5.238, 57.429, 2.103, 1) -- bottom jump hill sandy
  368.                         if health_lapnav1 or health_lapnav2 then
  369.                             if (obj_health < 1) then
  370.                                 bonushealth = timer(3000, "Bonus_HP", PlayerIndex)
  371.                             end
  372.                         end                    
  373.                         local red_base1 = inSphere(player_obj_id, -26.631, -10.149, 9.988, 1.5)
  374.                         local red_base2 = inSphere(player_obj_id, -26.622, -3.865, 9.988, 1.5)
  375.                         local blu_base1 = inSphere(player_obj_id, 29.824, 19.246, 8.665, 1.5)
  376.                         local blu_base2 = inSphere(player_obj_id, 29.956, 12.850, 8.665, 1.5)                      
  377.                         if red_base1 or red_base2 and isinvehicle(PlayerIndex) then
  378.                             moveobject(player_obj_id, -31.875, -7.144, 9.868)
  379.                             say(PlayerIndex, blocked_message)                          
  380.                         end
  381.                         if blu_base1 or blu_base2 and isinvehicle(PlayerIndex) then
  382.                             moveobject(player_obj_id, 35.013, 16.012, 8.485)
  383.                             say(PlayerIndex, blocked_message)
  384.                         end
  385.                        
  386.                     elseif map_name == "dangercanyon" then
  387.                    
  388.                         local health_lapnav = inSphere(player_obj_id, -0.110, 40.452, -5.807, 1) -- lap nav
  389.                         if health_lapnav then
  390.                             if (obj_health < 1) then
  391.                                 bonushealth = timer(3000, "Bonus_HP", PlayerIndex)
  392.                             end
  393.                         end
  394.                         local red_tun = inSphere(player_obj_id, -12.165, 2.978, -2.109, 1.5)
  395.                         local blu_tun = inSphere(player_obj_id, 11.982, 2.954, -2.109, 1.5)
  396.                         local red_tele = inSphere(player_obj_id, -4.034, -3.469, 1.874, 1)
  397.                         local blu_tele = inSphere(player_obj_id, 3.859, -3.452, 1.874, 1)                      
  398.                         if red_tun and isinvehicle(PlayerIndex) then
  399.                             moveobject(player_obj_id, -12.125, -3.429, -2.109)
  400.                             say(PlayerIndex, blocked_message)                          
  401.                         end
  402.                         if blu_tun and isinvehicle(PlayerIndex) then
  403.                             moveobject(player_obj_id, 11.983, -3.473, -2.109)
  404.                             say(PlayerIndex, blocked_message)
  405.                         end
  406.                         if red_tele and isinvehicle(PlayerIndex) then
  407.                             moveobject(player_obj_id, 8.027, -3.487, 0.004)
  408.                             rprint(PlayerIndex, "|c~~ Whoa! ~~ Ay Caramba! ~~")
  409.                         end
  410.                         if blu_tele and isinvehicle(PlayerIndex) then
  411.                             moveobject(player_obj_id, -8.002, -3.640, 0.004)
  412.                             rprint(PlayerIndex, "|c~~ Whoa! ~~ Ay Caramba! ~~")
  413.                         end                        
  414.                        
  415.                     end                
  416.                 end
  417.             end
  418.         end
  419.     end    
  420. end
  421.  
  422. function Bonus_HP(PlayerIndex)
  423.     if (game_started == true)  then
  424.         if player_alive(PlayerIndex) then
  425.             local player_object = get_dynamic_player(PlayerIndex)
  426.             if player_object ~= 0 then
  427.                 local obj_health = tonumber(get_var(PlayerIndex, "$hp"))
  428.                 if obj_health < 1 then
  429.                     write_float(player_object + 0xE0, 1)
  430.                     rprint(PlayerIndex, "|cYour health has been restored. ~~ Su salud se ha restaurado.")
  431.                 end
  432.             end
  433.         end
  434.     end
  435.     return false
  436. end
  437.  
  438. function flip_vehicle(object)
  439.     if (read_bit(object + 0x8B, 7) == 1) then
  440.         if (read_bit(object + 0x10, 1) == 0) then
  441.             return
  442.         end
  443.         write_vector3d(object + 0x80, 0, 0, 1)
  444.     end
  445. end
  446.                
  447. function continuous_vehicle_check()
  448.     if (game_started == true) then
  449.         for _,id in pairs(vehicles) do
  450.             local veh_obj = get_object_memory(id[1])
  451.             if (veh_obj ~= 0) then
  452.                 local driver = read_dword(veh_obj + 0x324) 
  453.                 if (driver == 0xFFFFFFFF) and (id[2] <= 0) then
  454.                     destroyvehicle = timer(34, "destroy_vehicle", id[1])
  455.                 elseif (driver == 0xFFFFFFFF) and (id[2] > 0) then
  456.                     id[2] = id[2] - 1      
  457.                 elseif (driver ~= 0xFFFFFFFF) then
  458.                     id[2] = destroy_time
  459.                 end    
  460.             end
  461.         end
  462.         return true
  463.     else
  464.         return false
  465.     end
  466. end
  467.  
  468. function destroy_vehicle(ObjectID)
  469.     if (game_started == true) then
  470.         local veh_obj = get_object_memory(ObjectID)
  471.         if (veh_obj == 0) then return false end
  472.         table.remove(vehicles, ObjectID)
  473.         destroy_object(ObjectID)
  474.     end
  475.     return false
  476. end
  477.                
  478. function OnPlayerPrespawn(PlayerIndex)
  479.     local player_object = get_dynamic_player(PlayerIndex)
  480.     if (player_object ~= 0) then
  481.         if (game_type == "race") then -- players will spawn at either teams base, random coin toss
  482.             local coin_toss = rand(1,3)
  483.             if (coin_toss == 1) then
  484.                 local redcoord = SelectRedSpawnCoord()
  485.                 if redcoord then       
  486.                     write_vector3d(player_object + 0x5C, red_spawn_coord[redcoord][1], red_spawn_coord[redcoord][2], red_spawn_coord[redcoord][3]+0.3)
  487.                     write_dword(get_player(PlayerIndex) + 0xF0, 0)
  488.                     write_dword(get_player(PlayerIndex) + 0x164, 0)            
  489.                     local fx, fy, fz = red_rotation[1][1],red_rotation[1][2],red_rotation[1][3]
  490.                     local px, py, pz = GetPlayerCoords(PlayerIndex)
  491.                     local vx = fx - px
  492.                     local vy = fy - py
  493.                     local vz = fz - pz
  494.                     local magnitude = math.sqrt(vx*vx + vy*vy + vz*vz)
  495.                     vx = vx / magnitude
  496.                     vy = vy / magnitude
  497.                     vz = vz / magnitude    
  498.                     write_float(player_object + 0x74, vx)
  499.                     write_float(player_object + 0x78, vy)
  500.                     write_float(player_object + 0x7c, vz)          
  501.                 end
  502.             elseif (coin_toss == 2) then
  503.                 local blucoord = SelectBluSpawnCoord()
  504.                 if blucoord then       
  505.                     write_vector3d(player_object + 0x5C, blu_spawn_coord[blucoord][1], blu_spawn_coord[blucoord][2], blu_spawn_coord[blucoord][3]+0.3)
  506.                     write_dword(get_player(PlayerIndex) + 0xF0, 0)
  507.                     write_dword(get_player(PlayerIndex) + 0x164, 0)
  508.                     local fx, fy, fz = blue_rotation[1][1],blue_rotation[1][2],blue_rotation[1][3]
  509.                     local px, py, pz = GetPlayerCoords(PlayerIndex)
  510.                     local vx = fx - px
  511.                     local vy = fy - py
  512.                     local vz = fz - pz
  513.                     local magnitude = math.sqrt(vx*vx + vy*vy + vz*vz)
  514.                     vx = vx / magnitude
  515.                     vy = vy / magnitude
  516.                     vz = vz / magnitude    
  517.                     write_float(player_object + 0x74, vx)
  518.                     write_float(player_object + 0x78, vy)
  519.                     write_float(player_object + 0x7c, vz)                          
  520.                 end
  521.             end
  522.         else -- it's not race
  523.             if team_play then -- players will only spawn with their team
  524.                 local team = get_var(PlayerIndex, "$team")
  525.                 if team == "red" then
  526.                     local redcoord = SelectRedSpawnCoord()
  527.                     if redcoord then       
  528.                         write_vector3d(player_object + 0x5C, red_spawn_coord[redcoord][1], red_spawn_coord[redcoord][2], red_spawn_coord[redcoord][3]+0.3)
  529.                         write_dword(get_player(PlayerIndex) + 0xF0, 0)
  530.                         write_dword(get_player(PlayerIndex) + 0x164, 0)            
  531.                         local fx, fy, fz = red_rotation[1][1],red_rotation[1][2],red_rotation[1][3]
  532.                         local px, py, pz = GetPlayerCoords(PlayerIndex)
  533.                         local vx = fx - px
  534.                         local vy = fy - py
  535.                         local vz = fz - pz
  536.                         local magnitude = math.sqrt(vx*vx + vy*vy + vz*vz)
  537.                         vx = vx / magnitude
  538.                         vy = vy / magnitude
  539.                         vz = vz / magnitude    
  540.                         write_float(player_object + 0x74, vx)
  541.                         write_float(player_object + 0x78, vy)
  542.                         write_float(player_object + 0x7c, vz)          
  543.                     end
  544.                 elseif team == "blue" then
  545.                     local blucoord = SelectBluSpawnCoord()
  546.                     if blucoord then       
  547.                         write_vector3d(player_object + 0x5C, blu_spawn_coord[blucoord][1], blu_spawn_coord[blucoord][2], blu_spawn_coord[blucoord][3]+0.3)
  548.                         write_dword(get_player(PlayerIndex) + 0xF0, 0)
  549.                         write_dword(get_player(PlayerIndex) + 0x164, 0)
  550.                         local fx, fy, fz = blue_rotation[1][1],blue_rotation[1][2],blue_rotation[1][3]
  551.                         local px, py, pz = GetPlayerCoords(PlayerIndex)
  552.                         local vx = fx - px
  553.                         local vy = fy - py
  554.                         local vz = fz - pz
  555.                         local magnitude = math.sqrt(vx*vx + vy*vy + vz*vz)
  556.                         vx = vx / magnitude
  557.                         vy = vy / magnitude
  558.                         vz = vz / magnitude    
  559.                         write_float(player_object + 0x74, vx)
  560.                         write_float(player_object + 0x78, vy)
  561.                         write_float(player_object + 0x7c, vz)                          
  562.                     end
  563.                 end
  564.             else -- players will spawn at either teams base, random coin toss
  565.                 local coin_toss = rand(1,3)
  566.                 if (coin_toss == 1) then
  567.                     local redcoord = SelectRedSpawnCoord()
  568.                     if redcoord then       
  569.                         write_vector3d(player_object + 0x5C, red_spawn_coord[redcoord][1], red_spawn_coord[redcoord][2], red_spawn_coord[redcoord][3]+0.3)
  570.                         write_dword(get_player(PlayerIndex) + 0xF0, 0)
  571.                         write_dword(get_player(PlayerIndex) + 0x164, 0)            
  572.                         local fx, fy, fz = red_rotation[1][1],red_rotation[1][2],red_rotation[1][3]
  573.                         local px, py, pz = GetPlayerCoords(PlayerIndex)
  574.                         local vx = fx - px
  575.                         local vy = fy - py
  576.                         local vz = fz - pz
  577.                         local magnitude = math.sqrt(vx*vx + vy*vy + vz*vz)
  578.                         vx = vx / magnitude
  579.                         vy = vy / magnitude
  580.                         vz = vz / magnitude    
  581.                         write_float(player_object + 0x74, vx)
  582.                         write_float(player_object + 0x78, vy)
  583.                         write_float(player_object + 0x7c, vz)          
  584.                     end
  585.                 elseif (coin_toss == 2) then
  586.                     local blucoord = SelectBluSpawnCoord()
  587.                     if blucoord then       
  588.                         write_vector3d(player_object + 0x5C, blu_spawn_coord[blucoord][1], blu_spawn_coord[blucoord][2], blu_spawn_coord[blucoord][3]+0.3)
  589.                         write_dword(get_player(PlayerIndex) + 0xF0, 0)
  590.                         write_dword(get_player(PlayerIndex) + 0x164, 0)
  591.                         local fx, fy, fz = blue_rotation[1][1],blue_rotation[1][2],blue_rotation[1][3]
  592.                         local px, py, pz = GetPlayerCoords(PlayerIndex)
  593.                         local vx = fx - px
  594.                         local vy = fy - py
  595.                         local vz = fz - pz
  596.                         local magnitude = math.sqrt(vx*vx + vy*vy + vz*vz)
  597.                         vx = vx / magnitude
  598.                         vy = vy / magnitude
  599.                         vz = vz / magnitude    
  600.                         write_float(player_object + 0x74, vx)
  601.                         write_float(player_object + 0x78, vy)
  602.                         write_float(player_object + 0x7c, vz)                          
  603.                     end
  604.                 end            
  605.             end
  606.         end    
  607.     end        
  608. end
  609.  
  610. function SelectRedSpawnCoord()
  611.     if #red_spawn_coord > 0 then
  612.         local index = rand(1, #red_spawn_coord+1)
  613.         local coord = red_spawn_coord[index]
  614.         if (CheckForDuplicateSpawn(coord) == false) then
  615.             return index    
  616.         end
  617.     end    
  618.     return nil 
  619. end
  620.  
  621. function SelectBluSpawnCoord()
  622.     if #blu_spawn_coord > 0 then
  623.         local index = rand(1, #blu_spawn_coord+1)
  624.         local coord = blu_spawn_coord[index]   
  625.         if (CheckForDuplicateSpawn(coord) == false) then
  626.             return index       
  627.         end
  628.     end
  629.     return nil 
  630. end
  631.  
  632. function CheckForDuplicateSpawn(coord)
  633.     for i=1,loop_end do
  634.         local dyn_player = get_dynamic_player(i)
  635.         if(dyn_player ~= 0) then
  636.             local px,py,pz = GetPlayerCoords(i)
  637.             local distance = DistanceFormula(coord[1],coord[2],coord[3],px,py,pz)
  638.             if (distance < 1/3) then
  639.                 return true
  640.             end
  641.         end
  642.     end
  643.     return false
  644. end
  645.  
  646. function DistanceFormula(x1,y1,z1,x2,y2,z2)
  647.     return math.sqrt(math.pow(x1 - x2,2) + math.pow(y1 - y2,2) + math.pow(z1 - z2,2))
  648. end
  649.  
  650. -- Colors:
  651. -- 0 = white, 1 = black, 2 = red, 3 = blue, 4 = gray, 5 = yellow, 6 = green
  652. -- 7 = pink, 8 = purple, 9 = cyan, 10 = cobalt, 11 = orange, 12 = teal, 13 = sage,
  653. -- 14 = brown, 15 = tan, 16 = maroon, 17 = salmon
  654. SKITTLES = {0,2,3,5,6,7,8,9,10,11,12,13,17} -- no dark colors: no black, gray, brown, tan, maroon
  655. function ChangeColor(PlayerIndex)
  656.     local color = rand(1, #SKITTLES+1) --old: rand(0, 18)
  657.     local red_color = 0
  658.     local blue_color = 11
  659.     if map_name == "boardingaction" then red_color = 7 blue_color = 5 end
  660.     if (player_present(PlayerIndex) == true) then
  661.         if team_play then
  662.             if (get_var(PlayerIndex,"$team") == "red") then
  663.                 write_word(get_player(PlayerIndex) + 0x60, red_color)
  664.             else
  665.                 write_word(get_player(PlayerIndex) + 0x60, blue_color)
  666.             end    
  667.         else
  668.             write_word(get_player(PlayerIndex) + 0x60, color)
  669.         end
  670.     end
  671. end
  672.  
  673. function Load_Tables()
  674.     red_spawn_coord = {}
  675.     blu_spawn_coord = {}
  676.     ffa_blu_spawn_coord = {}
  677.     ffa_red_spawn_coord = {}
  678.     red_rotation = {}
  679.     blue_rotation = {}
  680.     if map_name == "bloodgulch" then
  681.         red_rotation[1] = {60.987, -121.606, 0.274} -- direction a red player faces relative to this x,y,z coordinate (1st nav)
  682.         blue_rotation[1] = {60.987, -121.606, 0.274} -- direction a blue player faces relative to this x,y,z coordinate(1st nav)
  683.         if team_play then loop_end = 14 else loop_end = 28 end -- default number of spawns for duplicate spawn check
  684.         -- 14 red player spawns
  685.         red_spawn_coord[1] = {71.972, -149.555, 0.914}
  686.         red_spawn_coord[2] = {83.435, -147.405, 0.134}
  687.         red_spawn_coord[3] = {95.646, -141.733, 0.434}
  688.         red_spawn_coord[4] = {109.604, -133.539, 0.984}
  689.         red_spawn_coord[5] = {110.368, -145.701, 0.314}
  690.         red_spawn_coord[6] = {100.182, -152.792, 0.294}
  691.         red_spawn_coord[7] = {88.121, -159.214, 0.324}
  692.         red_spawn_coord[8] = {108.054, -163.087, 0.294}
  693.         red_spawn_coord[9] = {79.792, -163.393, 0.504}
  694.         red_spawn_coord[10] = {69.950, -172.245, 1.314}
  695.         red_spawn_coord[11] = {86.032, -168.319, 0.324}
  696.         red_spawn_coord[12] = {84.557, -176.190, 0.704}
  697.         red_spawn_coord[13] = {96.490, -175.511, 1.154}
  698.         red_spawn_coord[14] = {110.034, -173.677, 0.784}   
  699.         -- 14 blue player spawns   
  700.         blu_spawn_coord[1] = {56.687, -84.156, 0.324}
  701.         blu_spawn_coord[2] = {47.260, -81.080, 0.264}
  702.         blu_spawn_coord[3] = {42.720, -86.531, 0.294}
  703.         blu_spawn_coord[4] = {45.686, -96.196, 1.734}
  704.         blu_spawn_coord[5] = {30.861, -94.013, 0.974}
  705.         blu_spawn_coord[6] = {23.784, -104.564, 2.664}
  706.         blu_spawn_coord[7] = {33.291, -80.404, 0.214}
  707.         blu_spawn_coord[8] = {25.868, -79.263, 0.744}
  708.         blu_spawn_coord[9] = {13.501, -71.233, 3.974}
  709.         blu_spawn_coord[10] = {27.702, -68.885, 0.854}
  710.         blu_spawn_coord[11] = {41.159, -62.410, 1.264}
  711.         blu_spawn_coord[12] = {47.594, -72.545, 0.124}
  712.         blu_spawn_coord[13] = {52.955, -63.441, 1.684}
  713.         blu_spawn_coord[14] = {63.075, -70.659, 1.734}
  714.     elseif map_name == "boardingaction" then -- top circle duel
  715.         red_rotation[1] = {54.453, -3.000, 63.299} -- direction a red player faces relative to this x,y,z coordinate (1st nav)
  716.         blue_rotation[1] = {54.453, -3.000, 63.299} -- direction a blue player faces relative to this x,y,z coordinate(1st nav)    
  717.         if team_play then loop_end = 12 else loop_end = 24 end
  718.         -- 12 blue player spawns
  719.         red_spawn_coord[1] = {54.646, -22.164, 63.211}
  720.         red_spawn_coord[2] = {60.039, -20.691, 63.211}
  721.         red_spawn_coord[3] = {63.968, -18.362, 63.211}
  722.         red_spawn_coord[4] = {67.747, -14.964, 63.211}
  723.         red_spawn_coord[5] = {70.650, -11.336, 63.211}
  724.         red_spawn_coord[6] = {72.477, -7.185, 63.211}
  725.         red_spawn_coord[7] = {73.282, -2.899, 63.211}
  726.         red_spawn_coord[8] = {72.473, 1.539, 63.211}
  727.         red_spawn_coord[9] = {70.742, 6.051, 63.211}
  728.         red_spawn_coord[10] = {68.074, 9.748, 63.211}
  729.         red_spawn_coord[11] = {64.011, 12.583, 63.211}
  730.         red_spawn_coord[12] = {60.061, 14.715, 63.211}
  731.         -- 12 blue player spawns
  732.         blu_spawn_coord[1] = {54.447, 15.572, 63.211}
  733.         blu_spawn_coord[2] = {50.116, 14.673, 63.211}
  734.         blu_spawn_coord[3] = {46.262, 12.553, 63.211}
  735.         blu_spawn_coord[4] = {43.029, 9.801, 63.211}
  736.         blu_spawn_coord[5] = {40.269, 6.307, 63.211}
  737.         blu_spawn_coord[6] = {38.030, 1.624, 63.211}
  738.         blu_spawn_coord[7] = {37.312, -2.881, 63.211}
  739.         blu_spawn_coord[8] = {37.985, -7.338, 63.211}
  740.         blu_spawn_coord[9] = {40.191, -11.560, 63.211}
  741.         blu_spawn_coord[10] = {42.853, -15.126, 63.211}
  742.         blu_spawn_coord[11] = {46.043, -18.314, 63.211}
  743.         blu_spawn_coord[12] = {49.845, -20.785, 63.211}
  744.     elseif map_name == "sidewinder" then
  745.         red_rotation[1] = {1.984, 54.499, -2.801} -- direction a red player faces relative to this x,y,z coordinate (1st nav)
  746.         blue_rotation[1] = {1.984, 54.499, -2.801} -- direction a blue player faces relative to this x,y,z coordinate(1st nav)         
  747.         if team_play then loop_end = 10 else loop_end = 20 end -- default number of spawns for duplicate spawn check
  748.         -- 10 red player spawns
  749.         red_spawn_coord[1] = {-12.384, 0.223, -3.551}
  750.         red_spawn_coord[2] = {-27.763, -8.341, -3.551}
  751.         red_spawn_coord[3] = {-20.076, -19.530, -3.551}
  752.         red_spawn_coord[4] = {-29.403, -19.944, -3.551}
  753.         red_spawn_coord[5] = {-22.507, -36.581, -3.551}
  754.         red_spawn_coord[6] = {-32.377, -24.577, -3.551}
  755.         red_spawn_coord[7] = {-38.141, -21.449, -3.311}
  756.         red_spawn_coord[8] = {-47.971, -17.862, -3.551}
  757.         red_spawn_coord[9] = {-35.921, -6.185, -3.551}
  758.         red_spawn_coord[10] = {-44.115, 1.357, -3.551}
  759.         -- 10 blue player spawns
  760.         blu_spawn_coord[1] = {20.145, -33.973, -3.611}
  761.         blu_spawn_coord[2] = {27.842, -27.690, -3.381}
  762.         blu_spawn_coord[3] = {34.602, -28.499, -3.381}
  763.         blu_spawn_coord[4] = {44.241, -21.996, -3.491}
  764.         blu_spawn_coord[5] = {43.216, -9.929, -3.771}
  765.         blu_spawn_coord[6] = {48.448, 12.211, -3.711}
  766.         blu_spawn_coord[7] = {35.687, 2.006, -3.711}
  767.         blu_spawn_coord[8] = {19.494, -3.963, -3.611}
  768.         blu_spawn_coord[9] = {29.766, -10.996, -3.611}
  769.         blu_spawn_coord[10] = {18.778, -19.560, -3.611}
  770.     elseif map_name == "deathisland" then
  771.         red_rotation[1] = {-37.972, -7.168, 5.958} -- direction a red player faces relative to this x,y,z coordinate (1st nav)
  772.         blue_rotation[1] = {43.350, 16.334, 4.905} -- direction a blue player faces relative to this x,y,z coordinate(1st nav) 
  773.         if team_play then loop_end = 10 else loop_end = 20 end -- default number of spawns for duplicate spawn check
  774.         -- 10 red player spawns
  775.         red_spawn_coord[1] = {-72.592, 12.072, 1.918}
  776.         red_spawn_coord[2] = {-86.863, 2.426, 1.918}
  777.         red_spawn_coord[3] = {-72.936, -6.734, 1.918}
  778.         red_spawn_coord[4] = {-82.246, -12.163, 1.918}
  779.         red_spawn_coord[5] = {-71.184, -20.207, 1.918}
  780.         red_spawn_coord[6] = {-78.008, -29.144, 1.918}
  781.         red_spawn_coord[7] = {-64.951, -31.880, 1.918}
  782.         red_spawn_coord[8] = {-78.379, -43.287, 1.918}
  783.         red_spawn_coord[9] = {-68.724, -50.679, 1.918}
  784.         red_spawn_coord[10] = {-53.071, -61.466, 1.918}
  785.         -- 10 blue player spawns
  786.         blu_spawn_coord[1] = {67.315, -35.584, 1.985}
  787.         blu_spawn_coord[2] = {69.620, -17.083, 1.985}
  788.         blu_spawn_coord[3] = {83.420, -17.758, 1.985}
  789.         blu_spawn_coord[4] = {73.718, -2.966, 1.985}
  790.         blu_spawn_coord[5] = {88.080, 7.826, 1.985}
  791.         blu_spawn_coord[6] = {74.635, 17.851, 1.985}
  792.         blu_spawn_coord[7] = {82.911, 30.977, 1.985}
  793.         blu_spawn_coord[8] = {73.635, 38.455, 1.985}
  794.         blu_spawn_coord[9] = {68.304, 55.613, 1.985}
  795.         blu_spawn_coord[10] = {63.068, 64.263, 1.985}
  796.     elseif map_name == "dangercanyon" then
  797.         red_rotation[1] = {-0.018, 36.449, -7.517} -- direction a red player faces relative to this x,y,z coordinate (1st nav)
  798.         blue_rotation[1] = {-0.018, 36.449, -7.517} -- direction a blue player faces relative to this x,y,z coordinate(1st nav)
  799.         if team_play then loop_end = 9 else loop_end = 18 end -- default number of spawns for duplicate spawn check
  800.         -- 9 red player spawns
  801.         red_spawn_coord[1] = {-6.805, 55.087, -7.340}
  802.         red_spawn_coord[2] = {-14.742, 53.988, -8.430}
  803.         red_spawn_coord[3] = {-24.504, 48.229, -9.140}
  804.         red_spawn_coord[4] = {-33.591, 38.375, -7.360}
  805.         red_spawn_coord[5] = {-44.865, 33.303, -8.610}
  806.         red_spawn_coord[6] = {-52.497, 28.552, -10.140}
  807.         red_spawn_coord[7] = {-58.111, 19.136, -8.950}
  808.         red_spawn_coord[8] = {-43.594, -0.295, -1.820}
  809.         red_spawn_coord[9] = {-34.229, 24.165, -6.630}
  810.         -- 9 blue player spawns
  811.         blu_spawn_coord[1] = {7.086, 54.012, -7.940}
  812.         blu_spawn_coord[2] = {21.758, 51.079, -8.660}
  813.         blu_spawn_coord[3] = {27.562, 44.293, -9.500}
  814.         blu_spawn_coord[4] = {31.610, 39.054, -7.690}
  815.         blu_spawn_coord[5] = {42.533, 33.726, -7.690}
  816.         blu_spawn_coord[6] = {50.971, 29.671, -9.670}
  817.         blu_spawn_coord[7] = {57.635, 19.581, -8.950}
  818.         blu_spawn_coord[8] = {47.326, -0.289, -1.930}
  819.         blu_spawn_coord[9] = {38.166, 23.633, -7.300}  
  820.     end
  821. end
  822.  
  823. function moveobject(ObjectID, x, y, z)
  824.     if not game_started then return end
  825.     local object = get_object_memory(ObjectID)
  826.     if get_object_memory(ObjectID) ~= 0 then
  827.         local veh_obj = get_object_memory(read_dword(object + 0x11C))
  828.         write_vector3d((veh_obj ~= 0 and veh_obj or object) + 0x5C, x, y, z)
  829.     end
  830. end
  831.  
  832. function inSphere(ObjectID, X, Y, Z, R)
  833.     if not game_started then return end
  834.     if get_object_memory(ObjectID) ~= 0 then
  835.         local x,y,z = getobjectcoords(ObjectID)
  836.         if (X - x)^2 + (Y - y)^2 + (Z - z)^2 <= R then
  837.             return true
  838.         else
  839.             return false
  840.         end
  841.     end
  842. end
  843.  
  844. function getobjectcoords(ObjectID)
  845.     if not game_started then return end
  846.     local object = get_object_memory(ObjectID)
  847.     if get_object_memory(ObjectID) ~= 0 then
  848.         local veh_obj = get_object_memory(read_dword(object + 0x11C))
  849.         if veh_obj ~= 0 then
  850.             object = veh_obj
  851.         end
  852.     end
  853.     return read_vector3d(object + 0x5C)
  854. end
  855.  
  856. function isinvehicle(PlayerIndex)
  857.     local player_object = get_dynamic_player(PlayerIndex)
  858.     if player_object ~= 0 then
  859.         local vehicleId = read_dword(player_object + 0x11C)
  860.         if vehicleId == 0xFFFFFFFF then
  861.             return false
  862.         else
  863.             return true
  864.         end
  865.     else
  866.         return false
  867.     end
  868. end
  869.  
  870. function getteamplay()
  871.    if (get_var(0, "$ffa") == "0") then
  872.        return true
  873.    else
  874.        return false
  875.    end
  876. end
  877.  
  878. function GetPlayerCoords(PlayerIndex)
  879.     local player_object = get_dynamic_player(PlayerIndex)
  880.     if (player_object ~= 0) then
  881.         local x,y,z = read_vector3d(get_dynamic_player(PlayerIndex) + 0x5C)
  882.         local vehicle_objectid = read_dword(player_object + 0x11C)
  883.         local vehicle_object = get_object_memory(vehicle_objectid)
  884.         if (vehicle_object ~= 0 and vehicle_object ~= nil) then
  885.             local vx,vy,vz = read_vector3d(vehicle_object + 0x5C)
  886.             x = x + vx
  887.             y = y + vy
  888.             z = z + vz
  889.         end
  890.         return math.round(x, 2),math.round(y, 2),math.round(z, 2)
  891.     end
  892.     return nil 
  893. end
  894.  
  895. function math.round(num, idp)
  896.   return tonumber(string.format("%." .. (idp or 0) .. "f", num))
  897. end
  898.  
  899. function OnError(Message)
  900.     print(debug.traceback())
  901. end
  902.  
  903. -- Created by H® Shaft
  904. -- Visit http://halorace.org/forum/index.php
  905.  
  906. -- The player -db-GoNe/Juhleek - a well spoken liar, cheat.
  907. -- -db- is: "diverging from the believable" - How ironic. A race clan where admins use rcon to favor themselves to win.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement