My login problem - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: My login problem (
/showthread.php?tid=147822)
My login problem -
hardstop - 14.05.2010
When i disconnect the server it saves account details in .cfg file but when i connect and login then it doesnt load the settings and saves the details to 0 in .cfg whats the problem?
My Login:
Код:
public OnPlayerLogin(playerid,const string[])
{
new pname2[MAX_PLAYER_NAME];
new pname3[MAX_PLAYER_NAME];
new string2[64];
new string3[128];
GetPlayerName(playerid, pname2, sizeof(pname2));
format(string2, sizeof(string2), "%s.cfg", pname2);
new File: UserFile = fopen(string2, io_read);
if (UserFile)
{
new valtmp[128];
fread(UserFile, valtmp);strmid(PlayerInfo[playerid][pPassword], valtmp, 0, strlen(valtmp)-1, 255);
if ((strcmp(PlayerInfo[playerid][pPassword], string, true, strlen(valtmp)-1) == 0))
{
new key[128],val[128];
new Data[128];
while(fread(UserFile,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 , "Exp" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pExp] = strval( val ); }
if( strcmp( key , "Cash" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pCash] = strval( val ); }
if( strcmp( key , "GaraaziVхti" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pGaraaziVoti] = strval( val ); }
if( strcmp( key , "AdminiLevel" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pAdminiLevel] = strval( val ); }
if( strcmp( key , "Suitsud" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pSuitsud] = strval( val ); }
if( strcmp( key , "Joogid" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pJoogid] = strval( val ); }
if( strcmp( key , "Jax" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pJax] = strval( val ); }
GivePlayerMoney(playerid,PlayerInfo[playerid][pCash]);
}
fclose(UserFile);
gPlayerLogged[playerid] = 1;
gPlayerAccount[playerid] = 1;
new score = PlayerInfo[playerid][pLevel];
SetPlayerScore(playerid, score);
GetPlayerName(playerid, pname3, sizeof(pname3));
format(string3, sizeof(string3), "[Logisid Sisse]");
SendClientMessage(playerid, ROHELINE,string3);
SetPlayerPos(playerid, 672.0223,-520.2516,16.3359);
}
else
{
SendClientMessage(playerid, PUNANE, "[Vale Parool]");
fclose(UserFile);
}
}
return 1;
}
My Onplayerupdate
Код:
public OnPlayerUpdate(playerid)
{
new Float:HealthAmount;
GetPlayerHealth(playerid, HealthAmount);
if(HealthAmount <= 20)
{
ApplyAnimation(playerid, "CRACK", "crckdeth2", 4.0, 1, 0, 0, 0, 0);
}
if(IsPlayerConnected(playerid))
{
if(gPlayerLogged[playerid])
{
new string3[32];
new pname3[MAX_PLAYER_NAME];
GetPlayerName(playerid, pname3, sizeof(pname3));
format(string3, sizeof(string3), "%s.cfg", pname3);
new File: pFile = fopen(string3, io_write);
if (pFile)
{
new var[32];
format(var, 32, "%s\n", PlayerInfo[playerid][pPassword]);fwrite(pFile, var);
fclose(pFile);
new File: hFile = fopen(string3, io_append);
PlayerInfo[playerid][pCash] = GetPlayerMoney(playerid);
format(var, 32, "Kills:%d\n",PlayerInfo[playerid][pLevel]);fwrite(hFile, var);
format(var, 32, "Deaths:%d\n",PlayerInfo[playerid][pExp]);fwrite(hFile, var);
format(var, 32, "Cash:%d\n",PlayerInfo[playerid][pCash]);fwrite(hFile, var);
format(var, 32, "GaraaziVхti:%d\n",PlayerInfo[playerid][pGaraaziVoti]);fwrite(hFile, var);
format(var, 32, "AdminiLevel:%d\n",PlayerInfo[playerid][pAdminiLevel]);fwrite(hFile, var);
format(var, 32, "Suitsud:%d\n",PlayerInfo[playerid][pSuitsud]);fwrite(hFile, var);
format(var, 32, "Joogid:%d\n",PlayerInfo[playerid][pJoogid]);fwrite(hFile, var);
format(var, 32, "Jax:%d\n",PlayerInfo[playerid][pJax]);fwrite(hFile, var);
fclose(hFile);
}
}
}
return 1;
}