13.01.2013, 08:36
Alright, I got a couple of questions -
1. I'm trying to create an achievements system, and here's how I am planning to do it [Y_INI] -
Suppose it's an achievement for getting 250+ kills
I'll check if the var 'AchName_250KILLS' is set to ONE in the file, which will indicate the player ALREADY has the achievement
If that var is NOT 1 and player's kills are 250, it means he has earned a new achievement.
I'm trying to read only ONE variable from the player's file, And INI_ParseFile loads all data, which I don't want to.
Any idea how I can execute my plan without loading all the data? My anti-cheats is kind of delicate, and I don't want players to lose money/score.
2. My hash system is a little bugged.
This is sort of a complicated problem.
Alright, -
1. On player register, I hash their passwords and save them into a file
2. I /q and I come back, password works fine
3. I CLOSE SAMP-SERVER.EXE AND START IT AGAIN TO LOAD SOME NEW UPDATES, and the OLD PASSWORD DOESN'T WORK!
I did some debugging too, here are the results -
I DID check if the player's password is same in the file, and it is!
Here is my check for checking player's password
I am also doing this OnPlayerConnect to load pInfo[playerid][Password] -
And here's my LoadUser functoin
1. I'm trying to create an achievements system, and here's how I am planning to do it [Y_INI] -
Suppose it's an achievement for getting 250+ kills
I'll check if the var 'AchName_250KILLS' is set to ONE in the file, which will indicate the player ALREADY has the achievement
If that var is NOT 1 and player's kills are 250, it means he has earned a new achievement.
I'm trying to read only ONE variable from the player's file, And INI_ParseFile loads all data, which I don't want to.
Any idea how I can execute my plan without loading all the data? My anti-cheats is kind of delicate, and I don't want players to lose money/score.
2. My hash system is a little bugged.
This is sort of a complicated problem.
Alright, -
1. On player register, I hash their passwords and save them into a file
2. I /q and I come back, password works fine
3. I CLOSE SAMP-SERVER.EXE AND START IT AGAIN TO LOAD SOME NEW UPDATES, and the OLD PASSWORD DOESN'T WORK!
I did some debugging too, here are the results -
pawn Код:
[18:46:12] Incoming connection: 127.0.0.1:65185
[18:46:12] [join] [A]Gangs has joined the server (1:127.0.0.1)
[18:46:16] [REGISTERED] [A]Gangs registered with pass testing [Hashed - 203293439]
[18:51:17] [part] [A]Gangs has left the server (1:1)
[18:51:26] --- Server Shutting Down.
[18:51:47] [join] [A]Gangs has joined the server (1:127.0.0.1)
[18:51:48] [LOGIN] Fail login of [A]Gangs with password testing [Hashed - 203293439]
[19:14:12] [LOGIN] Fail login of [A]Gangs with password testing [Hashed - 203293439]
[19:14:13] [LOGIN] Fail login of [A]Gangs with password testing [Hashed - 203293439]
[19:14:14] [LOGIN] Fail login of [A]Gangs with password testing [Hashed - 203293439]
[19:14:15] [LOGIN] Fail login of [A]Gangs with password testing [Hashed - 203293439]
[19:14:16] [LOGIN] Fail login of [A]Gangs with password testing [Hashed - 203293439]
Here is my check for checking player's password
pawn Код:
case DIALOG_LOGIN:
{
if (!response) return Kick (playerid);
if(response)
{
if(udb_hash(inputtext) == pInfo[playerid][Password])
{
INI_ParseFile(getini(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
GivePlayerMoney(playerid, pInfo[playerid][Money]);
printf("[LOGIN] Success login of %s with password %s [Hashed - %d] ", pname(playerid), inputtext, udb_hash(inputtext) );
ShowPlayerDialog(playerid, DIALOG_LOGIN_SUCCESS, DIALOG_STYLE_MSGBOX,"Success!","You have successfully logged in!","Ok","");
}
else
{
printf("[LOGIN] Fail login of %s with password %s [Hashed - %d] ", pname(playerid), inputtext, udb_hash(inputtext) );
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,"Login","You have entered an incorrect password.\nType your password below to login.","Login","Quit");
}
return 1;
}
pawn Код:
if(fexist(getbanini(playerid)))
{
SendClientMessage(playerid, RED, "[ERROR] You're banned! Stop ban evading! ");
KickEx(playerid);
}
else
{
if(fexist(getini(playerid)))
{
INI_ParseFile(getini(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,"Login","Type your password below to login.","Login","Quit");
}
else
{
ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT,"Registering...","Type your password below to register a new account.","Register","Quit");
SendClientMessage(playerid, CYAN, "[SeRbErSShSHhs] W3lcUm t0 d4 sErVer");
}
pawn Код:
stock LoadUser_data(pid,name[],value[])
{
INI_Int("Password",pInfo[pid][Password]);
INI_Int("Money",pInfo[pid][Money]);
INI_Int("AdminLevel",pInfo[pid][ALevel]);
INI_Int("VIPLevel", pInfo[pid][VIPLevel]);
INI_Int("Kills",pInfo[pid][Kills]);
INI_Int("Deaths",pInfo[pid][Deaths]);
INI_Int("Helper", pInfo[pid][Helper]);
INI_Int("Password", pInfo[pid][Helper]);
INI_Int("Experience", pInfo[pid][Experience]);
INI_Int("Banned", pInfo[pid][Banned]);
return 1;
}