GetPedTargetStart: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
mNo edit summary
(Replace to root.)
 
(One intermediate revision by one other user not shown)
Line 18: Line 18:
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
function drawline()
function drawline()
   if (getPedTargetStart(localPlayer)) then --Checks if there is a Point to start From.
   local x, y, z = getPedTargetStart(localPlayer) -- Gets the Point to start From.
 
  if (x) then -- Checks if there is a Point to start From.
      local x,y,z = getPedTargetStart(localPlayer) -- Gets the Point to start From
       local sx, sy, sz = getPedTargetCollision(localPlayer) -- Gets the Point where the Targets Collision is.
       local sx,sy,sz = getPedTargetEnd(localPlayer) -- Gets the Point where the Target Ends
       dxDrawLine3D(x, y, z, sx, sy, sz) -- Draws the Line
 
       dxDrawLine3D(x,y,z,sx,sy,sz) -- Draws the Line
   end
   end
end
end
addEventHandler("onClientPreRender",getRootElement(),drawline) -- Adds the Handler
addEventHandler("onClientPreRender", root, drawline) -- Adds the Handler.
</syntaxhighlight>
</syntaxhighlight>


==See Also==
==See Also==
{{Client_ped_functions}}
{{Client_ped_functions}}

Latest revision as of 11:05, 31 May 2023

This function allows retrieval of the position a ped's target range begins, when he is aiming with a weapon.

Syntax

float float float getPedTargetStart ( ped targetingPed )

Required Arguments

  • targetingPed: The ped whose target start you wish to retrieve

Returns

Returns three floats, x,y,z, representing the position where the ped's target starts, or false if it was unsuccessful.

Example

This Example draws a line from where the Ped´s Target Starts to the Point where the Target Ends

function drawline()
   local x, y, z = getPedTargetStart(localPlayer) -- Gets the Point to start From.
   if (x) then -- Checks if there is a Point to start From.
      local sx, sy, sz = getPedTargetCollision(localPlayer) -- Gets the Point where the Targets Collision is.
      dxDrawLine3D(x, y, z, sx, sy, sz) -- Draws the Line
   end
end
addEventHandler("onClientPreRender", root, drawline) -- Adds the Handler.

See Also