[1] Highest Kills
#1

SOLVED
Reply
#2

it might be a good hint if you provide some information on how the algorithm should react if f.ex. 2 or more players share the same "highest" kill score. shall they all get a reward? or only the first found playerid, or the last one?
if they all get a reward, should it's amount be splitted? if so, rounded up/down, if its a fraction?
Reply
#3

aaaaa
Reply
#4

aaaaaaaa
Reply
#5

solved
Reply
#6

I've already helped you but let's code this from the scratch:

pawn Код:
new
    MostKills,
    RoundKills[MAX_PLAYERRS];

public OnPlayerConnect(playerid)
{
    RoundKills[playerid] = 0;
    return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
    RoundKills[killerid] ++;
    return 1;
}

// wherever the round ends

for(new i = 0; i < MAX_PLAYERS; i ++)
{
    if(!IsPlayerConnected(i)) continue;

    if(RoundKills[i] > MostKills)
    {
        MostKills = RoundKills[i];
    }

}

for(new i = 0; i < MAX_PLAYERS; i ++)
{
    if(!IsPlayerConnected(i)) continue;

    if(RoundKills[i] >= MostKills)
    {
        GetPlayerName(i, sendername, sizeof(sendername));
        format(string, sizeof(string),"%s has achieved the most kills.", sendername);
        SendClientMEssageToAll(COLOR_BLUE, string);
    }
    RoundKills[i] = 0;
}

MostKills = 0;
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)