Array Must Be Indexed
#1

Okay, this is the first time ever I am asking about help. But, it's because I was sitting very very very long and thought about this, but didn't find any solution. So, well... Here's my code:

pawn Код:
new text;
text = strval(params);
if(text == "red")
And the error is:

Quote:
Originally Posted by Pawno
error 033: array must be indexed (variable "-unknown-")
And "unknown" is "red". What do I have to do?
Reply
#2

Because U r using integer and string?
Код:
text = strval(params);
text is integer
Код:
if(text == "red")
and integer == string?
Reply
#3

I think this is what you need

Код:
if(strcmp(params,"red",true) == 0)
Reply
#4

Quote:
Originally Posted by Μαστερμινδ
I think this is what you need

Код:
if(strcmp(params,"red",true) == 0)
I don't want to make a "/red" command...

Quote:
Originally Posted by Jefff
Because U r using integer and string?
Код:
text = strval(params);
text is integer
Код:
if(text == "red")
and integer == string?
Yeah, maybe... Got any solutions?
Reply
#5

Quote:
Originally Posted by еddy
Quote:
Originally Posted by Μαστερμινδ
I think this is what you need

Код:
if(strcmp(params,"red",true) == 0)
I don't want to make a "/red" command...
this is not a command its check
if(!strcmp(text,"red",true)) //if your "text" is "red" do something
Reply
#6

Ok, Jefff, thanks for the notice.

And sorry Μαστερμινδ, it actually worked. Thank you guys.
Reply
#7

Quote:
Originally Posted by еddy
Quote:
Originally Posted by Μαστερμινδ
I think this is what you need

Код:
if(strcmp(params,"red",true) == 0)
I don't want to make a "/red" command...
Heres an example

pawn Код:
dcmd_setcolor(playerid, params[]) {
  if(!strlen(params)) return SendClientMessage(playerid, WHITE, "Use: /setcolor [color]");
  if(strcmp(params,"red",true) == 0) return SetPlayerColor(playerid, COLOR_RED);
  else if(strcmp(params,"blue",true) == 0) return SetPlayerColor(playerid, COLOR_BLUE);
  else return SendClientMessage(playerid, WHITE, "Unknown color..");
}
EDIT: np
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)