GetPedTargetEnd: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
 
(4 intermediate revisions by 3 users not shown)
Line 6: Line 6:
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
float float float getPedTargetEnd ( ped targetingPed )
float float float getPedTargetEnd ( ped targetingPed )
</syntaxhighlight>  
</syntaxhighlight>
{{OOP||[[ped]]:getTargetEnd}}


===Required Arguments===  
===Required Arguments===  
*'''targetingPed:''' The ped who is targeting whose target end you wish to retrieve
*'''targetingPed:''' the ped who is targeting whose target end you wish to retrieve


===Returns===
===Returns===
Line 17: Line 18:
This Example draws a line from where the Ped´s Target Starts to the Point where the Target Ends
This Example draws a line from where the Ped´s Target Starts to the Point where the Target Ends
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
function drawline()
addEventHandler("onClientPreRender", root,  -- Adds the Handler
  if (getPedTargetStart(localPlayer)) then --Checks if there is a Point to start From.
    function ()
        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
        local x, y, z = getPedTargetStart(localPlayer) -- Gets the Point to start From
      local sx,sy,sz = getPedTargetEnd(localPlayer) -- Gets the Point where the Target Ends
        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
)
</syntaxhighlight>
</syntaxhighlight>


==See Also==
==See Also==
{{Client_ped_functions}}
{{Client_ped_functions}}
[[Category:Needs_Example]]

Latest revision as of 18:30, 5 December 2014

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

Syntax

float float float getPedTargetEnd ( ped targetingPed )

OOP Syntax Help! I don't understand this!

Method: ped:getTargetEnd(...)


Required Arguments

  • targetingPed: the ped who is targeting whose target end you wish to retrieve

Returns

Returns three floats, x,y,z, representing the position where the ped's target ends according to his range, 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

addEventHandler("onClientPreRender", root,  -- Adds the Handler
    function ()
        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
        local sx, sy, sz = getPedTargetEnd(localPlayer) -- Gets the Point where the Target Ends

        dxDrawLine3D(x, y, z, sx, sy, sz) -- Draws the Line
    end
end
)

See Also