SA-MP Forums Archive
Need help on Array - 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: Need help on Array (/showthread.php?tid=154497)



Need help on Array - VirSpectorX - 14.06.2010

I have a script like this:
pawn Код:
dcmd_getclass(playerid, params[])
{
  if(strlen(params) == 0){
    SendClientMessage(playerid, 0x00FF00AA, "|- Usage: /getclass [class] -|");
    SendClientMessage(playerid, 0xFF0000AA, "___|- Classes -|___");
    SendClientMessage(playerid, 0xFFFF00AA, "Class \"Normal\" (Requirement: Nothing) (Cost: $0) (Extras: Nothing)");
    SendClientMessage(playerid, 0xFFFF00AA, "Class \"Pilot\" (Requirement: Kill >= 80 | Kill-Death >= -20) (Cost: $10000) (Extras: Able to spawn Planes [/getplane])");
    SendClientMessage(playerid, 0xFFFF00AA, "Class \"Rocket Launcher\" (Requirement: Kill >= 30) (Cost: $2000) (Extras: Get 50 Rocket Launchers every spawn)");
    return 1;
  }
  if(params == "normal"){
    SendClientMessage(playerid, 0x00FF00AA, "|- You are now a normal soldier -|");
  }
  return 1;
}
and it results:

Код:
X:\XXXXX\XXXXX\XXXXX\XXXXX.pwn(209) : error [ LINE OF if(params == "normal"){ ]: array must be indexed (variable "params")
I know why it's wrong. I know it's because that i need to index the array. But i don't know how to do it (fix it). Please help


Re: Need help on Array - Joe_ - 14.06.2010

pawn Код:
if(!strcmp(params, "normal", false)) // If params == "normal"
due to params being a string.


Re: Need help on Array - VirSpectorX - 14.06.2010

Oh yes, i forgot about strcmp...

Thanks a lot!