Sscanf warning: Strings without a length are deprecated, please add a destination size. -
denmark - 06.05.2014
Hello guys, so i'm not good at sscanf, and can't figure out what i've done wrong. But whenever i make a pm, i get this error in my server log: scanf warning: Strings without a length are deprecated, please add a destination size.
Well I do know that i need to add a string some where, but where exactly?
Could anyone help? Thanks.
Code:
PHP код:
CMD:pm(playerid, params[])
{
new pID, text[210], string[230];
if(sscanf(params, "us", pID, text)) return SendClientMessage(playerid, ERROR_COLOR, "USAGE: /pm (nick/id) (message) - Enter a valid Nick / ID");
if(!IsPlayerConnected(pID)) return SendClientMessage(playerid, ERROR_COLOR, "Player is not connected.");
if(pID == playerid) return SendClientMessage(playerid, ERROR_COLOR, "You cannot PM yourself.");
format(string, sizeof(string), "%s (%d) is not accepting private messages at the moment.", GetName(pID), pID);
if(PlayerInfo[pID][NoPM] == 1) return SendClientMessage(playerid, ERROR_COLOR, string);
format(string, sizeof(string), "PM to %s: %s", GetName(pID), text);
SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
format(string, sizeof(string), "PM from %s: %s", GetName(playerid), text);
SendClientMessage(pID, COLOR_LIGHTBLUE, string);
PlayerInfo[pID][Last] = playerid;
return 1;
}
CMD:r(playerid, params[])
{
new text[128], string[128];
if(sscanf(params, "s", text)) return SendClientMessage(playerid, ERROR_COLOR, "USAGE: /r (message) - Enter your message");
new pID = PlayerInfo[playerid][Last];
if(!IsPlayerConnected(pID)) return SendClientMessage(playerid, ERROR_COLOR, "Player is not connected.");
if(pID == playerid) return SendClientMessage(playerid, ERROR_COLOR, "You cannot PM yourself.");
format(string, sizeof(string), "%s (%d) is not accepting private messages at the moment.", GetName(pID), pID);
if(PlayerInfo[pID][NoPM] == 1) return SendClientMessage(playerid, ERROR_COLOR, string);
format(string, sizeof(string), "PM to %s: %s", GetName(pID), text);
SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
format(string, sizeof(string), "PM from %s: %s", GetName(playerid), text);
SendClientMessage(pID, COLOR_LIGHTBLUE, string);
PlayerInfo[pID][Last] = playerid;
return 1;
}
Re: Sscanf warning: Strings without a length are deprecated, please add a destination size. -
Konstantinos - 06.05.2014
For strings in sscanf, you should add the lenght in square brackets after "s" specifier. For example:
pawn Код:
if(sscanf(params, "us[100]", pID, text))
You don't need sscanf at the command /r since it uses only one parameter and that's string. You can use isnull to return the usage and params as "text".
Re: Sscanf warning: Strings without a length are deprecated, please add a destination size. -
PrivatioBoni - 06.05.2014
if(sscanf(params, "us[210]", pID, text))
Same principle for the other/s.
NOTE: I just used 210 because you did, but that's not necessary.
Re: Sscanf warning: Strings without a length are deprecated, please add a destination size. -
Eth - 06.05.2014
pawn Код:
CMD:pm(playerid, params[])
{
new pID, text[210], string[230],string2[250],string3[250];
if(sscanf(params, "us[110]", pID, text)) return SendClientMessage(playerid, ERROR_COLOR, "USAGE: /pm (nick/id) (message) - Enter a valid Nick / ID");
if(!IsPlayerConnected(pID)) return SendClientMessage(playerid, ERROR_COLOR, "Player is not connected.");
if(pID == playerid) return SendClientMessage(playerid, ERROR_COLOR, "You cannot PM yourself.");
format(string, sizeof(string), "%s (%d) is not accepting private messages at the moment.", GetName(pID), pID);
if(PlayerInfo[pID][NoPM] == 1) return SendClientMessage(playerid, ERROR_COLOR, string);
format(string2, sizeof(string2), "PM to %s: %s", GetName(pID), text);
SendClientMessage(playerid, COLOR_LIGHTBLUE, string2);
format(string3, sizeof(string3), "PM from %s: %s", GetName(playerid), text);
SendClientMessage(pID, COLOR_LIGHTBLUE, string3);
PlayerInfo[pID][Last] = playerid;
return 1;
}
CMD:r(playerid, params[])
{
new text[128], string[128],string2[128],string3[128];
if(sscanf(params, "us[110]", text)) return SendClientMessage(playerid, ERROR_COLOR, "USAGE: /r (message) - Enter your message");
new pID = PlayerInfo[playerid][Last];
if(!IsPlayerConnected(pID)) return SendClientMessage(playerid, ERROR_COLOR, "Player is not connected.");
if(pID == playerid) return SendClientMessage(playerid, ERROR_COLOR, "You cannot PM yourself.");
format(string, sizeof(string), "%s (%d) is not accepting private messages at the moment.", GetName(pID), pID);
if(PlayerInfo[pID][NoPM] == 1) return SendClientMessage(playerid, ERROR_COLOR, string);
format(string2, sizeof(string2), "PM to %s: %s", GetName(pID), text);
SendClientMessage(playerid, COLOR_LIGHTBLUE, string2);
format(string3, sizeof(string3), "PM from %s: %s", GetName(playerid), text);
SendClientMessage(pID, COLOR_LIGHTBLUE, string3);
PlayerInfo[pID][Last] = playerid;
return 1;
}
Re: Sscanf warning: Strings without a length are deprecated, please add a destination size. -
denmark - 06.05.2014
Thank you very much guys, really apperciated!