30.06.2011, 18:54
Okay, I have a drug system and I use dUserSetInt to save player data into a .txt file for all accounts in scriptfiles. I just made it so when someone buys drugs, it will save it in their user file also, just like money, score etc... When I purchase the drugs then /quit the game the drugs save (thankfully) and rejoin, the drugs are still there (thankfully lol). But the problem is if I close the server or gmx (restart) it, the drugs set are deleted in-game and are also set to 0 in the user file. I tried putting this line under OnGameModeInit and Exit:
but obviously doesn't work and doesn't compile because playerid isn't defined as default in OnGameModeInit and Exit, I also tried making a loop for those 2 callbacks:
it compiles, but doesnt work ingame either :S
So my question is how do I get it to save on game mode restart or when i close the server, because the drugs only saves if someone disconnects and rejoins which is good, but doesnt save when the server restarts/closes.
Thanks.
pawn Код:
if(udb_Exists(PlayerName2(playerid))) dUserSetINT(PlayerName2(playerid)).("drugs",playerdrugs[playerid]);
pawn Код:
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(udb_Exists(PlayerName2(i))) dUserSetINT(PlayerName2(i)).("drugs",playerdrugs[i]);
}
So my question is how do I get it to save on game mode restart or when i close the server, because the drugs only saves if someone disconnects and rejoins which is good, but doesnt save when the server restarts/closes.
Thanks.