#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <zombieplague>
#define PLUGIN "[ZP] Addon: APs Leader"
#define VERSION "1.2"
#define AUTHOR "Kiske"
// Cvars
new leader_msj
// Others
new MaxPlayers, SayText
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
// Language Files
register_dictionary("aps_leader.txt")
// Cvars
leader_msj = register_cvar("zp_leader_msj", "3")
/*
zp_leader_msj 0. Plugin Disable.
zp_leader_msj 1. Message at RoundStart.
zp_leader_msj 2. Message when you say or say_team "/leader".
zp_leader_msj 3. Both.
*/
// Client Commands
register_clcmd("say /leader", "CheckLeader_Ammo")
register_clcmd("say_team /leader", "CheckLeader_Ammo")
// Event
register_event("HLTV", "RoundStart", "a", "1=0", "2=0")
// Others
SayText = get_user_msgid("SayText")
MaxPlayers = get_maxplayers()
}
public RoundStart()
{
if ( get_pcvar_num(leader_msj) == 1 || get_pcvar_num(leader_msj) == 3 )
set_task(1.6, "Leader") // I use this set_task to the message appears then of "welcome_msg"
}
public Leader()
{
if ( get_pcvar_num(leader_msj) == 1 || get_pcvar_num(leader_msj) == 3 )
{
new iAmmoPacks
new iLeader = GetLeader_Ammo(iAmmoPacks)
new Players = UsersGetPlaying()
new iPlayers[32], iNum, Others
new szName[32]
get_user_name( iLeader, szName, 31 )
get_players( iPlayers, iNum, "ch" )
if ( Players == 0 )
ChatColor( 0, "%L", LANG_PLAYER, "NO_PLAYERS" )
else if ( iAmmoPacks == Others )
ChatColor( 0, "%L", LANG_PLAYER, "MORE_LEADERS_AMMO" )
else
ChatColor( 0, "%L", LANG_PLAYER, "LEADER_AMMO", szName, iAmmoPacks )
}
set_task(0.1, "Leader_Frags")
}
public Leader_Frags()
{
if ( get_pcvar_num(leader_msj) == 1 || get_pcvar_num(leader_msj) == 3 )
{
new iFrags
new iLeader = GetLeader_Frags(iFrags)
new Players = UsersGetPlaying()
new iPlayers[32], iNum, Others
new szName[32]
get_user_name( iLeader, szName, 31 )
get_players( iPlayers, iNum, "ch" )
for ( new i = 0; i < iNum; i++ )
Others = get_user_frags(i)
if ( Players == 0 )
ChatColor( 0, "%L", LANG_PLAYER, "NO_PLAYERS" )
else if ( iFrags == Others )
ChatColor( 0, "%L", LANG_PLAYER, "MORE_LEADERS_FRAGS" )
else
ChatColor( 0, "%L", LANG_PLAYER, "LEADER_FRAGS", szName, iFrags )
}
}
// Check Leader
public CheckLeader_Ammo(id)
{
if ( get_pcvar_num(leader_msj) == 2 || get_pcvar_num(leader_msj) == 3 )
{
new iAmmoPacks, iFrags
new iLeader_Ammo = GetLeader_Ammo(iAmmoPacks)
new iLeader_Frags = GetLeader_Frags(iFrags)
new Players = UsersGetPlaying()
new iPlayers[32], iNum, Others, Altii
new Name_Frags[32], Name_Ammo[32]
get_user_name( iLeader_Frags, Name_Frags, 31 )
get_user_name( iLeader_Ammo, Name_Ammo, 31 )
get_players( iPlayers, iNum, "ch" )
for ( new i = 0; i < iNum; i++ )
Others = zp_get_user_ammo_packs(i)
for ( new j = 0; j < iNum; j++ )
Altii = get_user_frags(j)
if ( Players == 0 )
ChatColor( id, "%L", LANG_PLAYER, "NO_PLAYERS" )
else if ( iFrags == Altii )
ChatColor( id, "%L", LANG_PLAYER, "MORE_LEADERS_FRAGS" )
else if ( iAmmoPacks == Others )
ChatColor( id, "%L", LANG_PLAYER, "MORE_LEADERS_AMMO" )
else
ChatColor( id, "%L", LANG_PLAYER, "LEADER_AMMO", Name_Ammo, iAmmoPacks )
}
return PLUGIN_HANDLED;
}
GetLeader_Ammo( &iAmmoPacks )
{
new iPlayers[32], iNum, id, i, iLeader, iPacks
get_players( iPlayers, iNum, "ch" )
for ( i = 0; i < iNum; i++ )
{
id = iPlayers[i]
iPacks = zp_get_user_ammo_packs(id)
if ( iPacks > iAmmoPacks )
{
iAmmoPacks = iPacks
iLeader = id
}
}
return iLeader;
}
GetLeader_Frags( &iFrags )
{
new iPlayers[32], iNum, id, i, iLeader, iFrag
get_players( iPlayers, iNum, "ch" )
for ( i = 0; i < iNum; i++ )
{
id = iPlayers[i]
iFrag = get_user_frags(id)
if ( iFrag > iFrags )
{
iFrags = iFrag
iLeader = id
}
}
return iLeader;
}
// ChatColor!
stock ChatColor(const id, const input[], any:...)
{
new count = 1, players[32]
static msg[191]
vformat(msg, 190, input, 3)
replace_all(msg, 190, "!g", "^4") // Green Color
replace_all(msg, 190, "!y", "^1") // Default Color
replace_all(msg, 190, "!t", "^3") // Team Color
if (id) players[0] = id; else get_players(players, count, "ch")
{
for ( new i = 0; i < count; i++ )
{
if ( is_user_connected(players[i]) )
{
message_begin(MSG_ONE_UNRELIABLE, SayText, _, players[i])
write_byte(players[i]);
write_string(msg);
message_end();
}
}
}
}
// Users Get Playing (Stock from the ZP)
UsersGetPlaying()
{
static iPlaying, id
iPlaying = 0
for ( id = 1; id <= MaxPlayers; id++ )
{
if ( is_user_connected(id) )
{
if ( get_user_team(id) == 1 || get_user_team(id) == 2 )
iPlaying++
}
}
return iPlaying;
}