Detecting a score
#1

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 :/
Reply
#2

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.
Reply
#3

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;
        }
    }
Reply
#4

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

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?
Reply
#6

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;
}
Reply
#7

Ohh ok thanks
Reply
#8

welcome
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)