Most players online ever
#1

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!
Reply
#2

pawn Код:
OnPlayerConnect:

playercount++;

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

OnPlayerDisconnect:

playercount--;
Reply
#3

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?
Reply
#4

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

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

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

yep.
Reply
#8

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

that fixed it. thanks!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)