pScore not working (Y_INI save system)
#1

Simply my score aint saving... Here is the code

I placed these things

Code:
public OnPlayerDisconnect(playerid, reason)
{
    new INI:File = INI_Open(UserPath(playerid));
    INI_SetTag(File,"PlayerData");
    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_WriteInt(File,"Score",PlayerInfo[playerid][pScore]);
    INI_Close(File);
	return 1;
}
stock UserPath(playerid)
{
    new string[128],playername[MAX_PLAYER_NAME];
    GetPlayerName(playerid,playername,sizeof(playername));
    format(string,sizeof(string),PATH,playername);
    return string;
}
forward LoadUser_data(playerid,name[],value[]);
public LoadUser_data(playerid,name[],value[])
{
    INI_String("Password",PlayerInfo[playerid][pPass], 129);
    INI_Int("Cash",PlayerInfo[playerid][pCash]);
    INI_Int("Admin",PlayerInfo[playerid][pAdmin]);
    INI_Int("Kills",PlayerInfo[playerid][pKills]);
    INI_Int("Deaths",PlayerInfo[playerid][pDeaths]);
    INI_Int("Score",PlayerInfo[playerid][pScore]);
    return 1;
}
switch( dialogid )
    {
        case DIALOG_REGISTER:
        {
            if (!response) return Kick(playerid);
            if(response)
            {
                if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, ""COL_WHITE"Making your account ..",""COL_RED"You have entered an invalid password.\n"COL_WHITE"Type your password below to register a new account.","Register","Quit");
                new INI:File = INI_Open(UserPath(playerid));
                INI_SetTag(File,"PlayerData");
                new HashPass[129];
                WP_Hash(HashPass, sizeof(HashPass), inputtext);
                INI_WriteString(File, "Password", HashPass);
                INI_WriteInt(File,"Cash",0);
                INI_WriteInt(File,"Admin",-1);
                INI_WriteInt(File,"Kills",0);
                INI_WriteInt(File,"Deaths",0);
                INI_WriteInt(File,"Score",0);
                INI_Close(File);

                SetSpawnInfo(playerid, 0, 0, 1958.33, 1343.12, 15.36, 269.15, 0, 0, 0, 0, 0, 0);
                ShowPlayerDialog(playerid, DIALOG_SUCCESS_1, DIALOG_STYLE_MSGBOX,""COL_WHITE"Account created!",""COL_GREEN"You've created an account successfuly. Relogging is recommended.","Ok","");
            }
        }

        case DIALOG_LOGIN:
        {
            if ( !response ) return Kick ( playerid );
            if( response )
            {
                new HashPass[129];
                WP_Hash(HashPass, sizeof(HashPass), inputtext);
                if(strcmp(HashPass, PlayerInfo[playerid][pPass]) == 0)
                {
                    INI_ParseFile(UserPath(playerid), "LoadUser_data", .bExtra = true, .extra = playerid);
                    GivePlayerMoney(playerid, PlayerInfo[playerid][pCash]);
                    SetPlayerScore(playerid, PlayerInfo[playerid][pScore]);
                    ShowPlayerDialog(playerid, DIALOG_SUCCESS_2, DIALOG_STYLE_MSGBOX,""COL_WHITE"Success!",""COL_GREEN"You have successfully logged in!","Ok","");
                }
                else
                {
                    ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD,""COL_WHITE"Login",""COL_RED"You have entered an incorrect password.\n"COL_WHITE"Type your password below to login.","Login","Quit");
                }
                return 1;
            }
        }
    }

enum pInfo
{
    pPass[129],
    pCash,
    pAdmin,
    pKills,
    pDeaths,
    pScore
}
It can load it perfectly, for example I set the score to 50 inside the scriptfile and when I enter the server it's good. I use command to set my score and after I relog it's gone. It stays on 50. The only way I can add the score is using the scriptfile
Reply
#2

pawn Code:
public OnPlayerDisconnect(playerid, reason)
{
    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_WriteInt(File,"Score",PlayerInfo[playerid][pScore]);
    INI_Close(File);
    return 1;
}
stock UserPath(playerid)
{
    new string[128],playername[MAX_PLAYER_NAME];
    GetPlayerName(playerid,playername,sizeof(playername));
    format(string,sizeof(string),PATH,playername);
    return string;
}
forward LoadUser_data(playerid,name[],value[]);
public LoadUser_data(playerid,name[],value[])
{
    INI_String("Password",PlayerInfo[playerid][pPass], 129);
    INI_Int("Cash",PlayerInfo[playerid][pCash]);
    INI_Int("Admin",PlayerInfo[playerid][pAdmin]);
    INI_Int("Kills",PlayerInfo[playerid][pKills]);
    INI_Int("Deaths",PlayerInfo[playerid][pDeaths]);
    INI_Int("Score",PlayerInfo[playerid][pScore]);
    return 1;
}
switch( dialogid )
    {
        case DIALOG_REGISTER:
        {
            if (!response) return Kick(playerid);
            if(response)
            {
                if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, ""COL_WHITE"Making your account ..",""COL_RED"You have entered an invalid password.\n"COL_WHITE"Type your password below to register a new account.","Register","Quit");
                new INI:File = INI_Open(UserPath(playerid));
                INI_SetTag(File,"data");
                new HashPass[129];
                WP_Hash(HashPass, sizeof(HashPass), inputtext);
                INI_WriteString(File, "Password", HashPass);
                INI_WriteInt(File,"Cash",0);
                INI_WriteInt(File,"Admin",-1);
                INI_WriteInt(File,"Kills",0);
                INI_WriteInt(File,"Deaths",0);
                INI_WriteInt(File,"Score",0);
                INI_Close(File);

                SetSpawnInfo(playerid, 0, 0, 1958.33, 1343.12, 15.36, 269.15, 0, 0, 0, 0, 0, 0);
                ShowPlayerDialog(playerid, DIALOG_SUCCESS_1, DIALOG_STYLE_MSGBOX,""COL_WHITE"Account created!",""COL_GREEN"You've created an account successfuly. Relogging is recommended.","Ok","");
            }
        }

        case DIALOG_LOGIN:
        {
            if ( !response ) return Kick ( playerid );
            if( response )
            {
                new HashPass[129];
                WP_Hash(HashPass, sizeof(HashPass), inputtext);
                if(strcmp(HashPass, PlayerInfo[playerid][pPass]) == 0)
                {
                    INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
                    GivePlayerMoney(playerid, PlayerInfo[playerid][pCash]);
                    SetPlayerScore(playerid, PlayerInfo[playerid][pScore]);
                    ShowPlayerDialog(playerid, DIALOG_SUCCESS_2, DIALOG_STYLE_MSGBOX,""COL_WHITE"Success!",""COL_GREEN"You have successfully logged in!","Ok","");
                }
                else
                {
                    ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD,""COL_WHITE"Login",""COL_RED"You have entered an incorrect password.\n"COL_WHITE"Type your password below to login.","Login","Quit");
                }
                return 1;
            }
        }
    }
Your problem was in the tags. Use the tag "data", as that's what your callback dictates. Fixed your INI_ParseFile aswell.
Reply
#3

Sooo I just need to replace all of my PlayerData tags or just that one under Disconnect?
Reply
#4

"PlayerData" will not properly load the file, you must use "data" because your callback is like so..

pawn Code:
forward LoadUser_data(playerid,name[],value[]);
public LoadUser_data(playerid,name[],value[])
{
    INI_String("Password",PlayerInfo[playerid][pPass], 129);
    INI_Int("Cash",PlayerInfo[playerid][pCash]);
    INI_Int("Admin",PlayerInfo[playerid][pAdmin]);
    INI_Int("Kills",PlayerInfo[playerid][pKills]);
    INI_Int("Deaths",PlayerInfo[playerid][pDeaths]);
    INI_Int("Score",PlayerInfo[playerid][pScore]);
    return 1;
}
LoadUser_data is the tag.
Reply
#5

Doesnt work. Tried editing it and etc. Still doesnt save the Score. It saves everything else, like cash etc
Reply
#6

That's a bit odd... Take a look at this mini-script I wrote to help a friend of mine understand Y_INI. Maybe it will help you find the source of your problem.

http://pastebin.com/5xFmEc92
Reply
#7

Hmm interesting. Can you try to do something with mine? Just check it out and tell me if something else might caught the problem.
only 1717 lines (with objects)

http://pastebin.com/sKQNTPfx


The weirdest thing is that it aint loading the score

It loads EVERYTHING else :/
Reply
#8

Why not try this?
pawn Code:
//OnPlayerDisconnect
INI_WriteInt(File,"Score",GetPlayerScore(playerid));
Reply
#9

Quote:
Originally Posted by newbienoob
View Post
Why not try this?
pawn Code:
//OnPlayerDisconnect
INI_WriteInt(File,"Score",GetPlayerScore(playerid));
Tried. No effect :/

Can it be because ZCMD (some bug or maybe something else I guess....)

Code:
COMMAND:test(playerid, params[])
{
	SetPlayerScore(playerid, GetPlayerScore(playerid) + 1000);
	GivePlayerMoney(playerid, 1000);
	return 1;
}
I do that command and logout and it doesnt save the score at all.
also tried with
Code:
SetPlayerScore(playerid, 1000);
Also here is my server.cfg file too :/
Code:
echo Executing Server Config...
lanmode 0
rcon_password NoPassNoSex
maxplayers 50
port 7777
hostname Roleplay Vanila [Prison RP]
gamemode0 RoleplayScript 1
filterscripts attachments skinchanger vspawner
announce 0
query 1
chatlogging 1
weburl www.sa-mp.com
onfoot_rate 40
incar_rate 40
weapon_rate 40
stream_distance 300.0
stream_rate 1000
maxnpc 0
plugins sscanf whirlpool
logtimeformat [%H:%M:%S]
Reply
#10

Well, i'm not sure...

but did you create the folder in scriptfiles? the folder you MIGHT defined above those lines?

pawn Code:
#define UserPath "Users/%s.ini"
If you did, forgive my stupid question.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)