Raised This Month: $ Target: $400
 0% 

Solved How to print all with highest int value at round end separately


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
alasfourom
Senior Member
Join Date: Feb 2022
Location: Saudi Arabia
Old 08-11-2022 , 07:36   Re: How to print all players/highest player kills at the end of the round?
Reply With Quote #8

Its working fine, but I'm not sure is this the right method, and if there is for example 0 kills, how to make it display "None"

PHP Code:
#include <sourcemod>
#include <sdktools>

#pragma semicolon 1
#pragma newdecls required

#define PLUGIN_VERSION "1.0"

bool  g_bRoundEnd;

int SI_KillCount     [MAXPLAYERS+1];
int Boss_KillCount [MAXPLAYERS+1];

public 
void OnPluginStart() 
{
    
HookEvent("round_start"Event_RoundStart);
    
HookEvent("round_end"Event_RoundEnd);
    
HookEvent("player_death"EVENT_OnSpecialDeath);
    
HookEvent("tank_killed"EVENT_OnTankDeath);
    
HookEvent("witch_killed"EVENT_OnWitchDeath);
}

/* =============================================================================================================== *
 *                                                   Round Start                                                   *
 *================================================================================================================ */

public void Event_RoundStart(Event event, const char[] namebool dontBroadcast)
{
    
g_bRoundEnd false;
    
    for (
int i 1<= MaxClientsi++)
    {
        if (
IsClientInGame(i))
        {
            
SI_KillCount     [i] = 0;
            
Boss_KillCount    [i] = 0;
        }
    }
}

/* =============================================================================================================== *
 *                                                   MVP: SI Kills                                                 *
 *================================================================================================================ */

public void EVENT_OnSpecialDeath(Event event, const char[] namebool dontBroadcast)
{
    
int victim GetClientOfUserId(event.GetInt("userid"));
    if (!
victim || !IsClientInGame(victim) || IsTank(victim)) return;
    
    
int attacker GetClientOfUserId(event.GetInt("attacker"));
    if (!
attacker || !IsClientInGame(attacker)) return;
    
    if(
attacker != victim && GetClientTeam(attacker) == 2)
    {
        
SI_KillCount[attacker]++;
        
        if (
SI_KillCount[attacker] > 0PrintHintText(attacker"Special Kills: %d"SI_KillCount[attacker]);
    }
}

/* =============================================================================================================== *
 *                                                   MVP: Boss Kills                                               *
 *================================================================================================================ */

public void EVENT_OnWitchDeath(Event event, const char[] namebool dontBroadcast)
{
    
int attacker GetClientOfUserId(event.GetInt("userid"));
    if (!
attacker || !IsClientInGame(attacker)) return;
    
    if(
GetClientTeam(attacker) == 2)
    {
        
Boss_KillCount[attacker]++;
        if (
Boss_KillCount[attacker] > 0PrintHintText(attacker"Boss Kills: %d"Boss_KillCount[attacker]);
    }
}

public 
void EVENT_OnTankDeath(Event event, const char[] namebool dontBroadcast)
{
    
int tank GetClientOfUserId(event.GetInt("userid"));
    if (!
tank || !IsClientInGame(tank)) return;
    
    
int attacker GetClientOfUserId(event.GetInt("attacker"));
    if (!
attacker || !IsClientInGame(attacker)) return;
    
    if(
attacker != tank && GetClientTeam(attacker) == 2)
    {
        
Boss_KillCount[attacker]++;
        if (
Boss_KillCount[attacker] > 0PrintHintText(attacker"Boss Kills: %d"Boss_KillCount[attacker]);
    }
}

/* =============================================================================================================== *
 *                                                       Round End                                                 *
 *================================================================================================================ */

public Action Event_RoundEnd(Event event, const char[] namebool dontBroadcast)
{
    if(!
g_bRoundEnd
    {
        
MVP_Display(); //Display Players With MVP
        
g_bRoundEnd true;
    }
    return 
Plugin_Handled;
}

/* =============================================================================================================== *
 *                                                       MVP Display                                               *
 *================================================================================================================ */

void MVP_Display()
{
    
int client;
    
int players 0;
    
    
int[] players_clients = new int[MaxClients+1];
    
    
int SI_KillCount_MVPBoss_KillCount_MVP;
    
    for (
client 1client <= MaxClientsclient++)
    {
        if (!
IsClientInGame(client) || GetClientTeam(client) == 3) continue;
        
players_clients[players] = client;
        
players++;
    }
    
    
SortCustom1D(players_clientsplayersSortDescending);
    {
        
client players_clients [0];
        
SI_KillCount_MVP SI_KillCount [client];
        
PrintToChatAll("MVP SI Kills: %N (%d)"clientSI_KillCount_MVP);
    }
    
    
SortCustom1D(players_clientsplayersSortDescending);
    {
        
client players_clients    [0];
        
Boss_KillCount_MVP Boss_KillCount [client];
        
PrintToChatAll("MVP Boss Kills: %N (%d)"clientBoss_KillCount_MVP);
    }
}

public 
int SortDescending(int elem1int elem2, const int[] array, Handle hndl)
{
    if (
SI_KillCount[elem1] > SI_KillCount[elem2]) return -1;
    else if (
Boss_KillCount[elem1] > Boss_KillCount[elem2]) return -1;
    else if (
SI_KillCount[elem2] > SI_KillCount[elem1]) return 1;
    else if (
Boss_KillCount[elem2] > Boss_KillCount[elem1]) return 1;
    else if (
elem1 elem2) return -1;
    else if (
elem2 elem1) return 1;
    return 
0;
}

/* =============================================================================================================== *
 *                                                       Check Tank                                                 *
 *================================================================================================================ */

stock bool IsTank(int client)
{
    return (
client 
        
&& client <= MaxClients 
        
&& IsClientInGame(client
        && 
GetClientTeam(client) == 
        
&& GetEntProp(clientProp_Send"m_zombieClass") == 8);

__________________

Last edited by alasfourom; 08-11-2022 at 07:38.
alasfourom is offline
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 01:01.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode