Saving Kills and Deaths into Registersystem?
#1

Hi!

I got an "INI" registersystem, where are saved "Admin,Score,Cash"...

Now, how should I add the Kills and Deaths into the Registersystem?

This is my code:

pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) {
        switch(dialogid) {
            case DIALOG_REGISTER: {
                if(!response) return Kick(playerid);
                if(response) {
                    if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_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("FirstTime", 0);
                        INI_WriteInt("Skin", 0);
                        INI_WriteInt("Score", 0);
                        INI_Save();
                        INI_Close();
                        ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_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(playerid, DIALOG_LOGIN, DIALOG_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(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, ""WHITE"Login",""RED"You have entered an incorrect password.\n"WHITE"Type your password below to login.","Login","Quit");
                        }
                        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" ) );
                        INI_Close();
                    }
                }
            }
        }
        return 1;
    }
Reply
#2

You will need to define them in the enum as well to use it. How have ya defined you enum for PlayerInfo mostly. Please give the code for that to work ahead.
Reply
#3

Put, "pKills" and "pDeaths" in your enum. And then use this code:

pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    switch(dialogid)
    {
        case DIALOG_REGISTER:
        {
            if(!response)
                return Kick(playerid);
            if(response)
            {
                if(!strlen(inputtext))
                    return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_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("FirstTime", 0);
                    INI_WriteInt("Skin", 0);
                    INI_WriteInt("Score", 0);
                    INI_WriteInt("Kills", 0);
                    INI_WriteInt("Deaths", 0);
                    INI_Save();
                    INI_Close();
                    ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_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(playerid, DIALOG_LOGIN, DIALOG_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(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, ""WHITE"Login",""RED"You have entered an incorrect password.\n"WHITE"Type your password below to login.","Login","Quit");
                    }
                    GivePlayerMoney( playerid, INI_ReadInt( "Cash" ) );
                    PlayerInfo[playerid][pAdmin] = INI_ReadInt("Admin");
                    PlayerInfo[playerid][pKills] = INI_ReadInt("Kills");
                    PlayerInfo[playerid][pDeaths] = INI_ReadInt("Deaths");
                    gFirstTimeHasJoined[playerid] = INI_ReadInt("FirstTime");
                    gPlayerSkinForEver[playerid] = INI_ReadInt("Skin");
                    SetPlayerScore( playerid, INI_ReadInt( "Score" ) );
                    INI_Close();
                }
            }
        }
    }
    return 1;
}
Reply
#4

And also add the +1 Kills/Deaths from OnPlayerDeath Callback.
pawn Код:
public OnPlayerDeath( playerid, killerid, reason )
{
    PlayerInfo[ playerid ][ pDeaths ] ++;
    if( killerid != INVALID_PLAYER_ID ) {
        PlayerInfo[ killerid ][ pKills ] ++;
    }
    // Rest
    return 1;
}
Reply
#5

Just to be clear if my "OnPlayerDeath"-callback is right...

pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
    {
        PlayerInfo[playerid][pDeaths] ++;
        if(killerid != INVALID_PLAYER_ID)
        {
            PlayerInfo[killerid][pKills] ++;
        }

        if(IsPlayerConnected(killerid) && gTeam[playerid] != gTeam[killerid]) // not a suicide or team kill
        {
        new zoneid = GetPlayerZone(playerid);
        if(zoneid != -1 && ZoneInfo[zoneid][zTeam] == gTeam[playerid]) // zone member has been killed in the zone
        {
            ZoneDeaths[zoneid]++;
            if(ZoneDeaths[zoneid] == MIN_DEATHS_TO_START_WAR)
            {
                ZoneDeaths[zoneid] = 0;
                ZoneAttacker[zoneid] = gTeam[killerid];
                ZoneAttackTime[zoneid] = 0;
                GangZoneFlashForAll(ZoneID[zoneid], GetTeamZoneColor(ZoneAttacker[zoneid]));
            }
        }
    }
Reply
#6

Quote:
Originally Posted by Twisted_Insane
Посмотреть сообщение
Just to be clear if my "OnPlayerDeath"-callback is right...

pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
    {
        PlayerInfo[playerid][pDeaths] ++;
        if(killerid != INVALID_PLAYER_ID)
        {
            PlayerInfo[killerid][pKills] ++;
        }

        if(IsPlayerConnected(killerid) && gTeam[playerid] != gTeam[killerid]) // not a suicide or team kill
        {
        new zoneid = GetPlayerZone(playerid);
        if(zoneid != -1 && ZoneInfo[zoneid][zTeam] == gTeam[playerid]) // zone member has been killed in the zone
        {
            ZoneDeaths[zoneid]++;
            if(ZoneDeaths[zoneid] == MIN_DEATHS_TO_START_WAR)
            {
                ZoneDeaths[zoneid] = 0;
                ZoneAttacker[zoneid] = gTeam[killerid];
                ZoneAttackTime[zoneid] = 0;
                GangZoneFlashForAll(ZoneID[zoneid], GetTeamZoneColor(ZoneAttacker[zoneid]));
            }
        }
    }
This will work for sure!

pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
    {
        PlayerInfo[playerid][pDeaths] ++;
        PlayerInfo[killerid][pKills] ++;
        if(IsPlayerConnected(killerid) && gTeam[playerid] != gTeam[killerid]) // not a suicide or team kill
        {
        new zoneid = GetPlayerZone(playerid);
        if(zoneid != -1 && ZoneInfo[zoneid][zTeam] == gTeam[playerid]) // zone member has been killed in the zone
        {
            ZoneDeaths[zoneid]++;
            if(ZoneDeaths[zoneid] == MIN_DEATHS_TO_START_WAR)
            {
                ZoneDeaths[zoneid] = 0;
                ZoneAttacker[zoneid] = gTeam[killerid];
                ZoneAttackTime[zoneid] = 0;
                GangZoneFlashForAll(ZoneID[zoneid], GetTeamZoneColor(ZoneAttacker[zoneid]));
            }
        }
    }
Reply
#7

Right this time? Wanna be 100 percent sure!

pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
    {

        PlayerInfo[playerid][pDeaths] ++;
        PlayerInfo[killerid][pKills] ++;

        if(IsPlayerConnected(killerid) && gTeam[playerid] != gTeam[killerid]) // not a suicide or team kill
        {
        new zoneid = GetPlayerZone(playerid);
        if(zoneid != -1 && ZoneInfo[zoneid][zTeam] == gTeam[playerid]) // zone member has been killed in the zone
        {
            ZoneDeaths[zoneid]++;
            if(ZoneDeaths[zoneid] == MIN_DEATHS_TO_START_WAR)
            {
                ZoneDeaths[zoneid] = 0;
                ZoneAttacker[zoneid] = gTeam[killerid];
                ZoneAttackTime[zoneid] = 0;
                GangZoneFlashForAll(ZoneID[zoneid], GetTeamZoneColor(ZoneAttacker[zoneid]));
            }
        }
    }
Reply
#8

By the way, it does NOT work, just read a file of one of the users from my saving-system with which I joined into the game:

Password=XXXX
Cash=0
Admin=10
Score=0
FirstTime=0
Skin=103

_________________________
No kills and no deaths are in it....
Reply
#9

Did you delete the accounts first. Becasue if I join and create a file with my name and you added kills/deaths, they will not on my file, I should register again.
Reply
#10

Nope, all old users, should I delete them ALL and then register myself from new?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)