SA-MP Forums Archive
No commands working - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: No commands working (/showthread.php?tid=205177)



No commands working - xir - 31.12.2010

Why doesnt any admin/afk commands working? I've put it all in one gamemode and made dcmd.. Ive not used zcmd or anything else...

Here is an example how my admin commands looks like..

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    new cmd[256], idx;
    cmd = strtok(cmdtext, idx);
    dcmd(explode, 6, cmdtext);
    return 0;
}
pawn Код:
dcmd_explode(playerid, params[])
{
    new pid;
    if(sscanf(params, "u", pid)) return SendClientMessage(playerid, Yellow, "Usage: /explode <playerid>");
    if(level[playerid] >= 3)
    {
    if(!IsPlayerConnected(pid)) return SendClientMessage(playerid, Red, "This player is not connected");
    new Float:X, Float:Y, Float:Z;
    GetPlayerPos(pid, X, Y, Z);
    CreateExplosion(X, Y, Z, 2, 10);
    SetPlayerArmour(pid, 0);
    SetPlayerHealth(pid, 0);
    new adminname[MAX_PLAYER_NAME], paramname[MAX_PLAYER_NAME], string[180];
    GetPlayerName(pid, paramname, sizeof(paramname));
    GetPlayerName(playerid, adminname, sizeof(adminname));
    format(string, sizeof(string), "Admin %s has exploded %s", adminname, paramname);
    MessageToAdmins(AdminColor, string);
    } else SendClientMessage(playerid, White, "SERVER: Unknown command.");
    return 1;
}
also should I put return 0; on the last onplayercommand cmd?


Re: No commands working - <Weponz> - 31.12.2010

ahh try removing this
pawn Код:
new cmd[256], idx;
    cmd = strtok(cmdtext, idx);
...


Edit:

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    dcmd(explode, 6, cmdtext);
    return 1;
}



Re: No commands working - HyperZ - 31.12.2010

Try this:
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    new cmd[256], idx;
    cmd = strtok(cmdtext, idx);
    dcmd(explode, 7, cmdtext);
    return 0;
}
pawn Код:
dcmd_explode(playerid, params[])
{
    if(level[playerid] < 3) SendClientMessage(playerid, White, "SERVER: Unknown command.");
    else
    {
        new pid;
        if(sscanf(params, "u", pid)) return SendClientMessage(playerid, Yellow, "Usage: /explode <playerid>");
        else if(IsPlayerConnected(pid) == 0) SendClientMessage(playerid, COLOR_RED, "Player is not connected");
        else
        {
        new Float:X, Float:Y, Float:Z;
        GetPlayerPos(pid, X, Y, Z);
        CreateExplosion(X, Y, Z, 2, 10);
        SetPlayerArmour(pid, 0);
        SetPlayerHealth(pid, 0);
        new adminname[MAX_PLAYER_NAME], paramname[MAX_PLAYER_NAME], string[180];
        GetPlayerName(pid, paramname, sizeof(paramname));
        GetPlayerName(playerid, adminname, sizeof(adminname));
        format(string, sizeof(string), "Admin %s has exploded %s", adminname, paramname);
        MessageToAdmins(AdminColor, string);
        }
    }
    return 1;
}



Re: No commands working - Mean - 31.12.2010

I had the same problem, it's actually "indentation" problem I think.
try
pawn Код:
dcmd_explode(playerid, params[])
instead of
pawn Код:
4spaces dcmd_explode(playerid, params[])



Re: No commands working - xir - 01.01.2011

I tried to delete everything and only left 1 command and that was /admins, and it worked both way So I will make each admin command and figure out which one was the problem


Re: No commands working - Kwarde - 01.01.2011

With dcmd you need to put the length of the command at the 2nd param:
dcmd(explode, 6, cmdtext);
is wrong. Explode has 7 characters. So this must work:
dcmd(explode, 7, cmdtext);