Y_Ini - Server stats save, read.
#1

I need to create a ServerStats.ini when GameModeStarts and open it. Later read it and write stats into in.
Example write in it record players online. I don't how to do that because it's Y_Ini. If it would be dini or djson i would do that but not with it. I need help guys.
Reply
#2

Anyone.
Reply
#3

pawn Code:
// Loading a INTEGER in file set as "Score = value"
forward LoadStats ( playerid, name[ ], value[ ] );
public LoadStats( playerid, name[ ], value[ ] )
{
    if( strcmp( name, "Score", true ) )
    {
        SetPlayerScore( playerid, strval( value ) );
    }
    return 1;
}
pawn Code:
// Example of loading that score
CMD:loadmyscore( playerid, params[ ] )
{
    new file[ 15 ]; format( file, sizeof file, "somefile.ini" );            // Sets the filepath
    INI_ParseFile( file, "LoadStats", false, true, playerid, true, false ); // Loads the score
    return 1;
}
Reply
#4

Where to put this?:
Code:
INI:ServerStats[](name[], value[])
{
    INI_Int("uptime", gUptime);
}
It'll create ServerStats.ini in Scriptfiles, yes? if yes, how to read something from there?
I just wanna read stats and show players. Like all kicked players, and showing in formatted message.
Reply
#5

Here try and use this just edit the COLOR_GRAD1 To your #Define that you have

pawn Code:
if(strcmp(cmd, "/stats", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            if(gPlayerLogged[playerid] != 0)
            {
                ShowStats(playerid,playerid);
            }
            else
            {
                SendClientMessage(playerid, COLOR_GRAD1, "   You are not Logged in !");
            }
        }
        return 1;
Reply
#6

What the fuck are you talking about? i need only help with create.ini when Serwer starts and if it's created i need to load this file and reading from it stats.

Example read all total deaths. I know how to create total but don't know how to create ServerStats.ini and read from it and load.
Reply
#7

I readed it but you're speaking to hard for my english and i don't know all what you saying. If you could be easier for me and tell me what function to create, load, write, read?

To read i need only in command.
pawn Code:
CMD:stats(playerid, params[])
{
SendFormattedMessage(playerid, COLOR, "* Total server kills: %d.", SerwerInfo[sTotalKills]);
return true;
}
Here you are ^ - reading from ServerStats.ini - i need only this.
Reply
#8

Tell me where to put this:
pawn Code:
INI:ServerStats[](name[], value[])
{
    INI_Int("uptime", gUptime);
}
And so.. if i wan't to show player total kills on server i need to this:

Code:
enum sInfo
{
sTotalKills
};
new ServerInfo[sInfo]
pawn Code:
public OnGameModeExit()
{
INI:ServerStats[](name[], value[])
{
    INI_Int("TotalKills", SerwerInfo[sTotalKills]);
}
return true;
}
pawn Code:
main()
{
    INI_Load("ServerStats.ini");
}
pawn Code:
public OnPlayerDeath(playerid, killerid, reason)
{
ServerInfo[sTotalKills]++;
/* Here i need to write into ServerStats.ini */
return true;
}
pawn Code:
CMD:stats(playerid, params[])
{
SendFormattedMessage(playerid, COLOR, "* Total server kills: %d.", SerwerInfo[sTotalKills]);
return true;
}
So.. more i don't know how to do.
Reply
#9

What? i don't understand you.
Reply
#10

pawn Code:
new INI:SerwerStats;
    SerwerStats = INI_Open("Polski eXtra Serwer/Statystyki/SerwerStats.ini");
    INI_Close(SerwerStats);
It's creating, yes? i mean.. it's created already. To put something in SerwerStats.ini i need every time to open it?
just like.. OnPlayerDeath
pawn Code:
new INI:SerwerStats;
    SerwerStats = INI_Open("Polski eXtra Serwer/Statystyki/SerwerStats.ini");
        INI_WriteInt(SerwerStats, "TotalDeaths", SerwerInfo[sTotalDeaths]+1);
    INI_Close(SerwerStats);
Yes? or there's better way?

To read i'll need only use SerwerInfo[sTotalDeaths] - in message/textdraw whatever i wan't, yes?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)