GetVehiclePos

From SA-MP Wiki

(Difference between revisions)
Jump to: navigation, search
Revision as of 15:07, 6 July 2016
AbyssMorgan (Talk | contribs)
(Add GetVehicleRotation)
← Previous diff
Current revision
Jelly23 (Talk | contribs)

Line 5: Line 5:
{{Parameters|vehicleid, &Float:X, &Float:Y, &Float:Z}} {{Parameters|vehicleid, &Float:X, &Float:Y, &Float:Z}}
{{Param|vehicleid|The ID of the vehicle to get the position of.}} {{Param|vehicleid|The ID of the vehicle to get the position of.}}
-{{Param|Float:X|A float variable in which to store the X coordinate, passed by reference.}}+{{Param|&Float:X|A float variable in which to store the X coordinate, passed by reference.}}
-{{Param|Float:Y|A float variable in which to store the Y coordinate, passed by reference.}}+{{Param|&Float:Y|A float variable in which to store the Y coordinate, passed by reference.}}
-{{Param|Float:Z|A float variable in which to store the Z coordinate, passed by reference.}}+{{Param|&Float:Z|A float variable in which to store the Z coordinate, passed by reference.}}
{{ReturnsSuccess||The vehicle specified does not exist.}} {{ReturnsSuccess||The vehicle specified does not exist.}}

Current revision



Description:

Gets the position of a vehicle.


Parameters:
(vehicleid, &Float:X, &Float:Y, &Float:Z)
vehicleidThe ID of the vehicle to get the position of.
&Float:XA float variable in which to store the X coordinate, passed by reference.
&Float:YA float variable in which to store the Y coordinate, passed by reference.
&Float:ZA float variable in which to store the Z coordinate, passed by reference.


Return Values:

  • 1: The function executed successfully.
  • 0: The function failed to execute. The vehicle specified does not exist.


Example Usage:

public OnPlayerCommandText(playerid, cmdtext[])
{
     if(strcmp(cmdtext, "/vehpos", true) == 0)
     {
          new currentveh;
          currentveh = GetPlayerVehicleID(playerid);
 
          new Float:vehx, Float:vehy, Float:vehz;
          GetVehiclePos(currentveh, vehx, vehy, vehz);
 
          new vehpostext[96];
          format(vehpostext, sizeof(vehpostext), "The current vehicle positions are: %f, %f, %f", vehx, vehy, vehz);
 
          SendClientMessage(playerid, 0xFFFFFFFF, vehpostext);
          return 1;
     }
 
     return 0;
}

Related Functions

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

Personal tools
In other languages