How to save stats after restart? +Rep
#1

How to save player stats after auto restart/normal restart/gmx restart?

I did register system but it's not save my stats when the server make a auto restart or I do the restart...

+Rep to helper!
Reply
#2

Just loop through all the players and save their stats OnGameModeExit

EDIT: another solution would be if you have a scripted command to reset the server you can save the players stats here too
Reply
#3

Quote:
Originally Posted by FailerZ
Посмотреть сообщение
Just loop through all the players and save their stats OnGameModeExit

EDIT: another solution would be if you have a scripted command to reset the server you can save the players stats here too
How to code it? and when I suicide in the game the the death in the score dont change...
Reply
#4

We need to see your codes to know why they don't change
Also We can't know how your game mode work to help you to code it. (Variables and so on)

Also this section isn't for requesting a script.
Reply
#5

Quote:
Originally Posted by CheckItOut
Посмотреть сообщение
How to code it? and when I suicide in the game the the death in the score dont change...
Use this to loop through all the players:
PHP код:
//Under OnGameModeInit
for(new 0GetPlayerPoolSize(); <= ji++)
{
    
//Do your saving stuff here

If you don't know how to get your saving stuff post your OnPlayerDisconnect code and I will tell you.

About your death score, Maybe you forget to increase the death variable under OnPlayerDeath or you are increasing it only if the ID of the killerid is valid (which won't trigger if player suicide).
Reply
#6

Quote:
Originally Posted by mongi
Посмотреть сообщение
We need to see your codes to know why they don't change
Also We can't know how your game mode work to help you to code it. (Variables and so on)

Also this section isn't for requesting a script.
PHP код:
public OnPlayerDisconnect(playeridreason)
{
new 
INI:File INI_Open(UserPath(playerid));
INI_SetTag(File,"data");
INI_WriteInt(File,"Kills",PlayerInfo[playerid][pKills]);
INI_WriteInt(File,"Deaths",PlayerInfo[playerid][pDeaths]);
INI_Close(File);
return 
1;

Reply
#7

Quote:
Originally Posted by FailerZ
Посмотреть сообщение
Use this to loop through all the players:
PHP код:
//Under OnGameModeInit
for(new 0GetPlayerPoolSize(); <= ji++)
{
    
//Do your saving stuff here

If you don't know how to get your saving stuff post your OnPlayerDisconnect code and I will tell you.

About your death score, Maybe you forget to increase the death variable under OnPlayerDeath or you are increasing it only if the ID of the killerid is valid (which won't trigger if player suicide).
I have disconnect saving stats, It's also need save my stats after restart? or need commands to save stats after restart also?
Reply
#8

Quote:
Originally Posted by CheckItOut
Посмотреть сообщение
I have disconnect saving stats, It's also need save my stats after restart? or need commands to save stats after restart also?
OnPlayerDisconnect is called for all the players when the server restart. however /rcon exit will not call it. so that is the only case you might lose data if you did. other than that it is auto called and your saving should work under onplayerdisconnect
Reply
#9

What you can simply do is just create a function that kicks every player right before you shut down the server.

This will force every player to endure the "OnPlayerDisconnect" code.

Meaning, they will have their stats force-saved in a way.
Reply
#10

Create a stock to save player statistics, Then refer it to OnGameModeExit, It will be automatically saved if the player connected, You can also make OnGameModeExit refer to OnPlayerDisconnect, There are much ways to save it out.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)