enum PlayerInfo { gName, Password, Level, Regged, Logged, Money, Kills, Deaths, } new pInfo[MAX_PLAYERS][PlayerInfo];
forward SaveData(playerid);
public SaveData(playerid)
{
new player[128];new saver[128];
new pname[MAX_PLAYER_NAME];
GetPlayerName(playerid,pname,sizeof(pname));
format(player, sizeof(player), "users/%s.txt",pname);
format(saver,sizeof(saver),"Password");
dini_Set(player,saver,PlayerData[playerid][Pass]);
PlayerData[playerid][Job]=GetPlayerMoney(playerid);
format(saver,sizeof(saver),"Money");
dini_IntSet(player,saver,PlayerData[playerid][Money]);
return 1;
}
Originally Posted by RaFsTar
forward SaveData(playerid);
public SaveData(playerid) { new player[128];new saver[128]; new pname[MAX_PLAYER_NAME]; GetPlayerName(playerid,pname,sizeof(pname)); format(player, sizeof(player), "users/%s.txt",pname); format(saver,sizeof(saver),"Password"); dini_Set(player,saver,PlayerData[playerid][Pass]); PlayerData[playerid][Job]=GetPlayerMoney(playerid); format(saver,sizeof(saver),"Money"); dini_IntSet(player,saver,PlayerData[playerid][Money]); return 1; } |
Originally Posted by [B
Vortex
That doesn't help at all, that has stuff I don't even need, looks like you just coppied and pasted from somewhere :S |
Originally Posted by RaFsTar
Quote:
Dude you just need to change it as u need, then use SaveData(playerid); when player data changes. |
forward SaveData(playerid);
public SaveData(playerid)
{
new player[128];new saver[128];
new pname[MAX_PLAYER_NAME];
GetPlayerName(playerid,pname,sizeof(pname));
format(player, sizeof(player), "users/%s.txt",pname); // Saving folder
PlayerInfo[playerid][Money]=GetPlayerMoney(playerid); //Gets player money
format(saver,sizeof(saver),"Money");
dini_IntSet(player,saver,PlayerInfo[playerid][Money]); // Saves it into users/Player.txt as "Money".
return 1;
}
new ActiveMoney[MAX_PLAYERS];// reset this to zero at onplayerexit...
public OnPlayerUpdate(playerid)
{
new CurMoney = GetPlayerMoney(playerid);
if(CurMoney != ActiveMoney[playerid]) OnPlayerMoneyChange(playerid, ActiveMoney[playerid], CurMoney);
return 1;
}
forward OnPlayerMoneyChange(playerid, OldMoney, NewMoney);
public OnPlayerMoneyChange(playerid, OldMoney, NewMoney)
{
// this is your new callback, its called every time a player change money.
//the current player money is NewMoney...
//the money he had before is OldMoney...
printf("player: %i as change money from: %i to: %i",playerid, OldMoney, NewMoney);
//we print the info, just for shit and giggle...
ActiveMoney[playerid] = NewMoney;// we save our current active money...
//you can save your data here using NewMoney or ActiveMoney[playerid]
return 1;
}