SA-MP Forums Archive
sscanf warnings - 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 warnings (/showthread.php?tid=637997)



sscanf warnings - roncohen7 - 25.07.2017

Hello everyone,
I've encountered those sscanf warnings on my server log and I have no idea how to fix it.
It happens when I use this command in game, can you please tell me how to solve this problem?

Thanks

Код:
CMD:adjust(playerid, params[])
{
	if(PlayerInfo[playerid][pFMember] == INVALID_FAMILY_ID)
	{
		SendClientMessageEx(playerid, COLOR_GREY, "You aren't in a family.");
		return 1;
	}
	new family = PlayerInfo[playerid][pFMember];
	new string[128], file[32], month, day, year;
	getdate(year,month,day);
	if(PlayerInfo[playerid][pRank] >= 5)
	{
		new choice[32], opstring[100];
		if(sscanf(params, "s[32]S[100]", choice, opstring))
		{
			SendClientMessageEx(playerid, COLOR_GREY, "USAGE: /adjust [name]");
			SendClientMessageEx(playerid, COLOR_WHITE, "Available Names: Name, Safe");
			return 1;
		}

		if(strcmp(choice,"name",true) == 0)
		{
			if(PlayerInfo[playerid][pRank] == 6)
			{
				if(!opstring[0])
				{
					SendClientMessageEx(playerid, COLOR_GREY, "USAGE: /adjust name [family name]");
					return 1;
				}
				if(strfind(opstring, "|", true) != -1)
				{
					SendClientMessageEx(playerid, COLOR_GRAD2,  "You can't use '|' in a family name.");
					return 1;
				}
				if(strlen(opstring) >= 40 )
				{
					SendClientMessageEx( playerid, COLOR_GRAD1, "That family name is too long, please refrain from using more than 40 characters." );
					return 1;
				}
				strmid(FamilyInfo[family][FamilyName], opstring, 0, strlen(opstring), 100);
				SaveFamilies();
				SendClientMessageEx(playerid, COLOR_WHITE, "You've adjusted your family's name.");
				format(string, sizeof(string), "%s adjusted %s's name to %s", GetPlayerNameEx(playerid), FamilyInfo[family][FamilyName], opstring);
				format(file, sizeof(file), "family_logs/%d/%d-%02d-%02d.log", family, year, month, day);
				Log(file, string);
			}
		}
		else if(strcmp(choice,"safe",true) == 0)
		{
			if(PlayerInfo[playerid][pRank] == 6)
			{
				SendClientMessageEx(playerid, COLOR_GRAD1, "Adjusting your Family Safe will reset all your safe stats.");
				SendClientMessageEx(playerid, COLOR_GRAD1, "If you want to adjust your safe, type /adjust confirm.");
				SendClientMessageEx(playerid, COLOR_GRAD1, "Upgrading your family safe will cost $50,000.");
				return 1;
			}
		}
		else if(strcmp(choice,"confirm",true) == 0)
		{
			if(PlayerInfo[playerid][pRank] == 6)
			{
				if(GetPlayerCash(playerid) < 50000)
				{
					SendClientMessageEx(playerid, COLOR_GRAD1, "You don't have $50,000 to upgrade your family safe.");
					return 1;
				}
				GivePlayerCash(playerid, -50000);
				GetPlayerPos(playerid, FamilyInfo[family][FamilySafe][0], FamilyInfo[family][FamilySafe][1], FamilyInfo[family][FamilySafe][2]);
				FamilyInfo[family][FamilySafeVW] = GetPlayerVirtualWorld(playerid);
				FamilyInfo[family][FamilySafeInt] = GetPlayerInterior(playerid);
				FamilyInfo[family][FamilyCash] = 0;
				FamilyInfo[family][FamilyMats] = 0;
				FamilyInfo[family][FamilyPot] = 0;
				FamilyInfo[family][FamilyCrack] = 0;
				if(FamilyInfo[family][FamilyUSafe]) DestroyDynamicPickup(FamilyInfo[family][FamilyPickup]);
				FamilyInfo[family][FamilyUSafe] = 1;
				FamilyInfo[family][FamilyPickup] = CreateDynamicPickup(1239, 23, FamilyInfo[family][FamilySafe][0], FamilyInfo[family][FamilySafe][1], FamilyInfo[family][FamilySafe][2], .worldid = FamilyInfo[family][FamilySafeVW], .interiorid = FamilyInfo[family][FamilySafeInt]);
				SaveFamilies();
				SendClientMessageEx(playerid, COLOR_WHITE, "You've adjusted your family's Safe.");
				format(string, sizeof(string), "%s adjusted %s's safe", GetPlayerNameEx(playerid), FamilyInfo[family][FamilyName]);
				format(file, sizeof(file), "family_logs/%d/%d-%02d-%02d.log", family, year, month, day);
				Log(file, string);
			}
		}
	}
	else
	{
		SendClientMessageEx(playerid, COLOR_GREY, "   You do not have a high enough rank to use this command!");
		return 1;
	}
	return 1;
Код:
sscanf warning: No default value found.
sscanf warning: Unknown format specifier '[', skipping.
sscanf warning: Unknown format specifier '1', skipping.
sscanf warning: Unknown format specifier '0', skipping.
sscanf warning: Unknown format specifier '0', skipping.
sscanf warning: Unknown format specifier ']', skipping.
sscanf warning: Format specifier does not match parameter count.



Re: sscanf warnings - Kane - 25.07.2017

Your first parameter.
Код:
S[100]
https://sampforum.blast.hk/showthread.php?tid=570927
Код:
S(string)[length]			Optional string
Like the warning shows, there's no default value found.

Change S[100] to S()[100] and see if the results are different.


Re: sscanf warnings - iLearner - 25.07.2017

Just change the Big S to small s. (S[100] to s[100])


Re: sscanf warnings - roncohen7 - 25.07.2017

Quote:
Originally Posted by Arthur Kane
Посмотреть сообщение
Your first parameter.
Код:
S[100]
https://sampforum.blast.hk/showthread.php?tid=570927
Код:
S(string)[length]			Optional string
Like the warning shows, there's no default value found.

Change S[100] to S()[100] and see if the results are different.
Thank you very much, I also encountered a similar problem look at this code.

Код:
CMD:editglocker(playerid, params[])
{
	if (PlayerInfo[playerid][pAdmin] >= 1337 || PlayerInfo[playerid][pGangModerator] >= 1)
	{
		new string[128], choice[32], id, amount;
		if(sscanf(params, "s[32]dD", choice, id, amount))
Sorry for asking too much because I am not a scripter and I don't know how to deal with scripting errors.


Re: sscanf warnings - iLearner - 25.07.2017

The identifiers are small letters, with non default values.


Re: sscanf warnings - jlalt - 25.07.2017

small letter for non optional parameter, capital letter for optional parameter which need to specif a default value for it too.
so if you wanna use S you gotta assign default value and a size.
default value inside () size inside []

so now we get that, your D needs a default value.

->
PHP код:
if(sscanf(params"s[32]dD(-1)"choiceidamount)) 



Re: sscanf warnings - roncohen7 - 27.07.2017

Quote:
Originally Posted by jlalt
Посмотреть сообщение
small letter for non optional parameter, capital letter for optional parameter which need to specif a default value for it too.
so if you wanna use S you gotta assign default value and a size.
default value inside () size inside []

so now we get that, your D needs a default value.

->
PHP код:
if(sscanf(params"s[32]dD(-1)"choiceidamount)) 
Well, I changed the code and I set the default value to 30 because my gang lockers are defined to 30 max.
And still when I restart the server the locker is being removed or not belongs to a family that I set it before.