19.05.2010, 14:08
Код:
if(listitem == 0) //Smoke if(GetPlayerMoney(playerid) >= 45) { GivePlayerMoney(playerid, -45); PlayerInfo[playerid][pCiggy] = 30; SendClientMessage(playerid, VALGE, "Vihje: /smoke");
Problem:
and i do /stats then there is Smokes[30]
but when i restart server then there is Smokes[0]
IT DOESNT SAVE, whats the problem?
_________________________________________
i have this under my enum pinfo
Код:
pCiggy
Код:
format(var, 32, "Smokes=%d\n",PlayerInfo[playerid][pCiggy]);fwrite(hFile, var);
Код:
if( strcmp( key , "Smokes" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pCiggy] = strval( val ); }
and thats all if you know the problem please help me
Heres my Onplayerlogin and onplayerregister
Код:
public OnPlayerLogin(playerid,password[]) { new string2[256]; new playername2[MAX_PLAYER_NAME]; GetPlayerName(playerid, playername2, sizeof(playername2)); format(string2, sizeof(string2), "cServer/kasutajad/%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 , "Warnings" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pWarns] = strval( val ); } 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 ); } if( strcmp( key , "Bank" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pBank] = strval( val ); } if( strcmp( key , "Skin" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pSkin] = strval( val ); } if( strcmp( key , "TimesConnected" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pTimes] = strval( val ); } if( strcmp( key , "PlayingHours" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pHours] = strval( val ); } if( strcmp( key , "PlayingMinutes" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pMins] = strval( val ); } if( strcmp( key , "JailTime" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pJailTime] = strval( val ); } if( strcmp( key , "DayRegistered" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pDate1] = strval( val ); } if( strcmp( key , "MonthRegistered" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pDate2] = strval( val ); } if( strcmp( key , "YearRegistered" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pDate3] = strval( val ); } if( strcmp( key , "Smokes" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pCiggy] = strval( val ); } }//end while fclose(UserFile);//close the file after everything has been read in the while } else { SendClientMessage(playerid, VALGE, "[Vale Salasхna, 3 korda = ban]"); fclose(UserFile); gPlayerLogTries[playerid] += 1; if(gPlayerLogTries[playerid] == 3) { Ban(playerid); } return 1; } if(PlayerInfo[playerid][pLevel] == -1) { SendClientMessage(playerid, PUNANE, "See kasutaja on bannitud!"); Kick(playerid); return 1; } else if(PlayerInfo[playerid][pLevel] == -2) { Ban(playerid); return 1; } PlaySound(playerid, 1054); ResetPlayerMoney(playerid); gPlayerLogged[playerid] = 1; ConsumingMoney[playerid] = 1; PlayerInfo[playerid][pTimes] ++; printf("%s Logis Sisse",playername2); SendClientMessage(playerid, ROHELINE,"[Sisse Logitud]"); SetTimerEx("PlayingTime", 60000, 1, "i", playerid); } return 1; }
Код:
public OnPlayerRegister(playerid, password[]) { if(IsPlayerConnected(playerid)) { new string3[256]; new string[256]; new playername3[MAX_PLAYER_NAME]; GetPlayerName(playerid, playername3, sizeof(playername3)); format(string3, sizeof(string3), "cServer/kasutajad/%s.ini", playername3); new File: hFile = fopen(string3, io_write); if (hFile) { new pIp[128]; GetPlayerIp(playerid, pIp, sizeof(pIp)); new var[32]; strmid(PlayerInfo[playerid][pPassword], password, 0, strlen(password), 255); format(var, 32, "Password=%s\n", PlayerInfo[playerid][pPassword]);fwrite(hFile, var); PlayerInfo[playerid][pCash] = GetPlayerMoney(playerid); format(var, 32, "IP=%s\n", pIp);fwrite(hFile, var); format(var, 32, "AdminLevel=%d\n",PlayerInfo[playerid][pAdmin]);fwrite(hFile, var); format(var, 32, "Warnings=%d\n",PlayerInfo[playerid][pWarns]);fwrite(hFile, var); format(var, 32, "Level=%d\n",PlayerInfo[playerid][pLevel]);fwrite(hFile, var); format(var, 32, "Kills=%d\n",PlayerInfo[playerid][pKills]);fwrite(hFile, var); format(var, 32, "Deaths=%d\n",PlayerInfo[playerid][pDeaths]);fwrite(hFile, var); format(var, 32, "Money=%d\n",PlayerInfo[playerid][pCash]);fwrite(hFile, var); format(var, 32, "Bank=%d\n",PlayerInfo[playerid][pBank]);fwrite(hFile, var); format(var, 32, "Skin=%d\n",PlayerInfo[playerid][pSkin]);fwrite(hFile, var); format(var, 32, "TimesConnected=%d\n",PlayerInfo[playerid][pTimes]);fwrite(hFile, var); format(var, 32, "PlayingHours=%d\n",PlayerInfo[playerid][pHours]);fwrite(hFile, var); format(var, 32, "PlayingMinutes=%d\n",PlayerInfo[playerid][pMins]);fwrite(hFile, var); format(var, 32, "JailTime=%d\n",PlayerInfo[playerid][pJailTime]);fwrite(hFile, var); format(var, 32, "Smokes=%d\n",PlayerInfo[playerid][pCiggy]);fwrite(hFile, var); new year,month,day; getdate(year,month,day); PlayerInfo[playerid][pDate1] = day; PlayerInfo[playerid][pDate2] = month; PlayerInfo[playerid][pDate3] = year; format(var, 32, "DayRegistered=%d\n",PlayerInfo[playerid][pDate1]);fwrite(hFile, var); format(var, 32, "MonthRegistered=%d\n",PlayerInfo[playerid][pDate2]);fwrite(hFile, var); format(var, 32, "YearRegistered=%d\n",PlayerInfo[playerid][pDate3]);fwrite(hFile, var); fclose(hFile); format(string, sizeof(string), "Kasutaja %s Registreeritud, /login [salasхna]", playername3); SendClientMessage(playerid, ROHELINE, string); } } return 1; }