Server stats help
#1

Hello,i made a little server stats code for saving the stats of my server (kills,bans etc),but i have a problem.

The code is this:

pawn Код:
LoadServerStats()
{
    if(!fexist(SERVER_STATS)) return 1;
    new File: i_FileHandle = fopen("serverstat.ini", io_read), sz_FileStr[256];
    fread(i_FileHandle, sz_FileStr);
    sscanf(sz_FileStr, "p<,>iiiiiii", TotalConnect,TotalAutoBan,TotalRegister,TotalUptime,TotalAdminBans,TotalAdminKicks,TotalLottoWins);
    return fclose(i_FileHandle);
}

SaveServerStats()
{
    new sz_FileStr[256], File: i_FileHandle = fopen(SERVER_STATS, io_write);
    format(sz_FileStr, sizeof(sz_FileStr), "%d,%d,%d,%d,%d,%d,%d", TotalConnect,TotalAutoBan,TotalRegister,TotalUptime,TotalAdminBans,TotalAdminKicks,TotalLottoWins);
    fwrite(i_FileHandle, sz_FileStr);
    return fclose(i_FileHandle);
}
It doesn't even open,read and write into the file,nothing.

The serverstat.ini is placed in /scriptfiles folder.

What can be the problem?
Reply
#2

If you actually wrote this yourself, then debug it. I see nothing wrong in the code.
Reply
#3

Quote:
Originally Posted by VincentDunn
Посмотреть сообщение
If you actually wrote this yourself, then debug it. I see nothing wrong in the code.
Debugged Load and Save,seems it prints just the LoadServerStats,it loads the file but can't save it:

This is for LoadServerStats:

Quote:

[11:02:13] Checking file
[11:02:13] Opening file
[11:02:13] Reading file
[11:02:13] Loading values in file

The SaveServerStats hasn't been printed,maybe it's that the problem?
Reply
#4

Did you make sure you add a debug (print) code in SaveServerStats?
Reply
#5

Quote:
Originally Posted by Romel
Посмотреть сообщение
Did you make sure you add a debug (print) code in SaveServerStats?
Yes i did,added but nothing got printed.

EDIT: Fixed,now it works.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)