GetVehiclePos
From SA-MP Wiki
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.
(vehicleid, &Float:X, &Float:Y, &Float:Z)
| vehicleid | The ID of the vehicle. |
| Float:X | The variable to store the X coordinate, passed by reference. |
| Float:Y | The variable to store the Y coordinate, passed by reference. |
| Float:Z | The 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.
- CreateVehicle: Create a vehicle.
- SetVehiclePos: Set the position of a vehicle.
- GetVehicleZAngle: Check the current angle of a vehicle.
