Jump to content

Getting player range.


Feche1320

Recommended Posts

range as in distance? since all weapons have different ranges.

either:

getDistanceBetweenPoints2D( float x1, float y1, float x2, float y2 )

getDistanceBetweenPoints3D( float x1, float y1, float z1, float x2, float y2, float z2 )

depending on what u need it for.

for more info:

https://wiki.multitheftauto.com/wiki/Get ... enPoints2D

https://wiki.multitheftauto.com/wiki/Get ... enPoints3D

Link to comment

You could use colshapes for that:

colShape = createColCircle(0,0,10)   --radius=10 
addEventHandler('onColShapeHit',colShape, 
    function(element) 
        if getElementType(element) == 'player' then 
               outputChatBox('You are near the 0,0 point!', element) 
        end 
    end 
)  

Link to comment

yes what i first posted would give you the distance from player to object as requested,

local x1,y1,z1 = getElementPosition(player)

local x2,y2,z2 = getElementPosition(object)

local distance = getDistanceBetweenPoints3D(x1, y1, z1, x2, y2, z2)

but its quicker to just use a colshape as SDK suggested.

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