Saving Player Stats On GMX
#1

Well i am trying to create my own server, but i have a problem i need everyone's stats to save after the server has done GMX, I have tried lots of tutorial and i either don't get them or they don't work, I am wondering if anyone here can show me a good working tutorial.


Scripter
Reply
#2

I have a system that saves money and the player's score if this help you:

pawn Код:
#include <Dini>

OnPlayerConnect:

    if(dini_Isset("score.ini",PlayerName(playerid))) SetPlayerScore(playerid,dini_Int("score.ini",PlayerName(playerid)));
    if(dini_Isset("money.ini",PlayerName(playerid))) GivePlayerMoney(playerid,dini_Int("money.ini",PlayerName(playerid)));

OnPlayerDisconnect :

    dini_IntSet("score.ini",PlayerName(playerid),GetPlayerScore(playerid));
    dini_IntSet("money.ini",PlayerName(playerid),GetPlayerMoney(playerid));

OnGameModeInit:

    if(!fexist("score.ini")) dini_Create("score.ini");
    if(!fexist("money.ini")) dini_Create("money.ini");
Reply
#3

Make a gmx command that loops through all the players, and save their stats, and calls gmx in the command
Код:
SendRconCommand("gmx");
Reply
#4

Quote:
Originally Posted by .FuneraL.
Посмотреть сообщение
I have a system that saves money and the player's score if this help you:

pawn Код:
#include <Dini>

OnPlayerConnect:

    if(dini_Isset("score.ini",PlayerName(playerid))) SetPlayerScore(playerid,dini_Int("score.ini",PlayerName(playerid)));
    if(dini_Isset("money.ini",PlayerName(playerid))) GivePlayerMoney(playerid,dini_Int("money.ini",PlayerName(playerid)));

OnPlayerDisconnect :

    dini_IntSet("score.ini",PlayerName(playerid),GetPlayerScore(playerid));
    dini_IntSet("money.ini",PlayerName(playerid),GetPlayerMoney(playerid));

OnGameModeInit:

    if(!fexist("score.ini")) dini_Create("score.ini");
    if(!fexist("money.ini")) dini_Create("money.ini");
Naa, Thank You anyway, Im using Y_INI, Its really annoying i just need to find a decent tutorial or a way how to do it.
Reply
#5

Quote:
Originally Posted by VincentDunn
Посмотреть сообщение
Make a gmx command that loops through all the players, and save their stats, and calls gmx in the command
Код:
SendRconCommand("gmx");
I have done that, but it just dont work, Can you give me a little start ?
Reply
#6

I'm assuming that you are saving player data when the OnPlayerDisconnect callback is called.
If so, do this:
pawn Код:
public OnGameModeExit()
{
    foreach(Player, i) OnPlayerDisconnect(i, 1);
}
This'll require the foreach include of course, which you can easily find using the search function.
Reply
#7

Put This in OnGamemodeExit

pawn Код:
for(new i = 0; i < MAX_PLAYERS; i++)
{
//player files [replace playerid to i]
}
Reply
#8

Quote:
Originally Posted by awsomedude
Посмотреть сообщение
Put This in OnGamemodeExit

pawn Код:
for(new i = 0; i < MAX_PLAYERS; i++)
{
//player files [replace playerid to i]
}
So like this ?


pawn Код:
for(new i = 0; i < MAX_PLAYERS; i++)
{
        new INI:File = INI_Open(UserPath(i));
    INI_SetTag(File,"data");
    INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));
    INI_WriteInt(File,"Admin",PlayerInfo[playerid][pAdmin]);
    INI_WriteInt(File,"Kills",PlayerInfo[playerid][pKills]);
    INI_WriteInt(File,"Deaths",PlayerInfo[playerid][pDeaths]);
    INI_Close(File);
}

?
Reply
#9

Quote:
Originally Posted by Scripter12345
Посмотреть сообщение
So like this ?


pawn Код:
for(new i = 0; i < MAX_PLAYERS; i++)
{
        new INI:File = INI_Open(UserPath(i));
    INI_SetTag(File,"data");
    INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));
    INI_WriteInt(File,"Admin",PlayerInfo[playerid][pAdmin]);
    INI_WriteInt(File,"Kills",PlayerInfo[playerid][pKills]);
    INI_WriteInt(File,"Deaths",PlayerInfo[playerid][pDeaths]);
    INI_Close(File);
}

?
yeah but replace playerid with i
Reply
#10

Quote:
Originally Posted by awsomedude
Посмотреть сообщение
yeah but replace playerid with i
Tried that it still did not work, I really want this to work
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)