Help me, you get a rep
#1

When players register They automatically get 5000$, but after relogging, they it just comes back though they spent an amount of it

pawn Code:
public OnPlayerDisconnect(playerid, reason)
{
    SaveAccountStats(playerid);
    return 1;
}

function SetPlayerToTeamColor(playerid)
{
    if(IsPlayerConnected(playerid))
    {
        SetPlayerColor(playerid,TEAM_HIT_COLOR);
    }
}

function OOCOff(color,const string[])
{
    foreach (Player,i)
    {
        if(!gOoc{i})
        {
            SendClientMessage(i, color, string);
        }
    }
}

function SaveAccountStats(playerid)
{
    if(Logged[playerid] == 1)
    {
    new
        INI:File = INI_Open(UserPath(playerid))
    ;
    INI_SetTag(File,"data");
   
    PlayerInfo[playerid][pSkin] = GetPlayerSkin(playerid);
    PlayerInfo[playerid][pCash] = GetPlayerCash(playerid);
    new
        Float:x,
        Float:y,
        Float:z
    ;
    GetPlayerPos(playerid,x,y,z);
    PlayerInfo[playerid][pPos_x] = x;
    PlayerInfo[playerid][pPos_y] = y;
    PlayerInfo[playerid][pPos_z] = z;
   
    INI_WriteInt(File,"Cash",PlayerInfo[playerid][pCash]);
    INI_WriteInt(File,"Admin",PlayerInfo[playerid][pAdmin]);
    INI_WriteInt(File,"Sex",PlayerInfo[playerid][pSex]);
    INI_WriteInt(File,"Age",PlayerInfo[playerid][pAge]);
    INI_WriteFloat(File,"Pos_x",PlayerInfo[playerid][pPos_x]);
    INI_WriteFloat(File,"Pos_y",PlayerInfo[playerid][pPos_y]);
    INI_WriteFloat(File,"Pos_z",PlayerInfo[playerid][pPos_z]);
    INI_WriteInt(File,"Skin",PlayerInfo[playerid][pSkin]);
    INI_WriteInt(File,"Team",PlayerInfo[playerid][pTeam]);
    INI_WriteInt(File,"Accent",PlayerInfo[playerid][pAccent]);
   
    INI_Close(File);
    }
    return 1;
}

function SaveAccounts()
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            SaveAccountStats(i);
        }
    }
}

function GameModeExitFunc()
{
    GameModeExit();
    return 1;
}

function LoadUser_data(playerid,name[],value[])
{
    INI_Int("Password",PlayerInfo[playerid][pPass]);
    INI_Int("Cash",PlayerInfo[playerid][pCash]);
    INI_Int("Admin",PlayerInfo[playerid][pAdmin]);
    INI_Int("Sex",PlayerInfo[playerid][pSex]);
    INI_Int("Age",PlayerInfo[playerid][pAge]);
    INI_Float("Pos_x",PlayerInfo[playerid][pPos_x]);
    INI_Float("Pos_y",PlayerInfo[playerid][pPos_y]);
    INI_Float("Pos_z",PlayerInfo[playerid][pPos_z]);
    INI_Int("Skin",PlayerInfo[playerid][pSkin]);
    INI_Int("Team",PlayerInfo[playerid][pTeam]);
    INI_Int("Accent",PlayerInfo[playerid][pAccent]);
    return 1;
}

function MoneyUpdate(playerid)
{
    if(GetPlayerCash(playerid) < GetPlayerMoney(playerid))
    {
        foreach(Player, i)
        {
            new const old_money = GetPlayerCash(playerid);
            ResetPlayerCash(playerid), GivePlayerCash(playerid, old_money);
        }
    }
    return 1;
}

function ProxDetector(Float:radi, playerid, string[],col1,col2,col3,col4,col5)
{
    if(IsPlayerConnected(playerid))
    {
        new Float:posx, Float:posy, Float:posz;
        new BigEar[MAX_PLAYERS];
        new Float:oldposx, Float:oldposy, Float:oldposz;
        new Float:tempposx, Float:tempposy, Float:tempposz;
        GetPlayerPos(playerid, oldposx, oldposy, oldposz);
        for(new i = 0; i < MAX_PLAYERS; i++)
        {
            if(IsPlayerConnected(i) && (GetPlayerVirtualWorld(playerid) == GetPlayerVirtualWorld(i)))
            {
                if(!BigEar[i])
                {
                    GetPlayerPos(i, posx, posy, posz);
                    tempposx = (oldposx -posx);
                    tempposy = (oldposy -posy);
                    tempposz = (oldposz -posz);
                    if (((tempposx < radi/16) && (tempposx > -radi/16)) && ((tempposy < radi/16) && (tempposy > -radi/16)) && ((tempposz < radi/16) && (tempposz > -radi/16)))
                    {
                        SendClientMessage(i, col1, string);
                    }
                    else if (((tempposx < radi/8) && (tempposx > -radi/8)) && ((tempposy < radi/8) && (tempposy > -radi/8)) && ((tempposz < radi/8) && (tempposz > -radi/8)))
                    {
                        SendClientMessage(i, col2, string);
                    }
                    else if (((tempposx < radi/4) && (tempposx > -radi/4)) && ((tempposy < radi/4) && (tempposy > -radi/4)) && ((tempposz < radi/4) && (tempposz > -radi/4)))
                    {
                        SendClientMessage(i, col3, string);
                    }
                    else if (((tempposx < radi/2) && (tempposx > -radi/2)) && ((tempposy < radi/2) && (tempposy > -radi/2)) && ((tempposz < radi/2) && (tempposz > -radi/2)))
                    {
                        SendClientMessage(i, col4, string);
                    }
                    else if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
                    {
                        SendClientMessage(i, col5, string);
                    }
                }
                else
                {
                    SendClientMessage(i, col1, string);
                }
            }
        }
    }
    return 1;
}
I want when player disconnect, cash saves,
Reply
#2

Try making your users save in a file, then the script reads from the file the info and loads it.
Reply
#3

Also try adding this under your onplayerdisconnect
pawn Code:
INI_WriteInt(File,"Cash",getplayermoney(playerid));
Reply
#4

Do you have a folder in scriptfiles for your accounts to save to?
Reply
#5

Yeah i have
Reply
#6

is your script using an anti money hack?If so try using GivePlayerCash(playerid, 5000); instead of GivePlayerMoney
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)