Raised This Month: $ Target: $400
 0% 

Hud not shown on death


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
PrinceOf
Junior Member
Join Date: Mar 2011
Old 05-01-2011 , 11:28   Hud not shown on death
Reply With Quote #1

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_maxplayersiLeaders[3][2];

public 
plugin_init() 
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
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], iduser_team;
    for (
id 1id <= g_maxplayersid++) // makes a list of all alive players split into teams
        
if (is_user_alive(id))
        {
            
user_team get_user_team(id);
            if (
<= user_team <= 2// player is 1 for t or 2 for ct
                
iTeams[user_team][iTeamCount[user_team]++] = id;
        }

    new 
ifoundoverflowpl;
    for (
13i++) // pulls leaders from the list of alive players for both teams
        
switch (iTeamCount[i])
        {
            case 
0iLeaders[i][0] = iLeaders[i][1] = 0;
            case 
1iLeaders[i][0] = iTeams[i][0], iLeaders[i][1] = 0;
            case 
2iLeaders[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 && 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 (
13i++) // finish the leaders for each team
    
{
        if (!
iLeaders[i][0]) // no leaders were found for their team
            
break;

        for (
id 0id 2id++) // 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 0id iTeamCount[i]; id++) // notify teams of their leaders
        
{
            
set_hudmessage((== 2) ? 25530, (== 2) ? 255 00.300.3005.05.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], (== 2) ? "Counter " "");
            else
                
show_hudmessage(iTeams[i][id], "%s is the %sTerrorist Leader"szNames[0], (== 2) ? "Counter " "");
        }
    }
}

public 
fw_PlayerKilled(victimattackeriid)
{
    new 
victim read_data);
    if(
victim == iLeaders[i][id] && cs_get_user_team(iLeaders[i][id]) == CS_TEAM_CT)
    {
        
set_hudmessage(255000.290.2806.012.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(0255,2550.290.2806.012.0)
        
show_hudmessage(0"Terrorist Team leader is dead")
    }
}

public 
logevent_round_end()
{
    for (new 
team 1team 3team++) // reset models
        
for (new id 0id 2id++)
            if (
is_user_connected(iLeaders[team][id]))
                
cs_reset_user_model(iLeaders[team][id]);

PrinceOf is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 05-01-2011 , 12:48   Re: Hud not shown on death
Reply With Quote #2

PHP Code:
public fw_PlayerKilled(victimattackeriid

    new 
victim read_data); 
...

You mixed Ham_Killed and DeathMsg...
Also, Ham_Kill only takes 3 params, victim, killer and gib.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
PrinceOf
Junior Member
Join Date: Mar 2011
Old 05-02-2011 , 01:14   Re: Hud not shown on death
Reply With Quote #3

you mean

PHP Code:
public fw_PlayerKilled(victimattackergibiid)
{
    if(
victim == iLeaders[i][id] && cs_get_user_team(iLeaders[i][id]) == CS_TEAM_CT)
    {
        
set_hudmessage(255000.290.2806.012.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(0255,2550.290.2806.012.0)
        
show_hudmessage(0"Terrorist Team leader is dead")
    }

if i dont add i and id , it will give me an error , or do i have to
use this again for (id = 1; id <= g_maxplayers; id++)?
PrinceOf is offline
jc980
Veteran Member
Join Date: Jan 2010
Location: God is with us...
Old 05-02-2011 , 01:47   Re: Hud not shown on death
Reply With Quote #4

PHP Code:
public fw_PlayerKilled(victimattacker,gib)
{
    if(
iLeaders[i][victim] && cs_get_user_team(iLeaders[i][victim]) == CS_TEAM_CT)
    {
        
set_hudmessage(255000.290.2806.012.0)
        
show_hudmessage(0"Counter-Terrorist Team leader is dead")
    }
    else if(
iLeaders[i][victim] && cs_get_user_team(iLeaders[i][victim]) == CS_TEAM_T)
    {
        
set_hudmessage(0255,2550.290.2806.012.0)
        
show_hudmessage(0"Terrorist Team leader is dead")
    }

the id, can be also victim.
i dont know what "i" means.
__________________
jc980 is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 05-02-2011 , 01:52   Re: Hud not shown on death
Reply With Quote #5

Quote:
Originally Posted by PrinceOf View Post
you mean

PHP Code:
public fw_PlayerKilled(victimattackergibiid)
{
    if(
victim == iLeaders[i][id] && cs_get_user_team(iLeaders[i][id]) == CS_TEAM_CT)
    {
        
set_hudmessage(255000.290.2806.012.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(0255,2550.290.2806.012.0)
        
show_hudmessage(0"Terrorist Team leader is dead")
    }

if i dont add i and id , it will give me an error , or do i have to
use this again for (id = 1; id <= g_maxplayers; id++)?
Your code seems to be wrong in more places than only that Killed callback.
"i" and "id", here, can't be another value than 0 because you won't get any other params than the 3 ones we talked about.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
SonicSonedit
Veteran Member
Join Date: Nov 2008
Location: Silent Hill
Old 05-02-2011 , 03:45   Re: Hud not shown on death
Reply With Quote #6

Declare new variable at the begging of your plugin (where iLeaders declared):
new s_team[][] = {"BLAAAARRGGGHH", "Terrorist", "Counter-Terrorist"}


PHP Code:
public fw_PlayerKilled(victimattackershouldgib)
{
    static 
iname[32], team
    
    team
=cs_get_user_team(victim)

    for (
i=0;i<32;i++)
    if(
victim == iLeaders[i][team])
    {
        
get_user_name(victimnamecharsmax(name))
        
set_hudmessage(255000.290.2806.012.0)
        
show_hudmessage(0"% leader % has fallen!"s_team[team], name)
    }

__________________


Last edited by SonicSonedit; 05-02-2011 at 03:50.
SonicSonedit is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 05-02-2011 , 05:27   Re: Hud not shown on death
Reply With Quote #7

for (i=0;i<32;i++)
->
new maxClients = get_maxplayers();
for( new i = 1; i <= maxClients; i ++)
__________________

Last edited by Arkshine; 05-02-2011 at 05:39.
Arkshine is offline
SonicSonedit
Veteran Member
Join Date: Nov 2008
Location: Silent Hill
Old 05-02-2011 , 07:01   Re: Hud not shown on death
Reply With Quote #8

Actually I overlooked iLeaders[3][2]
Fixed:
PHP Code:
public fw_PlayerKilled(victimattackershouldgib)
{
    static 
name[32], team
    
    team
=cs_get_user_team(victim)

    if (
victim==iLeaders[team][0] || victim==iLeaders[team][1])
    {
        
get_user_name(victimnamecharsmax(name))
        
set_hudmessage(255000.290.2806.012.0)
        
show_hudmessage(0"% leader % has fallen!"s_team[team], name)
    }

__________________


Last edited by SonicSonedit; 05-02-2011 at 07:05.
SonicSonedit is offline
Old 05-03-2011, 00:58
PrinceOf
This message has been deleted by PrinceOf.
PrinceOf
Junior Member
Join Date: Mar 2011
Old 05-03-2011 , 03:39   Re: Hud not shown on death
Reply With Quote #9

this is kinda wierd ... but its still not announcing

PHP Code:
public fw_PlayerKilled(victimattackershouldgib)
{
    static 
iname[32], team
    team 
get_user_team(victim)
    
    for (
032i++)
    if(
victim == iLeaders[i][team])
    {
        
get_user_name(victimnamecharsmax(name))
        
set_hudmessage(255000.290.2806.012.0)
        
show_hudmessage(0"% leader % has fallen!"s_team[team], name)
    }

PrinceOf is offline
SonicSonedit
Veteran Member
Join Date: Nov 2008
Location: Silent Hill
Old 05-03-2011 , 05:40   Re: Hud not shown on death
Reply With Quote #10

PrinceOf
That was wrong code - use http://forums.alliedmods.net/showpos...39&postcount=8
__________________

SonicSonedit is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 04:20.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode