SA-MP Forums Archive
Some commands not 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)
+--- Thread: Some commands not working. (/showthread.php?tid=383092)



Some commands not working. - tsonn1 - 06.10.2012

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);
}



Re: Some commands not working. - xMCx - 06.10.2012

with zcmd you dont need OnPlayerCommandText


Re: Some commands not working. - tsonn1 - 06.10.2012

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



Re: Some commands not working. - arakuta - 06.10.2012

Change this strcmp command into a zcmd command.


Re: Some commands not working. - gtakillerIV - 06.10.2012

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]


Re: Some commands not working. - tsonn1 - 06.10.2012

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


Re: Some commands not working. - gtakillerIV - 06.10.2012

Then convert them all

It is not hard to convert them really.


Re: Some commands not working. - tsonn1 - 06.10.2012

Well... I'll get converting then.


Re: Some commands not working. - tsonn1 - 06.10.2012

Aam...

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



Re: Some commands not working. - gtakillerIV - 06.10.2012

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