None of my cmdtext is being detected.
#1

Well, title says it all, none of my cmdtext is being detected, I debugged it and tried to print the cmdtext, but it prints nothing. I started off with the plain old strcmp, then tried dcmd, but still didn't work, because something in my script is stopping the cmdtext from being detected, but I'd have no idea what? I've got no FilterScripts that would make this happen, if it helps here's my OnPlayerCommandText:
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    print(cmdtext);
    new string[258];
    new tmp[128];
    new cmd[128];
    new sendername[MAX_PLAYER_NAME];
    new giveplayer[MAX_PLAYER_NAME];
    new giveplayerid, idx;
    cmd = strtok(cmdtext, idx);
    if(strcmp(cmd, "/stats", true) == 0)
    {
        if(GetPVarInt(playerid, "Logged") == 0)
        {
            SendClientMessage(playerid, COLOR_LIGHTRED, "You are not logged in!");
            return 1;
        }
        new line2[128], line3[128], line4[128], team[128];
        format( line2, sizeof(line2), ">>      Los Santos Gang Wars Statitics    <<");
        format( line3, sizeof(line3), "__________________________________________");
        new level = PlayerInfo[playerid][pScore];
        new admlevel = PlayerInfo[playerid][pAdmin];
        new kills = PlayerInfo[playerid][pKills];
        new deaths = PlayerInfo[playerid][pDeaths];
        new cash = PlayerInfo[playerid][pMoney];
        new vip = PlayerInfo[playerid][pVIP];
        SendClientMessage(playerid, COLOR_ORANGE, line2);
        SendClientMessage(playerid, COLOR_LIGHTBLUE, line3);
        format(string, sizeof(string), "Name: %s(%d)", PlayerName(playerid), playerid);
        SendClientMessage(playerid, COLOR_WHITE, string);
        format(string, sizeof(string), "Level: %d", level);
        SendClientMessage(playerid, COLOR_WHITE, string);
        format(string, sizeof(string), "Admin Level: %d", admlevel);
        SendClientMessage(playerid, COLOR_WHITE, string);
        format(string, sizeof(string), "Kills: %d - Deaths: %d", kills, deaths);
        SendClientMessage(playerid, COLOR_WHITE, string);
        format(string, sizeof(string), "Cash: %d", cash);
        SendClientMessage(playerid, COLOR_WHITE, string);
        format(string, sizeof(string), "VIP: %d", vip);
        SendClientMessage(playerid, COLOR_WHITE, string);
        if(gTeam[playerid] == TEAM_GROVE) { team = "Grove St. Gangstas (1)"; }
        if(gTeam[playerid] == TEAM_BALLAS) { team = "Temple Drive Ballas (2)"; }
        if(gTeam[playerid] == TEAM_AZTECAS) { team = "Los Aztecas (3)"; }
        if(gTeam[playerid] == TEAM_VAGOS) { team = "Los Santos Vagos (4)"; }
        format(string, sizeof(string), "Team: %s", team);
        SendClientMessage(playerid, COLOR_WHITE, string);
        format( line4, sizeof(line4), "__________________________________________");
        SendClientMessage(playerid, COLOR_LIGHTRED, line4);
        return 1;
    }
    if(strcmp(cmd, "/g", true) == 0 || strcmp(cmd, "/global", true) == 0)
    {
        if(GetPVarInt(playerid, "Logged") == 0)
        {
            SendClientMessage(playerid, COLOR_LIGHTRED, "You are not logged in!");
            return 1;
        }
        new len = strlen(cmd);
        if(!strlen(cmdtext[len+1]))
        {
            SendClientMessage(playerid, COLOR_ORANGE, "CMD: /g(lobal) [message]");
            return 1;
        }
        GetPlayerName(playerid, sendername, sizeof(sendername));
        format(string, sizeof(string), "[GLOBAL] %s(%d) says: %s", sendername, playerid, cmdtext[len+1]);
        SendClientMessageToAll(COLOR_WHITE, string);
        return 1;
    }

    if(strcmp(cmd, "/pm", true) == 0)
    {
        if(GetPVarInt(playerid, "Logged") == 0)
        {
            SendClientMessage(playerid, COLOR_LIGHTRED, "You are not logged in!");
            return 1;
        }
        tmp = strtok(cmdtext, idx);
        if(!strlen(tmp))
        {
            SendClientMessage(playerid, COLOR_ORANGE, "CMD: /pm [playerid/name] [message]");
            return 1;
        }
        giveplayerid = ReturnUser(tmp);
        if(GetPVarInt(giveplayerid, "Logged") == 0)
        {
            SendClientMessage(playerid, COLOR_LIGHTRED, "That player has not logged in!");
            return 1;
        }
        if(playerid == giveplayerid)
        {
            SendClientMessage(playerid, COLOR_LIGHTRED, "You cannot PM yourself, silly!");
            return 1;
        }
        if(BlockingPM[giveplayerid] == 1)
        {
            SendClientMessage(playerid, COLOR_LIGHTRED, "That player is blocking PMs!");
            return 1;
        }
        if(!strlen(cmdtext[strlen(cmd)+strlen(tmp)+2]))
        {
            SendClientMessage(playerid, COLOR_ORANGE, "CMD: /pm [playerid/name] [message]");
            return 1;
        }
        GetPlayerName(playerid, sendername, sizeof(sendername));
        GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
        format(string, sizeof(string), "PM: You have sent a PM to %s.", giveplayer);
        SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
        format(string, sizeof(string), "PM From %s(%d): %s", sendername, playerid, cmdtext[strlen(cmd)+strlen(tmp)+2]);
        SendClientMessage(giveplayerid, COLOR_LIGHTBLUE, string);
        return 1;
    }
    if(strcmp(cmd, "/ban", true) == 0)
    {
        if(GetPVarInt(playerid, "Logged") == 0)
        {
            SendClientMessage(playerid, COLOR_LIGHTRED, "You are not logged in!");
            return 1;
        }
        if(PlayerInfo[playerid][pAdmin] < 1)
        {
            SendClientMessage(playerid, COLOR_LIGHTRED, "ADM: You're not authorized to use this command!");
            return 1;
        }
        tmp = strtok(cmdtext, idx);
        if(!strlen(tmp))
        {
            SendClientMessage(playerid, COLOR_ORANGE, "ADM: /ban [playerid/name] [ban reason]");
            return 1;
        }
        giveplayerid = ReturnUser(tmp);
        if(giveplayerid == INVALID_PLAYER_ID)
        {
            SendClientMessage(playerid, COLOR_LIGHTRED, "Invalid playerid/name!");
            return 1;
        }
        if(GetPVarInt(giveplayerid, "Logged") == 0)
        {
            SendClientMessage(playerid, COLOR_LIGHTRED, "That player has not logged in!");
            return 1;
        }
        if(playerid == giveplayerid)
        {
            SendClientMessage(playerid, COLOR_LIGHTRED, "You cannot ban yourself, silly!");
            return 1;
        }
        GetPlayerName(playerid, sendername, sizeof(sendername));
        GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
        if(!strlen(cmdtext[strlen(cmd)+strlen(tmp)+2]))
        {
            SendClientMessage(playerid, COLOR_ORANGE, "CMD: /pm [playerid/name] [message]");
            return 1;
        }
        new banreason = cmdtext[strlen(cmd)+strlen(tmp)+2];
        format(string, sizeof(string), "ADM: %s has been banned by an Admin, reason: %s", giveplayer, banreason);
        SendClientMessageToAll(COLOR_LIGHTRED, string);
        format(string, sizeof(string), "ADM: You've been banned by an Admin, reason: %s", banreason);
        SendClientMessage(giveplayerid, COLOR_LIGHTRED, string);
        format(string, sizeof(string), "ADMWARN: %s has banned %s for %s", sendername, giveplayer, banreason);
        foreach (Player, i)
        {
            if(PlayerInfo[i][pAdmin] >= 1)
            {
                SendClientMessage(i, COLOR_LIGHTRED, string);
                return 1;
            }
        }
        PlayerInfo[giveplayerid][pBanned] = 1;
        format(string, sizeof(string), "Ban Reason: %s", banreason);
        strmid(PlayerInfo[giveplayerid][pBanReason], string, 0, strlen(string), 255);
        Kick(giveplayerid);
        return 1;
    }
    if(strcmp(cmd, "/blockpm", true) == 0)
    {
        if(GetPVarInt(playerid, "Logged") == 0)
        {
            SendClientMessage(playerid, COLOR_LIGHTRED, "You are not logged in!");
            return 1;
        }
        if(BlockingPM[playerid] == 0)
        {
            BlockingPM[playerid] = 1;
            SendClientMessage(playerid, COLOR_ORANGE, "CMD: You are now blocking PMs!");
            return 1;
        }
        if(BlockingPM[playerid] == 1)
        {
            BlockingPM[playerid] = 0;
            SendClientMessage(playerid, COLOR_ORANGE, "CMD: You have unblocked PMs!");
            return 1;
        }
        return 1;
    }
    if(strcmp(cmd, "/buylevel", true) == 0)
    {
        if(GetPVarInt(playerid, "Logged") == 0)
        {
            SendClientMessage(playerid, COLOR_LIGHTRED, "You are not logged in!");
            return 1;
        }
        new levelcost = 10000;
        new nxtlevel = PlayerInfo[playerid][pScore]+1;
        new costlevel = nxtlevel*levelcost;
        if(PlayerInfo[playerid][pMoney] < costlevel)
        {
            format(string, sizeof(string), "You can't afford that! (%d)", costlevel);
            SendClientMessage(playerid, COLOR_LIGHTRED, string);
            return 1;
        }
        else
        {
            GivePlayerMoney(playerid, -costlevel);
            PlayerInfo[playerid][pMoney] = PlayerInfo[playerid][pMoney] - costlevel;
            PlayerInfo[playerid][pScore]++;
            format(string, sizeof(string), "You've bought Level %d for %d!", nxtlevel, costlevel);
            SendClientMessage(playerid, COLOR_VAGOS, string);
            SetPlayerScore(playerid, nxtlevel);
            return 1;
        }
        return 1;
    }
    if (strcmp(cmd, "/savepos", true)==0)
    {
        new Float:X, Float:Z, Float:Y, Float:A;
        GetPlayerPos(playerid, X, Y, Z);
        GetPlayerFacingAngle(playerid, A);
        new File:pos=fopen("OnFootPos.txt", io_append);
        format(string, sizeof(string), "(%f, %f, %f, %f);\r\n", X, Y, Z, A);
        SendClientMessage(playerid,COLOR_GREY,"OnFootPosition saved to OnFootPos.txt !");
        fwrite(pos, string);
        fclose(pos);
        return 1;
    }
    if (strcmp(cmd, "/savecampos", true)==0)
    {
        new Float:X, Float:Z, Float:Y;
        GetPlayerCameraPos(playerid, X, Y, Z);
        new File:pos=fopen("CameraPos.txt", io_append);
        format(string, sizeof(string), "(%f, %f, %f);\r\n", X, Y, Z);
        SendClientMessage(playerid,COLOR_GREY,"CameraPos saved to CameraPos.txt !");
        fwrite(pos, string);
        fclose(pos);
        return 1;
    }
    if(strcmp(cmd, "/kill", true) == 0)
    {
        SetPlayerHealth(playerid, 0);
        format(string, sizeof(string), "%s(%d) has just committed suicide!", PlayerName(playerid), playerid);
        SendClientMessageToAll(COLOR_LIGHTRED, string);
        return 1;
    }
    if(strcmp(cmd, "/class", true) == 0)
    {
        SetPlayerHealth(playerid, 0);
        ForceClassSelection(playerid);
        format(string, sizeof(string), "%s(%d) has killed himself.", PlayerName(playerid), playerid);
        SendClientMessageToAll(COLOR_LIGHTRED, string);
        ForceClassSelection(playerid);
        return 1;
    }
    return 0;
}
And please don't tell me to use dcmd or anything else because I've already tried, it's my actual cmdtext that isn't being read.
Reply
#2

Are you using zcmd/ycmd at all in your script, like is it even included?
Reply
#3

try
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
new string[256];
new sendername[MAX_PLAYER_NAME];
new giveplayer[MAX_PLAYER_NAME];
new giveplayerid, idx;
new tmp[128];
new cmd[128];
cmd = strtok(cmdtext, idx);
Reply
#4

Quote:
Originally Posted by PrawkC
Посмотреть сообщение
Are you using zcmd/ycmd at all in your script, like is it even included?
Wow, I did have y_commands included, and that's why, you were the first person to even mention that so I removed it and it worked, weird. Thankyou!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)