error 017: undefined symbol "strtok"
#1

Код:
C:\Users\Matt\Desktop\SA-MP Files\TZUMO\gamemodes\sumoteampro.pwn(1648) : error 017: undefined symbol "strtok"
C:\Users\Matt\Desktop\SA-MP Files\TZUMO\gamemodes\sumoteampro.pwn(1648) : error 033: array must be indexed (variable "tmp")
C:\Users\Matt\Desktop\SA-MP Files\TZUMO\gamemodes\sumoteampro.pwn(1648) : error 017: undefined symbol "strtok"
C:\Users\Matt\Desktop\SA-MP Files\TZUMO\gamemodes\sumoteampro.pwn(1648) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


4 Errors.
pawn Код:
new file[256], tmp[256],tmp2[256], Index; tmp = strtok(params,Index); tmp2 = strtok(params,Index);
pawn Код:
dcmd_changepass(playerid, params[]){
    new file[256], tmp[256],tmp2[256], Index; tmp = strtok(params,Index); tmp2 = strtok(params,Index);
    GetPlayerName(playerid, pname, sizeof(pname));
    format(file, sizeof(file), "System/Users/%s.sav", pname);
    if(!dini_Exists(file)){
      if(Options[Language]==1)SendClientMessage(playerid, COLOR_RED, "Non sei registrato!");else
      if(Options[Language]==2)SendClientMessage(playerid, COLOR_RED, "You are not registered!");
      return 1;}
    if(!strlen(tmp)){
      if(Options[Language]==1)SendClientMessage(playerid, COLOR_RED, "UTILIZZA /changepass [vecchia password] [nuova password]");else
      if(Options[Language]==2)SendClientMessage(playerid, COLOR_RED, "USAGE /changepass [old password] [new password]");
      return 1;}
    if(!strlen(tmp2)){
      if(Options[Language]==1)SendClientMessage(playerid, COLOR_RED, "UTILIZZA /changepass [vecchia password] [nuova password]");else
      if(Options[Language]==2)SendClientMessage(playerid, COLOR_RED, "USAGE /changepass [old password] [new password]");
      return 1;}
    if(Account[playerid][pLoggedin]!=1){
      if(Options[Language]==1)SendClientMessage(playerid, COLOR_RED, "Prima di cambiare password devi accedere!!! (/login [password])");else
      if(Options[Language]==2)SendClientMessage(playerid, COLOR_RED, "Before changing password you must login!!!");
      return 1;}
    new tmp3[256]; tmp3 = dini_Get(file, "hashPW");
    if(udb_hash(tmp) != strval(tmp3)){
        if(Options[Language]==1)format(str, 256, "Hai sbagliato password %s!", pname),SendClientMessage(playerid, COLOR_RED, str);else
        if(Options[Language]==2)format(str, 256, "You wrote wrong password, %s!", pname),SendClientMessage(playerid, COLOR_RED, str);}else{
          PlayerPlaySound(playerid,1057,0.0,0.0,0.0);
          dini_IntSet(file, "hashPW", udb_hash(tmp2));
          dini_Set(file, "password", tmp2);
          if(Options[Language]==1)format(str, 256, "Hai cambiato password con successo [nickname: %s][Nuova password: %s]", pname, tmp2),SendClientMessage(playerid, COLOR_LIGHTGREEN, str);else
          if(Options[Language]==2)format(str, 256, "You succesfully changed your password [nickname: %s][New password: %s]", pname, tmp2),SendClientMessage(playerid, COLOR_LIGHTGREEN, str);
          printf("%s (%i) logged in with password %s", pname, playerid, params);}
    return 1;}
Reply
#2

pawn Код:
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;
}
place this anywhere in your script.
Reply
#3

Have you decleared strtok function?
Read the wiki: https://sampwiki.blast.hk/wiki/Strtok

You have to add this:
Код:
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;
}
To your code.

Anyway, i really suggest you replacing d_cmd with ZCMD and Strtok with SSCANF.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)