Jump to content

Ped distance


Hero192

Recommended Posts

Hey guys,

i want to know how to set a ped distance for example you can't click on the PED if you went too far like ~30metres.

addEventHandler ( 'onClientClick', root, 
    function ( button, state, absoluteX, absoluteY, worldX, worldY, worldZ, clickedElement ) 
        if  ( clickedElement ) and ( getElementType ( clickedElement )  == 'ped' ) then 
        if ( not getPlayerTeam (localPlayer) or getTeamName ( getPlayerTeam (localPlayer) ) ~= 'Criminal' ) then        sendMessage(" You must be criminal.",255,0,0) return end 
            for i=1, #deliverys do 
                if  ( clickedElement == deliverys[i] ) then 
                setElementData(deliverys[i], "del", true) 
                if getElementData(deliverys[i],"del") then 
                    if ( guiGetVisible ( Window ) == false ) then guiSetVisible ( Window,true ) end 
                    end 
                end 
          end 
    end 
end) 

Link to comment
addEventHandler ( 'onClientClick', root, 
    function ( button, state, absoluteX, absoluteY, worldX, worldY, worldZ, clickedElement ) 
        if  ( clickedElement ) and ( getElementType ( clickedElement )  == 'ped' ) then 
         local x, y, z = getElementPosition(localPlayer) 
        if getDistanceBetweenPoints3D(x, y, z, worldX, worldY, worldZ)<=13 then 
        if ( not getPlayerTeam (localPlayer) or getTeamName ( getPlayerTeam (localPlayer) ) ~= 'Criminal' ) then        sendMessage(" You must be criminal.",255,0,0) return end 
            for i=1, #deliverys do 
                if  ( clickedElement == deliverys[i] ) then 
                setElementData(deliverys[i], "del", true) 
                if getElementData(deliverys[i],"del") then 
                    if ( guiGetVisible ( Window ) == false ) then guiSetVisible ( Window,true )  
                               end 
                         end 
                    end 
                end 
          end 
    end 
end) 

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