SA-MP Forums Archive
if player score - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: if player score (/showthread.php?tid=180896)



if player score - XxerykxX - 03.10.2010

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?


Re: if player score - LarzI - 03.10.2010

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


Re: if player score - Finn - 03.10.2010

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.


Re: if player score - olabv - 13.12.2010

nice