Executed ZCMD command returns SERVER: Unknown Command
#1

Hello everyone,
I use ZCMD, sscanf and Diler's MultiLanguage include.
When I try to use /kick command without being an admin, first MultiLanguage language returns both !success message and SERVER: Unknown command.
Here is the command:
Code:
COMMAND:kick(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] >= 3) return 0; //LanguageMessage(playerid, COLOR_RED, LANGUAGE_EN, "You can't use this command!", LANGUAGE_LT, "Negali naudoti рios komandos!");
    new pid, reason[105];
	if(sscanf(params, "uS(No Reason Given)[128]", pid, reason)) return LanguageMessage(playerid, COLOR_RED, LANGUAGE_EN, ""GREEN"Usage: "WHITE"/kick [playerid/name] [reason].", LANGUAGE_LT, ""WHITE"Naudojimas:"GREEN" /kick [id/vardas] [prieюastis]");
    if(IsPlayerConnected(pid) && pid != INVALID_PLAYER_ID && pid != playerid)
    {
        new adminname[MAX_PLAYER_NAME], paramname[MAX_PLAYER_NAME], string[180], ltstring[180];
        GetPlayerName(pid, paramname, sizeof(paramname));
        GetPlayerName(playerid, adminname, sizeof(adminname));
        format(string, sizeof(string), "%s has been kicked by %s for: %s", paramname, adminname, reason);
        format(ltstring, sizeof(ltstring), "%s iрkickino %s uю: %s", adminname, paramname, reason);
        LanguageMessageToAll(COLOR_LIME, LANGUAGE_EN, string, LANGUAGE_LT, ltstring);
        Kick(pid);
    }
    else return LanguageMessage(playerid, COLOR_RED, LANGUAGE_EN, "You can't kick yourself or player that is not connected!", LANGUAGE_LT, "Negali iрkickinti savжs ar юaidлjo kuris neprisijungжs!");
	return 1;
}
When this
Code:
if(PlayerInfo[playerid][pAdmin] >= 3) return 0; //LanguageMessage(playerid, COLOR_RED, LANGUAGE_EN, "You can't use this command!", LANGUAGE_LT, "Negali naudoti рios komandos!");
is used, it returns me 3 messages:
You can't use this command!
There is no such command. Type /cmds for commands list.
SERVER: Unknown command.

Here is my OnPlayerCommandPerformed callback:
Code:
public OnPlayerCommandPerformed(playerid, cmdtext[], success)
{
   	if(!success) return LanguageMessage(playerid, 0xFF0000FF, LANGUAGE_EN, "{FFFFFF}[LFR]: {FF0000}There is no such command. Type /cmds for commands list.", LANGUAGE_LT, "{FFFFFF}[LFR]: {FF0000}Tokios komandos nлra! Raрykite /komandos, kad pamatytumлte komandш saraра.");
   	return 1;
}
I'm out of ideas. Don't know what to do. Could it be MultiLanguage's fault?
Reply
#2

pawn Code:
COMMAND:kick(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] >= 3) return 0; //LanguageMessage(playerid, COLOR_RED, LANGUAGE_EN, "You can't use this command!", LANGUAGE_LT, "Negali naudoti рios komandos!");
    new pid, reason[105];
    if(sscanf(params, "us[128]", pid, reason))
        return LanguageMessage(playerid, COLOR_RED, LANGUAGE_EN, ""GREEN"Usage: "WHITE"/kick [playerid/name] [reason].", LANGUAGE_LT, ""WHITE"Naudojimas:"GREEN" /kick [id/vardas] [prieюastis]");

    if(reason == ' ' || reason == EOS) format(reason, sizeof(reason),"No Reason Given");
   
    if(IsPlayerConnected(pid) && pid != INVALID_PLAYER_ID && pid != playerid)
    {
        new adminname[MAX_PLAYER_NAME], paramname[MAX_PLAYER_NAME], string[180], ltstring[180];
        GetPlayerName(pid, paramname, sizeof(paramname));
        GetPlayerName(playerid, adminname, sizeof(adminname));
        format(string, sizeof(string), "%s has been kicked by %s for: %s", paramname, adminname, reason);
        format(ltstring, sizeof(ltstring), "%s iрkickino %s uю: %s", adminname, paramname, reason);
        LanguageMessageToAll(COLOR_LIME, LANGUAGE_EN, string, LANGUAGE_LT, ltstring);
        Kick(pid);
    }
    else return LanguageMessage(playerid, COLOR_RED, LANGUAGE_EN, "You can't kick yourself or player that is not connected!", LANGUAGE_LT, "Negali iрkickinti savжs ar юaidлjo kuris neprisijungжs!");
    return 1;
}
Reply
#3

Your code gives me
Code:
error 033: array must be indexed (variable "reason")
wich is this line:
Code:
if(reason == ' ' || reason == EOS) format(reason, sizeof(reason),"No Reason Given");
Huh
Reply
#4

reason[0]
Reply
#5

yeah
pawn Code:
if(reason[0] == ' ' || reason[0] == EOS) format(reason, sizeof(reason),"No Reason Given");
Reply
#6

Thank you for your help, but still, once I type this, or any other command it gives me:
Reply
#7

public OnPlayerCommandReceived(playerid, cmdtext[])
Reply
#8

Can you explain what do I need to do with it? I've added OnPlayerCommandReceived(playerid, cmdtext[]).
Reply
#9

Sorry for BUMP'ing, but I need to know this. Script developing has stopped. :/
Reply
#10

Use this
PHP Code:
if(PlayerInfo[playerid][pAdmin] <= 3) return 0
or
PHP Code:
if(PlayerInfo[playerid][pAdmin] == 3) return 0
Reply
#11

>= not == nor <=
Reply
#12

Change the

if(PlayerInfo[playerid][pAdmin] >= 3) return 0;

to

if(PlayerInfo[playerid][pAdmin] < 3) return 1;
Reply
#13

Still shows this:
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)