02.09.2010, 06:51
Hello, I need some help with saving the players money. Here's how my script goes:
Well, I get no errors or anything, it reads the player money in OnPlayerUpdate, and it updates i GameModeExit and OnPlayerDisconnect. Can anybody help me because it doesn't save the money, it just sets it back to 0 when restarts or relogging
pawn Код:
public OnPlayerUpdate(playerid)
{
new file[256], pname [MAX_PLAYER_NAME];
GetPlayerName(playerid, pname, sizeof(pname));
format(file, sizeof(file), PlayerFile, pname);
PlayerInfo[playerid][pCash] = GetPlayerMoney(playerid);
dini_IntSet(file, "Cash" , PlayerInfo[playerid][pCash]);
return 1;
}
public OnPlayerLogin(playerid)
{
new file[256], pname [MAX_PLAYER_NAME];
GetPlayerName(playerid, pname, sizeof(pname));
format(file, sizeof(file), PlayerFile, pname);
PlayerInfo[playerid][pCash] = dini_Int(file, "Cash");
ResetPlayerMoney(playerid);
GivePlayerMoney(playerid,PlayerInfo[playerid][pCash]);
return 0;
}
public OnPlayerRegister(playerid)
{
new file[256], pname [MAX_PLAYER_NAME];
GetPlayerName(playerid, pname, sizeof(pname));
format(file, sizeof(file), PlayerFile, pname);
PlayerInfo[playerid][pCash] = GetPlayerMoney(playerid);
dini_IntSet(file, "Cash", 625);
GivePlayerMoney(playerid, 625);
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
OnPlayerUpdate(playerid);
return 1;
}
public OnGameModeExit()
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
OnPlayerUpdate(i);
}
return 1;
}