On Player Disconnect
#1

How can I make players money save?
this is my enum info
pawn Код:
enum pInfo
{
    Password,
    Admin,
    Origin,
    Gender,
    Age,
    Float:sPosX,
    Float:sPosY,
    Float:sPosZ,
    Float:sPosA,
    Float:sHealth,
    Float:sArmor,
    Money,
    BankBalance,
    BankPin,
    Cellphone,
    HouseID,
    CarID,
    Gun1,
    Gun2,
    Gun3,
    Gun4,
    Gun5,
    Gun6,
    Gun7,
    Gun8,
    Gun9,
    Gun10,
    Gun11,
    Gun12,
    Gun13,
    WTChannel,
    Faction,
    FLeader,
    Job,
    sInterior,
    sVW,
    Skin,
    Muted,
    nMute,
    Helper,
    Developer,
    Wolf,
    SFCS,
    SFCMS,
    RentingID,
    FRank,
}
new PlayerInfo[MAX_PLAYERS][pInfo];
This is my on player disconnect what do I need to add in it?

pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
    gLastCar[playerid] = 0;
    BigEar[playerid] = 0;
    KnowsIt[playerid] = 0;
    SavePlayer(playerid);
    return 1;
}
Reply
#2

Do you really expect us to help you? The only thing useful you showed us was the enum with the money variable AND the fact you have a stock that saves players. Show us your load/save functions.
Reply
#3

Here you can see SavePlayer thing

pawn Код:
public SavePlayer(playerid)
{
    new INI:File = INI_Open(UserPath(playerid));
    INI_SetTag(File,"data");
    new Float:sX, Float:sY, Float:sZ, Float:sA, Float:sH, Float:sAr;
    GetPlayerPos(playerid, sX, sY, sZ);
    GetPlayerFacingAngle(playerid, sA);
    GetPlayerHealth(playerid, sH);
    GetPlayerArmour(playerid, sAr);
    INI_WriteInt(File, "Password", PlayerInfo[playerid][Password]);
    INI_WriteInt(File, "Admin", PlayerInfo[playerid][Admin]);
    INI_WriteInt(File, "Origin", PlayerInfo[playerid][Origin]);
    INI_WriteInt(File, "Gender", PlayerInfo[playerid][Gender]);
    INI_WriteInt(File, "Age", PlayerInfo[playerid][Age]);
    INI_WriteFloat(File, "sPosX", sX);
    INI_WriteFloat(File, "sPosY", sY);
    INI_WriteFloat(File, "sPosZ", sZ);
    INI_WriteFloat(File, "sPosA", sA);
    INI_WriteFloat(File, "sHealth", sH);
    INI_WriteFloat(File, "sArmor", sAr);
    INI_WriteInt(File, "Money", PlayerInfo[playerid][Money]);
    INI_WriteInt(File, "BankBalance", PlayerInfo[playerid][BankBalance]);
    INI_WriteInt(File, "BankPin", PlayerInfo[playerid][BankPin]);
    INI_WriteInt(File, "Cellphone", PlayerInfo[playerid][Cellphone]);
    INI_WriteInt(File, "HouseID", PlayerInfo[playerid][HouseID]);
    INI_WriteInt(File, "CarID", PlayerInfo[playerid][CarID]);
    INI_WriteInt(File, "Gun1", 0);
    INI_WriteInt(File, "Gun2", 0);
    INI_WriteInt(File, "Gun3", 0);
    INI_WriteInt(File, "Gun4", 0);
    INI_WriteInt(File, "Gun5", 0);
    INI_WriteInt(File, "Gun6", 0);
    INI_WriteInt(File, "Gun7", 0);
    INI_WriteInt(File, "Gun8", 0);
    INI_WriteInt(File, "Gun9", 0);
    INI_WriteInt(File, "Gun10", 0);
    INI_WriteInt(File, "Gun11", 0);
    INI_WriteInt(File, "Gun12", 0);
    INI_WriteInt(File, "Gun13", 0);
    INI_WriteInt(File, "WTChannel", PlayerInfo[playerid][WTChannel]);
    INI_WriteInt(File, "Faction", PlayerInfo[playerid][Faction]);
    INI_WriteInt(File, "FLeader", PlayerInfo[playerid][FLeader]);
    INI_WriteInt(File, "Job", PlayerInfo[playerid][Job]);
    INI_WriteInt(File, "sInterior", GetPlayerInterior(playerid));
    INI_WriteInt(File, "sVW", GetPlayerVirtualWorld(playerid));
    INI_WriteInt(File, "Skin", PlayerInfo[playerid][Skin]);
    INI_WriteInt(File, "Muted", PlayerInfo[playerid][Muted]);
    INI_WriteInt(File, "nMute", PlayerInfo[playerid][nMute]);
    INI_WriteInt(File, "Helper", PlayerInfo[playerid][Helper]);
    INI_WriteInt(File, "Developer", PlayerInfo[playerid][Developer]);
    INI_WriteInt(File, "Wolf", PlayerInfo[playerid][Wolf]);
    INI_WriteInt(File, "SFCS", PlayerInfo[playerid][SFCS]);
    INI_WriteInt(File, "SFCMS", PlayerInfo[playerid][SFCMS]);
    INI_WriteInt(File, "RentingID", PlayerInfo[playerid][RentingID]);
    INI_Close(File);
    gPlayerLoggedIn[playerid] = 0;
    return 1;
}
Reply
#4

Add this: INI_WriteInt(File, "Money", GetPlayerMoney(playerid));

And when a player logins in, load it by using: SetPlayerMoney(playerid, INI_Int(File, "Money"));
Reply
#5

Add this above INI_Close:

pawn Код:
INI_WriteInt(File, "Money", GetPlayerMoney(playerid));
Then load it like so:

pawn Код:
SetPlayerMoney(playerid, INI_Int(File, "Money"));
EDIT: Beat me to it!
Reply
#6

pawn Код:
#define PATH "/citizens/%s.ini"

forward LoadUser_data(playerid,name[],value[]);
public LoadUser_data(playerid,name[],value[])
{
    INI_Int("Password", PlayerInfo[playerid][Password]);
    INI_Int("Admin", PlayerInfo[playerid][Admin]);
    INI_Int("Origin", PlayerInfo[playerid][Origin]);
    INI_Int("Gender", PlayerInfo[playerid][Gender]);
    INI_Int("Age", PlayerInfo[playerid][Age]);
    INI_Float("sPosX", PlayerInfo[playerid][sPosX]);
    INI_Float("sPosY", PlayerInfo[playerid][sPosY]);
    INI_Float("sPosZ", PlayerInfo[playerid][sPosZ]);
    INI_Float("sPosA", PlayerInfo[playerid][sPosA]);
    INI_Float("sHealth", PlayerInfo[playerid][sHealth]);
    INI_Float("sArmor", PlayerInfo[playerid][sArmor]);
    INI_Int("Money", PlayerInfo[playerid][Money]);
    INI_Int("BankBalance", PlayerInfo[playerid][BankBalance]);
    INI_Int("BankPin", PlayerInfo[playerid][BankPin]);
    INI_Int("Cellphone", PlayerInfo[playerid][Cellphone]);
    INI_Int("HouseID", PlayerInfo[playerid][HouseID]);
    INI_Int("CarID", PlayerInfo[playerid][CarID]);
    INI_Int("Gun1", PlayerInfo[playerid][Gun1]);
    INI_Int("Gun2", PlayerInfo[playerid][Gun2]);
    INI_Int("Gun3", PlayerInfo[playerid][Gun3]);
    INI_Int("Gun4", PlayerInfo[playerid][Gun4]);
    INI_Int("Gun5", PlayerInfo[playerid][Gun5]);
    INI_Int("Gun6", PlayerInfo[playerid][Gun6]);
    INI_Int("Gun7", PlayerInfo[playerid][Gun7]);
    INI_Int("Gun8", PlayerInfo[playerid][Gun8]);
    INI_Int("Gun9", PlayerInfo[playerid][Gun9]);
    INI_Int("Gun10", PlayerInfo[playerid][Gun10]);
    INI_Int("Gun11", PlayerInfo[playerid][Gun11]);
    INI_Int("Gun12", PlayerInfo[playerid][Gun12]);
    INI_Int("Gun13", PlayerInfo[playerid][Gun13]);
    INI_Int("WTChannel", PlayerInfo[playerid][WTChannel]);
    INI_Int("Faction", PlayerInfo[playerid][Faction]);
    INI_Int("FLeader", PlayerInfo[playerid][FLeader]);
    INI_Int("Job", PlayerInfo[playerid][Job]);
    INI_Int("sInterior", PlayerInfo[playerid][sInterior]);
    INI_Int("sVW", PlayerInfo[playerid][sVW]);
    INI_Int("Skin", PlayerInfo[playerid][Skin]);
    INI_Int("Muted", PlayerInfo[playerid][Muted]);
    INI_Int("nMute", PlayerInfo[playerid][nMute]);
    INI_Int("Helper", PlayerInfo[playerid][Helper]);
    INI_Int("Developer", PlayerInfo[playerid][Developer]);
    INI_Int("Wolf",PlayerInfo[playerid][Wolf]);
    INI_Int("SFCS",PlayerInfo[playerid][SFCS]);
    INI_Int("SFCMS",PlayerInfo[playerid][SFCMS]);
    INI_Int("RentingID", PlayerInfo[playerid][RentingID]);
    return 1;
}

stock UserPath(playerid)
{
    new string[128],playername[MAX_PLAYER_NAME];
    GetPlayerName(playerid,playername,sizeof(playername));
    format(string,sizeof(string),PATH,playername);
    return string;
}


stock udb_hash(buf[]) {
    new length=strlen(buf);
    new s1 = 1;
    new s2 = 0;
    new n;
    for (n=0; n<length; n++)
    {
       s1 = (s1 + buf[n]) % 65521;
       s2 = (s2 + s1)     % 65521;
    }
    return (s2 << 16) + s1;
}
Here
Reply
#7

This crashes my compiler can you help?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)