20.02.2013, 17:22
It gives me a printf error:
sscanf warning: String buffer overflow.
And this doesn't work... what should I do?
It's the last question
The freaking /note give [playerid] does not work, and it's the same as the others..
sscanf warning: String buffer overflow.
And this doesn't work... what should I do?
It's the last question
Код:
CMD:note(playerid, params[])
{
new option[7],str[256];
if(sscanf(params,"s[7]",option)) return SyntaxMSG(playerid, "/note [show/create/remove/give]");
if(!strcmp(option, "show", true))
{
SCM(playerid, COLOR_YELLOWG, "|____________Notes____________|");
format(str, sizeof(str), "Note 1: {94EDED}%s{FFFFFF}.", PlayerInfo[playerid][pNote1]);
SCM(playerid, -1, str);
format(str, sizeof(str), "Note 2: {94EDED}%s{FFFFFF}.", PlayerInfo[playerid][pNote2]);
SCM(playerid, -1, str);
format(str, sizeof(str), "Note 3: {94EDED}%s{FFFFFF}.", PlayerInfo[playerid][pNote3]);
SCM(playerid, -1, str);
SCM(playerid, COLOR_YELLOWG, "|_____________________________|");
format(str, sizeof(str), "* %s takes out a few paper notes and looks through them.", GetNameWithMask(playerid));
ProxDetector(30.0, playerid, str, COLOR_PURPLE);
}
else if(!strcmp(option, "create", true))
{
new szText[129];
if(sscanf(params, "{s[7]}s[129]", szText)) return SyntaxMSG(playerid, "/note create [text]");
if(PlayerInfo[playerid][pNote1s] == 0)
{
strmid(PlayerInfo[playerid][pNote1], szText, 0, strlen(szText), 255);
PlayerInfo[playerid][pNote1s] = 1;
NoteMSG(playerid, "Note created successfuly.");
return 1;
}
else if(PlayerInfo[playerid][pNote2s] == 0)
{
strmid(PlayerInfo[playerid][pNote2], szText, 0, strlen(szText), 255);
PlayerInfo[playerid][pNote2s] = 1;
NoteMSG(playerid, "Note created successfuly.");
return 1;
}
else if(PlayerInfo[playerid][pNote3s] == 0)
{
strmid(PlayerInfo[playerid][pNote3], szText, 0, strlen(szText), 255);
PlayerInfo[playerid][pNote3s] = 1;
NoteMSG(playerid, "Note created successfuly.");
return 1;
}
else
{
NoteMSG(playerid, "You have no free pages left at your notebook.");
return 1;
}
}
else if(!strcmp(option, "remove", true))
{
new iNoteID;
if(sscanf(params, "{s[7]}d", iNoteID)) return SyntaxMSG(playerid, "/note remove [note id]");
switch(iNoteID)
{
case 1:
if(PlayerInfo[playerid][pNote1s] == 1)
{
strmid(PlayerInfo[playerid][pNote1], "None", 0, strlen("None"), 255);
PlayerInfo[playerid][pNote1s] = 0;
NoteMSG(playerid, "(slot 1) has been deleted successfuly.");
}
else
{
NoteMSG(playerid, "You don't have a note at slot 1.");
}
case 2:
if(PlayerInfo[playerid][pNote2s] == 1)
{
strmid(PlayerInfo[playerid][pNote2], "None", 0, strlen("None"), 255);
PlayerInfo[playerid][pNote2s] = 0;
NoteMSG(playerid, "(slot 2) has been deleted successfuly.");
}
else
{
NoteMSG(playerid, "You don't have a note at slot 2.");
}
case 3:
if(PlayerInfo[playerid][pNote3s] == 1)
{
strmid(PlayerInfo[playerid][pNote3], "None", 0, strlen("None"), 255);
PlayerInfo[playerid][pNote3s] = 0;
NoteMSG(playerid, "(slot 3) has been deleted successfuly.");
}
else
{
NoteMSG(playerid, "You don't have a note at slot 3.");
}
}
}
else if(!strcmp(option, "give", true))
{
new pid;
if(sscanf(params, "{s[7]}d", pid)) return SyntaxMSG(playerid, "/note give [playerid]");
}
return 1;
}

