GetPlayerLastShotVectors

From SA-MP Wiki

(Difference between revisions)
Jump to: navigation, search
Revision as of 22:11, 7 December 2016
OstGot (Talk | contribs)

← Previous diff
Revision as of 14:29, 18 March 2017
OstGot (Talk | contribs)

Next diff →
Line 14: Line 14:
{{Param|&Float:fHitPosY|A float variable in which to save the Z coordinate of where the bullet hit.}} {{Param|&Float:fHitPosY|A float variable in which to save the Z coordinate of where the bullet hit.}}
-{{ReturnsSuccess||The player specified does not exist.}}+{{ReturnsSuccess||The player specified does not exist.
 +* The position of last bullet is stored in the specified variables.}}
{{notes2| {{notes2|

Revision as of 14:29, 18 March 2017



GetPlayerLastShotVectors was added in SA-MP 0.3z This function was added in SA-MP 0.3z and will not work in earlier versions!


Description:

Retrieves the start and end (hit) position of the last bullet a player fired.


Parameters:
(playerid, &Float:fOriginX, &Float:fOriginY, &Float:fOriginZ, &Float:fHitPosX, &Float:fHitPosY, &Float:fHitPosZ)
playeridThe ID of the player to get the last bullet shot information of.
&Float:fOriginXA float variable in which to save the X coordinate of where the bullet originated from.
&Float:fOriginYA float variable in which to save the Y coordinate of where the bullet originated from.
&Float:fOriginZA float variable in which to save the Z coordinate of where the bullet originated from.
&Float:fHitPosXA float variable in which to save the X coordinate of where the bullet hit.
&Float:fHitPosYA float variable in which to save the Y coordinate of where the bullet hit.
&Float:fHitPosYA float variable in which to save the Z coordinate of where the bullet hit.


Return Values:

  • 1: The function executed successfully.
  • 0: The function failed to execute. The player specified does not exist.
  • The position of last bullet is stored in the specified variables.


Image:32px-Circle-style-warning.png

Important
Notes

  • This function will only work when lag compensation is enabled.
  • If the player hit nothing, the hit positions will be 0. This means you can't currently calculate how far a bullet travels through open air.


Example Usage:

public OnPlayerCommandText(playerid, cmdtext[])
{
    if(strcmp(cmdtext, "/lastshot", true) == 0)
    {
        new lsString[128],
            Float:fOriginX, Float:fOriginY, Float:fOriginZ,
            Float:fHitPosX, Float:fHitPosY, Float:fHitPosZ;
 
        GetPlayerLastShotVectors(playerid, fOriginX, fOriginY, fOriginZ, fHitPosX, fHitPosY, fHitPosZ);
        format(lsString, 128, "Last Shot Information: Origin: %f, %f, %f. Hit position: %f, %f, %f", fOriginX, fOriginY, fOriginZ, fHitPosX, fHitPosY, fHitPosZ);
        SendClientMessage(playerid, -1, lsString);
        return 1;
    }
    return 0;
}

Related Functions

The following functions may be useful, as they are related to this function in one way or another.


Related Callbacks

The following callbacks might be useful, as they're related to this function in one way or another.

Personal tools
In other languages