26.05.2010, 18:42
Hello everyone, since I tried to improve my register account system... and wanted to use dini for that as it's the simplest for me...
So I changed everything to dini functions... and now in game when I /register password it works, and /login password it says Incorrect password all the times...
Can anyone help please? Here is the code...
This function above is called when please leaves, OnPlayerDisconnect...
_________________________________________________
This code above is used on dcmd_register...
_________________________________________________
This code above is used in dcmd_login...
If you know where the problem may be, please help me as it's URGENTLY....
So I changed everything to dini functions... and now in game when I /register password it works, and /login password it says Incorrect password all the times...
Can anyone help please? Here is the code...
pawn Code:
stock PlayerStats( playerid )
{
if (IsPlayerConnected(playerid))
{
if (PlayerInfo[playerid][ pLogged ] ==1)
{
new string3[32];
new playername3[MAX_PLAYER_NAME];
GetPlayerName(playerid, playername3, sizeof(playername3));
format(string3, sizeof(string3), "/Accounts/%s.ini", playername3);
new ip[ 20 ];
GetPlayerIp(playerid,ip,sizeof(ip));
new File: hFile = fopen(string3, io_write);
if (hFile)
{
dini_Set(string3, "Password", PlayerInfo[playerid][ pPassword ]);
dini_IntSet(string3, "AdminLevel", PlayerInfo[playerid][pAdmin]);
dini_IntSet(string3, "Money", PlayerInfo[playerid][pCash]);
dini_IntSet(string3, "Score", PlayerInfo[playerid][pScore]);
dini_IntSet(string3, "Kills", PlayerInfo[playerid][pKills]);
dini_IntSet(string3, "Deaths", PlayerInfo[playerid][pDeaths]);
dini_IntSet(string3, "Level", PlayerInfo[playerid][Level]);
dini_IntSet(string3, "Exp", PlayerInfo[playerid][Exppoints]);
fclose(hFile);
}
}
}
return 1;
}
_________________________________________________
pawn Code:
stock OnPlayerRegister( playerid, password[] )
{
if (IsPlayerConnected(playerid)) {
new string3[32], playername3[MAX_PLAYER_NAME];
GetPlayerName(playerid, playername3, sizeof(playername3));
format(string3, sizeof(string3), "/Accounts/%s.ini", playername3);
new ip[ 20 ];
GetPlayerIp(playerid,ip,sizeof(ip));
new File: hFile = fopen(string3, io_write);
if (hFile) {
strmid(PlayerInfo[playerid][ pPassword ], password, 0, strlen(password), 255);
dini_Set(string3, "Password", PlayerInfo[playerid][ pPassword ]);
dini_IntSet(string3, "AdminLevel", 0);
dini_IntSet(string3, "Money", 0);
dini_IntSet(string3, "Score", 0);
dini_IntSet(string3, "Kills", 0);
dini_IntSet(string3, "Deaths", 0);
dini_IntSet(string3, "Level", 0);
dini_IntSet(string3, "Exp", 0);
dini_Set(string3, "IP", ip);
fclose(hFile);
SendClientMessage(playerid, COLOR_FINALSCORE, "You have successfully registered! You may now use /login password to login.");
ResetPlayerMoney(playerid);
}
}
return 1;
}
_________________________________________________
pawn Code:
stock OnPlayerLogin( playerid, password[] )
{
new string2[ 64 ], playername2[ MAX_PLAYER_NAME ], string[ 128 ];
GetPlayerName(playerid, playername2, sizeof(playername2));
format(string2, sizeof(string2), "/Accounts/%s.ini", playername2);
new File: UserFile = fopen(string2, io_read);
if ( UserFile )
{
new PassData[256];
new keytmp[256], valtmp[256];
fread( UserFile , PassData , sizeof( PassData ) );
keytmp = ini_GetKey( PassData );
if( strcmp( keytmp , "Password" , true ) == 0 )
{
valtmp = ini_GetValue( PassData );
strmid(PlayerInfo[playerid][ pPassword ], valtmp, 0, strlen(valtmp)-1, 255);
}
if(strcmp(PlayerInfo[playerid][ pPassword ],password, true ) == 0 )
{
new Data[ 256 ];
while ( fread( UserFile , Data , sizeof( Data ) ) )
{
PlayerInfo[playerid][pAdmin] = dini_Int(string2, "AdminLevel");
PlayerInfo[playerid][pCash] = dini_Int(string2, "Money");
PlayerInfo[playerid][pScore] = dini_Int(string2, "Score");
PlayerInfo[playerid][pKills] = dini_Int(string2, "Kills");
PlayerInfo[playerid][pDeaths] = dini_Int(string2, "Deaths");
PlayerInfo[playerid][Level] = dini_Int(string2, "Level");
PlayerInfo[playerid][Exppoints] = dini_Int(string2, "Exp");
}//end while
fclose(UserFile);//close the file after everything has been read in the while
}
else
{
SetPVarInt(playerid, "LWarn", GetPVarInt(playerid, "LWarn")+1);
format(string, sizeof(string), "ERROR: Incorrect password! [WARNINGS %d/3]", GetPVarInt(playerid, "LWarn"));
SendClientMessage(playerid, COLOR_RED, string);
if(GetPVarInt(playerid, "LWarn") == 3) {
SendClientMessage(playerid, COLOR_RED, "You have been kicked from the server for too many failed logins");
Kick(playerid);
fclose(UserFile);
}
return 1;
}
PlayerInfo[ playerid ][ pLogged ] =1;
GivePlayerMoney(playerid,PlayerInfo[playerid][ pCash ]);
SetPlayerScore(playerid,PlayerInfo[playerid][ pKills ]);
SystemMsg(playerid, "You have successfully logged in! You may now select your team.");
}
return 1;
}
If you know where the problem may be, please help me as it's URGENTLY....