Hey Jafri!
I don't know what type of file system you have or if you have a login system, but something like this is easy to do with
dini. You'll need to download the dini include.
Something like this would work:
Save the pcash on disconnect
Код:
public OnPlayerDisconnect(playerid, reason)
{
new file[128], pname[MAX_PLAYER_NAME];
GetPlayerName(playerid, pname, sizeof(pname));
format(file, sizeof(file), "%s.ini", pname);
if(!dini_Exists(file))
{
dini_Create(file);
}
dini_IntSet(file, "PCash", GetPlayerPCash(playerid));
ResetPlayerPCash(playerid); //reset Pcash for security
return 1;
}
Give the player their PCash when they connect (or add something like this to your login system otherwise anyone with the same name could join and get the pcash)
Код:
public OnPlayerConnect(playerid)
{
new file[128], pname[MAX_PLAYER_NAME];
GetPlayerName(playerid, pname, sizeof(pname));
format(file, sizeof(file), "%s.ini", pname);
if(dini_Exists(file))
{
GivePlayerPCash(playerid, dini_Int(file, "PCash"));
}
return 1;
}
Hope this helps