unknown command -
StR_MaRy - 07.10.2016
hey guys i have a /nre command but for me is working when i type /nre message but for a friend it gives a error but i get the answear , but he get this error:
http://imgur.com/a/kmsmE
Код HTML:
CMD:nre(playerid, params[])
{
new message[164], nstring[164];
if(gLogged[playerid] == 0) return SendClientMessage(playerid, COLOR_ERROR, "Tu nu esti logat si nu poti sa folosesti aceasta comanda!");
if(PlayerInfo[playerid][pGamingPerk] == 0) return SendClientMessage(playerid, COLOR_ERROR, "Nu ai acces la aceasta comanda!");
if(HelperAnswer[playerid] == -1) return SendClientMessage(playerid, COLOR_ERROR, "Nu ai primit o intrebare.");
if(sscanf(params,"s[164]", message)) return SendClientMessage(playerid, COLOR_SYN,"Sintaxa:{FFFFFF} /nre <raspuns>");
{
if(PlayerInfo[playerid][pHelper] >= 1)
{
PlayerInfo[playerid][pStaffPoints]++;
Update(playerid, pStaffPointsx);
Questions--;
UpdateStaffTextdraw();
format(gString, sizeof(gString), "(N - A) Helper %s: @%s, %s", GetName(playerid),GetName(HelperAnswer[playerid]), message);
new string2[128];
if(strlen(gString) > 120)
{
strmid(string2, gString, 110, 256);
strdel(gString, 110, 256);
format(gString,128,"%s ...",gString);
format(string2,128,"... %s",string2);
}
foreach(new x : Player)
{
if(NewbieEnabled[x] == 1)
{
format(nstring, sizeof(nstring), "(N - Q) Newbie %s: %s", GetName(HelperAnswer[playerid]),PlayerInfo[HelperAnswer[playerid]][pNewbie]);
SendClientMessage(x,COLOR_NOB, nstring);
if(strlen(gString) > 120)
{
SendClientMessageToAll(COLOR_YELLOW, gString);
SendClientMessageToAll(COLOR_NOB, string2);
}
else
{
SendClientMessage(x,COLOR_YELLOW, gString);
}
}
if(HelperAnswer[x] == playerid)
{
format(PlayerInfo[x][pNewbie],164," ");
HelperAnswer[x] = -1;
HelperAnswer[playerid] = -1;
}
if(strlen(PlayerInfo[x][pNewbie]) > 1 && HelperAnswer[x] == -1)
{
format(gString, sizeof(gString), "(Question) %s - lvl %d: %s", GetName(x), PlayerInfo[x][pLevel], PlayerInfo[x][pNewbie]);
SendClientMessage(playerid, COLOR_NEWBIE, gString);
HelperAnswer[x] = playerid;
HelperAnswer[playerid] = x;
format(gString, sizeof(gString), "Intrebarea ta a fost atribuita helperului %s, te rugam sa astepti raspunsul acestuia.", GetName(HelperAnswer[playerid]));
SendClientMessage(x,COLOR_NOB,gString);
SendClientMessage(x,COLOR_NOB,"Chat-ul (/n)ewbie a fost activat automat. Dupa ce primesti un raspuns il poti dezactiva (/nonewbie)");
break;
}
}
}
else return SendClientMessage(playerid, COLOR_GREY, "Nu ai gradul necesar ca sa folosesti aceasta comanda!");
}
return 1;
}
Re: unknown command -
AndySedeyn - 07.10.2016
You are opening the if body after
if(sscanf(...)) return SendClientMessage(...);. The if-statement stops the moment you return something or the moment it reaches its closing bracket. So having all that code in a non-existing (function/if/else/else if) body may be causing the error.
PHP код:
CMD:nre(playerid, params[])
{
new message[164], nstring[164];
if(gLogged[playerid] == 0) return SendClientMessage(playerid, COLOR_ERROR, "Tu nu esti logat si nu poti sa folosesti aceasta comanda!");
if(PlayerInfo[playerid][pGamingPerk] == 0) return SendClientMessage(playerid, COLOR_ERROR, "Nu ai acces la aceasta comanda!");
if(HelperAnswer[playerid] == -1) return SendClientMessage(playerid, COLOR_ERROR, "Nu ai primit o intrebare.");
if(sscanf(params,"s[164]", message)) return SendClientMessage(playerid, COLOR_SYN,"Sintaxa:{FFFFFF} /nre <raspuns>");
if(PlayerInfo[playerid][pHelper] >= 1)
{
PlayerInfo[playerid][pStaffPoints]++;
Update(playerid, pStaffPointsx);
Questions--;
UpdateStaffTextdraw();
format(gString, sizeof(gString), "(N - A) Helper %s: @%s, %s", GetName(playerid),GetName(HelperAnswer[playerid]), message);
new string2[128];
if(strlen(gString) > 120)
{
strmid(string2, gString, 110, 256);
strdel(gString, 110, 256);
format(gString,128,"%s ...",gString);
format(string2,128,"... %s",string2);
}
foreach(new x : Player)
{
if(NewbieEnabled[x] == 1)
{
format(nstring, sizeof(nstring), "(N - Q) Newbie %s: %s", GetName(HelperAnswer[playerid]),PlayerInfo[HelperAnswer[playerid]][pNewbie]);
SendClientMessage(x,COLOR_NOB, nstring);
if(strlen(gString) > 120)
{
SendClientMessageToAll(COLOR_YELLOW, gString);
SendClientMessageToAll(COLOR_NOB, string2);
}
else
{
SendClientMessage(x,COLOR_YELLOW, gString);
}
}
if(HelperAnswer[x] == playerid)
{
format(PlayerInfo[x][pNewbie],164," ");
HelperAnswer[x] = -1;
HelperAnswer[playerid] = -1;
}
if(strlen(PlayerInfo[x][pNewbie]) > 1 && HelperAnswer[x] == -1)
{
format(gString, sizeof(gString), "(Question) %s - lvl %d: %s", GetName(x), PlayerInfo[x][pLevel], PlayerInfo[x][pNewbie]);
SendClientMessage(playerid, COLOR_NEWBIE, gString);
HelperAnswer[x] = playerid;
HelperAnswer[playerid] = x;
format(gString, sizeof(gString), "Intrebarea ta a fost atribuita helperului %s, te rugam sa astepti raspunsul acestuia.", GetName(HelperAnswer[playerid]));
SendClientMessage(x,COLOR_NOB,gString);
SendClientMessage(x,COLOR_NOB,"Chat-ul (/n)ewbie a fost activat automat. Dupa ce primesti un raspuns il poti dezactiva (/nonewbie)");
break;
}
}
}
else SendClientMessage(playerid, COLOR_GREY, "Nu ai gradul necesar ca sa folosesti aceasta comanda!");
return 1;
}
Also, you don't need a character size of 164 for your message as the maximum chat input is 128 characters. Besides, you don't even need sscanf. Using
isnull(params) is more than sufficient when you have 1 parameter.
isnull() comes with ZCMD, else:
https://sampwiki.blast.hk/wiki/Isnull
Re: unknown command -
StR_MaRy - 07.10.2016
is not working , same thing
Re: unknown command -
DTV - 08.10.2016
Try debugging it by placing prints throughout bits of the code:
pawn Код:
CMD:nre(playerid, params[])
{
new message[164], nstring[164];
if(gLogged[playerid] == 0) return SendClientMessage(playerid, COLOR_ERROR, "Tu nu esti logat si nu poti sa folosesti aceasta comanda!");
if(PlayerInfo[playerid][pGamingPerk] == 0) return SendClientMessage(playerid, COLOR_ERROR, "Nu ai acces la aceasta comanda!");
if(HelperAnswer[playerid] == -1) return SendClientMessage(playerid, COLOR_ERROR, "Nu ai primit o intrebare.");
if(sscanf(params,"s[164]", message)) return SendClientMessage(playerid, COLOR_SYN,"Sintaxa:{FFFFFF} /nre <raspuns>");
print("1");
if(PlayerInfo[playerid][pHelper] >= 1)
{
PlayerInfo[playerid][pStaffPoints]++;
Update(playerid, pStaffPointsx);
Questions--;
UpdateStaffTextdraw();
print("2");
//other code, I think you get the idea