Raised This Month: $12 Target: $400
 3% 

Solved Total Kills of a team


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
shadow728988
Member
Join Date: Sep 2017
Old 06-11-2019 , 23:33   Total Kills of a team
Reply With Quote #1

Is it possible to add up the kills of all the players in same team and display on hud?
I already have created the hud just cant get the kills to add up.
Thank you for your help.

Last edited by shadow728988; 06-18-2019 at 08:05.
shadow728988 is offline
<VeCo>
Veteran Member
Join Date: Jul 2009
Location: Bulgaria
Old 06-12-2019 , 11:24   Re: Total Kills of a team
Reply With Quote #2

Detect kill, check team of killer, add +1 to a global variable depending on the team, show that in the hud.
__________________
<VeCo> is offline
shadow728988
Member
Join Date: Sep 2017
Old 06-12-2019 , 23:13   Re: Total Kills of a team
Reply With Quote #3

Quote:
Originally Posted by <VeCo> View Post
Detect kill, check team of killer, add +1 to a global variable depending on the team, show that in the hud.
I am new at this so i cant you know.
But we register a death event then what?
I mean how do you detect a kill
Like new attacker = get_user_id
New team = get_user_team(attacker) something like this?
shadow728988 is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 06-13-2019 , 04:20   Re: Total Kills of a team
Reply With Quote #4

Quote:
Originally Posted by shadow728988 View Post
But we register a death event then what?
I mean how do you detect a kill
If you registered DeathMsg(the death event) then you already detected a kill. The event will be called when a player is killed.

Then get the attacker,(read_data(1) IIRC), team = get_user_team(attacker), globalVariable[team]++.
__________________

Last edited by HamletEagle; 06-13-2019 at 04:22.
HamletEagle is offline
shadow728988
Member
Join Date: Sep 2017
Old 06-13-2019 , 08:24   Re: Total Kills of a team
Reply With Quote #5

Quote:
Originally Posted by HamletEagle View Post
If you registered DeathMsg(the death event) then you already detected a kill. The event will be called when a player is killed.

Then get the attacker,(read_data(1) IIRC), team = get_user_team(attacker), globalVariable[team]++.
What if i want to show both the total kills of ts as well as cts?
Still just the one global variable?
shadow728988 is offline
shadow728988
Member
Join Date: Sep 2017
Old 06-13-2019 , 09:19   Re: Total Kills of a team
Reply With Quote #6

Quote:
Originally Posted by HamletEagle View Post
If you registered DeathMsg(the death event) then you already detected a kill. The event will be called when a player is killed.

Then get the attacker,(read_data(1) IIRC), team = get_user_team(attacker), globalVariable[team]++.
Code:
#include <amxmodx>
#include <amxmisc>
#include <cstrike>

new TKills
new CTKills
public plugin_init()
{
    register_plugin("hud", "", "rinf")
	
	register_event("DeathMsg", "Event_DeathMsg", "a", "1")
	hudmessage()
}


public Event_DeathMsg()
{
  new attacker = read_data(1)
  new Team = get_user_team(attacker)
  if(Team == 1)
   {
     TKills++;
   }
  else if(Team == 2)
   {
     CTKills++
   }
} 
public hudmessage()
{
set_dhudmessage(0, 255, 0, -1.0, 0.0, 0, 6.0, 12.0)
show_dhudmessage(0, "〕Point〔^n〔%i〕       〔%i〕", TKills, CTKills);
}
correct me please thank you.

Last edited by shadow728988; 06-13-2019 at 10:03. Reason: full code
shadow728988 is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 06-13-2019 , 11:02   Re: Total Kills of a team
Reply With Quote #7

It's almost fine. You need to use a task to display the hud message(so it gets updated every time the variables change). So you should do something like set_task(1.0, "hudmessage", .flags = "b") in plugin_init. Also change the hudmessage hold time from 12.0 to something like 2.0(last param from set_dhudmessage).
__________________
HamletEagle is offline
shadow728988
Member
Join Date: Sep 2017
Old 06-13-2019 , 11:11   Re: Total Kills of a team
Reply With Quote #8

Quote:
Originally Posted by HamletEagle View Post
It's almost fine. You need to use a task to display the hud message(so it gets updated every time the variables change). So you should do something like set_task(1.0, "hudmessage", .flags = "b") in plugin_init. Also change the hudmessage hold time from 12.0 to something like 2.0(last param from set_dhudmessage).
I was testing this and when i change team from ct to t it increments +1 to ct..what to do about this?

Add a victim condition too if so how?

Last edited by shadow728988; 06-13-2019 at 11:12. Reason: Typo
shadow728988 is offline
thEsp
BANNED
Join Date: Aug 2017
Old 06-13-2019 , 11:17   Re: Total Kills of a team
Reply With Quote #9

Check if victim (Second param) is dead, or use Ham_Killed instead (And check if victim is not attacker).
https://forums.alliedmods.net/showthread.php?t=190333
Another method is to make a looping thread where you loop throughout all players and get their kills.

Last edited by thEsp; 06-13-2019 at 11:33.
thEsp is offline
shadow728988
Member
Join Date: Sep 2017
Old 06-13-2019 , 11:32   Re: Total Kills of a team
Reply With Quote #10

Quote:
Originally Posted by HamletEagle View Post
It's almost fine. You need to use a task to display the hud message(so it gets updated every time the variables change). So you should do something like set_task(1.0, "hudmessage", .flags = "b") in plugin_init. Also change the hudmessage hold time from 12.0 to something like 2.0(last param from set_dhudmessage).
Quote:
Originally Posted by thEsp View Post
Check if victim (Second param) is dead, or use Ham_Killed instead.
https://forums.alliedmods.net/showthread.php?t=190333
Code:
if(Team ==1 && attacker != victim)
What will this do coz i didn't understand much about ham_killed
shadow728988 is offline
Reply


Thread Tools
Display Modes

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 11:54.


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