Scores won't save!
#1

Hi!

I am using INI to write into files, and the problem is:

My score won't save, any other things will!

I tested it while killing some other players, and after a restart, everything was gone!
Reply
#2

Show me the code where you are trying to save score into a file
Reply
#3

PHP код:
if(INI_Open(getINI(playerid))) {
            
INI_WriteInt("Cash"GetPlayerMoney(playerid));
            
INI_WriteInt("Admin"PlayerInfo[playerid][pAdmin]);
            
INI_WriteInt("FirstTime"gFirstTimeHasJoined[playerid]);
            
INI_WriteInt("Skin"GetPlayerSkin(playerid));
            
INI_Save();
            
INI_Close();
        } 
PHP код:
public OnDialogResponse(playeriddialogidresponselistiteminputtext[]) {
        switch(
dialogid) {
            case 
DIALOG_REGISTER: {
                if(!
response) return Kick(playerid);
                if(
response) {
                    if(!
strlen(inputtext)) return ShowPlayerDialog(playeridDIALOG_REGISTERDIALOG_STYLE_INPUT""WHITE"Registering...",""RED"You have entered an invalid password.\n"WHITE"Type your password below to register a new account.","Register","Quit");
                    if(
INI_Open(getINI(playerid))) {
                        
INI_WriteString("Password",inputtext);
                        
INI_WriteInt("Cash"0);
                        
INI_WriteInt("Admin"0);
                        
INI_WriteInt("Score"0);
                        
INI_WriteInt("FirstTime"0);
                        
INI_WriteInt("Skin"0);
                        
INI_Save();
                        
INI_Close();
                        
ShowPlayerDialog(playeridDIALOG_LOGINDIALOG_STYLE_INPUT,""WHITE"Login",""WHITE"Type your password below to login.","Login","Quit");
                    }
                }
            } case 
DIALOG_LOGIN: {
                if(!
response) return Kick playerid );
                if(
response) {
                    if(!
strlen(inputtext)) return ShowPlayerDialog(playeridDIALOG_LOGINDIALOG_STYLE_INPUT""WHITE"Login",""RED"You have entered an invalid password.\n"WHITE"Type your password below to login.","Login","Quit");
                    if(
INI_Open(getINI(playerid))) {
                        
INI_ReadString(PlayerInfo[playerid][pPass],"Password",20);
                        if(
strcmp(inputtext,PlayerInfo[playerid][pPass],false)) {
                            
ShowPlayerDialog(playeridDIALOG_LOGINDIALOG_STYLE_INPUT""WHITE"Login",""RED"You have entered an incorrect password.\n"WHITE"Type your password below to login.","Login","Quit");
                        }
                        
GivePlayerMoneyplayeridINI_ReadInt"Cash" ) );
                        
PlayerInfo[playerid][pAdmin] = INI_ReadInt("Admin");
                        
SetPlayerScoreplayeridINI_ReadInt"Score" ) );
                        
gFirstTimeHasJoined[playerid] = INI_ReadInt("FirstTime");
                        
gPlayerSkinForEver[playerid] = INI_ReadInt("Skin");
                        
INI_Close();
                    }
                }
            }
        }
        return 
1;
    } 
PHP код:
    enum pInfo
    
{
        
pPass,
        
pCash,
        
pAdmin,
    } 
Reply
#4

I knew your script. I still have it on my PC.

OnPlayerDisconnect saving (remove your old one)
pawn Код:
if(INI_Open(getINI(playerid)))
    {
        INI_WriteInt("Cash", GetPlayerMoney(playerid));
        INI_WriteInt("Admin", PlayerInfo[playerid][pAdmin]);
        INI_WriteInt("FirstTime", gFirstTimeHasJoined[playerid]);
        INI_WriteInt("Skin", GetPlayerSkin(playerid));
        INI_WriteInt("Score", GetPlayerScore(playerid));
        INI_Save();
        INI_Close();
    }
OnDialogResponse. DIALOG_REGISTER:

pawn Код:
INI_WriteString("Password",inputtext);
INI_WriteInt("Cash", 0);
INI_WriteInt("Admin", 0);
INI_WriteInt("FirstTime", 0);
INI_WriteInt("Skin", 0);
INI_WriteInt("Score", 0);
DIALOG_LOGIN:
pawn Код:
GivePlayerMoney( playerid, INI_ReadInt( "Cash" ) );
                        PlayerInfo[playerid][pAdmin] = INI_ReadInt("Admin");
                        gFirstTimeHasJoined[playerid] = INI_ReadInt("FirstTime");
                        gPlayerSkinForEver[playerid] = INI_ReadInt("Skin");
                        SetPlayerScore( playerid, INI_ReadInt( "Score" ) );
Remove old ones and put mine.
Reply
#5

Nothing add to enum?

PHP код:
GivePlayerMoneyplayeridINI_ReadInt"Cash" ) );
                        
PlayerInfo[playerid][pAdmin] = INI_ReadInt("Admin");
                        
gFirstTimeHasJoined[playerid] = INI_ReadInt("FirstTime");
                        
gPlayerSkinForEver[playerid] = INI_ReadInt("Skin");
                        
SetPlayerScoreplayeridINI_ReadInt"Score" ) ); 
Why did u add this two times?^^

SetPlayerScore( playerid, INI_ReadInt( "Score" ) );
Reply
#6

Don't know what you mean Two times. And no.. you don't need to put anything to your enum. It's the same thing how you saving player money.
Reply
#7

Quote:
Originally Posted by Riddick94
Посмотреть сообщение
I knew your script. I still have it on my PC.

OnPlayerDisconnect saving (remove your old one)
pawn Код:
if(INI_Open(getINI(playerid)))
    {
        INI_WriteInt("Cash", GetPlayerMoney(playerid));
        INI_WriteInt("Admin", PlayerInfo[playerid][pAdmin]);
        INI_WriteInt("FirstTime", gFirstTimeHasJoined[playerid]);
        INI_WriteInt("Skin", GetPlayerSkin(playerid));
        INI_WriteInt("Score", GetPlayerScore(playerid));
        INI_Save();
        INI_Close();
    }
OnDialogResponse. DIALOG_REGISTER:

pawn Код:
INI_WriteString("Password",inputtext);
INI_WriteInt("Cash", 0);
INI_WriteInt("Admin", 0);
INI_WriteInt("FirstTime", 0);
INI_WriteInt("Skin", 0);
INI_WriteInt("Score", 0);
DIALOG_LOGIN:
pawn Код:
GivePlayerMoney( playerid, INI_ReadInt( "Cash" ) );
                        PlayerInfo[playerid][pAdmin] = INI_ReadInt("Admin");
                        gFirstTimeHasJoined[playerid] = INI_ReadInt("FirstTime");
                        gPlayerSkinForEver[playerid] = INI_ReadInt("Skin");
                        SetPlayerScore( playerid, INI_ReadInt( "Score" ) );
Remove old ones and put mine.
The script in which you 'knew' was my tutorial.

When the player disconnects > https://sampwiki.blast.hk/wiki/GetPlayerScore
Reply
#8

Kush, can u do that for me please? Saving those gangzones! That they will stay after a server restart !

http://pastebin.com/YLeYibM7
Reply
#9

Quote:
Originally Posted by samtey
Посмотреть сообщение
Kush, can u do that for me please? Saving those gangzones! That they will stay after a server restart !

http://pastebin.com/YLeYibM7
I'm confused a bit now. What do you want saved? Gang zones, scores, what exactly?
Reply
#10

Well, my scores are saved now, Riddick did it already!

I want: That the gangzones, which got for example overtaken, will stay! Also, after server restart!

Also, I got some errors, can u fix them?
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)