Jump to content

getElementVelocity


SkatCh

Recommended Posts

Posted

guys please i need some help cn anyone tell me what's the problem here :

In this part :

function vehiclestatus ( ) 
    if ( isPedInVehicle ( localPlayer ) == false ) then return false end 
    local x, y, z = getElementPosition( localPlayer ) 
    local car = getPedOccupiedVehicle ( localPlayer ) 
    local sx, sy, sz = getElementVelocity(car) 
    local kphSpeed = math.ceil (( ( sx^2 + sy^2 + sz^2 ) ^ ( 0.5 ) ) * 161 ) 
    local mphSpeed = math.ceil (( ( ( sx^2 + sy^2 + sz^2 ) ^ ( 0.5 ) ) * 161 ) / 1.61 ) 

Error + warning :

c08733ea74.png

9eaa48ac8e.png

Posted

Heres your problem:

  
    local car = getPedOccupiedVehicle ( localPlayer ) 
    local sx, sy, sz = getElementVelocity(car) 

Go with this:

  
local car = getPedOccupiedVehicle ( localPlayer ) 
if car then 
local sx, sy, sz = getElementVelocity(car) 
else 
local sx,sy,sz = getElementVelocity( localPlayer ) 
end 

Posted

The 'sx' variable is local inside the condition... either remove the local in front of it or add local sx, sy, sz above the if statement.

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