SA-MP Forums Archive
[1] Highest Kills - 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)
+--- Thread: [1] Highest Kills (/showthread.php?tid=494092)



SOLVED - Samjoc18 - 11.02.2014

SOLVED


Re: [1] Highest Kills - Babul - 11.02.2014

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?


a - Samjoc18 - 11.02.2014

aaaaa


A - Samjoc18 - 12.02.2014

aaaaaaaa


solved - Samjoc18 - 14.02.2014

solved


Re: [1] Highest Kills - CuervO - 14.02.2014

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;