Raised This Month: $32 Target: $400
 8% 

Solved Total Kills of a team


Post New Thread Reply   
 
Thread Tools Display Modes
<VeCo>
Veteran Member
Join Date: Jul 2009
Location: Bulgaria
Old 06-13-2019 , 11:37   Re: Total Kills of a team
Reply With Quote #11

DeathMsg is fine, just check if attacker isn't the same as victim, i.e. read_data(2). That will rule out suicides.

Just to make sure everything works without errors, add a check if the attacker is a connected player before doing anything else, players might die from fall or other sources which don't really have a team.


OR you could try using the client_death forward from csx, it has easy to use parameters and makes sure it's called only when players kill each other (it even has a teamkill parameter).
__________________

Last edited by <VeCo>; 06-13-2019 at 11:40.
<VeCo> is offline
thEsp
BANNED
Join Date: Aug 2017
Old 06-13-2019 , 11:48   Re: Total Kills of a team
Reply With Quote #12

Take this as an simple example.
PHP Code:
#include <amxmodx>
#include <amxmisc>

public plugin_init() 
{
    
set_task(1.0,"tskShowKills",0,_,_,"b")
}

public 
tskShowKills()
{
    new 
kills_t,kills_ct
    
new players_t[32],players_t_num
    
new players_ct[32],players_ct_num
    
    get_players
(players_t,players_t_num,"e","TERRORIST")
    
get_players(players_ct,players_ct_num,"e","CT")

    for(new 
i=0;i<players_t_num;i++)
    {
        
kills_t += get_user_frags(players_t[i])
    }
    
    for(new 
i=0;i<players_ct_num;i++)
    {
        
kills_ct += get_user_frags(players_ct[i])
    }
    
    
set_hudmessage(255,0,0,0.11,0.86,0,6.0,1.0)
    
show_hudmessage(0,"CT: %i ^nTT: %i",kills_ct,kills_t)

thEsp is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 06-13-2019 , 18:46   Re: Total Kills of a team
Reply With Quote #13

PHP Code:

#include <amxmodx>
#include <cstrike>

new csTeamScoreCsTeams ];

public 
plugin_init()
{
    
register_plugin"hud" "" "rinf" );

    
register_event"DeathMsg" "Event_DeathMsg" "a" "1" );
    
set_task1.0 "ShowHUD" , .flags="b" );
}

public 
Event_DeathMsg()
{
    new 
iAttacker read_data);
    new 
iVictim read_data);
    
    if ( ( 
iAttacker != iVictim ) && is_user_connectediAttacker ) )
    {
        new 
CsTeams:csTeamAttacker cs_get_user_teamiAttacker );
        
        if( 
csTeamAttacker != cs_get_user_teamiVictim ) )
        {
            
csTeamScorecsTeamAttacker ]++;
        }
    }


public 
ShowHUD()
{
    
set_dhudmessage255 , -1.0 0.0 0.0 0.9 )
    
show_dhudmessage"T: %d^nCT: %d" csTeamScoreCS_TEAM_T ] , csTeamScoreCS_TEAM_CT ] );

__________________
Bugsy is offline
shadow728988
Member
Join Date: Sep 2017
Old 06-15-2019 , 08:42   Re: Total Kills of a team
Reply With Quote #14

Quote:
Originally Posted by thEsp View Post
Take this as an simple example.
PHP Code:
#include <amxmodx>
#include <amxmisc>

public plugin_init() 
{
    
set_task(1.0,"tskShowKills",0,_,_,"b")
}

public 
tskShowKills()
{
    new 
kills_t,kills_ct
    
new players_t[32],players_t_num
    
new players_ct[32],players_ct_num
    
    get_players
(players_t,players_t_num,"e","TERRORIST")
    
get_players(players_ct,players_ct_num,"e","CT")

    for(new 
i=0;i<players_t_num;i++)
    {
        
kills_t += get_user_frags(players_t[i])
    }
    
    for(new 
i=0;i<players_ct_num;i++)
    {
        
kills_ct += get_user_frags(players_ct[i])
    }
    
    
set_hudmessage(255,0,0,0.11,0.86,0,6.0,1.0)
    
show_hudmessage(0,"CT: %i ^nTT: %i",kills_ct,kills_t)

thank you it worked pretty well can you tell me one more thing how do i make the kills start from 00 rather than just single digit
Eg.\01,02,03...11,12
shadow728988 is offline
<VeCo>
Veteran Member
Join Date: Jul 2009
Location: Bulgaria
Old 06-15-2019 , 09:10   Re: Total Kills of a team
Reply With Quote #15

Quote:
Originally Posted by shadow728988 View Post
can you tell me one more thing how do i make the kills start from 00 rather than just single digit
Eg.\01,02,03...11,12
Use %02d to display the numbers
__________________
<VeCo> is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 06-15-2019 , 10:58   Re: Total Kills of a team
Reply With Quote #16

shadow728988, just wanted to give you some info on the difference between my code and thEsp's code.

thEsp's code will sum the kills of all players currently on each team, so if a player changes team, his scores comes with him.

My code will keep the score on the team where the kill was made. So if I kill 15 on T then switch to CT, my 15 kills remain with T...while thEsp's code will transfer the kills to the other team.
__________________
Bugsy is offline
shadow728988
Member
Join Date: Sep 2017
Old 06-16-2019 , 01:26   Re: Total Kills of a team
Reply With Quote #17

Quote:
Originally Posted by Bugsy View Post
shadow728988, just wanted to give you some info on the difference between my code and thEsp's code.

thEsp's code will sum the kills of all players currently on each team, so if a player changes team, his scores comes with him.

My code will keep the score on the team where the kill was made. So if I kill 15 on T then switch to CT, my 15 kills remain with T...while thEsp's code will transfer the kills to the other team.
Oh thank you for the information didn't knew bout it
shadow728988 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 12:33.


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