How to load X, Y, Z
#1

I am trying to make it so it will save player stats on gmx it is working fine apart from saving and loading the stats when i do gmx, the X, Y, Z dont save, so they wont load how can i fix this


pawn Код:
forward LoadUser_data(playerid,name[],value[]);
public LoadUser_data(playerid,name[],value[])
{

    INI_Int("Password",PlayerInfo[playerid][pPass]);
    INI_Int("Admin",PlayerInfo[playerid][pAdmin]);
    INI_Int("Kills",PlayerInfo[playerid][pKills]);
    INI_Int("Deaths",PlayerInfo[playerid][pDeaths]);
    INI_Float("PosX",PlayerInfo[playerid][PosX]);
    INI_Float("PosY",PlayerInfo[playerid][PosY]);
    INI_Float("PosZ",PlayerInfo[playerid][PosZ]);
    INI_Int("AdminLevel",PlayerData[playerid][AdminLevel]);
    INI_String("AdminName",PlayerData[playerid][AdminName], 24);
    INI_Int("AdminDuty",PlayerData[playerid][AdminDuty]);
    INI_Int("AdminSkin",PlayerData[playerid][AdminSkin]);
    INI_Int("OriginalSkin",PlayerData[playerid][OriginalSkin]);
    INI_String("OriginalName",PlayerData[playerid][OriginalName], 24);

    return 1;
}

Thank You


Please Help Me Please
Reply
#2

Well, SetPlayerPos?

pawn Код:
SetPlayerPos(playerid, PlayerInfo[playerid][PosX],  PlayerInfo[playerid][PosY], PlayerInfo[playerid][PosZ]);
Or, if your coordinates won't save when you restart your server, maybe the OnPlayerDisconnect callback is not called ? It happens to me too. Why don't you try with /q to see if the position is saved when you relog?
Reply
#3

Quote:
Originally Posted by antonio112
Посмотреть сообщение
Well, SetPlayerPos?

pawn Код:
SetPlayerPos(playerid, PlayerInfo[playerid][PosX],  PlayerInfo[playerid][PosY], PlayerInfo[playerid][PosZ]);
Or, if your coordinates won't save when you restart your server, maybe the OnPlayerDisconnect callback is not called ? It happens to me too. Why don't you try with /q to see if the position is saved when you relog?
When i do /q they do save
Reply
#4

you have to find where in your script it saves the users data.. Try OnPlayerUpdate
Reply
#5

Quote:
Originally Posted by Marco_Valentine
Посмотреть сообщение
you have to find where in your script it saves the users data.. Try OnPlayerUpdate
pawn Код:
CMD:restart(playerid, params[])
{
    for(new i=0; i<MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
         GetPlayerPos(playerid,PlayerInfo[playerid][PosX],PlayerInfo[playerid][PosY],PlayerInfo[playerid][PosZ]);
             
         new INI:File = INI_Open(UserPath(playerid));
         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_WriteFloat(File,"PosX",PlayerInfo[playerid][PosX]);
         INI_WriteFloat(File,"PosY",PlayerInfo[playerid][PosY]);
         INI_WriteFloat(File,"PosZ",PlayerInfo[playerid][PosZ]);
         INI_WriteInt(File,"AdminLevel",PlayerData[playerid][AdminLevel]);
         INI_WriteString(File,"AdminName",PlayerData[playerid][AdminName]);
         INI_WriteInt(File,"AdminDuty",PlayerData[playerid][AdminDuty]);
         INI_WriteInt(File,"AdminSkin",PlayerData[playerid][AdminSkin]);
         INI_WriteInt(File,"OriginalSkin",PlayerData[playerid][OriginalSkin]);
         INI_WriteString(File,"OriginalName",PlayerData[playerid][OriginalName]);
         INI_Close(File);
       }
    }
}

Thank You


Please Help Me Please
Reply
#6

Not sure if it will work. But try this


Код:
CMD:restart(playerid, params[])
{
    for(new i=0; i<MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
         new Float:X,Y,Z;
         GetPlayerPos(playerid,X,Y,Z);
             
         new INI:File = INI_Open(UserPath(playerid));
         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_WriteFloat(File,"PosX",X);
         INI_WriteFloat(File,"PosY",Y);
         INI_WriteFloat(File,"PosZ",Z);
         INI_WriteInt(File,"AdminLevel",PlayerData[playerid][AdminLevel]);
         INI_WriteString(File,"AdminName",PlayerData[playerid][AdminName]);
         INI_WriteInt(File,"AdminDuty",PlayerData[playerid][AdminDuty]);
         INI_WriteInt(File,"AdminSkin",PlayerData[playerid][AdminSkin]);
         INI_WriteInt(File,"OriginalSkin",PlayerData[playerid][OriginalSkin]);
         INI_WriteString(File,"OriginalName",PlayerData[playerid][OriginalName]);
         INI_Close(File);
       }
    }
}
Reply
#7

The loading and saving code looks fine for me, I just would like to know if "LoadUser_data" actually gets called, just put a print statment inside and check your server window
If not than its mostly the INI_ParseFile line which is wrong
Reply
#8

Quote:
Originally Posted by Nero_3D
Посмотреть сообщение
The loading and saving code looks fine for me, I just would like to know if "LoadUser_data" actually gets called, just put a print statment inside and check your server window
If not than its mostly the INI_ParseFile line which is wrong
I made a print and it did come up


This is this not fixed


Thank You


Please Help Me Please
Reply
#9

Like I posted above, the "OnPlayerDisconnect" callback is not called when you restart your server. For example, if you click "X" button at the server command prompter (or what ever is the black screen), it just shuts the gamemode down, without calling 'any' callback ? Like you said, it saves when you do /q but when you close the server, no. So, what you can do, is either make a command to restart the server, which loops through all online players and will save all their stats and after that restart the server or just kick all players, forcing them to save their stats.
Reply
#10

i suggest save the player stats using OnPlayerUpdate. Although apparently that might cause lag but i have never experienced this and i use onplayerupdate for a lot of things.

Place a print at the bottom your restart command after the close function and see if it gets printed.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)