| PrinceOf |
05-01-2011 11:28 |
Hud not shown on death
Well , first 2 players are selected from each teams and made captains , if one of them dies , an hud is supposed to be displayed , that he is killed ...
But is doesnt show
PHP Code:
#include <amxmodx>
#include <cstrike>
#include <fun>
#include <hamsandwich>
#define PLUGIN "None"
#define VERSION "1.0"
#define AUTHOR "Prince"
new g_maxplayers, iLeaders[3][2];
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
register_logevent("logevent_round_start", 2, "1=Round_Start")
register_logevent("logevent_round_end", 2, "1=Round_End")
g_maxplayers = get_maxplayers()
RegisterHam(Ham_Killed, "player", "fw_PlayerKilled" )
}
public plugin_precache()
{
precache_model("models/player/vip/vip.mdl")
}
public logevent_round_start()
{
set_task(7.0, "Leaders");
}
public Leaders()
{
new iTeams[3][16], iTeamCount[3], id, user_team;
for (id = 1; id <= g_maxplayers; id++) // makes a list of all alive players split into teams
if (is_user_alive(id))
{
user_team = get_user_team(id);
if (1 <= user_team <= 2) // player is 1 for t or 2 for ct
iTeams[user_team][iTeamCount[user_team]++] = id;
}
new i, found, overflow, pl;
for (i = 1; i < 3; i++) // pulls leaders from the list of alive players for both teams
switch (iTeamCount[i])
{
case 0: iLeaders[i][0] = iLeaders[i][1] = 0;
case 1: iLeaders[i][0] = iTeams[i][0], iLeaders[i][1] = 0;
case 2: iLeaders[i][0] = iTeams[i][0], iLeaders[i][1] = iTeams[i][1];
default: {
iLeaders[i][0] = iLeaders[i][1] = found = overflow = 0; // clear leaders and vars
while (found < 2 && overflow++ < 300)
{
pl = random(iTeamCount[i]);
if (iTeams[i][pl] && iLeaders[i][0] != iTeams[i][pl]) // check if random player is real and if he wasnt already selected
iLeaders[i][found++] = iTeams[i][pl];
}
}
}
new szNames[2][32];
for (i = 1; i < 3; i++) // finish the leaders for each team
{
if (!iLeaders[i][0]) // no leaders were found for their team
break;
for (id = 0; id < 2; id++) // set the two leaders and get their names
if (iLeaders[i][id])
{
get_user_name(iLeaders[i][id], szNames[id], 31);
cs_set_user_model(iLeaders[i][id], "vip");
set_user_health(iLeaders[i][id], 400 + get_user_health(iLeaders[i][id]))
}
for (id = 0; id < iTeamCount[i]; id++) // notify teams of their leaders
{
set_hudmessage((i == 2) ? 0 : 255, 30, (i == 2) ? 255 : 0, 0.30, 0.30, 0, 5.0, 5.0);
if (iLeaders[i][1]) // check to see if there were enough players for the 2nd leader
show_hudmessage(iTeams[i][id], "%s and %s are the %sTerrorist Leaders", szNames[0], szNames[1], (i == 2) ? "Counter " : "");
else
show_hudmessage(iTeams[i][id], "%s is the %sTerrorist Leader", szNames[0], (i == 2) ? "Counter " : "");
}
}
}
public fw_PlayerKilled(victim, attacker, i, id)
{
new victim = read_data( 2 );
if(victim == iLeaders[i][id] && cs_get_user_team(iLeaders[i][id]) == CS_TEAM_CT)
{
set_hudmessage(255, 0, 0, 0.29, 0.28, 0, 6.0, 12.0)
show_hudmessage(0, "Counter-Terrorist Team leader is dead")
}
else if(victim == iLeaders[i][id] && cs_get_user_team(iLeaders[i][id]) == CS_TEAM_T)
{
set_hudmessage(0, 255,255, 0.29, 0.28, 0, 6.0, 12.0)
show_hudmessage(0, "Terrorist Team leader is dead")
}
}
public logevent_round_end()
{
for (new team = 1; team < 3; team++) // reset models
for (new id = 0; id < 2; id++)
if (is_user_connected(iLeaders[team][id]))
cs_reset_user_model(iLeaders[team][id]);
}
|