SA-MP Forums Archive
Not loading stats? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Not loading stats? (/showthread.php?tid=273924)



Not loading stats? - Dr - 03.08.2011

Hello,

The player registers and everything is working fine, but then say I change their money in their .ini file to 5000, it does not load it...

Here is the parsefile:
pawn Code:
forward LoadUser_data(playerid,name[],value[]);
public LoadUser_data(playerid,name[],value[])
{
    INI_Int("Password",PlayerInfo[playerid][pPassword]);
    INI_Int("Bank",PlayerInfo[playerid][pBank]);
    INI_Int("Money",PlayerInfo[playerid][pMoney]);
    INI_Int("Gender",PlayerInfo[playerid][pGender]);
    INI_Int("Skin",PlayerInfo[playerid][pSkin]);
    INI_Int("Age",PlayerInfo[playerid][pAge]);
    INI_Int("Origin",PlayerInfo[playerid][pOrigin]);
    INI_Int("Accent",PlayerInfo[playerid][pAccent]);
    INI_Int("Job",PlayerInfo[playerid][pJob]);
    INI_Int("Faction",PlayerInfo[playerid][pFaction]);
    INI_Int("Rank",PlayerInfo[playerid][pRank]);
    INI_Int("License",PlayerInfo[playerid][pLicense]);
    INI_Int("Cocaine",PlayerInfo[playerid][pCocaine]);
    INI_Int("Marijuana",PlayerInfo[playerid][pMarijuana]);
    INI_Int("Donater",PlayerInfo[playerid][pDonater]);
    INI_Int("DonaterPoints",PlayerInfo[playerid][pDonaterPoints]);
    INI_Int("Watch",PlayerInfo[playerid][pWatch]);
    INI_Int("Phone",PlayerInfo[playerid][pPhone]);
    INI_Int("PhoneNumber",PlayerInfo[playerid][pPhoneNumber]);
    INI_Int("Cigars",PlayerInfo[playerid][pCigars]);
    INI_Int("Lighter",PlayerInfo[playerid][pLighter]);
    INI_Int("Mask",PlayerInfo[playerid][pMask]);
    INI_Int("JailTime",PlayerInfo[playerid][pJailTime]);
    INI_Int("Gun01",PlayerInfo[playerid][pGun01]);
    INI_Int("Ammo01",PlayerInfo[playerid][pAmmo01]);
    INI_Int("Gun02",PlayerInfo[playerid][pGun02]);
    INI_Int("Ammo02",PlayerInfo[playerid][pAmmo02]);
    INI_Int("Gun03",PlayerInfo[playerid][pGun03]);
    INI_Int("Ammo03",PlayerInfo[playerid][pAmmo03]);
    INI_Int("Gun04",PlayerInfo[playerid][pGun04]);
    INI_Int("Ammo04",PlayerInfo[playerid][pAmmo04]);
    INI_Int("Gun05",PlayerInfo[playerid][pGun05]);
    INI_Int("Ammo05",PlayerInfo[playerid][pAmmo05]);
    INI_Int("Gun06",PlayerInfo[playerid][pGun06]);
    INI_Int("Ammo06",PlayerInfo[playerid][pAmmo06]);
    INI_Int("Gun07",PlayerInfo[playerid][pGun07]);
    INI_Int("Ammo07",PlayerInfo[playerid][pAmmo07]);
    INI_Int("Gun08",PlayerInfo[playerid][pGun08]);
    INI_Int("Ammo08",PlayerInfo[playerid][pAmmo08]);
    INI_Int("Gun09",PlayerInfo[playerid][pGun09]);
    INI_Int("Ammo09",PlayerInfo[playerid][pAmmo09]);
    INI_Int("Gun11",PlayerInfo[playerid][pGun11]);
    INI_Int("Ammo11",PlayerInfo[playerid][pAmmo11]);
    INI_Int("Registered",PlayerInfo[playerid][pRegistered]);
    return 1;
}



Re: Not loading stats? - Shockey HD - 03.08.2011

Quote:
Originally Posted by Dr
View Post
Hello,

The player registers and everything is working fine, but then say I change their money in their .ini file to 5000, it does not load it...

Here is the parsefile:
pawn Code:
forward LoadUser_data(playerid,name[],value[]);
public LoadUser_data(playerid,name[],value[])
{
    INI_Int("Password",PlayerInfo[playerid][pPassword]);
    INI_Int("Bank",PlayerInfo[playerid][pBank]);
    INI_Int("Money",PlayerInfo[playerid][pMoney]);
    INI_Int("Gender",PlayerInfo[playerid][pGender]);
    INI_Int("Skin",PlayerInfo[playerid][pSkin]);
    INI_Int("Age",PlayerInfo[playerid][pAge]);
    INI_Int("Origin",PlayerInfo[playerid][pOrigin]);
    INI_Int("Accent",PlayerInfo[playerid][pAccent]);
    INI_Int("Job",PlayerInfo[playerid][pJob]);
    INI_Int("Faction",PlayerInfo[playerid][pFaction]);
    INI_Int("Rank",PlayerInfo[playerid][pRank]);
    INI_Int("License",PlayerInfo[playerid][pLicense]);
    INI_Int("Cocaine",PlayerInfo[playerid][pCocaine]);
    INI_Int("Marijuana",PlayerInfo[playerid][pMarijuana]);
    INI_Int("Donater",PlayerInfo[playerid][pDonater]);
    INI_Int("DonaterPoints",PlayerInfo[playerid][pDonaterPoints]);
    INI_Int("Watch",PlayerInfo[playerid][pWatch]);
    INI_Int("Phone",PlayerInfo[playerid][pPhone]);
    INI_Int("PhoneNumber",PlayerInfo[playerid][pPhoneNumber]);
    INI_Int("Cigars",PlayerInfo[playerid][pCigars]);
    INI_Int("Lighter",PlayerInfo[playerid][pLighter]);
    INI_Int("Mask",PlayerInfo[playerid][pMask]);
    INI_Int("JailTime",PlayerInfo[playerid][pJailTime]);
    INI_Int("Gun01",PlayerInfo[playerid][pGun01]);
    INI_Int("Ammo01",PlayerInfo[playerid][pAmmo01]);
    INI_Int("Gun02",PlayerInfo[playerid][pGun02]);
    INI_Int("Ammo02",PlayerInfo[playerid][pAmmo02]);
    INI_Int("Gun03",PlayerInfo[playerid][pGun03]);
    INI_Int("Ammo03",PlayerInfo[playerid][pAmmo03]);
    INI_Int("Gun04",PlayerInfo[playerid][pGun04]);
    INI_Int("Ammo04",PlayerInfo[playerid][pAmmo04]);
    INI_Int("Gun05",PlayerInfo[playerid][pGun05]);
    INI_Int("Ammo05",PlayerInfo[playerid][pAmmo05]);
    INI_Int("Gun06",PlayerInfo[playerid][pGun06]);
    INI_Int("Ammo06",PlayerInfo[playerid][pAmmo06]);
    INI_Int("Gun07",PlayerInfo[playerid][pGun07]);
    INI_Int("Ammo07",PlayerInfo[playerid][pAmmo07]);
    INI_Int("Gun08",PlayerInfo[playerid][pGun08]);
    INI_Int("Ammo08",PlayerInfo[playerid][pAmmo08]);
    INI_Int("Gun09",PlayerInfo[playerid][pGun09]);
    INI_Int("Ammo09",PlayerInfo[playerid][pAmmo09]);
    INI_Int("Gun11",PlayerInfo[playerid][pGun11]);
    INI_Int("Ammo11",PlayerInfo[playerid][pAmmo11]);
    INI_Int("Registered",PlayerInfo[playerid][pRegistered]);
    return 1;
}
Why would you change money Via .ini. Dont be cheap and make a command.

SSCANF is the way to go for making this kind of command.

I will show you mine. (You can have it if you want)

pawn Code:
CMD:givecash(playerid,params[])
{
    if(PlayerInfo[playerid][pAdminLevel] >=2)
    {
        new
            id,
            amount;
        new Str[64];
        if(sscanf(params, "ud", id, amount)) SendClientMessage(playerid,COLOR_RED,"Usage: /givecash <ID> <Amount>");
        else if(id == INVALID_PLAYER_ID) SendClientMessage(playerid,COLOR_RED,"Error: Player Not Connected!");
        else
        {
            new name[MAX_PLAYER_NAME], PlayerName[MAX_PLAYER_NAME];
            GetPlayerName(playerid, name, sizeof(name));
            GetPlayerName(id, PlayerName, sizeof(PlayerName));
            GivePlayerMoney(id,amount);
            new str[40+MAX_PLAYER_NAME];
            format(str, sizeof(str), "You have sent %d to %s(ID:%d)",amount,PlayerName,id);
            SendClientMessage(playerid, COLOR_GREEN, str);
            format(str, sizeof(str), "Admin:%s(ID:%d)Has gave you %d!",name,id,amount);
            SendClientMessage(id, COLOR_GREEN, str);
            SaveToLog("Givecash_Log.txt", Str);
            }
        return 1;
        }
    else return SendClientMessage(playerid, COLOR_RED, " You are not allowed to use this command");
}
This is for admins only.


Re: Not loading stats? - Kush - 03.08.2011

Post in section where you got this next time.

Make sure that when you disconnect, it 'GetPlayerMoney'. If you've edited the .INI file, and the value goes back to 0, you've done something wrong.


Re: Not loading stats? - Dr - 03.08.2011

Dude the money is not the point, I already use sscanf and I already know how to make that command... The point is nothing is loading from their player file.


Re: Not loading stats? - Kush - 03.08.2011

Quote:
Originally Posted by Shockey HD
View Post
Why would you change money Via .ini. Dont be cheap and make a command.

SSCANF is the way to go for making this kind of command.

I will show you mine. (You can have it if you want)

pawn Code:
CMD:givecash(playerid,params[])
{
    if(PlayerInfo[playerid][pAdminLevel] >=2)
    {
        new
            id,
            amount;
        new Str[64];
        if(sscanf(params, "ud", id, amount)) SendClientMessage(playerid,COLOR_RED,"Usage: /givecash <ID> <Amount>");
        else if(id == INVALID_PLAYER_ID) SendClientMessage(playerid,COLOR_RED,"Error: Player Not Connected!");
        else
        {
            new name[MAX_PLAYER_NAME], PlayerName[MAX_PLAYER_NAME];
            GetPlayerName(playerid, name, sizeof(name));
            GetPlayerName(id, PlayerName, sizeof(PlayerName));
            GivePlayerMoney(id,amount);
            new str[40+MAX_PLAYER_NAME];
            format(str, sizeof(str), "You have sent %d to %s(ID:%d)",amount,PlayerName,id);
            SendClientMessage(playerid, COLOR_GREEN, str);
            format(str, sizeof(str), "Admin:%s(ID:%d)Has gave you %d!",name,id,amount);
            SendClientMessage(id, COLOR_GREEN, str);
            SaveToLog("Givecash_Log.txt", Str);
            }
        return 1;
        }
    else return SendClientMessage(playerid, COLOR_RED, " You are not allowed to use this command");
}
This is for admins only.
This is beside the point Shockey. He's having issues with values saving.


Re: Not loading stats? - PrawkC - 03.08.2011

Is your problem that you're ingame, you alt tab.. open your file, change the value, then go back in game and your money hasn't changed? .. if so thats because the file isnt being reloaded.


Re: Not loading stats? - Calgon - 03.08.2011

Have you opened the file correctly?


Re: Not loading stats? - Dr - 03.08.2011

Yeah I went edited the file in my FTP and it is not loading what I edited...


Re: Not loading stats? - Calgon - 03.08.2011

If you edit your file while your server is active and you're connected, your stats won't be updated. If you look at your code, you probably load the player's file (this is called caching) and store it in variables on the server and then save the data when the player disconnects - the problem here is that your file is not re-checked to reflect the changes on your file, so you need to disconnect your client from the server or use another name and then edit your file, save it and then reconnect to your server.


Re: Not loading stats? - Dr - 04.08.2011

I was offline and then edited it, wasn't on the server, and it still did not work.