SA-MP Forums Archive
Detecting a 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: Detecting a score (/showthread.php?tid=220172)



Detecting a score - Lorenc_ - 03.02.2011

Hey guys im wondering how can i detect the player with the most kills. I'm willing to make a sort of high score system with a friend :/


Re: Detecting a score - Code_Red - 03.02.2011

Make a loop and 2 variables to store the id with the highest score and his score amount, check the score of the currect loop id, if its higher then the variable you set the 1st variable to the loop id and the score variable to the players score etc.


Re: Detecting a score - Steven Paul - 03.02.2011

for highest score use this



pawn Код:
if(!strcmp(cmdtext, "/highestscore", true))
    {
        if(IsPlayerConnected(playerid))
        {
            #define TOPLINE 10
            new
                Player_ID[TOPLINE],
                Top_Info[TOPLINE];

            foreach(Player, i)
        //  for(new i, max_players = GetMaxPlayers(); i < max_players; i++)
            {
        //      if(!IsPlayerConnected(i)) continue;
                HighestTopList(i, GetPlayerScore(i), Player_ID, Top_Info, TOPLINE);
            }

            SendClientMessage(playerid, 0xFFFFFFAA, "Highest Score:");

           
            for(new i; i < TOPLINE; i++)
            {
                if(Top_Info[i] <= 0) continue;
                format(string, sizeof string, " %s ID:%d - $%d", plName(Player_ID[i]), Player_ID[i], Top_Info[i]);
                SendClientMessage(playerid, 0xFFFFFFAA, string);
            }
            #undef TOPLINE
            return 1;
        }
    }



Re: Detecting a score - Retardedwolf - 03.02.2011

I'd recommend you to use BUD and use the implemented function.


Re: Detecting a score - Lorenc_ - 03.02.2011

Dude, you've recommended me farking 10 times, im using y_ini, y_ini ftw!

btw HighestTopList(i, GetPlayerScore(i), Player_ID, Top_Info, TOPLINE);
That function isnt the native samps?


Re: Detecting a score - Steven Paul - 03.02.2011

I really forget to add this

pawn Код:
stock HighestTopList(const playerid, const Valuez, Player_ID[], Top_Score[], Loop)  //   Created by Phento
{
    new
        t = 0,
        p = Loop-1;
    while(t <= p) {
        if(Valuez >= Top_Score[t]) {
            if(Top_Score[t+1] <= 0) p = t+1;
            while(p > t) { Top_Score[p] = Top_Score[p - 1]; Player_ID[p] = Player_ID[p - 1]; p--; }
            Top_Score[t] = Valuez; Player_ID[t] = playerid;
            break;
        } t++; }
    return 1;
}



Re: Detecting a score - Lorenc_ - 03.02.2011

Ohh ok thanks


Re: Detecting a score - Steven Paul - 03.02.2011

welcome