21.05.2009, 13:50
sorry for the errors.
I didn\'t really understand why dini wasn\'t working so I just copied the way the saved info is loaded when you log in.
I didn\'t really understand why dini wasn\'t working so I just copied the way the saved info is loaded when you log in.
pawn Code:
public OnPlayerConnect(playerid)
{
new string[256];
new pName[MAX_PLAYER_NAME];
GetPlayerName(playerid, pName, sizeof(pName));
PlayerInfo[playerid][pLevel] = 0;
PlayerInfo[playerid][pKills] = 0;
PlayerInfo[playerid][pDeaths] = 0;
PlayerInfo[playerid][pCash] = 0;
gPlayerAccount[playerid] = 0;
gPlayerLogged[playerid] = 0;
//Does Account Exist?
format(string, sizeof(string), "Users/%s.ini", pName);
if(fexist(string))
{
new File:PFILE=fopen(string, io_read);
if(PFILE)
{
gPlayerAccount[playerid] = 1;
//IP Checker
new IP[20];
new IP2[20];
new key[256] , val[256];
new Data[256];
while (fread(PFILE,Data,sizeof(Data)))
{
key = ini_GetKey( Data );
if( strcmp( key , "IP" , true ) == 0 ) { val = ini_GetValue( Data ); format(IP2,sizeof(IP2),"%s",val);}
fclose(PFILE);
}
GetPlayerIp(playerid,IP,sizeof(IP));
if(strcmp(IP,IP2,true)==0)
{
while (fread(PFILE,Data,sizeof(Data)))
{
key = ini_GetKey( Data );
if( strcmp( key , "Level" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pLevel] = strval( val ); }
if( strcmp( key , "Kills" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pKills] = strval( val ); }
if( strcmp( key , "Deaths" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pDeaths] = strval( val ); }
if( strcmp( key , "Money" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pCash] = strval( val ); }
}
fclose(PFILE);
gPlayerLogged[playerid] = 1;
format(string, sizeof(string), "[SUCESS]%s, you have been automatically logged in.", pName);
SendClientMessage(playerid, COLOR_GREEN, string);
}
else
{
format(string, sizeof(string), "[SERVER]Welcome back %s! Please login.", pName);
SendClientMessage(playerid, COLOR_YELLOW, string);
return 1;
}
}
}
else
{
format(string, sizeof(string),"[SERVER]Account %s isn\'t registered. Register using /register password",pName);
SendClientMessage(playerid, COLOR_YELLOW,string);
return 1;
}
return 1;
}