GetVehiclePos

From SA-MP Wiki

Jump to: navigation, search

GetVehiclePos


Saves the x, y and z position of a vehicle in variables.


Important Note: Will Only retrieve coords of where the last player was in vehicle or Vehicles Spawn Position. Will not retrieve true coords if it has rolled down a hill for example.


Parameters:
(vehicleid, &Float:X, &Float:Y, &Float:Z)
vehicleidThe ID of the vehicle.
Float:XThe variable to store the X coordinate, passed by reference.
Float:YThe variable to store the Y coordinate, passed by reference.
Float:ZThe variable to store the Z coordinate, passed by reference.


This function does not return a specific value.


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 might be useful as well, as they're related to this function in one way or another.

Personal tools
In other languages