[HELP] strtok problem.
#1

Hello, I got a problem with defining strtok plus array index problem as you see:

Код:
C:\GTA.DECODER.LV\gamemodes\decoder.pwn(4099) : error 017: undefined symbol "strtok"
C:\GTA.DECODER.LV\gamemodes\decoder.pwn(4099) : error 033: array must be indexed (variable "cmd")
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


2 Errors.
Heres the code to that lines:

Код:
public OnPlayerCommandText(playerid, cmdtext[])
{		new cmd[256];
 		cmd = strtok(cmdtext, idx); // Line 4099

//------------------------------------------------------------------------------
//=====================[ TELEPORT COMMANDS ]====================================
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
		if(!strcmp(cmd, "/ammunations",true) || !strcmp(cmd, "/ammunations",true))
 		{
	 		ShowMenuForPlayer(Ammunations,playerid);
	 		SendClientMessage(playerid, COLOR_YELLOW, "Laipni lugti municijas izvelne, izmanto lidzeklus un iegadajies ko velies.");
	  		TogglePlayerControllable(playerid, 0);
			return 1;
 		}
Reply
#2

The error says everything tought...
Reply
#3

I dont know how to fix it..
Reply
#4

So anyone can help somehow?
Reply
#5

You need to add the strtok function, to your script.
Also add a
pawn Код:
new idx;
under your cmd[256];

Edit: Hint: You don't need strtok, for these kind of commands.
Reply
#6

pawn Код:
new cmd[256],tmp[256],idx;// at top of script

// at bottom of script.
strtok(const string[], &index)
{
  new length = strlen(string);
  while ((index < length) && (string[index] <= ' '))
  {
    index++;
  }
  new offset = index;
  new result[20];
  while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
  {
    result[index - offset] = string[index];
    index++;
  }
  result[index - offset] = EOS;
  return result;
}
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)