Array must be indexed -
Mado - 15.12.2012
I have got this code in my script and it says the array must be indexed (target), while I think I did. What might be the issue?
pawn Код:
new target[26];
target = ReturnUser("inputtext");
if(target != INVALID_PLAYER_ID)
Re: Array must be indexed -
Huxley - 15.12.2012
I think the index was supposed to be MAX_PLAYERS.
Re: Array must be indexed -
C00K13M0N$73R - 15.12.2012
Remove [26] as target is a id.
Re: Array must be indexed -
Mado - 15.12.2012
Can you explain that a little bit better?
Re: Array must be indexed -
C00K13M0N$73R - 15.12.2012
pawn Код:
new target;
target = ReturnUser("inputtext");
if(target != INVALID_PLAYER_ID)
Target is a integer. Not a string. ReturnUser return's a ID, not a name.
Re: Array must be indexed -
Konstantinos - 15.12.2012
Target gets the ID of a user. In your case, you're getting the user's name by inputtext.
pawn Код:
new
target
;
target = ReturnUser(inputtext);
if(target != INVALID_PLAYER_ID)
If you use on inputtext " ", that means that you're searching for a player named inputtext!
Re: Array must be indexed -
Mado - 15.12.2012
Quote:
Originally Posted by C00K13M0N$73R
Remove [26] as target is a id.
|
Actually it is a name, since the player must insert a full name in the dialog.
-----
Alright I did this:
pawn Код:
new target = ReturnUser("inputtext");
And it compiles, but when I am ingame this part won't work:
pawn Код:
if(target != INVALID_PLAYER_ID)
{
//blabla
}
else
{
//blabla
}
Ofcourse the //blabla contains code, but even if the name is a correct one it is recognized as an invalid one.
Re: Array must be indexed -
C00K13M0N$73R - 15.12.2012
if(target != INVALID_PLAYER_ID)
This means if the target is NOT a valid playerid. Make sure your code isn't backwards.
Re: Array must be indexed -
Konstantinos - 15.12.2012
If you read my post above, you'll understand that the name you insert into the dialog is not called to the
ReturnUser, as you've got
and it searchs for a player named inputtext, not what you've inserted into the dialog.
Quote:
Originally Posted by C00K13M0N$73R
if(target != INVALID_PLAYER_ID)
This means if the target is NOT a valid playerid. Make sure your code isn't backwards.
|
That means the opposite from what you said. If the target is not an invalid player, continue!
Re: Array must be indexed -
ikey07 - 15.12.2012
You should use
IsPlayerConnected(target ); instead of
if(target != INVALID_PLAYER_ID) because if someone enter player id what isnt connected, but is valid, your script wont work