Must be assigned to an array
#1

Hi all..
This is the code..
And the error..
Can you help me?
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/prigione1", cmdtext, true, 10) == 0)
{
stato[playerid]="prigione1";
return 1;
}
if (strcmp("/prigione2", cmdtext, true, 10) == 0)
{
stato[playerid]="prigione2";
return 1;
}
if (strcmp("/base1", cmdtext, true, 10) == 0)
{
stato[playerid]="base1";
return 1;
}
if (strcmp("/base2", cmdtext, true, 10) == 0)
{
stato[playerid]="base2";
return 1;
}
return 0;
}




C:\DOCUME~1\Gugli0\Desktop\ZOMBIE~1\FILTER~1\limit i.pwn(4 : error 006: must be assigned to an array
C:\DOCUME~1\Gugli0\Desktop\ZOMBIE~1\FILTER~1\limit i.pwn(53) : error 006: must be assigned to an array
C:\DOCUME~1\Gugli0\Desktop\ZOMBIE~1\FILTER~1\limit i.pwn(5 : error 006: must be assigned to an array
C:\DOCUME~1\Gugli0\Desktop\ZOMBIE~1\FILTER~1\limit i.pwn(63) : error 006: must be assigned to an array
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


4 Errors.
Reply
#2

Код:
new stato[MAX_PLAYERS][128];
Reply
#3

And why this code?
Reply
#4

because "base1" is a string and strings are stored in arrays
Reply
#5

Quote:
Originally Posted by ssǝן‾ʎ
I count 10 characters max there, why do you need an array of size 128 to store 10 characters - what are the other 118 cells for?
Would this be an improvement?

Код:
new stato[MAX_PLAYERS][10];
Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
	if(strcmp("/prigione1", cmdtext, true, 10) == 0) return stato[playerid]="prigione1";

	if (strcmp("/prigione2", cmdtext, true, 10) == 0) return stato[playerid]="prigione2";

	if (strcmp("/base1", cmdtext, true, 10) == 0) return stato[playerid]="base1";

	if (strcmp("/base2", cmdtext, true, 10) == 0) return stato[playerid]="base2";

	return 0;
}
Reply
#6

Ok, thanks. I saw some other code like that a few days ago and wasn't sure if it was correct.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)