SA-MP Forums Archive
Simple administrator script - PLEASE READ! - 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: Simple administrator script - PLEASE READ! (/showthread.php?tid=129848)



Simple administrator script - PLEASE READ! - Galcio - 23.02.2010

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.


Re: Simple administrator script - PLEASE READ! - Torran - 23.02.2010

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.");
  }
}



Re: Simple administrator script - PLEASE READ! - Galcio - 23.02.2010

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.


Re: Simple administrator script - PLEASE READ! - Torran - 23.02.2010

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


Re: Simple administrator script - PLEASE READ! - Galcio - 23.02.2010

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.


Re: Simple administrator script - PLEASE READ! - Torran - 23.02.2010

What number did you put?

Was it 64?

Like

new tmp[64];
new tmp2[64];


Re: Simple administrator script - PLEASE READ! - Galcio - 23.02.2010

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


Re: Simple administrator script - PLEASE READ! - HydraX - 23.02.2010

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.


Re: Simple administrator script - PLEASE READ! - Galcio - 23.02.2010

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.


Re: Simple administrator script - PLEASE READ! - HydraX - 23.02.2010

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];