Simple administrator script - PLEASE READ!
#1

Hello, I'm following the "Simple administrator script" tutorial at samp wiki. But right now it feels that I've got to an end. This is what happens:
I try compiling my script, these errors show:
pawn Код:
error 047: array sizes do not match, or destination array is too small
error 047: array sizes do not match, or destination array is too small
This is the part of my script where I think the problems is:
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[30],
        tmp2[30],
        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.");
  }
}
Thanks for any helpful answer.
Reply
#2

Try this,

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[248],
        tmp2[248],
        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.");
  }
}
Reply
#3

Gives the same errors. The line it states the problems are at is these:
pawn Код:
tmp = strtok(params, index);
tmp2 = strtok(params, index);
I'd be very grateful if someone gave me the solution.
Reply
#4

Quote:
Originally Posted by Galcio
Gives the same errors. The line it states the problems are at is these:
pawn Код:
tmp = strtok(params, index);
tmp2 = strtok(params, index);
I'd be very grateful if someone gave me the solution.
Try

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[64],
  tmp2[64],
  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.");
  }
}
Its the new tmp[30]; new tmp2[30]; thats the problem, yes it says them lines but its really this thats causing it
Reply
#5

Tried your code, still giving me the exact same errors.

I really appreciate your help, and please continue trying to help me until we find the solution to my problem.
Reply
#6

What number did you put?

Was it 64?

Like

new tmp[64];
new tmp2[64];
Reply
#7

I'm not sure what you mean by that. Could you explain what I'm supposed to do, please?
Reply
#8

Quote:
Originally Posted by Galcio
I'm not sure what you mean by that. Could you explain what I'm supposed to do, please?
He means the string. I think he want's you to increase the string value to fix your problem.
Reply
#9

I'm still learning pawn and frankly talking I'm a quite noob at it. If you could please post the correct code with comments in it I'd be very happy, or explain a way I might explain. It's just this part of the tutorial I'm stuck at. Rest I've understood pretty nice.
Reply
#10

Quote:
Originally Posted by Torran
What number did you put?

Was it 64?

Like

new tmp[64];
new tmp2[64];
He wants you to change this..
new tmp[64];
new tmp2[64];
to a higher number like this..
new tmp[128];
new tmp2[128];
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)