Hero192 Posted August 13, 2015 Share Posted August 13, 2015 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
Hero192 Posted August 13, 2015 Author Share Posted August 13, 2015 I know this function but how to set the distance for it Link to comment
KariiiM Posted August 13, 2015 Share Posted August 13, 2015 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
t3wz Posted August 13, 2015 Share Posted August 13, 2015 Just to explain more... getDistanceBetweenPoints3D returns a float wich you can check if is lower or equal to 30 with the operator <= . if you want, here's a list of all operators of Lua, this might help in the future. Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now