SA-MP Forums Archive
Stats does not saving - 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)
+--- Thread: Stats does not saving (/showthread.php?tid=651865)



Stats does not saving - PEKKA - 29.03.2018

Hi there.
I would like to explain the problem: In my server, stats does not saving on player disconnect.
It's only saving player score and deaths, not money etc. I have already Mysql, and these things but it's still not saving even i type /savestats... Any solution please?



Re: Stats does not saving - RxErT - 29.03.2018

Provide some codes please.


Re: Stats does not saving - PEKKA - 29.03.2018

Quote:
Originally Posted by RxErT
Посмотреть сообщение
Provide some codes please.
Do you mean compiling? Not sure if can I understand.


Re: Stats does not saving - RxErT - 29.03.2018

Stats saving command.. or anything related with stats saving.


Re: Stats does not saving - PEKKA - 30.03.2018

Quote:
Originally Posted by RxErT
Посмотреть сообщение
Stats saving command.. or anything related with stats saving.
PHP код:
enum UserEnum
{
    
//saved data
    
u_admin,
    
u_vip,
    
u_kills,
    
u_deaths,
    
u_score,
    
u_money,
    
u_hours,
    
u_minutes,
    
u_seconds,
    
//not saved data
    
u_attempts,
    
u_sessionkills,
    
u_sessiondeaths,
    
u_spree,
    
//conditions data
    
u_jailtime,
    
u_mutetime,
    
u_cmutetime,
    
u_specdata[2],
    
Float:u_specpos[4],
    
u_vehicle,
    
u_warnings
PHP код:
public OnFilterScriptInit()
{
    print(
"------------------------------------------------");
    print(
"Running GAdmin System | Developed by Gammix | Loaded...");
    print(
"------------------------------------------------");
    
BUD::Setting(opt.DatabaseLOCATION_DATABASE);
    
BUD::Setting(opt.KeepAliveTime3000);
    
BUD::Initialize();
    
BUD::VerifyColumn("ip"BUD::TYPE_STRING);
    
BUD::VerifyColumn("joindate"BUD::TYPE_STRING);
    
BUD::VerifyColumn("laston"BUD::TYPE_STRING);
    
BUD::VerifyColumn("admin"BUD::TYPE_NUMBER);
    
BUD::VerifyColumn("vip"BUD::TYPE_NUMBER);
    
BUD::VerifyColumn("kills"BUD::TYPE_NUMBER);
    
BUD::VerifyColumn("deaths"BUD::TYPE_NUMBER);
    
BUD::VerifyColumn("score"BUD::TYPE_NUMBER);
    
BUD::VerifyColumn("money"BUD::TYPE_NUMBER);
    
BUD::VerifyColumn("hours"BUD::TYPE_NUMBER);
    
BUD::VerifyColumn("minutes"BUD::TYPE_NUMBER);
    
BUD::VerifyColumn("seconds"BUD::TYPE_NUMBER);
    
BUD::VerifyColumn("logged"BUD::TYPE_NUMBER);
    
BUD::VerifyColumn("autologin"BUD::TYPE_NUMBER);
    
SetTimer("PunishmentHandle"1000true); 
PHP код:
CMD:stats(playeridparams[])
{
    new 
target;
    if(
sscanf(params"u"target))
    {
          
target playerid;
        
SendClientMessage(playeridCOLOR_KHAKI"TIP: You can also view other players stats by /stats [player]");
    }
    if(! 
IsPlayerConnected(target)) return SendClientMessage(playeridCOLOR_RED"ERROR: The specified player is not conected.");
    
GetPlayerConnectedTime(targetgUser[target][u_hours], gUser[target][u_minutes], gUser[target][u_seconds]);
    
//Stats stuff !:D!
    
new DIALOG[676];
    new 
string[156];
    
format(stringsizeof(string), ""WHITE"You are now viewing "LIME"%s's [id: %i]"WHITE", statics:\n\n"ReturnPlayerName(target), target);
    
strcat(DIALOGstring);
    
format(stringsizeof(string), ""SAMP_BLUE"Kills: "CORAL"%i\n"gUser[target][u_kills]);
    
strcat(DIALOGstring);
    
format(stringsizeof(string), ""SAMP_BLUE"Deaths: "CORAL"%i\n"gUser[target][u_deaths]);
    
strcat(DIALOGstring);
    
format(stringsizeof(string), ""SAMP_BLUE"Session Kills: "CORAL"%i\n"gUser[target][u_sessionkills]);
    
strcat(DIALOGstring);
    
format(stringsizeof(string), ""SAMP_BLUE"Session Deaths: "CORAL"%i\n"gUser[target][u_sessiondeaths]);
    
strcat(DIALOGstring);
    
format(stringsizeof(string), ""SAMP_BLUE"Killing Spree: "CORAL"%i\n"gUser[target][u_spree]);
    
strcat(DIALOGstring);
    
//calculate Kill/Deaths ratio
    
new Float:ratio;
    if(
gUser[target][u_deaths] <= 0ratio 0.0;
    else 
ratio = (gUser[target][u_kills] / gUser[target][u_deaths]);
    
format(stringsizeof(string), ""SAMP_BLUE"K/D Ratio: "CORAL"%0.2f\n"ratio);
    
strcat(DIALOGstring);
    
format(stringsizeof(string), ""SAMP_BLUE"Score: "CORAL"%i\n"GetPlayerScore(target));
    
strcat(DIALOGstring);
    
format(stringsizeof(string), ""SAMP_BLUE"Money: "CORAL"$%i\n"GetPlayerMoney(target));
    
strcat(DIALOGstring);
    
//player game play time
    
format(stringsizeof(string), ""SAMP_BLUE"Played time: "CORAL"%02i hours %02i minutes %02i seconds\n"gUser[target][u_hours], gUser[target][u_minutes], gUser[target][u_seconds]);
    
strcat(DIALOGstring);
    
//print if registered or not
    
new yes[4] = "YES"no[3] = "NO";
    
format(stringsizeof(string), ""SAMP_BLUE"Registered: "CORAL"%s\n", ((GetPVarType(playerid"GAdmin_Loggedin") != PLAYER_VARTYPE_NONE) ? yes no));
    
strcat(DIALOGstring);
    
//get user id
    
new userid BUD::GetNameUID(ReturnPlayerName(target));
    new 
DATE[18];
    
//joined date
    
BUD::GetStringEntry(userid"joindate"DATE);
    
format(stringsizeof(string), ""SAMP_BLUE"Join date: "CORAL"%s\n"DATE);
    
strcat(DIALOGstring);
    
//last visit to server date
    
BUD::GetStringEntry(userid"laston"DATE);
    
format(stringsizeof(string), ""SAMP_BLUE"Last visit: "CORAL"%s\n"DATE);
    
strcat(DIALOGstring);
    
//current team id
    
format(stringsizeof(string), ""SAMP_BLUE"Team: "CORAL"%i\n\n"GetPlayerTeam(target));
    
strcat(DIALOGstring);
    
//shit!
    
strcat(DIALOG""WHITE"If you think your stats are wrong or not saved according to last log out, Please place an appeal in forums.\n");
    
strcat(DIALOG"Make sure you have a screen of your last stats and this.");
    
//show stats in dialog
    
ShowPlayerDialog(playeridDIALOG_COMMONDIALOG_STYLE_MSGBOX"Player statics"DIALOG"Close""");
    return 
1;




Re: Stats does not saving - OmerKhan - 30.03.2018

Hmm I think money saving system in gadmin is bugged, I also made a topic regarding same issue.


Re: Stats does not saving - AdamsLT - 30.03.2018

Try showing your /savestats command.
Since the command you showed only displays the stats but doesn't save them.


Re: Stats does not saving - PEKKA - 30.03.2018

Quote:
Originally Posted by AdamsLT
Посмотреть сообщение
Try showing your /savestats command.
Since the command you showed only displays the stats but doesn't save them.
Can't find, i just want to know which FS have i to use for player money saving.
By the way, i found this code, what to do with it, i tried to put this to my game mode, but when i
compile it, it's showing many errors.
So if someone knowing how to fix money saving, i will be thanksful.



Re: Stats does not saving - FaLLenGirL - 30.03.2018

Maybe you reset the player stats before the saving. Be sure that you are not reseting the variables (stats of the player) just after the stats will be saved like:

PHP код:
public OnPlayerDisconnectplayeridreason )
{
    if( 
PlayerInfoplayerid ][ LoggedIn ] == )
        
SavePlayerplayerid );
        
    
//After the save reset the variables like:
    
PlayerInfoplayerid ][ Score ] = 0;
    
PlayerInfoplayerid ][ Coins ] = 0;
    
PlayerInfoplayerid ][ Admin ] = 0;
    return 
1;

Also, if u say that your score and deaths are not saving, search in your gamemode/FS if you don't
reset them in some place before the auto save or something like this.


Re: Stats does not saving - PEKKA - 30.03.2018

For info, i just found this in my server log when i started it first time..

PHP код:
BUD NoticeThe database "GAdmin/server.d" doesn't exist; it will be created.
BUD v1.0.5 BETA loaded.
BUD - Notice: The column "ip" doesn'
t existattempting to create it.
BUD NoticeThe column "joindate" doesn't exist; attempting to create it.
BUD - Notice: The column "laston" doesn'
t existattempting to create it.
BUD NoticeThe column "admin" doesn't exist; attempting to create it.
BUD - Notice: The column "vip" doesn'
t existattempting to create it.
BUD NoticeThe column "kills" doesn't exist; attempting to create it.
BUD - Notice: The column "deaths" doesn'
t existattempting to create it.
BUD NoticeThe column "score" doesn't exist; attempting to create it.
BUD - Notice: The column "money" doesn'
t existattempting to create it.
BUD NoticeThe column "hours" doesn't exist; attempting to create it.
BUD - Notice: The column "minutes" doesn'
t existattempting to create it.
BUD NoticeThe column "seconds" doesn't exist; attempting to create it.
BUD - Notice: The column "logged" doesn'
t existattempting to create it.
BUD NoticeThe column "autologin" doesn't exist; attempting to create it. 
And this in server.d

PHP код:
SQLite format 3   @                                                                     -в
                                                                                                                                                                                                                                                                                                                                                                                                                                           
&#131;h‡/tableusersusersCREATE TABLE users (uid INTEGER PRIMARY KEY, name TEXT, passhash BLOB, `ip` TEXT DEFAULT(''), `joindate` TEXT DEFAULT(''), `laston` TEXT DEFAULT(''), `admin` INTEGER DEFAULT(0), `vip` INTEGER DEFAULT(0), `kills` INTEGER DEFAULT(0), `deaths` INTEGER DEFAULT(0), `score` INTEGER DEFAULT(0), `money` INTEGER DEFAULT(0), `hours` INTEGER DEFAULT(0), `minutes` INTEGER DEFAULT(0), `seconds` INTEGER DEFAULT(0), `logged` INTEGER DEFAULT(0), `autologin` INTEGER DEFAULT(0))