dener189 Posted November 19, 2018 Posted November 19, 2018 I'm trying to spawn in every hospital in GTA S.A, I want the player to be born in the nearest hospital. What band could I add in my script to work this function? I'm sorry for my english xD
Dimos7 Posted November 19, 2018 Posted November 19, 2018 Well first create a table with all hospital locations then takes the location of player died and use to get where is closer take a loop for all hospitals and put > to check which is closer getDistanceBetweenPoints3D 1
dener189 Posted November 19, 2018 Author Posted November 19, 2018 6 minutes ago, Dimos7 said: Bem, primeiro crie uma tabela com todos os locais do hospital, em seguida, leva a localização do jogador morreu e use para chegar onde está mais perto fazer um loop para todos os hospitais e colocar> para verificar o que está mais perto could you give an example with a simple one-track script?
Dimos7 Posted November 19, 2018 Posted November 19, 2018 you can ask to your native language if you want more help
dener189 Posted November 19, 2018 Author Posted November 19, 2018 33 minutes ago, Dimos7 said: você pode perguntar em sua língua nativa se quiser mais ajuda the native wiki of mine is very bad
dener189 Posted November 19, 2018 Author Posted November 19, 2018 1 minute ago, Dimos7 said: não eu quero dizer aqui there they take a long time to help me. I just need a sample strip so I have a base to do
Dimos7 Posted November 19, 2018 Posted November 19, 2018 as i tell you need a table with all hospital location that all
dener189 Posted November 19, 2018 Author Posted November 19, 2018 1 minute ago, Dimos7 said: as i tell you need a table with all hospital location that all Hospital_LS" posX="2034.9428710938" posY="-1403.2003173828" posZ="18" Hospital_SF" posX="-2655.3991699219" posY="638.16137695313" posZ="15" Hospital_El_Quebrados" posX="-1514.6713867188" posY="2522.4748535156" posZ="56" Hospital_LV" posX="1607.62890625" posY="1818.9958496094" posZ="11" Hospital_Angel_Pine" posX="-2198.5632324219" posY="-2306.6220703125" posZ="31" All Spawns
Dimos7 Posted November 19, 2018 Posted November 19, 2018 (edited) local Hospitals = {2034.9428710938,-1403.2003173828, 18, -2655.3991699219 ,638.16137695313, 15, -1514.6713867188 ,2522.4748535156, 56, 1607.62890625 , 1818.9958496094 , 11, -2198.5632324219, -2306.6220703125, 31, } function spawnNearHospital() for _, v in ipairs(Hospitals) do local x, y, z = getElementPosition(source) if getDistanceBetweenPoints3D(x, y, z, v[1], v[2], v[3]) < getDistanceBetweenPoints3D(x, y, z, v[4], v[5] , v[6]) < getDistanceBetweenPoints3D(x, y, z, v[7], v[8] , v[9]) < getDistanceBetweenPoints3D(x, y, z, v[10], v[11], v[12]) < getDistanceBetweenPoints3D(x, y, z, v[13], v[14], v[15]) then spawnPlayer(source, v[1], v[2], v[3]) end end end addEventHandler("onPlayerWasted", root, spawnNearHospital) something like this Edited November 19, 2018 by Dimos7 1
dener189 Posted November 19, 2018 Author Posted November 19, 2018 1 minute ago, Dimos7 said: local Hospitals = {2034.9428710938,-1403.2003173828, 18, -2655.3991699219 ,638.16137695313, 15, -1514.6713867188 ,2522.4748535156, 56, 1607.62890625 , 1818.9958496094 , 11, -2198.5632324219, -2306.6220703125, 31, } function spawnNearHospital() for _, v in ipairs(Hospitals) do local x, y, z = getElementPosition(source) if getDistanceBetweenPoints3D(x, y, z, v[1], [v2], v[3]) < getDistanceBetweenPoints3D(x, y, z, v[4], [v5] , v[6]) < getDistanceBetweenPoints3D(x, y, z, v[7], v[8] , v[9]) < getDistanceBetweenPoints3D(x, y, z, v[10], v[11], v[12]) < getDistanceBetweenPoints3D(x, y, z, v[13], v[14], v[15]) then spawnPlayer(source, v[1], v[2], v[3]) end end end addEventHandler("onPlayerWasted", root, spawnNearHospital) something like this thank you very much
Dimos7 Posted November 19, 2018 Posted November 19, 2018 3 minutes ago, dener189 said: thank you very much np ofc that is only for spawn at one hospital but you can do the same for other hospitals too
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