SA-MP Forums Archive
sscanf warning: Strings without a length... - 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 length... (/showthread.php?tid=503070)



sscanf warning: Strings without a length... - MikeMike1997 - 27.03.2014

"sscanf warning: Strings without a length are deprecated, please add a destination size"

Код:
CMD:createorg(playerid,params[])
{
	if(!IsPlayerAdmin(playerid)) return 0;
	new orgid,DBResult:Result;
	if(sscanf(params,"iis",orgid,orggenre,oname)) return SCM(playerid,grey,"Usage: /createorg [Orgid] [Genre] [Name]");
	if(orgid == 0) return SCM(playerid,red,"ERROR: Available Org 1-9");
	if(orgid > MAX_ORGS) return SCM(playerid,red,"Available Org 1-19");
	if(orggenre < 1) return SCM(playerid,red,"ERROR: Available Genre 1-3");
	if(orggenre > 3) return SCM(playerid,red,"ERROR: Available Genre 1-3");
	if(!DoesOrgExist(orgid))
	{
	    db_free_result(Result);
	 	format(str,sizeof(str),"INSERT INTO `orgs` (Orgid,Name,Genre,Leader,Bank,Members) VALUES ('%d','%s','%d','No Leader','1000','0')",orgid,oname,orggenre);
  	 	db_query(Database,str);
        format(OrgInfo[orgid][Orgname],50,"%s",oname);
		OrgInfo[orgid][Bank] = 1000;
		OrgInfo[orgid][Genre] = orggenre;
		OrgInfo[orgid][Member] = 0;
	   	format(str,sizeof(str),"You have created created org id %d with genre %d",orgid,orggenre);
		SCM(playerid,blue,str);
		format(str,sizeof(str),"Org Name: %s",oname);
		SCM(playerid,blue,str);
	}
	else return SCM(playerid, red, "ERROR: Organization ID already in use");
	return 1;
}



Re: sscanf warning: Strings without a length... - Konstantinos - 27.03.2014

If you use specifier "s" without any size, it's by default 32.

Use a size for it, an example:
pawn Код:
if(sscanf(params,"iis[24]",orgid,orggenre,oname)) return SCM(playerid,grey,"Usage: /createorg [Orgid] [Genre] [Name]");
Change 24 to the size of oname (if it's not 24).


Re: sscanf warning: Strings without a length... - MikeMike1997 - 27.03.2014

Thank you