add player score
#1

Hello
I need some help i want to add one point to players score when a player make a stunt.. is there any callback or function i can use to make it? I can figure how to save it then but i need some help with this
Thank you
Reply
#2

pawn Код:
SetPlayerScore(playerid, GetPlayerScore(playerid) + 1);
Reply
#3

Thats useful but wheree or how i can add it i cant figure how to add it when players make stunts
Reply
#4

If you mean the stunts like in single player then I don't think there is a callback or anything for that.
Reply
#5

You got to detect when they receive money from a stunt or something, and set the score accordingly.
If there are other possibilities for players to get money while they're in a car, it becomes increasingly difficult.

Otherwise, you could do something like:
(This is untested)

pawn Код:
new OldMoney[MAX_PLAYERS];
forward OnPlayerPerformedStunt(playerid, cash);

public OnPlayerUpdate(playerid)
{
    if(IsPlayerInAnyVehicle(playerid))
    {
        new
            NewMoney = GetPlayerMoney(playerid);

        if(NewMoney > OldMoney[playerid])
        {
            OnPlayerPerformedStunt(playerid, (NewMoney - OldMoney[playerid]) );
            OldMoney[playerid] = NewMoney; // Sync the money again
        }
    }
    return 1;
}

public OnPlayerPerformedStunt(playerid, cash)
{
    new
        score = floatround(cash/100, floatround_floor); // imagine that you recieve 312$ from a stunt. You will gain 3 points

    SetPlayerScore(playerid, GetPlayerScore(playerid)+score);
    return 1;
}
Reply
#6

Nice one Vince, just needed it. Couldn't be arsed to think of it myself
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)