Jump to content

[SOLVED] getElementPosition


Recommended Posts

Hello ,

i am trying to make when player die he spawns to the nearest place from his death place

so i created peds in made editor and take the file map to the mod folder and put in the meta ofc

the problem which i got is : when i get peds position i get there (x) position only , idk how to get the (y) and (z)

Server :

addEventHandler("onResourceStart",getResourceRootElement(), 
function() 
    for i,v in pairs (getElementsByType("ped")) do 
        setTimer  ( function () 
            local x,y,z = getElementPosition(v) 
            --outputChatBox (x..","..y..","..z,root) 
            local location = getZoneName ( x,y,z ) 
            local city = getZoneName ( x,y,z, true ) 
            WorldSpawn = {x,y,z,location,city} 
            destroyElement(v) 
        end,500,1) 
    end 
end) 
  
addEventHandler("onPlayerWasted", root, 
function() 
    for i,positions in ipairs (WorldSpawn) do 
        local x,y,z = getElementPosition (source) 
        local Dist = getDistanceBetweenPoints3D (positions[1],positions[2],positions[3],x,y,z) 
        if Dist < 100  then 
            spawnPlayer (source,positions[1],positions[2],positions[3]) 
            setCameraTarget(source,source) 
            fadeCamera(source,true) 
        end 
    end 
end) 

i hope someone explain my problem

Edited by Guest
Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...