[DCMD] Problem
#1

Hi. I want to do a command with several parameters. For example, someone typed "/p show" that displays something, someone enters "/p delete" displays something else. I have such a code is:
Код:
dcmd_p(playerid, cmdtext[])
{
	new tag[64];
	if(sscanf(cmdtext, "u", tag))
	{
	  SendClientMessage(playerid, WHITE, "Usage /p (show,delete)");
	  
	}
	else
	{
	  if(tag == "show")
	  {
	  	SendClientMessage(playerid,WHITE,"adsadada:");
		}
		
	}
	return 1;
}
Error:
Quote:

error 033: array must be indexed (variable "tag")

Reply
#2

pawn Код:
dcmd_p(playerid, cmdtext[])
{
    new tag[64];
    if(sscanf(cmdtext, "u", tag))
    {
      SendClientMessage(playerid, WHITE, "Usage /p (show,delete)");
     
    }
    else
    {
      if(strval(tag) == "show")
      {
        SendClientMessage(playerid,WHITE,"adsadada:");
        }
       
    }
    return 1;
}
Reply
#3

Quote:

array must be indexed (variable "-unknown-")

Reply
#4

pawn Код:
dcmd_p(playerid, cmdtext[])
{
    new tag[64];
    if(sscanf(cmdtext, "s", tag))
    {
      SendClientMessage(playerid, WHITE, "Usage /p (show,delete)");
     
    }
    else
    {
      if(strcmp(tag, "show", true) == 0)
      {
        SendClientMessage(playerid,WHITE,"adsadada:");
        }
       
    }
    return 1;
}
Reply
#5

Working, thanks man!
Reply
#6

You wrote:
Код:
if(sscanf(cmdtext, "u", tag))
the "u" stands for its a playername or playerid, if you replace with an s its a string. i or d if its a interger.
Reply
#7

I know I made a mistake on. Thanks for the help
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)