SA-MP Forums Archive
Server stats help - 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: Server stats help (/showthread.php?tid=383583)



Server stats help - Face9000 - 07.10.2012

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?


Re: Server stats help - ReneG - 08.10.2012

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


Re: Server stats help - Face9000 - 08.10.2012

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?


Re: Server stats help - JaKe Elite - 08.10.2012

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


Re: Server stats help - Face9000 - 08.10.2012

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.