Jump to content

[HELP] Ped looking at an object


..:D&G:..

Recommended Posts

function pedLooks(theElement) 
   local x, y, z = getElementPosition(localPlayer) 
   local bx, by, bz = getElementPosition(theElement) 
   local distance = getDistanceBetweenPoints3D(x, y, z, bx, by, bz) 
   if setPedLookAt(localPlayer, theElement)  and  distance <= 5 then 
      outputChatBox("You looking at "..theElement) 
   end 
end 

Link to comment
  
hit, hitX, hitY, hitZ, hitElement = processLineOfSight ( float startX, float startY, float startZ,  
                                       float endX, float endY, float endZ,  
                                       [ bool checkBuildings = true,  
                                       bool checkVehicles = true,  
                                       bool checkPlayers = true,  
                                       bool checkObjects = true,  
                                       bool checkDummies = true,  
                                       bool seeThroughStuff = false,  
                                       bool ignoreSomeObjectsForCamera = false,  
                                       bool shootThroughStuff = false,  
                                       element ignoredElement = nil, 
                                       bool includeWorldModelInformation = false, 
                                       bool bIncludeCarTyres ] ) 
  

set ignoredElement to localPlayer and where its positions do

startX, startY, startZ, endX, endY, endZ = getCameraMatrix()

and then check if 'hit' is true and hitElement is the element which are u looking on.

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