if player score
#1

Hello. First of all tell me if its right:
Код:
public OnPlayerUpdate(playerid)
{
    if((GetPlayerScore(playerid) >= 0) && (GetPlayerScore(playerid) <= 100))
    {
    SetPlayerColor(playerid, WHITE);
    return 1;
    }
    if((GetPlayerScore(playerid) > 100) && (GetPlayerScore(playerid) <= 500))
    {
    SetPlayerColor(playerid, GREEN);
    return 1;
    }
    if((GetPlayerScore(playerid) > 500) && (GetPlayerScore(playerid) <= 1100))
    {
    SetPlayerColor(playerid, GREY);
    return 1;
    }
    if((GetPlayerScore(playerid) > 1100) && (GetPlayerScore(playerid) <= 2000))
    {
    SetPlayerColor(playerid, YELLOW);
    return 1;
    }
    if((GetPlayerScore(playerid) > 2000) && (GetPlayerScore(playerid) <= 20000))
    {
    SetPlayerColor(playerid, LTBLUE);
    return 1;
    }
    
    return 1;
}
Second i wanted that to change player color if they get enough score.

Is it right?
Reply
#2

Why don't you try it before asking?
It looks pretty correct, yes.

I'd recommend to changing the 'if's to else if (except the first one), then remove the all the returns except the last one. Makes your code alot more tidy
Reply
#3

Also, having that in OnPlayerUpdate... Is that really needed? Some 5 second timer should be enough.

Or if players' score is the kill count, use OnPlayerDeath callback instead.
Reply
#4

nice
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)