xyz Posted April 15, 2016 Posted April 15, 2016 I'm in middle of making a hospital spawn script, but how can I get the respawns from table and spawn the player to the one that is nearest? local LSH = {2030.03125, -1418.8076171875, 16.9921875} local LSMH = {2030.03515625, -1418.8623046875, 16.9921875} local hospitals = {LSH, LSMH} function respawn(player) spawnPlayer() fadeCamera(player, true) setCameraTarget(player, player) end
Electro88 Posted April 15, 2016 Posted April 15, 2016 local Hospitals = { {2030.03125, -1418.8076171875, 16.9921875}, {2030.03515625, -1418.8623046875, 16.9921875}, } function DeathSpawn( thePlayer, Hospitals ) local random = math.random( 1, #Hospitals ) spawnPlayer( thePlayer, Hospitals[random][1], Hospitals[random][2] ) end function respawn(player) fadeCamera ( source, false, 1.0, 255, 0, 0 ) setTimer( DeathSpawn, 3000, 1, source,Hospitals ) setTimer( fadeCamera, 2500, 1, source, true, 0.5 ) end addEventHandler("onPlayerWasted", root, respawn
xyz Posted April 15, 2016 Author Posted April 15, 2016 That looks like it spawns them randomly, I want it to be like spawn the person to the closest hospital.
xyz Posted April 15, 2016 Author Posted April 15, 2016 I know that I have to use that, but how can I get the hospital with the closest range to the player that was killed
Simple0x47 Posted April 15, 2016 Posted April 15, 2016 I know that I have to use that, but how can I get the hospital with the closest range to the player that was killed Why do you ask if you know you've got to use that?
xyz Posted April 15, 2016 Author Posted April 15, 2016 I don't know how to get the closest hospital as I said. Get player position Get hospital position What then?
Simple0x47 Posted April 15, 2016 Posted April 15, 2016 if getDistanceBetweenPoints3D(px, py, pz, 1x, 1y, 1z) > getDistanceBetweenPoints3D(px, py, pz, 1x, 1y, 1z) --Code to spawn at the first hospital. else --Code to spawn at the second hospital. end
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now