Jump to content

DIST_FOOT and DIST_CAR stats


megaman54

Recommended Posts

Try something like this:

g_distance = 0 
function addDistance() 
    if x then 
        local xNew,yNew,zNew = getElementPosition(localPlayer) 
        local addedDistance = getDistanceBetweenPoints3D(xNew,yNew,zNew,x,y,z) 
        g_distance = g_distance+addedDistance 
    end 
    x,y,z = xNew,yNew,zNew 
end 
addEventHandler ("onClientRender", root, addDistance) 

It checks the distance you traveled between two frames and adds it to a global counter. You can add aditional checks to see if the player is on foot or not and depending on that add the traveled distance to a different counter.

Link to comment
Try something like this:
g_distance = 0 
function addDistance() 
    if x then 
        local xNew,yNew,zNew = getElementPosition(localPlayer) 
        local addedDistance = getDistanceBetweenPoints3D(xNew,yNew,zNew,x,y,z) 
        g_distance = g_distance+addedDistance 
    end 
    x,y,z = xNew,yNew,zNew 
end 
addEventHandler ("onClientRender", root, addDistance) 

It checks the distance you traveled between two frames and adds it to a global counter. You can add aditional checks to see if the player is on foot or not and depending on that add the traveled distance to a different counter.

Thanks! This should get me started :)

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...