Array too small? -
LeeXian99 - 20.04.2013
pawn Код:
dcmd_changepass(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: /changepass [password] [new password]");
tmp2 = strtok(params, index);
if(!strlen(tmp2))
return SendClientMessage(playerid, COLOUR_ORANGE, "USAGE: /changepass [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[128]; 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.");
}
Код:
C:\Documents and Settings\User\Desktop\SAMP 0.3X Scripting\gamemodes\stuntproject.pwn(573) : error 047: array sizes do not match, or destination array is too small
C:\Documents and Settings\User\Desktop\SAMP 0.3X Scripting\gamemodes\stuntproject.pwn(576) : 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.
And where should I put #pragma unused params at the top?
Re: Array too small? -
JaKe Elite - 20.04.2013
did you use this tutorial?
https://sampwiki.blast.hk/wiki/Creating_...n_FilterScript
PLAYER_PASS is not a string.
Re: Array too small? -
LeeXian99 - 20.04.2013
Yes, I followed its instruction but duh, just making a simple login/register system by MYSELF only.
Anyway, how to fix it?
Re: Array too small? -
JaKe Elite - 20.04.2013
You need to make it string.
If you will make the PLAYER_PASS in cell size 129.
then do this
pawn Код:
format(gPlayerInfo[playerid][PLAYER_PASS], 129, "%s", newpassword);
Re: Array too small? -
LeeXian99 - 20.04.2013
What line should I put there?
Re: Array too small? -
JaKe Elite - 20.04.2013
Do you use Whirlpool or something else to hash the password?
I recommend you to use Whirlpool. Don't use the old tutorials.
Go to the tutorial section and check for newbienoob's tutorial.
It uses YSI and Whirlpool.
Re: Array too small? -
HurtLocker - 20.04.2013
credits to Dracoblue. Simple.
pawn Код:
adler32_hash(buf[])
{
new length=strlen(buf);
new s1 = 1;
new s2 = 0;
new n;
for (n=0; n<length; n++)
{
s1 = (s1 + buf[n]) % 65521;
s2 = (s2 + s1) % 65521;
}
return (s2 << 16) + s1;
}
Re: Array too small? -
Misiur - 20.04.2013
Please don't use format to copy a string
pawn Код:
//instead
format(gPlayerInfo[playerid][PLAYER_PASS], 129, "%s", newpassword);
//use
strcat((gPlayerInfo[playerid][PLAYER_PASS][0] = EOS, gPlayerInfo[playerid][PLAYER_PASS]), newpassword, 129);
Use ****** strcpy macro to keep it simple
pawn Код:
strcpy(gPlayerInfo[playerid][PLAYER_PASS], newpassword, 129);
Re: Array too small? -
Vince - 20.04.2013
Added a huge note on that wiki page. Dini is obsolete, as is strtok. Furthermore adler32 (udb_hash) is not a hashing algorithm, but a checksum algorithm. It is cracked in seconds.