SA-MP Forums Archive
Y_Ini - Server stats save, read. - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Y_Ini - Server stats save, read. (/showthread.php?tid=248215)



Y_Ini - Server stats save, read. - Riddick94 - 12.04.2011

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.


Re: Y_Ini - Server stats save, read. - Riddick94 - 13.04.2011

Anyone.


Re: Y_Ini - Server stats save, read. - Mean - 13.04.2011

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;
}



Re: Y_Ini - Server stats save, read. - Riddick94 - 13.04.2011

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.


Re: Y_Ini - Server stats save, read. - blazee14 - 13.04.2011

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;



Re: Y_Ini - Server stats save, read. - Riddick94 - 13.04.2011

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.


Re: Y_Ini - Server stats save, read. - Riddick94 - 13.04.2011

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.


Re: Y_Ini - Server stats save, read. - Riddick94 - 13.04.2011

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.


Re: Y_Ini - Server stats save, read. - Riddick94 - 13.04.2011

What? i don't understand you.


Re: Y_Ini - Server stats save, read. - Riddick94 - 14.04.2011

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?