[CODE] String buffer overflow - help please
#1

//admin message/////////////////////////////////////////////////////////////
dcmd_a(playerid, params[])
{
if(pAdminLevel[playerid] >= 1 || IsPlayerAdmin(playerid))
{
new amessage[256], stringamessage[512], sendername[64];
if (sscanf(params, "s", amessage)) return SendClientMessage(playerid, 0xff0000aa, "* Usage: /a [message]");
GetPlayerName(playerid, sendername, sizeof(sendername));
format(stringamessage, sizeof(stringamessage), "ADMIN MESSAGE | %s: %s", sendername,amessage);
SendClientMessageToAll(blue, stringamessage);
return 1;
}
else return SendClientMessage(playerid, red, "You do not have permission to use this command");
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

no matter how big the string memory, when the message gets sent, 60% of it gets cut off and I get a message on the server saying


string buffer overflow and strings without a length are deprecated, please add a destination size
Reply
#2

pawn Код:
if (sscanf(params, "s[256]", amessage)) return SendClientMessage(playerid, 0xff0000aa, "* Usage: /a [message]");
instead of
pawn Код:
if (sscanf(params, "s", amessage)) return SendClientMessage(playerid, 0xff0000aa, "* Usage: /a [message]");
Replace the line
Reply
#3

thank you so much
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)