SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 18/05/2020, 11:25 PM   #1
ChandraLouis
Banned
 
Join Date: Mar 2013
Location: Indonesia
Posts: 438
Reputation: 37
Default Account is not saving

The player's account is not saving properly. Sometime it saves their stats but sometime when they connect to the server, their stat's are gone.

pawn Code:
stock SaveStats(playerid)
{
    new file[128], name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, MAX_PLAYER_NAME);
    format(file, sizeof(file), "Accounts/%s.ini", name);
    if(dini_Exists(file))
    {
        dini_IntSet(file,   "AdminLevel", pInfo[playerid][pAdmin]);
        dini_IntSet(file,   "VIPLevel", pInfo[playerid][pVIP]);
        dini_IntSet(file,   "Cash", GetPlayerCash(playerid));
        dini_IntSet(file,   "Score", GetPlayerScore(playerid));
        dini_IntSet(file,   "Kills", pInfo[playerid][pKills]);
        dini_IntSet(file,   "Death", pInfo[playerid][pDeaths]);
        dini_Set(file,      "IP", GetPlayerIP2(playerid));
        dini_IntSet(file,   "Banned", pInfo[playerid][pBanned]);
        dini_IntSet(file,   "Bank", pInfo[playerid][pBank]);
        dini_IntSet(file,   "Hours", pInfo[playerid][pHours]);
        dini_IntSet(file,   "Minutes", pInfo[playerid][pMinutes]);
        dini_IntSet(file,   "Second", pInfo[playerid][pSecond]);
       
    }
    return 1;
}

That is the stock i used everytime i need to save their accounts.
ChandraLouis is offline   Reply With Quote
Old 19/05/2020, 12:08 AM   #2
v1k1nG
Huge Clucker
 
v1k1nG's Avatar
 
Join Date: Feb 2018
Posts: 497
Reputation: 35
Default Re: Account is not saving

Use MySQL!
__________________
My test server: 51.91.122.18:7778
My Discord contact: [SF]kAn3#9933
YT https://www.youtube.com/channel/UCrM...QtP2pczguqvppw
v1k1nG is offline   Reply With Quote
Old 19/05/2020, 12:11 AM   #3
jasperschellekens
High-roller
 
jasperschellekens's Avatar
 
Join Date: Dec 2016
Location: Holland
Posts: 1,168
Reputation: 165
Default Re: Account is not saving

Yeah, and that's only a glimp of the many issues those saving systems from the stone age have. It's buggy and outdated and people avoid it for a reason. So what @v1k1nG said; Use MySQL, or if you don't have access to a phpmyadmin database, use SQLite.
__________________
Undead Wasteland Roleplay | Visit website
The year is 1996. San Andreas is a wasteland ruled by the undead. the once so glorius landscape of San Andreas, is now a shattered decayed place that is only a vague memory of the world as we used to know it.
jasperschellekens is offline   Reply With Quote
Old 19/05/2020, 12:11 AM   #4
KevTheJoker
Big Clucker
 
KevTheJoker's Avatar
 
Join Date: Dec 2018
Location: South America
Posts: 80
Reputation: 7
Default Re: Account is not saving

I agree with v1k1ng, you should use MySQL to save your data. It's way secure, and fast in retrieving data.
KevTheJoker is offline   Reply With Quote
Old 19/05/2020, 12:20 AM   #5
ChandraLouis
Banned
 
Join Date: Mar 2013
Location: Indonesia
Posts: 438
Reputation: 37
Default Re: Account is not saving

I didn't understand MySQL at all, even after reading the tutorials.
ChandraLouis is offline   Reply With Quote
Old 19/05/2020, 06:48 AM   #6
GameOvr
Huge Clucker
 
GameOvr's Avatar
 
Join Date: Jun 2018
Posts: 296
Reputation: 9
Default Re: Account is not saving

Save player's stats only if they are logged in.
Use a variable to check weather player is logged or not!
if someone quit without login.. this situation will occur (as you are directly saving stats without checking weather the player is logged in)

and Also use a repeating timer to save all data!
__________________
GameOvr is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with account saving TaligaroW Scripting Help 4 09/09/2018 05:00 PM
[Include] sampfw - account.inc | Dynamic player account data (loading & saving) nG Inverse Includes 0 11/09/2017 12:24 AM
INI Account Saving. iKevin Scripting Help 10 23/04/2016 09:17 AM
UG-RP Account not saving TheMafien Scripting Help 0 03/04/2016 01:27 PM
Account not saving? AmsterdamCopsAndRobbers Scripting Help 6 26/04/2013 01:29 PM


All times are GMT. The time now is 01:25 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.