SA-MP Forums Archive
Most players online ever - 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: Most players online ever (/showthread.php?tid=295634)



Most players online ever - sciman001 - 07.11.2011

Hey guys. I want to make a simple script that saves the most players that have ever been online at one time in a ini file using dini. And I want it in my gamemode. So, if anyone can let me know how to do this, I would really appreciate it. Thanks! p.s., i want something like RoaRec but 10000 times simpler and with dini. I looked at that code but i didnt understand it.. So.. yeah. PLEASE HELP! THANKS FOR UR TIME!


Re: Most players online ever - Snipa - 07.11.2011

pawn Код:
OnPlayerConnect:

playercount++;

if(playercount > oldcount)
dini_Int(//blah blah blah);

OnPlayerDisconnect:

playercount--;



Re: Most players online ever - sciman001 - 07.11.2011

I made a filterscript first so it would be easier to understand. Heres what I got:

pawn Код:
#include <a_samp>
#include <dini>

#pragma unused strtok
#pragma unused ret_memcpy

#define OLD dini_Int(SERVER_RECORD_FILE, "record")
#define SERVER_RECORD_FILE "SERVER/STATS/record.ini"

public OnFilterScriptInit()
{
    rcrd();
    return 1;
}

public OnPlayerConnect(playerid)
{
    if(!IsPlayerNPC(playerid))
    {
        rcrd();
    }
    return 1;
}

stock rcrd()
{
    if(!fexist(SERVER_RECORD_FILE))
    {
        dini_Create(SERVER_RECORD_FILE);
        dini_IntSet(SERVER_RECORD_FILE, "record", CountPlayersOnline());
    }
    else
    {
        if(CountPlayersOnline() > OLD)
        {
            dini_IntSet(SERVER_RECORD_FILE, "record", CountPlayersOnline());
        }
    }
    return 1;
}

stock CountPlayersOnline()
{
    new iCount;
    for(new slots = GetMaxPlayers(), i; i < slots; i++)
    {
        if(IsPlayerConnected(i) && !IsPlayerNPC(i)) iCount++;
    }
    return iCount;
}
But the value in the file is always 0. Am I making a stupid mistake? If so, what?


Re: Most players online ever - MP2 - 07.11.2011

Make sure it is the first filterscript in server.cfg; OnPlayerConnect won't be called otherwise.


Re: Most players online ever - sciman001 - 07.11.2011

really? i didnt know that. thanks! - edit: its still 0!


Re: Most players online ever - MP2 - 07.11.2011

Did you FULLY restart the server? As in CLOSE samp-server.exe


Re: Most players online ever - sciman001 - 07.11.2011

yep.


Re: Most players online ever - Norn - 07.11.2011

pawn Код:
#define OLD dini_Int(SERVER_RECORD_FILE, "record")
That's the issue, I don't even believe you can call functions like that.


Re: Most players online ever - sciman001 - 07.11.2011

that fixed it. thanks!