[pawn]
#include <amxmodx>
#include <hamsandwich>
#include <zombieplague>
#include <dhudmessage>
#define zp_give_user_ammo_packs(%0,%1) zp_set_user_ammo_packs(%0, zp_get_user_ammo_packs(%0) + %1)
#define MAX_CLIENTS 32
#define EACH_INFECT 5 // За каждые 5 заражений будет вознаграждение
#define EACH_KILL 7 // За каждые 7 убийств будет вознаграждение
#define EACH_DAMAGE 5000 // За каждые 5000 урона будет вознаграждение
#define INFECT_BONUS 1 // Сколько давать аммо за каждые EACH_INFECT заражений
#define KILL_BONUS 1 // Сколько давать аммо за каждые EACH_KILL заражений
#define DAMAGE_BONUS 1 // Сколько давать аммо за каждые EACH_DAMAGE заражений
enum _: e_TotalData
{
INFECTIONS = 0,
KILLED,
DAMAGE
};
enum _: e_DataType
{
TYPE = 0,
BONUS,
LEADER
};
new g_iMaxPlayers;
new g_iData[e_DataType][e_TotalData];
new iUserData[e_TotalData][MAX_CLIENTS + 1];
public plugin_init()
{
register_plugin("[ZP] Addon: Round Leaders", "1.1", "xUnicorn");
register_dictionary("zp_round_leaders.txt")
g_iMaxPlayers = get_maxplayers();
RegisterHam(Ham_Killed, "player", "CBasePlayer__Killed_Pre", false);
RegisterHam(Ham_TakeDamage, "player", "CBasePlayer__TakeDamage_Pre", false);
}
public zp_round_ended()
{
Func_GetLeaders();
}
public Func_GetLeaders()
{
for(new iPlayer = 1; iPlayer <= g_iMaxPlayers; iPlayer++)
{
if(!is_user_connected(iPlayer))
continue;
if(iUserData[INFECTIONS][iPlayer] > g_iData[TYPE][INFECTIONS])
{
g_iData[TYPE][INFECTIONS] = iUserData[INFECTIONS][iPlayer];
g_iData[LEADER][INFECTIONS] = iPlayer;
}
if(iUserData[KILLED][iPlayer] > g_iData[TYPE][KILLED])
{
g_iData[TYPE][KILLED] = iUserData[KILLED][iPlayer];
g_iData[LEADER][KILLED] = iPlayer;
}
if(iUserData[DAMAGE][iPlayer] > g_iData[TYPE][DAMAGE])
{
g_iData[TYPE][DAMAGE] = iUserData[DAMAGE][iPlayer];
g_iData[LEADER][DAMAGE] = iPlayer;
}
iUserData[INFECTIONS][iPlayer] = 0;
iUserData[KILLED][iPlayer] = 0;
iUserData[DAMAGE][iPlayer] = 0;
}
static szName[32];
static szInfector[256], szKiller[256], szDamager[256];
if(g_iData[LEADER][INFECTIONS])
{
get_user_name(g_iData[LEADER][INFECTIONS], szName, charsmax(szName));
if(g_iData[TYPE][INFECTIONS] >= EACH_INFECT)
{
g_iData[BONUS][INFECTIONS] = INFECT_BONUS * (g_iData[TYPE][INFECTIONS] / EACH_INFECT);
zp_give_user_ammo_packs(g_iData[LEADER][INFECTIONS], g_iData[BONUS][INFECTIONS]);
formatex(szInfector, charsmax(szInfector), "%L (+%i)^n", LANG_PLAYER, "ML_TOP_INFECTOR", szName, g_iData[TYPE][INFECTIONS], g_iData[BONUS][INFECTIONS]);
}
else formatex(szInfector, charsmax(szInfector), "%L^n", LANG_PLAYER, "ML_TOP_INFECTOR", szName, g_iData[TYPE][INFECTIONS]);
}
if(g_iData[LEADER][KILLED])
{
get_user_name(g_iData[LEADER][KILLED], szName, charsmax(szName));
if(g_iData[TYPE][KILLED] >= EACH_KILL)
{
g_iData[BONUS][KILLED] = KILL_BONUS * (g_iData[TYPE][KILLED] / EACH_KILL);
zp_give_user_ammo_packs(g_iData[LEADER][KILLED], g_iData[BONUS][KILLED]);
formatex(szKiller, charsmax(szKiller), "%L (+%i)^n", LANG_PLAYER, "ML_TOP_KILLER", szName, g_iData[TYPE][KILLED], g_iData[BONUS][KILLED]);
}
else formatex(szKiller, charsmax(szKiller), "%L^n", LANG_PLAYER, "ML_TOP_KILLER", szName, g_iData[TYPE][KILLED]);
}
if(g_iData[LEADER][DAMAGE])
{
get_user_name(g_iData[LEADER][DAMAGE], szName, charsmax(szName));
if(g_iData[TYPE][DAMAGE] >= EACH_DAMAGE)
{
g_iData[BONUS][DAMAGE] = DAMAGE_BONUS * (g_iData[TYPE][DAMAGE] / EACH_DAMAGE);
zp_give_user_ammo_packs(g_iData[LEADER][DAMAGE], g_iData[BONUS][DAMAGE]);
formatex(szDamager, charsmax(szDamager), "%L (+%i)", LANG_PLAYER, "ML_TOP_DAMAGER", szName, g_iData[TYPE][DAMAGE], g_iData[BONUS][DAMAGE]);
}
else formatex(szDamager, charsmax(szDamager), "%L", LANG_PLAYER, "ML_TOP_DAMAGER", szName, g_iData[TYPE][DAMAGE]);
}
if(g_iData[LEADER][INFECTIONS] || g_iData[LEADER][KILLED] || g_iData[LEADER][DAMAGE])
{
set_dhudmessage(128, 128, 128, 0.65, 0.25, 1, 5.0, 5.0, 0.035, 0.05);
show_dhudmessage(0, "%L^n^n%s%s%s", LANG_PLAYER, "ML_TOP_PLAYERS", szInfector, szKiller, szDamager);
}
g_iData[TYPE] = { 0, 0, 0 };
g_iData[BONUS] = { 0, 0, 0 };
g_iData[LEADER] = { 0, 0, 0 };
}
public client_putinserver(iPlayer)
{
iUserData[INFECTIONS][iPlayer] = 0;
iUserData[KILLED][iPlayer] = 0;
iUserData[DAMAGE][iPlayer] = 0;
}
public zp_user_infected_post(iPlayer, iInfector)
{
if(!is_user_connected(iInfector))
return;
iUserData[INFECTIONS][iInfector]++;
}
public CBasePlayer__Killed_Pre(iVictim, iAttacker, iGib)
{
if(!is_user_connected(iAttacker) || zp_get_user_zombie(iAttacker) || iVictim == iAttacker)
return HAM_IGNORED;
if(zp_get_user_zombie(iVictim) && !zp_get_user_zombie(iAttacker))
{
iUserData[KILLED][iAttacker]++;
}
return HAM_IGNORED;
}
public CBasePlayer__TakeDamage_Pre(iVictim, iInflictor, iAttacker, Float: flDamage)
{
if(!is_user_connected(iAttacker) || zp_get_user_zombie(iAttacker) || iVictim == iAttacker)
return HAM_IGNORED;
if(zp_get_user_zombie(iVictim) && !zp_get_user_zombie(iAttacker))
{
iUserData[DAMAGE][iAttacker] += floatround(flDamage);
}
return HAM_IGNORED;
}[/pawn]
#include <amxmodx>
#include <hamsandwich>
#include <zombieplague>
#include <dhudmessage>
#define zp_give_user_ammo_packs(%0,%1) zp_set_user_ammo_packs(%0, zp_get_user_ammo_packs(%0) + %1)
#define MAX_CLIENTS 32
#define EACH_INFECT 5 // За каждые 5 заражений будет вознаграждение
#define EACH_KILL 7 // За каждые 7 убийств будет вознаграждение
#define EACH_DAMAGE 5000 // За каждые 5000 урона будет вознаграждение
#define INFECT_BONUS 1 // Сколько давать аммо за каждые EACH_INFECT заражений
#define KILL_BONUS 1 // Сколько давать аммо за каждые EACH_KILL заражений
#define DAMAGE_BONUS 1 // Сколько давать аммо за каждые EACH_DAMAGE заражений
enum _: e_TotalData
{
INFECTIONS = 0,
KILLED,
DAMAGE
};
enum _: e_DataType
{
TYPE = 0,
BONUS,
LEADER
};
new g_iMaxPlayers;
new g_iData[e_DataType][e_TotalData];
new iUserData[e_TotalData][MAX_CLIENTS + 1];
public plugin_init()
{
register_plugin("[ZP] Addon: Round Leaders", "1.1", "xUnicorn");
register_dictionary("zp_round_leaders.txt")
g_iMaxPlayers = get_maxplayers();
RegisterHam(Ham_Killed, "player", "CBasePlayer__Killed_Pre", false);
RegisterHam(Ham_TakeDamage, "player", "CBasePlayer__TakeDamage_Pre", false);
}
public zp_round_ended()
{
Func_GetLeaders();
}
public Func_GetLeaders()
{
for(new iPlayer = 1; iPlayer <= g_iMaxPlayers; iPlayer++)
{
if(!is_user_connected(iPlayer))
continue;
if(iUserData[INFECTIONS][iPlayer] > g_iData[TYPE][INFECTIONS])
{
g_iData[TYPE][INFECTIONS] = iUserData[INFECTIONS][iPlayer];
g_iData[LEADER][INFECTIONS] = iPlayer;
}
if(iUserData[KILLED][iPlayer] > g_iData[TYPE][KILLED])
{
g_iData[TYPE][KILLED] = iUserData[KILLED][iPlayer];
g_iData[LEADER][KILLED] = iPlayer;
}
if(iUserData[DAMAGE][iPlayer] > g_iData[TYPE][DAMAGE])
{
g_iData[TYPE][DAMAGE] = iUserData[DAMAGE][iPlayer];
g_iData[LEADER][DAMAGE] = iPlayer;
}
iUserData[INFECTIONS][iPlayer] = 0;
iUserData[KILLED][iPlayer] = 0;
iUserData[DAMAGE][iPlayer] = 0;
}
static szName[32];
static szInfector[256], szKiller[256], szDamager[256];
if(g_iData[LEADER][INFECTIONS])
{
get_user_name(g_iData[LEADER][INFECTIONS], szName, charsmax(szName));
if(g_iData[TYPE][INFECTIONS] >= EACH_INFECT)
{
g_iData[BONUS][INFECTIONS] = INFECT_BONUS * (g_iData[TYPE][INFECTIONS] / EACH_INFECT);
zp_give_user_ammo_packs(g_iData[LEADER][INFECTIONS], g_iData[BONUS][INFECTIONS]);
formatex(szInfector, charsmax(szInfector), "%L (+%i)^n", LANG_PLAYER, "ML_TOP_INFECTOR", szName, g_iData[TYPE][INFECTIONS], g_iData[BONUS][INFECTIONS]);
}
else formatex(szInfector, charsmax(szInfector), "%L^n", LANG_PLAYER, "ML_TOP_INFECTOR", szName, g_iData[TYPE][INFECTIONS]);
}
if(g_iData[LEADER][KILLED])
{
get_user_name(g_iData[LEADER][KILLED], szName, charsmax(szName));
if(g_iData[TYPE][KILLED] >= EACH_KILL)
{
g_iData[BONUS][KILLED] = KILL_BONUS * (g_iData[TYPE][KILLED] / EACH_KILL);
zp_give_user_ammo_packs(g_iData[LEADER][KILLED], g_iData[BONUS][KILLED]);
formatex(szKiller, charsmax(szKiller), "%L (+%i)^n", LANG_PLAYER, "ML_TOP_KILLER", szName, g_iData[TYPE][KILLED], g_iData[BONUS][KILLED]);
}
else formatex(szKiller, charsmax(szKiller), "%L^n", LANG_PLAYER, "ML_TOP_KILLER", szName, g_iData[TYPE][KILLED]);
}
if(g_iData[LEADER][DAMAGE])
{
get_user_name(g_iData[LEADER][DAMAGE], szName, charsmax(szName));
if(g_iData[TYPE][DAMAGE] >= EACH_DAMAGE)
{
g_iData[BONUS][DAMAGE] = DAMAGE_BONUS * (g_iData[TYPE][DAMAGE] / EACH_DAMAGE);
zp_give_user_ammo_packs(g_iData[LEADER][DAMAGE], g_iData[BONUS][DAMAGE]);
formatex(szDamager, charsmax(szDamager), "%L (+%i)", LANG_PLAYER, "ML_TOP_DAMAGER", szName, g_iData[TYPE][DAMAGE], g_iData[BONUS][DAMAGE]);
}
else formatex(szDamager, charsmax(szDamager), "%L", LANG_PLAYER, "ML_TOP_DAMAGER", szName, g_iData[TYPE][DAMAGE]);
}
if(g_iData[LEADER][INFECTIONS] || g_iData[LEADER][KILLED] || g_iData[LEADER][DAMAGE])
{
set_dhudmessage(128, 128, 128, 0.65, 0.25, 1, 5.0, 5.0, 0.035, 0.05);
show_dhudmessage(0, "%L^n^n%s%s%s", LANG_PLAYER, "ML_TOP_PLAYERS", szInfector, szKiller, szDamager);
}
g_iData[TYPE] = { 0, 0, 0 };
g_iData[BONUS] = { 0, 0, 0 };
g_iData[LEADER] = { 0, 0, 0 };
}
public client_putinserver(iPlayer)
{
iUserData[INFECTIONS][iPlayer] = 0;
iUserData[KILLED][iPlayer] = 0;
iUserData[DAMAGE][iPlayer] = 0;
}
public zp_user_infected_post(iPlayer, iInfector)
{
if(!is_user_connected(iInfector))
return;
iUserData[INFECTIONS][iInfector]++;
}
public CBasePlayer__Killed_Pre(iVictim, iAttacker, iGib)
{
if(!is_user_connected(iAttacker) || zp_get_user_zombie(iAttacker) || iVictim == iAttacker)
return HAM_IGNORED;
if(zp_get_user_zombie(iVictim) && !zp_get_user_zombie(iAttacker))
{
iUserData[KILLED][iAttacker]++;
}
return HAM_IGNORED;
}
public CBasePlayer__TakeDamage_Pre(iVictim, iInflictor, iAttacker, Float: flDamage)
{
if(!is_user_connected(iAttacker) || zp_get_user_zombie(iAttacker) || iVictim == iAttacker)
return HAM_IGNORED;
if(zp_get_user_zombie(iVictim) && !zp_get_user_zombie(iAttacker))
{
iUserData[DAMAGE][iAttacker] += floatround(flDamage);
}
return HAM_IGNORED;
}[/pawn]