sscanf error
#1

PHP код:
[19:22:53] sscanf warning: Strings without a length are deprecated, please add a destination size. 
I get this every time I use this command:

PHP код:
CMD:asv(playerid, params[])
{
    if(
IsPlayerInAnyVehicle(playerid))
    {
        new 
vehicleid = GetPlayerVehicleID(playerid);
        new 
vehmodel = GetVehicleModel(vehicleid);
        new 
string[25], Float:vehx, Float:vehy, Float:vehz, Float:vehrot;
        
        
GetVehiclePos(vehicleid, vehx, vehy, vehz);
        
GetVehicleZAngle(vehicleid, vehrot);
        new 
col1, col2, vehtype, price, plate[24], DB_Query[256];
        if (
sscanf(params, "iiiis", col1, col2, vehtype, price, plate)) SendClientMessage(playerid, COLOR_GREY, "> Type /asv <color1> <color2> <VehicleType> <Price> <Plate>");
        if(
vehtype == 1)
        {
            
mysql_format(Database, DB_Query, sizeof(DB_Query), "INSERT INTO `Vehicles` ( `vModel`, `Pos_x`, `Pos_y`, `Pos_z`, `Rot`, `Fuel`, `Type`, `Plate`, `vLock`, `Color1`, `Color2`, `RespawnDelay`, `Price`)\
            VALUES ( %d, %f, %f, %f, %f, '100', %d, '%s', 0, %d, %d, -1, %d)"
, vehmodel, vehx, vehy, vehz, vehrot, vehtype, plate, col1, col2, price);
             
mysql_tquery(Database, DB_Query);
        }
        else if(
vehtype == 2)
        {
        
        }
        else if(
vehtype == 3)
        {
            
mysql_format(Database, DB_Query, sizeof(DB_Query), "INSERT INTO `Vehicles` ( `vModel`, `Pos_x`, `Pos_y`, `Pos_z`, `Rot`, `Fuel`, `Type`, `Plate`, `vLock`, `Color1`, `Color2`, `RespawnDelay`, `Price`)\
            VALUES ( %d, %f, %f, %f, %f, '100', %d, '%s', 0, %d, %d, -1, %d)"
, vehmodel, vehx, vehy, vehz, vehrot, vehtype, plate, col1, col2, price);
             
mysql_tquery(Database, DB_Query);
        }
        else if(
vehtype == 4)
        {
            
mysql_format(Database, DB_Query, sizeof(DB_Query), "INSERT INTO `Vehicles` ( `vModel`, `Pos_x`, `Pos_y`, `Pos_z`, `Rot`, `Fuel`, `Type`, `Plate`, `vLock`, `Color1`, `Color2`, `RespawnDelay`, `Price`)\
            VALUES ( %d, %f, %f, %f, %f, '100', %d, '%s', 0, %d, %d, -1, %d)"
, vehmodel, vehx, vehy, vehz, vehrot, vehtype, plate, col1, col2, price);
             
mysql_tquery(Database, DB_Query);
        }
        
format(string, sizeof(string), "Vehicle model is: %d | Type: %d | Price: %d | Plate: %s", vehmodel, vehtype, price, plate);
        
SendClientMessage(playerid, COLOR_YELLOW, string);
    }
    return 
1;
} 
Reply
#2

Not sure if it would make any deffirence, try this
PHP код:
if (sscanf(params, "iiiis[24]", col1, col2, vehtype, price, plate)) 
Reply
#3

Quote:
Originally Posted by Eoussama
Посмотреть сообщение
Not sure if it would make any deffirence, try this
PHP код:
if (sscanf(params, "iiiis[24]", col1, col2, vehtype, price, plate)) 
I thought of that too but didn't try it yet, will test and come back to update this post.
Reply
#4

Код:
if (sscanf(params, "iiiis", col1, col2, vehtype, price, plate))
The error basically explains itself. "Strings without a length are deprecated, please add a destination size." Add a length to that string there and it shouldn't appear anymore as Eoussama indicated.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)