15.04.2010, 19:24
Hello dear forum users...
Here I am again, and guess what... I need your help again...
Currently I am using this system to save accounts and stats
OnPlayerRegister is called when I'm using /register command
OnPlayerLogin is called when I'm using /login command
OnPlayerUpdate is called OnGameModeExit and OnPlayerDisconnect....
_________________________________________________
So I heard there are some other ways of doing same thing, just faster!
I need an advice which registration system to use, djson, dini or any other... And please keep it mind that it needs to support INI files reading, as I'm not going to rewrite all files currently registered on my server...
Please help!
Here I am again, and guess what... I need your help again...
Currently I am using this system to save accounts and stats
Code:
stock OnPlayerLogin( playerid, password[] ) { new string2[ 64 ], playername2[ MAX_PLAYER_NAME ]; 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 key[ 256 ] , val[ 256 ]; new Data[ 256 ]; while ( fread( UserFile , Data , sizeof( Data ) ) ) { key = ini_GetKey( Data ); if( strcmp( key , "Adminlevel" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][ pAdmin ] = strval( val ); } if( strcmp( key , "Money" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][ pCash ] = strval( val ); } if( strcmp( key , "Score" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][ pScore ] = 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 ); } } return 1; }
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); new var[128]; format(var, 128, "Password=%s\n", PlayerInfo[playerid][ pPassword ]);fwrite(hFile, var); format(var, 128, "Adminlevel=%d\n",PlayerInfo[playerid][ pAdmin ]);fwrite(hFile, var); format(var, 128, "Money=%d\n",PlayerInfo[playerid][ pCash ]);fwrite(hFile, var); format(var, 128, "Score=%d\n",PlayerInfo[playerid][ pScore ]);fwrite(hFile, var); format(var, 128, "Kills=%d\n",PlayerInfo[playerid][ pKills ]);fwrite(hFile, var); format(var, 128, "Deaths=%d\n",PlayerInfo[playerid][ pDeaths ]);fwrite(hFile, var); fclose(hFile); SendClientMessage(playerid, COLOR_FINALSCORE, "Nickname registered."); SendClientMessage(playerid, COLOR_FINALSCORE, "Type /login (password) now."); ResetPlayerMoney(playerid); } } return 1; }
Code:
stock OnPlayerUpdate( 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) { new var[128]; format(var, 128, "Password=%s\n", PlayerInfo[playerid][pPassword]);fwrite(hFile, var); format(var, 128, "AdminLevel=%d\n",PlayerInfo[playerid][pAdmin]);fwrite(hFile, var); PlayerInfo[playerid][pCash] = AC_GetPlayerMoney(playerid); format(var, 128, "Money=%d\n",PlayerInfo[playerid][pCash]);fwrite(hFile, var); PlayerInfo[playerid][pScore] = GetPlayerScore(playerid); format(var, 128, "Score=%d\n",PlayerInfo[playerid][pScore]);fwrite(hFile, var); PlayerInfo[playerid][pKills] = GetPlayerScore(playerid); format(var, 128, "Kills=%d\n",PlayerInfo[playerid][pKills]);fwrite(hFile, var); format(var, 128, "Deaths=%d\n",PlayerInfo[playerid][pDeaths]);fwrite(hFile, var); fclose(hFile); } } new CurVirtualWorld[MAX_PLAYERS]; CurVirtualWorld[playerid] = GetPlayerVirtualWorld(playerid); if(CurVirtualWorld[playerid] != CurrentVirtualWorld[playerid]) { OnPlayerVirtualWorldChange(playerid, CurVirtualWorld[playerid], CurrentVirtualWorld[playerid]); CurrentVirtualWorld[playerid] = CurVirtualWorld[playerid]; } } return 1; }
OnPlayerLogin is called when I'm using /login command
OnPlayerUpdate is called OnGameModeExit and OnPlayerDisconnect....
_________________________________________________
So I heard there are some other ways of doing same thing, just faster!
I need an advice which registration system to use, djson, dini or any other... And please keep it mind that it needs to support INI files reading, as I'm not going to rewrite all files currently registered on my server...
Please help!