SA-MP Forums Archive
Password array bug - 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: Password array bug (/showthread.php?tid=154075)



Password array bug - newarvuti - 12.06.2010

Well, I was looking on the Adminscript tutorial, but I have problem with command.
pawn Код:
dcmd_password(playerid, params[])
{
  if(gPlayerInfo[playerid][PLAYER_REGGED] != 1)
    return SendClientMessage(playerid, COLOUR_ORANGE, "ERROR: You must register first to do that! Use /register [password] to register and login.");
  else if(gPlayerInfo[playerid][PLAYER_LOGGED] == 0)
        return SendClientMessage(playerid, COLOUR_ORANGE, "ERROR: You must be logged-in to do that! Use /login [password] to login.");
  else
  {
    new tmp[128],
      tmp2[128],
      index;
    tmp = strtok(params, index);
    if(!strlen(tmp))
    return SendClientMessage(playerid, COLOUR_ORANGE, "USAGE: /password [password] [new password]");
    tmp2 = strtok(params, index);
    if(!strlen(tmp2))
    return SendClientMessage(playerid, COLOUR_ORANGE, "USAGE: /password [password] [new password]");
  new oldpassword = num_hash(tmp), newpassword = num_hash(tmp2);
    if(gPlayerInfo[playerid][PLAYER_PASS] == oldpassword)
    {
      if(oldpassword == newpassword)
        return SendClientMessage(playerid, COLOUR_ORANGE, "ERROR: Your old password can not be the same as your new password.");
        else if(strlen(tmp2) < gSettings[PASS_MIN] || strlen(tmp2) > gSettings[PASS_MAX])
        {
            new string[100]; format(string, sizeof(string), "ERROR: Your new password must be between %d and %d characters long!", gSettings[PASS_MIN], gSettings[PASS_MAX]);
            return SendClientMessage(playerid, COLOUR_ORANGE, string);
        }
      gPlayerInfo[playerid][PLAYER_PASS] = newpassword;
      new string[256]; format(string, sizeof(string), "You have successfully changed your password from \'%s\' to \'%s\'.", tmp, tmp2);
      return SendClientMessage(playerid, COLOUR_LIGHTBLUE, string);
    }
    else
      return SendClientMessage(playerid, COLOUR_ORANGE, "ERROR: Incorrect password.");
  }
}
It gives those errors:
Код:
C:\Documents and Settings\Janar\Desktop\SAMP\filterscripts\myadmin.pwn(468) : error 047: array sizes do not match, or destination array is too small
C:\Documents and Settings\Janar\Desktop\SAMP\filterscripts\myadmin.pwn(471) : error 047: array sizes do not match, or destination array is too small
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


2 Errors.
What's wrong with the array sizes? I don't understand it...


Re: Password array bug - WackoX - 12.06.2010

WTF? You are using DCMD + strtok? that's the wrong methode dude.. use sscanf.


Re: Password array bug - Flashy - 12.06.2010

What are you talking about? Donґt post things that you donґt know.
Topic: Post the lines 468 and 471 please


Re: Password array bug - DJDhan - 12.06.2010

Quote:
Originally Posted by WackoX
WTF? You are using DCMD + strtok? that's the wrong methode dude.. use sscanf.
What? What's so wrong in using dcmd with strtok? Please specify the lines in your code.

EDIT: Why did you define new string two times?


Re: Password array bug - newarvuti - 12.06.2010

I copied it from https://sampwiki.blast.hk/wiki/Creating_...n_FilterScript.

468 - tmp = strtok(params, index);
471 - tmp2 = strtok(params, index);

Sorry, but I am just so beginner about that.


Re: Password array bug - Carickov - 13.06.2010

Код:
test
edit:delete this
this is test



DELETE


Re: Password array bug - Jefff - 13.06.2010

Код:
	tmp = strtok(params, index);
	if(!strlen(tmp))
	return SendClientMessage(playerid, COLOUR_ORANGE, "USAGE: /password [password] [new password]");
	tmp2 = strtok(params, index);
	if(!strlen(tmp2))
	return SendClientMessage(playerid, COLOUR_ORANGE, "USAGE: /password [password] [new password]");
to

Код:
	format(tmp,128,"%s",strtok(params, index));
	if(!strlen(tmp))
	return SendClientMessage(playerid, COLOUR_ORANGE, "USAGE: /password [password] [new password]");
	format(tmp2,128,"%s",strtok(params, index));
	if(!strlen(tmp2))
	return SendClientMessage(playerid, COLOUR_ORANGE, "USAGE: /password [password] [new password]");