/*
To do:
T = needs testing
X = done
- = cancelled
[T] register Ham_Killed instead of using zpnm killed native
[T] CZ bots support
[T] fix possible overflow
[T] remove unnecessary checks
[T] remove zpnm alive/connected native checks and use default ones instead
[T] charsmax instead of constant values
[T] support for the new zpnm modes
[T] display mod as unknown or not at all if it's out of bounds
v1.1.9
[T] remove hud sync object from the round status hud
[T] use static hud channels instead of auto
[-] reduce hud character length from 512(hud messages seem to have a 480 character limit)
[T] display the first 10 players only to avoid filling the screen with hud
v1.2.2
[T] fix plugin not displaying players if their IDs are > 10
v1.2.3
[ ] constantly display number of classes or humans/zombies left?
[ ] optimize
[ ] show hud even when no mode running as ZPNM_MODE_NONE?
[ ]
*/
/*================================================================================
*********************************************************
*********** [Zombie Plague Multi HUD Info] **************
*********************************************************
----------------------
-*- Licensing Info -*-
----------------------
Zombie Plague Multi HUD Info
by schmurgel1983(@msn.com)
Copyright (C) 2008-2011 Stefan "schmurgel1983" Focke
Versions 1.1.0 and higher by george.distinct(@gmail.com)
Copyright (C) 2011-2013 D i 5 7 i n c T
This program is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation, either version 3 of the License, or (at your
option) any later version.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
Public License for more details.
You should have received a copy of the GNU General Public License along
with this program. If not, see <http://www.gnu.org/licenses/>.
In addition, as a special exception, the author gives permission to
link the code of this program with the Half-Life Game Engine ("HL
Engine") and Modified Game Libraries ("MODs") developed by Valve,
L.L.C ("Valve"). You must obey the GNU General Public License in all
respects for all of the code used other than the HL Engine and MODs
from Valve. If you modify this file, you may extend this exception
to your version of the file, but you are not obligated to do so. If
you do not wish to do so, delete this exception statement from your
version.
No warranties of any kind. Use at your own risk.
-------------------
-*- Description -*-
-------------------
Shows stats like csstats with zombie/human remaining.
Gives every 3 seconds info about the HP from first zombie,
last human, nemesis, survivor, sniper or all of these classes.
Shows currently played game mode.
--------------------
-*- Requirements -*-
--------------------
* Mods: Counter-Strike 1.6 or Condition-Zero
* AMXX: Version 1.8.0 or later
* Module: fakemeta, hamsandwich
-----------------
-*- Changelog -*-
-----------------
* v1.0.0:
- Initial release Privat (30th Aug 2008)
- Initial release Alliedmodders (2nd Feb 2011)
* v1.1.0 (1st Nov 2011 - Private):
- Fully rescripted the plug-in (optimized very much)
- Removed the hamsandwich module and support for CZ bots
- Added support for Zombie Plague Nightmare (version 1.9f or later)
* v1.1.1 (17th Nov 2011 - Private):
- Renamed plug-in from "Zombie Plague Stats" to "Zombie Plague Multi HUD Info"
(Thanks to suNx for the inspiration and idea)
- Fixed human and zombie count error
- Added support for showing the current game mode and different colors
- Added multilingual support
- Optimized the plug-in a bit more and removed useless code
=================================================================================*/
// Modules
#include <amxmodx>
#include <hamsandwich>
#if AMXX_VERSION_NUM < 180
#assert AMX Mod X v1.8.0 or later library required!
#endif
// Plug-in APIs
#include <cs_ham_bots_api>
#include <zombieplaguenightmare>
/*================================================================================
[Global Variables]
=================================================================================*/
// Game vars
new g_iMaxPlayers // max player counter
new g_HudSync // message sync objects
new g_zombie_count // zombie count
new g_human_count // human count
new g_name[33][32] // player name
new g_szLangKeysModes[][] =
{
"ZPNM_MODE_NONE",
"ZPNM_MODE_INFECTION",
"ZPNM_MODE_NEMESIS",
"ZPNM_MODE_SURVIVOR",
"ZPNM_MODE_SWARM",
"ZPNM_MODE_MULTI",
"ZPNM_MODE_PLAGUE",
"ZPNM_MODE_SNIPER",
"ZPNM_MODE_ASSASSIN",
"ZPNM_SURVIVOR_NEMESIS",
"ZPNM_MODE_SURVIVOR_ASSASSIN",
"ZPNM_MODE_SNIPER_NEMESIS",
"ZPNM_MODE_SNIPER_ASSASSIN",
"ZPNM_MODE_SURVSNIP_NEMASS",
"ZPNM_MODE_UNKNOWN"
}
const g_iSizeLangKeysModes = sizeof g_szLangKeysModes - 1;
/*
enum g_hud_color_R[9]
{
0,
0,
255,
0,
255,
0,
255,
0,
175
}
enum g_hud_color_G[9]
{
0,
255,
0,
0,
255,
255,
255,
0,
0
}
enum g_hud_color_B[9]
{
0,
0,
0,
255,
0,
0,
0,
255,
255
}*/
/*================================================================================
[Init]
=================================================================================*/
public plugin_init()
{
register_plugin("[ZPNM] Multi HUD Info", "1.2.3", "schmurgel1983, D i 5 7 i n c T")
register_event("HLTV", "event_round_start", "a", "1=0", "2=0")
register_dictionary("zpnm_multi_hud_info.txt")
RegisterHam(Ham_Killed, "player", "fwHamKilledPlayer", 1)
RegisterHamBots(Ham_Killed, "fwHamKilledPlayer", 1)
g_iMaxPlayers = get_maxplayers()
g_HudSync = CreateHudSyncObj()
}
public client_disconnect(iID)
{
if (!is_user_alive(iID) || zp_has_round_started() != -1)
return;
if (zp_get_user_zombie(iID))
{
g_zombie_count--
if (g_zombie_count)
display_enemy_remaining()
}
else
{
g_human_count--
if (g_human_count)
display_enemy_remaining()
}
}
public client_infochanged(iID)
{
if (!is_user_connected(iID))
return;
get_user_info(iID, "name", g_name[iID], 31)
}
/*================================================================================
[Main Forwards]
=================================================================================*/
// Event Round Start
public event_round_start()
{
g_zombie_count = 0
g_human_count = 0
}
public zp_round_started(mode)
{
new temp[1]
if (mode <= g_iSizeLangKeysModes)
temp[0] = mode
else
temp[0] = g_iSizeLangKeysModes;
display_multi_hud_info(temp)
set_task(1.757, "display_multi_hud_info", _, temp, 1, "b")
}
public zp_round_ended()
remove_task()
public zpnm_user_spawn_post(iID)
{
g_human_count++
if (zp_has_round_started() == 1)
display_enemy_remaining()
}
public zp_user_infected_pre(iID)
{
if (zp_get_user_zombie(iID))
return;
g_human_count--
g_zombie_count++
display_enemy_remaining()
}
public zp_user_humanized_pre(iID)
{
if (!zp_get_user_zombie(iID))
return;
g_human_count++
g_zombie_count--
display_enemy_remaining()
}
public fwHamKilledPlayer(const iID)
{
if (zp_get_user_zombie(iID))
{
g_zombie_count--
if (g_zombie_count)
display_enemy_remaining()
}
else
{
g_human_count--
if (zp_has_round_started() == 1 && g_human_count)
display_enemy_remaining()
}
}
/*================================================================================
[Other Functions]
=================================================================================*/
public display_multi_hud_info(mode[1])
{
//480 max hud length apparently
static message[512];
new pos, i, count;
pos += formatex(message[pos], charsmax(message) - pos, "%L: %L^n^n", LANG_SERVER, "ZPNM_CURRENT_MODE", LANG_SERVER, g_szLangKeysModes[mode[0]])
for (i = 1; i <= g_iMaxPlayers; i++)
{
if (count >= 10)
break;
else if (!is_user_alive(i))
continue;
if (zp_get_user_first_zombie(i))
pos += formatex(message[pos], charsmax(message) - pos, "%L^n", LANG_SERVER, "ZPNM_FIRST_ZOMBIE", g_name, get_user_health(i))
else if (zp_get_user_last_human(i))
pos += formatex(message[pos], charsmax(message) - pos, "%L^n", LANG_SERVER, "ZPNM_LAST_HUMAN", g_name, get_user_health(i))
else if (zp_get_user_last_zombie(i))
pos += formatex(message[pos], charsmax(message) - pos, "%L^n", LANG_SERVER, "ZPNM_LAST_ZOMBIE", g_name, get_user_health(i))
else if (zp_get_user_nemesis(i))
pos += formatex(message[pos], charsmax(message) - pos, "%L^n", LANG_SERVER, "ZPNM_NEMESIS", g_name, get_user_health(i))
else if (zp_get_user_survivor(i))
pos += formatex(message[pos], charsmax(message) - pos, "%L^n", LANG_SERVER, "ZPNM_SURVIVOR", g_name, get_user_health(i))
else if (zpnm_get_user_sniper(i))
pos += formatex(message[pos], charsmax(message) - pos, "%L^n", LANG_SERVER, "ZPNM_SNIPER", g_name, get_user_health(i))
else if (zpnm_get_user_assassin(i))
pos += formatex(message[pos], charsmax(message) - pos, "%L^n", LANG_SERVER, "ZPNM_ASSASSIN", g_name, get_user_health(i))
else
continue;
count++
/*
if (is_user_alive(i))
// set_hudmessage(g_hud_color_R[mode[0]], g_hud_color_G[mode[0]], g_hud_color_B[mode[0]], -1.0, 0.0, 0, 0.01, 3.57, 0.01, 0.01, -1)
set_hudmessage(0, 255, 255, -1.0, 0.0, 0, 0.01, 3.57, 0.01, 0.01, -1)
else
// set_hudmessage(g_hud_color_R[mode[0]], g_hud_color_G[mode[0]], g_hud_color_B[mode[0]], -1.0, 0.357, 0, 0.01, 3.57, 0.01, 0.01, -1)
set_hudmessage(0, 255, 255, -1.0, 0.357, 0, 0.01, 3.57, 0.01, 0.01, -1)
ShowSyncHudMsg(i, g_HudSync, "%s", message)*/
}
set_hudmessage(0, 255, 255, -1.0, 0.13157, 0, 0.0, 1.757 + 0.01, 0.0, 0.0, 3)
show_hudmessage(0, message)
}
public display_enemy_remaining()
{
static message[128]
set_hudmessage(175, 175, 175, 0.0157, 0.975, 2, 0.02, 3.57, 0.01, 1.57, 4)
for (new i = 1; i <= g_iMaxPlayers; i++)
{
if (!is_user_connected(i))
continue;
if (!zp_get_user_zombie(i))
{
formatex(message, charsmax(message), "%L", i, "ZPNM_ZOMBIES_REMAINING", g_zombie_count)
ShowSyncHudMsg(i, g_HudSync, "%s", message)
}
else
{
formatex(message, charsmax(message), "%L", i, "ZPNM_HUMANS_REMAINING", g_human_count)
ShowSyncHudMsg(i, g_HudSync, "%s", message)
}
}
}