Score resets
#1

Hi I have a problem. When a player kill another one he gets score but it resets after a while. Help please
pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{

if(killerid != INVALID_PLAYER_ID)
{
SendDeathMessage(killerid,playerid,reason);
SetPlayerScore(killerid,GetPlayerScore(killerid)+2); // Score gaved to killer
SetPlayerScore(playerid,GetPlayerScore(playerid)-2); // Score to take from victim
GivePlayerMoney(killerid, 100); // Cash to give to the killer
GivePlayerMoney(playerid, (GetPlayerMoney(playerid)-100)); // Cash to take from victim
}

return 1;
}
This is my code.
Reply
#2

I don't mean to offend you, but this is the 3rd topic you've made in a very short time. It's good you come here to ask, but you should really try to solve things on your own, because we're not going to help you with every single little problem you walk into every few minutes.

I don't see any problem with the code you've posted, there's probably something going wrong elsewhere. Either you change the player's score in another function or you don't save it in an enum/database.
Reply
#3

Quote:
Originally Posted by DrDoom151
Посмотреть сообщение
I don't mean to offend you, but this is the 3rd topic you've made in a very short time. It's good you come here to ask, but you should really try to solve things on your own, because we're not going to help you with every single little problem you walk into every few minutes.

I don't see any problem with the code you've posted, there's probably something going wrong elsewhere. Either you change the player's score in another function or you don't save it in an enum/database.
Don't you think that I already tried to fix it? And if I post so many times is because I don't get help.

PD: How do I save it in an enum/database?
Reply
#4

It's not that you don't get help, but you post a topic for every little thing.

You'd have to create a new enum for every player.

pawn Код:
enum PlayerStats
{
    Score,
};

new pStats[MAX_PLAYERS][PlayerStats];

public OnPlayerDeath(playerid, killerid, reason)
{

    if(killerid != INVALID_PLAYER_ID)
    {
        SendDeathMessage(killerid,playerid,reason);
        pStats[killerid][Score]+2;
        SetPlayerScore(killerid,pStats[playerid][Score]); // Score gaved to killer
        pStats[playerid][Score]+2;
        SetPlayerScore(playerid,pStats[playerid][Score]); // Score to take from victim
    }
    return 1;
}
EDIT: I'm not sure if pStats[killerid][Score]+2 works, I've never used it.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)