Cash and score bug?
#1

I have a few problems with my TDM, i use Y_Ini

First problem: When you kill a player, it should add score, it does on /stats but not on tab.

Player cash doesn't seem to save.
Onplayerconnect:
pawn Код:
if(fexist(UserPath(playerid)))
    {
        INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
        ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""COLOR_WHITE"Login",""COLOR_WHITE"Type your password below to login.","Login","Quit");
    }
    else
    {
        ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT,""COLOR_WHITE"Registering...",""COLOR_WHITE"Type your password below to register a new account.","Register","Quit");
    }
Loaduser:
pawn Код:
forward LoadUser_data(playerid,name[],value[]);
public LoadUser_data(playerid,name[],value[])
{
    INI_Int("Password",PlayerInfo[playerid][pPass]);
    INI_Int("Cash",PlayerInfo[playerid][pCash]);
    INI_Int("Admin",PlayerInfo[playerid][pAdmin]);
    INI_Int("Score",PlayerInfo[playerid][pScores]);
    INI_Int("Kills",PlayerInfo[playerid][pKills]);
    INI_Int("Deaths",PlayerInfo[playerid][pDeaths]);
    return 1;
}

onplayerdisconnect:
pawn Код:
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,"Score",GetPlayerScore(playerid));
    INI_WriteInt(File,"Kills",PlayerInfo[playerid][pKills]);
    INI_WriteInt(File,"Deaths",PlayerInfo[playerid][pDeaths]);
    INI_Close(File);
    return 1;
}
And when you login:
pawn Код:
case DIALOG_LOGIN:
        {
            if ( !response ) return Kick ( playerid );
            if( response )
            {
                if(udb_hash(inputtext) == PlayerInfo[playerid][pPass])
                {
                    INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
                    GivePlayerMoney(playerid, PlayerInfo[playerid][pCash]);
                    SetPlayerScore(playerid, PlayerInfo[playerid][pScores]);
                }
                else
                {
                    ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""COLOR_WHITE"Login",""COLOR_RED"You have entered an incorrect password.\n"COLOR_WHITE"Type your password below to login.","Login","Quit");
                }
                return 1;
            }
        }
It's a TDM server. with different classes.
Reply
#2

Some functions may not work in onplayerdisconnect.
Use SetPlayerScore to set score.
Reply
#3

pawn Код:
//OnPlayerDeath
SetPlayerScore(killerid, GetPlayerScore(killerid)+1);
About the money, sounds weird, because I have similar settings to you on my current project, and it works just fine. Maybe you haven't set write rights on your FTP server.
Reply
#4

pawn Код:
PlayerInfo[killerid][pScores]++;
    GivePlayerMoney(playerid, -100);
    GivePlayerMoney(killerid, 500);
I have this @onplayerdeath.
Reply
#5

Add
pawn Код:
PlayerInfo[killerid][pKills]++; // Assuming you're registering kills & deaths
PlayerInfo[playerid][Deaths]++; // Assuming you' registering kills & deaths
PlayerInfo[killerid][pScores]++; // Add 1 to playerscore
SendClientMessage(killerid, COLOR_YELLOW,"You have received $500 for taking out another player!"); // optional money info message to killer
SendClientMessage(playerid, COLOR_YELLOW,"You have lost $100 for dying."); // optional money info msg to target
SetPlayerScore(killerid, GetPlayerScore(killerid)+1); // Set player score +1 on TAB
SendDeathMessage(killerid,playerid,reason); // Show kill on kill list
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)