SA-MP Forums Archive
ERROR: array must be indexed (variable "cmd") - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: ERROR: array must be indexed (variable "cmd") (/showthread.php?tid=197088)



ERROR: array must be indexed (variable "cmd") - universe - 07.12.2010

C:\Users\JordiX\Desktop\samp\gamemodes\lvdm.pwn(19 0) : error 033: array must be indexed (variable "cmd")

what is this?? how to fix? line 190:

public OnPlayerCommandText(playerid, cmdtext[])
{
cmd = strtok(cmdtext, idx);
if(!strcmp(cmdtext, "/help", true))
{
ShowPlayerDialogHelpCommand(playerid);
return 1;
}
return 0;


Re: ERROR: array must be indexed (variable "cmd") - JaTochNietDan - 07.12.2010

Why do you even have it in that snippet of code, you never use it?

Anyway it needs to be indexed, like it says. When you create the variable cmd, create it as an array.

pawn Код:
new cmd [128];



Re: ERROR: array must be indexed (variable "cmd") - universe - 07.12.2010

where to put it?

i get the same error :S


Re: ERROR: array must be indexed (variable "cmd") - SkizzoTrick - 07.12.2010

Put that before using it

like OnPlayerCommandText

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
        new string[256];
        new tmp[256];
        new cmd[256];
        cmd = strtok(cmdtext, idx);
This is an example of my script