Quote:
Originally Posted by Basssiiie
- The 'u' specifier in sscanf is for players, not for vehicles. It will check if there's someone with playerid 80, which there isn't.
- The '%d' specifier in format is for integers. The position and the angle of a vehicle are point numbers, or Floats. These have to be specified with '%f' instead of '%d'.
- It might be a good idea to check if the vehicle ID does actually exist, before you check it's position. There's a hidden native called 'IsValidVehicle'. If you want to use this, you need to add this to the top of your script:
Код:
native IsValidVehicle(vehicleid);
Edit: For your last question; the vehicle id it just an integer, so '%d' or '%i' will both work just fine. More information about format here.
|
pawn Код:
native IsValidVehicle(vehicleid);
dcmd_carpos(playerid,params[])
{
#pragma unused params
new string[128], CARID;
if(IsValidVehicle(CARID))
{
new Float: carx, Float: cary, Float: carz;
GetVehiclePos(CARID, carx, cary, carz);
format(string, sizeof(string), "%i's Position: %f, %f, %f.", CARID, carx, cary, carz);
SendClientMessage(playerid, COLOR_WHITE, string);
new Float: carangle;
GetVehicleZAngle(CARID, carangle);
format(string, sizeof(string), "%i's angle: %f.", CARID, carangle);
SendClientMessage(playerid, COLOR_WHITE, string);
}
return 1;
}
Should work?