04.05.2018, 16:27
PHP код:
#include <a_samp>
new p_Deaths[MAX_PLAYERS] = {0, ...};
public OnPlayerDisconnect(playerid, reason)
{
p_Deaths[playerid] = 0; //reset player deaths
return 1;
}
public OnPlayerDeath(playerid, killerid, reason)
{
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 = -1, last_score; //set top score to 0 at first and player to -1
for(new i = 0, j = GetPlayerPoolSize(); i <= j; i++) //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_player, name, sizeof(name));
format(str, sizeof(str), "%s {FFFFFF}died the most this round {FF0000}%d {FFFFFF}deaths", name, p_Deaths[last_player]);
SendClientMessageToAll(0xFFFF00FF, str);
return 1;
}