How to get Highest deaths with player name in a Round
#1

Hi all

If a round starts like team deathmatch.Then,
At last on round finish, how to get highest deaths of player.

Help me rep++.

Thank You.
Reply
#2

PHP код:
#include <a_samp>

new p_Deaths[MAX_PLAYERS] = {0, ...};

public 
OnPlayerDisconnect(playeridreason)
{
    
p_Deaths[playerid] = 0//reset player deaths
    
return 1;
}

public 
OnPlayerDeath(playeridkilleridreason)
{
    
p_Deaths[playerid] ++; //+1 death when player dies
    
return 1;
}

forward onroundend(); //on round end

public onroundend() //on round end
{
    new 
str[85], name[MAX_PLAYER_NAME], last_player = -1last_score//set top score to 0 at first and player to -1
    
for(new 0GetPlayerPoolSize(); <= ji++) //loop
    
{
        if(!
IsPlayerConnected(i) || IsPlayerNPC(i) || p_Deaths[i] <= last_score//if player not connected, npc or got same score as previous player or less (skip)
        
last_player i//set the last player with best score
    
}
    
//after we got the top player lets get his name and send message to all that he died the most
    
GetPlayerName(last_playernamesizeof(name));
    
format(strsizeof(str), "%s {FFFFFF}died the most this round {FF0000}%d {FFFFFF}deaths"namep_Deaths[last_player]);
    
SendClientMessageToAll(0xFFFF00FFstr);
    return 
1;

Reply
#3

Thank You.
Reply
#4

a fix on @Lokii solution. not skipping and never assigning last_score to a value.

PHP код:
        if(!IsPlayerConnected(i) || IsPlayerNPC(i) || p_Deaths[i] <= last_score || (last_player  != -&& p_Deaths[i] <= p_Deaths[last_player] )) continue; //if player not connected, npc or got same score as previous player or less (skip)
        
last_player i//set the last player with best score
        
last_score p_Deaths[i]; 
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)