PLEASE HELP ME !!!! sscanf warning: Strings without a length are deprecated
#1

My error is :[09:52:08] sscanf warning: Strings without a length are deprecated, please add a destination size. , it appears when i do command /gdeposit.
The command is:
Код HTML:
CMD:gdeposit(playerid, params[])
{
    if(playerVariables[playerid][pStatus] != 1) return 1;
    if(playerVariables[playerid][pGroup] != 0) {

		new
			item[9],
			string[64],
			amount;

		if(sscanf(params, "sd", item, amount)) {
			SendClientMessage(playerid, COLOR_GREY, SYNTAX_MESSAGE"/gdeposit [money/materials/drugs] [amount]");

			format(string, sizeof(string), "Safe balance: $%d, %d materials, %d drugs.", groupVariables[playerVariables[playerid][pGroup]][gSafe][0], groupVariables[playerVariables[playerid][pGroup]][gSafe][1], groupVariables[playerVariables[playerid][pGroup]][gSafe][2]);
			SendClientMessage(playerid, COLOR_GREY, string);
		}
		else {
		    if(amount > 0) {
			    if(IsPlayerInRangeOfPoint(playerid, 5.0, groupVariables[playerVariables[playerid][pGroup]][gSafePos][0], groupVariables[playerVariables[playerid][pGroup]][gSafePos][1], groupVariables[playerVariables[playerid][pGroup]][gSafePos][2])) {
			        if(strcmp(item, "money", true) == 0) {
						if(playerVariables[playerid][pMoney] >= amount) {
					    	playerVariables[playerid][pMoney] -= amount;
					    	groupVariables[playerVariables[playerid][pGroup]][gSafe][0] += amount;
					    	format(string, sizeof(string), "You have deposited $%d in your group safe.", amount);
				    		SendClientMessage(playerid, COLOR_WHITE, string);
				    		saveGroup(playerVariables[playerid][pGroup]);

							GetPlayerName(playerid, szPlayerName, MAX_PLAYER_NAME);
							format(string, sizeof(string), "* %s deposits $%d in their group safe.", szPlayerName, amount);
							nearByMessage(playerid, COLOR_PURPLE, string);
						}
						else {
					    	SendClientMessage(playerid, COLOR_WHITE, "You don't have that amount of money.");
						}
					}
					else if(strcmp(item, "materials", true) == 0 ) {
						if(playerVariables[playerid][pMaterials] >= amount) {
					    	playerVariables[playerid][pMaterials] -= amount;
					    	groupVariables[playerVariables[playerid][pGroup]][gSafe][1] += amount;
					    	format(string, sizeof(string), "You have deposited %d materials in your group safe.", amount);
				    		SendClientMessage(playerid, COLOR_WHITE, string);
				    		saveGroup(playerVariables[playerid][pGroup]);

							GetPlayerName(playerid, szPlayerName, MAX_PLAYER_NAME);
							format(string, sizeof(string), "* %s deposits %d materials in their group safe.", szPlayerName, amount);
							nearByMessage(playerid, COLOR_PURPLE, string);
						}
						else {
					    	SendClientMessage(playerid, COLOR_WHITE, "You don't have that amount of materials.");
						}
					}
					else if(strcmp(item, "drugs", true) == 0 ) {
						if(playerVariables[playerid][pDrugs] >= amount) {
					    	playerVariables[playerid][pDrugs] -= amount;
					    	groupVariables[playerVariables[playerid][pGroup]][gSafe][2] += amount;
					    	format(string, sizeof(string), "You have deposited %d drugs in your group safe.", amount);
				    		SendClientMessage(playerid, COLOR_WHITE, string);
				    		saveGroup(playerVariables[playerid][pGroup]);

							GetPlayerName(playerid, szPlayerName, MAX_PLAYER_NAME);
							format(string, sizeof(string), "* %s deposits %d drugs in their group safe.", szPlayerName, amount);
							nearByMessage(playerid, COLOR_PURPLE, string);
						}
						else {
					    	SendClientMessage(playerid, COLOR_WHITE, "You don't have that amount of drugs");
						}
					}
				}
				else {
				    SendClientMessage(playerid, COLOR_WHITE, "You must be at your group safe to do this.");
				}
			}
		}
	}
	return 1;
}
Reply
#2

pawn Код:
if(sscanf(params, "s[9]d", item, amount))
Reply
#3

Now /gdeposit materials doesen't working.
And console says [10:20:17] sscanf warning: String buffer overflow.
Reply
#4

"materials" is exactly 9 byts long. Change the size to like 11 or something.
pawn Код:
new item[11];
if(sscanf(params, "s[11]d", item, amount))
Reply
#5

Thanks.
Fixed!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)