SA-MP Forums Archive
Problems saving 'Cash' with Dini. (solved) - 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: Problems saving 'Cash' with Dini. (solved) (/showthread.php?tid=124543)



Problems saving 'Cash' with Dini. (solved) - kmzr - 30.01.2010

Ok, Im tryna set it so when a user registers, they get $5000.. so i'v got this upon registering:

pawn Код:
format(st,sizeof(st),"accounts/%s.user",name[playerid]);
                dini_Create((st));
                dini_IntSet((st), "Password", udb_hash(inputtext));
                dini_Set((st),"Pass",inputtext);
                dini_IntSet((st), "Level", 0);
                dini_IntSet((st), "Cash", 5000);
                dini_IntSet((st), "Skinid", 0);
                dini_IntSet((st), "Deaths", 0);
                dini_IntSet((st), "Kills", 0);
                printf(st);
                format(st, sizeof(st), "** [SERVER] Your account '%s' has been created with the password %s **", name[playerid], inputtext);
                SendClientMessage(playerid, COLOR_YELLOW, st);
                Entry(playerid);
and this upon when a user logs in:
pawn Код:
{
                dini_Set((st),"Pass",inputtext);
                stats[playerid][level] = dini_Int((name[playerid]), "Level");
                stats[playerid][cash] = dini_Int((name[playerid]), "Cash");
                stats[playerid][skinid] = dini_Int((name[playerid]), "Skinid");
                stats[playerid][death] = dini_Int((name[playerid]), "Deaths");
                stats[playerid][kill] = dini_Int((name[playerid]), "Kills");
                SetPlayerMoney(playerid, stats[playerid][cash]);
                SendClientMessage(playerid, COLOR_GREEN, "Welcome to Esperanza Roleplay.");
                SpawnPlayer(playerid);
                    }
But for some reason i don't get 5000 once registered and logged in. can you spot anything wrong in the code?


Re: Help with Dini - Backwardsman97 - 30.01.2010

How about after you register go and check the file to see if cash is set to 5000.


Re: Help with Dini - kmzr - 31.01.2010

The cash is there i get "Cash=5000", but IG i have no cash, and when i disconnect and check the file it says "Cash=0"

I have this too

pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
  dini_IntSet((st),"Cash", GetPlayerMoney(playerid));
    return 1;
}
Ok, so i added this in the 'register' section of the code
pawn Код:
GivePlayerMoney(playerid, 10000);
and changed the value '5000' in this section of the dini code to 0
pawn Код:
dini_IntSet((st), "Cash", 0);
I got $5000 once registered, but when i Login my money resets to 0.

This is the script that i'm trying but failing to save and give 'Cash' with.

http://pastebin.com/f5079dabd


Re: Help with Dini - kmzr - 31.01.2010

Sorry about the bump, i'm off to sleep now but i have left a more in-depth post above than what was in the OP. Hope someone could help me out, thanks.


Re: Problems saving 'Cash' with Dini. - kmzr - 31.01.2010

fixed