Some commands not working.
#1

HI!

I changed the old dcmd for a new command processor zCMD and all of my strcmp commands stopped working.
Here's the OnPlayerCommandText and 1 command:

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if(gPlayerLogged[playerid] == 0) return SendClientMessage(playerid, COLOR_RED, "Teade: Sa pead sisse logima!");
   
    new giveplayerid, moneys, idx;
    idx = 0;
    new string[128];
    new sendername[MAX_PLAYER_NAME];
    new giveplayer[MAX_PLAYER_NAME];
    new playername[MAX_PLAYER_NAME];
    new cmd[256];
    new tmp[256];
    cmd = strtok(cmdtext, idx);

        if(strcmp(cmd, "/togpm", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            if(KasutajaInfo[playerid][pDonateRank] > 2 || KasutajaInfo[playerid][pAdmin] > 1)
            {
                if (!HidePM[playerid])
                {
                    HidePM[playerid] = 1;
                    SendClientMessage(playerid, COLOR_GRAD2, "   PMs closed.");
                }
                else if (HidePM[playerid])
                {
                    HidePM[playerid] = 0;
                    SendClientMessage(playerid, COLOR_GRAD2, "   PMs opened.");
                }
            }
            else
            {
                SendClientMessage(playerid, COLOR_GREY, "   Not an Admin / Premium Account User!");
                return 1;
            }
        }
        return 1;
    }

    new veateade[128];
    format(veateade, sizeof(veateade), "Unknown command.");
        return SendClientMessage(playerid,GREEN,veateade);
}
Reply
#2

with zcmd you dont need OnPlayerCommandText
Reply
#3

I'm not usin it with zCMD. The problem is with strcmp. The commands don't work.

The placement of zCMD:
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if(gPlayerLogged[playerid] == 0) return SendClientMessage(playerid, COLOR_RED, "Teade: Sa pead sisse logima!");
   
    new giveplayerid, moneys, idx;
    idx = 0;
    new string[128];
    new sendername[MAX_PLAYER_NAME];
    new giveplayer[MAX_PLAYER_NAME];
    new playername[MAX_PLAYER_NAME];
    new cmd[256];
    new tmp[256];
    cmd = strtok(cmdtext, idx);

        if(strcmp(cmd, "/togpm", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            if(KasutajaInfo[playerid][pDonateRank] > 2 || KasutajaInfo[playerid][pAdmin] > 1)
            {
                if (!HidePM[playerid])
                {
                    HidePM[playerid] = 1;
                    SendClientMessage(playerid, COLOR_GRAD2, "   PMs closed.");
                }
                else if (HidePM[playerid])
                {
                    HidePM[playerid] = 0;
                    SendClientMessage(playerid, COLOR_GRAD2, "   PMs opened.");
                }
            }
            else
            {
                SendClientMessage(playerid, COLOR_GREY, "   Not an Admin / Premium Account User!");
                return 1;
            }
        }
        return 1;
    }

    new veateade[128];
    format(veateade, sizeof(veateade), "Unknown command.");
        return SendClientMessage(playerid,GREEN,veateade);
}
//---------------------------------zCMD------------------------------//
ZCMD COMMANDS
Reply
#4

Change this strcmp command into a zcmd command.
Reply
#5

Try this:

Код:
CMD:topgm(playerid,params[])
{
    if(gPlayerLogged[playerid] == 0) return SendClientMessage(playerid, COLOR_RED, "Teade: Sa pead sisse logima!");
	new giveplayerid, moneys, idx;
	idx = 0;
	new string[128];
	new sendername[MAX_PLAYER_NAME];
	new giveplayer[MAX_PLAYER_NAME];
	new playername[MAX_PLAYER_NAME];
	new cmd[256];
	new tmp[256];
	cmd = strtok(cmdtext, idx);
 	if(IsPlayerConnected(playerid))
  	{
   		if(KasutajaInfo[playerid][pDonateRank] > 2 || KasutajaInfo[playerid][pAdmin] > 1)
     	{
			if (!HidePM[playerid])
			{
				HidePM[playerid] = 1;
				SendClientMessage(playerid, COLOR_GRAD2, "   PMs closed.");
			}
			else if (HidePM[playerid])
			{
				HidePM[playerid] = 0;
				SendClientMessage(playerid, COLOR_GRAD2, "   PMs opened.");
			}
		}
		else
		{
  			SendClientMessage(playerid, COLOR_GREY, "   Not an Admin / Premium Account User!");
     		return 1;
		}
	}
	return 1;
}
For some reason identations are bad in [code][/ code]
Reply
#6

Aam...
I've got like 30-40 strcmp commands, that aren't working.
Reply
#7

Then convert them all

It is not hard to convert them really.
Reply
#8

Well... I'll get converting then.
Reply
#9

Aam...

pawn Код:
error 017: undefined symbol "tmp"
error 017: undefined symbol "cmdtext"
Reply
#10

Change cmdtext to params[]. Tmp Error: Add: new tmp[128];

Tip: Use Sccanf it's 100% better and easier to use + it's modern.

2nd Tip: Use SA-MP WIKI
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)