Get Car Pos
#9

Quote:
Originally Posted by Basssiiie
Посмотреть сообщение


  1. 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.
  2. 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'.
  3. 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?
Reply


Messages In This Thread
Get Car Pos - by Stefand - 13.10.2012, 13:17
Re : Get Car Pos - by lelemaster - 13.10.2012, 13:19
Re: Get Car Pos - by gtakillerIV - 13.10.2012, 13:22
Re: Get Car Pos - by Stefand - 13.10.2012, 13:26
Re: Get Car Pos - by fordawinzz - 13.10.2012, 13:28
Re: Get Car Pos - by Stefand - 13.10.2012, 13:31
Re: Get Car Pos - by Stefand - 13.10.2012, 13:33
Re: Get Car Pos - by Basssiiie - 13.10.2012, 13:36
Re: Get Car Pos - by Stefand - 13.10.2012, 13:42
Re: Get Car Pos - by Basssiiie - 13.10.2012, 13:44

Forum Jump:


Users browsing this thread: 1 Guest(s)