/givecookie bug -
Maxandmov - 14.02.2012
I was updating my JMTDM script to new version and when I scripted this /givecookie CMD it bugged. When I type integer reason then it works good... Else if it's string then it bugs me with SERVER: Unknown command! Help me to fix that!
Код:
CMD:givecookie(playerid, params[]) // CMD for giving somebody a cookie
{
new pid;
new reason;
new str[128];
if(sscanf(params, "us", pid, reason)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /givecookie [Player ID] [Reason]");
if(!IsPlayerConnected(pid)) return SendClientMessage(playerid, COLOR_RED, "PlayerID is not connected.");
if (PlayerInfo[playerid][pAdmin]>=4)
{
format(str, sizeof(str), "%s have been granted a cookie by %s. Reason: %s", GetName(pid), GetName(playerid), reason);
SendClientMessageToAll(COLOR_RED, str);
format(str, sizeof(str), "You just gave a cookie to %s.", GetName(pid));
SendClientMessage(playerid, COLOR_RED, str);
PlayerInfo[playerid][pCookies]=PlayerInfo[playerid][pCookies]+1;
}
else SendClientMessage(playerid, COLOR_RED, "You must be an admin to use that command!");
return 1;
}
Re: /givecookie bug -
emokidx - 14.02.2012
pawn Код:
if(sscanf(params, "us[128]", pid..........
i think
Re: /givecookie bug -
SpiderWalk - 14.02.2012
100 percent bug is in 2 lines i quess in those
pawn Код:
new str[144];
if(sscanf(params, "us[144]", pid, reason)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /givecookie [Player ID] [Reason]");
Maybe this will work...Just dont add that variable for string!
Re: /givecookie bug -
Maxandmov - 14.02.2012
Yeah it bugs somewhere in the line
Код:
if(sscanf(params, "us", pid, reason))...
because it writes that it's unknown command and nothing happens.
I'll try to make s[128] as you suggested.
Re: /givecookie bug -
Maxandmov - 14.02.2012
More I found: If I type one letter, then it works. Why it doesn't work with 2+ letters?
Re: /givecookie bug -
Konstantinos - 14.02.2012
sscanf needs for string "s[value]". Also, you have to define reason as a string with array.
pawn Код:
CMD:givecookie(playerid, params[]) // CMD for giving somebody a cookie
{
new pid;
new reason[128];
new str[128];
if(sscanf(params, "us[128]", pid, reason)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /givecookie [Player ID] [Reason]");
if(!IsPlayerConnected(pid)) return SendClientMessage(playerid, COLOR_RED, "PlayerID is not connected.");
if (PlayerInfo[playerid][pAdmin]>=4)
{
format(str, sizeof(str), "%s have been granted a cookie by %s. Reason: %s", GetName(pid), GetName(playerid), reason);
SendClientMessageToAll(COLOR_RED, str);
format(str, sizeof(str), "You just gave a cookie to %s.", GetName(pid));
SendClientMessage(playerid, COLOR_RED, str);
PlayerInfo[pid][pCookies] ++; // ++ -> x = x + 1
}
else SendClientMessage(playerid, COLOR_RED, "You must be an admin to use that command!");
return 1;
}
Re: /givecookie bug -
Maxandmov - 14.02.2012
Let me check it..
Re: /givecookie bug -
Maxandmov - 14.02.2012
This works for now. Thanks.
Re: /givecookie bug -
Konstantinos - 14.02.2012
Also, I edited. That
pawn Код:
PlayerInfo[playerid][pCookies] ++;
should be
pawn Код:
PlayerInfo[pid][pCookies] ++;
Because it will give the cookie to the Admin and not at the pid!