I'm trying to write a plugin that displays the number of enemies still alive on the other team.
It does not work and I can't figure out why..
Problems:
When I test it with bots, the counter show 0.
When I test it with humans, the counter still show 0.
Counter is only visible for CTs
WARNING [46]: tag mismatch: if (get_user_team(victim) == CS_TEAM_T)
WARNING [51]: tag mismatch: if (get_user_team(victim) == CS_TEAM_CT)
Questions when problems are solved:
How do I make it so that players can enable/disable this function.
Is this code hard on the CPU, will it cause the server to lag?
Thank you very much.
Code:
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <fun>
#define PLUGIN "gn_enemiesleft"
#define VERSION "0.1"
#define AUTHOR "GoldNux"
public plugin_init()
{
set_hudmessage(0, 255, 0, 0.009, 0.00, 0, 6.0, 105.0, 0.3, 0.3, 1)
register_plugin(PLUGIN, VERSION, AUTHOR)
register_event("HLTV", "eventNewRound", "a", "1=0", "2=0")
register_event( "DeathMsg" , "registerDeath" , "a" );
}
new playersT[32]
new playersCT[32]
new playerCount_T
new playerCount_CT
new playersAliveT
new playersAliveCT
public eventNewRound()
{
get_players(playersCT, playerCount_CT, "e", "CT")
get_players(playersT, playerCount_T, "e", "TERRORIST")
playersAliveT = playerCount_T
playersAliveCT = playerCount_CT
new iCT
for (iCT = 0; iCT < playerCount_CT; iCT++)
show_hudmessage(playersCT[iCT], "%d", playersAliveT)
new iT
for (iT = 0; iT < playerCount_T; iT++)
show_hudmessage(playersT[iT], "%d", playersAliveCT)
}
public registerDeath()
{
new victim = read_data(2);
if (get_user_team(victim) == CS_TEAM_T)
{
playersAliveT--
updateCT_HUD
}
if (get_user_team(victim) == CS_TEAM_CT)
{
playersAliveCT--
updateT_HUD
}
}
public updateCT_HUD()
{
new i
for (i = 0; i < playerCount_CT; i++)
show_hudmessage(playersCT[i], "%d", playersAliveT)
}
public updateT_HUD()
{
new i
for (i = 0; i < playerCount_T; i++)
show_hudmessage(playersT[i], "%d", playersAliveCT)
}
__________________