player info is repeated ...... ? +REP
#7

im using Y_ini , here's the parts of the code where it saves and loads stats

Код:
enum pInfo
{
    pPass[129],
	pScore,
    pCash,
    pAdmin,
    AFKstatus,
    pVIP,
    pKills,
    pDeaths,
    pWantedLvl,
    pMoneybag,
    pReactionTest,
    pMathTest,
    pMuted,
    pJailed,
	pWarnings,
	pKicks,
	pBans,
	pBanned
}

new PlayerInfo[MAX_PLAYERS][pInfo];
OnPlayerDisconnect callback
Код:
    if(fexist(Path(playerid)))
	{
	    new INI:File = INI_Open(Path(playerid));
		INI_SetTag(File,"Player's Data");
		INI_WriteInt(File,"Score",GetPlayerScore(playerid));
		INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));
		INI_WriteInt(File,"Admin",PlayerInfo[playerid][pAdmin]);
		INI_WriteInt(File,"AFK",PlayerInfo[playerid][AFKstatus]);
		INI_WriteInt(File,"VIP",PlayerInfo[playerid][pVIP]);
		INI_WriteInt(File,"Kills",PlayerInfo[playerid][pKills]);
		INI_WriteInt(File,"Deaths",PlayerInfo[playerid][pDeaths]);
		INI_WriteInt(File,"Wanted Level",GetPlayerWantedLevel(playerid));
		INI_WriteInt(File,"Moneybags",PlayerInfo[playerid][pMoneybag]);
		INI_WriteInt(File,"Reaction Tests",PlayerInfo[playerid][pReactionTest]);
	    INI_WriteInt(File,"Math Tests",PlayerInfo[playerid][pMathTest]);
	    INI_WriteInt(File,"Muted",PlayerInfo[playerid][pMuted]);
	    INI_WriteInt(File,"Jailed",PlayerInfo[playerid][pJailed]);
	    INI_WriteInt(File,"Total Warnings",PlayerInfo[playerid][pWarnings]);
	    INI_WriteInt(File,"Total Kicks",PlayerInfo[playerid][pKicks]);
	    INI_WriteInt(File,"Total Bans",PlayerInfo[playerid][pBans]);
	    INI_WriteInt(File,"Banned",PlayerInfo[playerid][pBanned]);
		INI_Close(File);
	}
load account callback
Код:
forward loadaccount_user(playerid, name[], value[]);
public loadaccount_user(playerid, name[], value[])
{
    INI_String("Password",PlayerInfo[playerid][pPass],129);
	INI_Int("Score",PlayerInfo[playerid][pScore]);
	INI_Int("Cash",PlayerInfo[playerid][pCash]);
	INI_Int("Admin",PlayerInfo[playerid][pAdmin]);
	INI_Int("AFK",PlayerInfo[playerid][AFKstatus]);
	INI_Int("VIP",PlayerInfo[playerid][pVIP]);
	INI_Int("Kills",PlayerInfo[playerid][pKills]);
    INI_Int("Deaths",PlayerInfo[playerid][pDeaths]);
    INI_Int("Wanted Level",PlayerInfo[playerid][pWantedLvl]);
    INI_Int("Moneybags",PlayerInfo[playerid][pMoneybag]);
    INI_Int("Reaction Tests",PlayerInfo[playerid][pReactionTest]);
    INI_Int("Math Tests",PlayerInfo[playerid][pMathTest]);
    INI_Int("Muted",PlayerInfo[playerid][pMuted]);
    INI_Int("Jailed",PlayerInfo[playerid][pJailed]);
    INI_Int("Total Warnings",PlayerInfo[playerid][pWarnings]);
    INI_Int("Total Kicks",PlayerInfo[playerid][pKicks]);
    INI_Int("Total Bans",PlayerInfo[playerid][pBans]);
    INI_Int("Banned",PlayerInfo[playerid][pBanned]);
    return 1;
}
OnDialogResponse callback
Код:
    if(dialogid == dregister)
    {
        if(!response) return 1;
        if(response)
        {
            if(!strlen(inputtext))
            {
                ShowPlayerDialog(playerid,dregister,DIALOG_STYLE_INPUT,"Register","Enter your password below to create a new account.","Register","Quit");
                return 1;
            }
            WP_Hash(hashpass,sizeof(hashpass),inputtext);

            new INI:File = INI_Open(Path(playerid));
            INI_SetTag(File,"Player's Data");
            INI_WriteString(File,"Password",hashpass);
            INI_WriteInt(File,"Score",0);
            INI_WriteInt(File,"Cash",0);
            INI_WriteInt(File,"Admin",0);
            INI_WriteInt(File,"AFK",0);
            INI_WriteInt(File,"VIP",0);
            INI_WriteInt(File,"Kills",0);
            INI_WriteInt(File,"Deaths",0);
            INI_WriteInt(File,"Wanted Level",0);
            INI_WriteInt(File,"Moneybags",0);
            INI_WriteInt(File,"Reaction Tests",0);
            INI_WriteInt(File,"Math Tests",0);
            INI_WriteInt(File,"Muted",0);
            INI_WriteInt(File,"Jailed",0);
            INI_WriteInt(File,"Total Warnings",0);
            INI_WriteInt(File,"Total Kicks",0);
            INI_WriteInt(File,"Total Bans",0);
            INI_WriteInt(File,"Banned",0);
            INI_Close(File);
            SendClientMessage(playerid,COLOR_YELLOW,"INFO: You have been successfully registered.");
			GivePlayerMoney(playerid,50000);
            return 1;
        }
    }
    if(dialogid == dlogin)
    {
        if(!response) return Kick(playerid);
        if(response)
        {
            WP_Hash(hashpass,sizeof(hashpass),inputtext);
            if(strcmp(hashpass, PlayerInfo[playerid][pPass], false))
            {
            	ShowPlayerDialog(playerid,dlogin,DIALOG_STYLE_INPUT,"Login","Invalid Password. \nWrite your password please.","Login","Quit");
            }
            else
            {
            	INI_ParseFile(Path(playerid),"loadaccount_%s",.bExtra = true, .extra = playerid);
                SetPlayerScore(playerid,PlayerInfo[playerid][pScore]);
                GivePlayerMoney(playerid,PlayerInfo[playerid][pCash]);
				SetPlayerWantedLevel(playerid,PlayerInfo[playerid][pWantedLvl]);
				SetPVarInt(playerid,"VIP",PlayerInfo[playerid][pVIP]);
				SetPVarInt(playerid,"Admin",PlayerInfo[playerid][pAdmin]);
				if(PlayerInfo[playerid][pJailed]!=0)
				{
				
				}
                SendClientMessage(playerid,COLOR_YELLOW,"INFO: You have successfully logged in.");
            }
        }
    }
Path stock
Код:
stock Path(playerid)
{
    new str[128],name[MAX_PLAYER_NAME];
    GetPlayerName(playerid,name,sizeof(name));
    format(str,sizeof(str),Userpath,name);
    return str;
}
Reply


Messages In This Thread
player info is repeated ...... ? +REP - by YoussefHammad - 03.09.2015, 21:39
Re: player info is repeated ...... ? +REP - by Vince - 03.09.2015, 21:57
Re: player info is repeated ...... ? +REP - by YoussefHammad - 03.09.2015, 22:00
Re: player info is repeated ...... ? +REP - by Freezo - 03.09.2015, 22:02
Re: player info is repeated ...... ? +REP - by YoussefHammad - 03.09.2015, 22:22
Re : player info is repeated ...... ? +REP - by Dutheil - 03.09.2015, 22:35
Re: player info is repeated ...... ? +REP - by YoussefHammad - 04.09.2015, 01:31
Re: player info is repeated ...... ? +REP - by SickAttack - 04.09.2015, 01:40
Re: player info is repeated ...... ? +REP - by YoussefHammad - 04.09.2015, 02:57

Forum Jump:


Users browsing this thread: 2 Guest(s)