SA-MP Forums Archive
sscanf warning: strings without a lenght....... - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: sscanf warning: strings without a lenght....... (/showthread.php?tid=590718)



sscanf warning: strings without a lenght....... - faff - 03.10.2015

While performing this command ingame the console shows me two warnings.
Код:
CMD:veh(playerid, params[])
{
    new model[32], color1, color2, VehicleID, string[128];
    if(PlayerInfo[playerid][pAdmin] >= 4)
    {
    	if(sscanf(params, "sii", model, color1, color2)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /veh [ID/NAME] || Optional: [Color1] [Color2]");
		VehicleID = GetVehicleModelIDFromName(model);
     	if(VehicleID == -1 )
      	{
			VehicleID = strval(model);
			if(VehicleID < 400 || VehicleID > 611 )
   				{
       				return SendClientMessage(playerid, COLOR_WHITE, "SERVER: You entered an invalid vehicle name or ID!");
           		}
       	}
	    if(IsPlayerInAnyVehicle(playerid))
		{
			new vehicle = GetPlayerVehicleID(playerid);
			RemovePlayerFromVehicle(playerid);
			DestroyVehicle(vehicle);
		}
		if(AdmVeh[playerid] != 0){
		DestroyVehicle(AdmVeh[playerid]);}
	    new	Float:X, Float:Y, Float:Z, Float:A;
        GetPlayerPos(playerid, X,Y,Z);
		GetPlayerFacingAngle(playerid,A);
		new carid = CreateVehicle(VehicleID, X,Y,Z,A, color1, color2, -1);
	    PutPlayerInVehicle(playerid,carid, 0);
	    LinkVehicleToInterior(carid,GetPlayerInterior(playerid));
     	format(string, sizeof(string), "{FFFFFF}SERVER: You've spawned the selected vehicle.");
     	SendClientMessage(playerid, COLOR_WHITE, string);
     	AdmVeh[playerid] = carid;
    }
    else return SendClientMessage(playerid, COLOR_GRAD2, NOTADMIN);
    return 1;
}
I really have no idea what causes this.
Код:
[11:27:32] sscanf warning: Strings without a length are deprecated, please add a destination size.
[11:27:32] sscanf warning: Format specifier does not match parameter count.
I'd really hope somebody can help me out.
The command is working perfectly anyway.


Re: sscanf warning: strings without a lenght....... - faff - 03.10.2015

Код:
    if(!strcmp(cmd, "pass", true))
    {
        new password[128];
		if(sscanf(cmd, "s", password))return print("USEAGE = 'pass [TEXT]'");
        print("\n'pass' performed - Password HASHED: %s ====== %s\n", udb_hash(password), password);
        print("\nPassword generated.\n");
        return 1;
    }
Also this one isn't working? :O


Re: sscanf warning: strings without a lenght....... - Bolex_ - 03.10.2015

try...........

Quote:

if(sscanf(params, "sii[100]", pID, text))




Re: sscanf warning: strings without a lenght....... - karemmahmed22 - 03.10.2015

actually you should size the arrays in sscanf
Try this
PHP код:
CMD:veh(playeridparams[])
{
    new 
model[32], color1color2VehicleIDstring[128];
    if(
PlayerInfo[playerid][pAdmin] >= 4)
    {
        if(
sscanf(params"s[32]ii"modelcolor1color2)) return SendClientMessage(playeridCOLOR_WHITE"USAGE: /veh [ID/NAME] || Optional: [Color1] [Color2]");
        
VehicleID GetVehicleModelIDFromName(model);
         if(
VehicleID == -)
          {
            
VehicleID strval(model);
            if(
VehicleID 400 || VehicleID 611 )
                   {
                       return 
SendClientMessage(playeridCOLOR_WHITE"SERVER: You entered an invalid vehicle name or ID!");
                   }
           }
        if(
IsPlayerInAnyVehicle(playerid))
        {
            new 
vehicle GetPlayerVehicleID(playerid);
            
RemovePlayerFromVehicle(playerid);
            
DestroyVehicle(vehicle);
        }
        if(
AdmVeh[playerid] != 0){
        
DestroyVehicle(AdmVeh[playerid]);}
        new    
Float:XFloat:YFloat:ZFloat:A;
        
GetPlayerPos(playeridX,Y,Z);
        
GetPlayerFacingAngle(playerid,A);
        new 
carid CreateVehicle(VehicleIDX,Y,Z,Acolor1color2, -1);
        
PutPlayerInVehicle(playerid,carid0);
        
LinkVehicleToInterior(carid,GetPlayerInterior(playerid));
         
format(stringsizeof(string), "{FFFFFF}SERVER: You've spawned the selected vehicle.");
         
SendClientMessage(playeridCOLOR_WHITEstring);
         
AdmVeh[playerid] = carid;
    }
    else return 
SendClientMessage(playeridCOLOR_GRAD2NOTADMIN);
    return 
1;




Re: sscanf warning: strings without a lenght....... - faff - 03.10.2015

Thanks, worked