Release TeamCounter class
#1
Hey everyone

I created a pretty simple class to count the players in a team.
It's a class that makes it easier for plugin developers to count the players in a team, it's not a plugin so don't ask why it doesn't work.

Functions:

Count(teamname); - returns the number of players in the team
GetLastAlive(); - if there's only one player in team allies it returns the client, if not it returns null.
Allies(); - a list of all survivors/team allies
Axis(); - a list of all zombies/team axis
_Team.TeamName - used for Count()

here's an example of how you can use the class, add TeamCounter.dll as a reference and inherit: TeamCounter.Counter

it's adding a waypoint on the radar to mark the last player alive

Code:
using System; using System.Collections.Generic; using System.Text; using Addon; using System.Timers; namespace Point { #region VecClass public class VecXY { public float xVec; public float yVec; public int Icon; public VecXY(float x, float y, int icon) { xVec = x; yVec = y; Icon = icon; } } #endregion public class main :TeamCounter.Counter { Timer timer = new Timer(); Timer timer2 = new Timer(); public void checking(object s, ElapsedEventArgs e) { if (Count(_Team.Allies) == 1) { timer2.Enabled = true; } } public void updateLocation(object s, ElapsedEventArgs e) { if (GetLastAlive() != null) { Activate(); x = GetLastAlive().OriginX; y = GetLastAlive().OriginY; ChangeIcon(); SetPosition(); } else { Deactivate(); timer2.Enabled = false; } } public override void OnAddonFrame() { foreach (ServerClient c in Allies()) { } foreach (ServerClient c in Axis()) { } } #region PointStuff IntPtr activate, icon, X, Y; public static int iconNum; public static float x; public static float y; public override void OnServerLoad() { activate = (IntPtr)Convert.ToInt32(0x01B1EE9C); icon = (IntPtr)Convert.ToInt32(0x01B1EEBC); X = (IntPtr)Convert.ToInt32(0x01B1EEA0); Y = (IntPtr)Convert.ToInt32(0x01B1EEA4); timer.Elapsed += new ElapsedEventHandler(checking); timer.Interval = 2000; timer.Enabled = true; timer2.Elapsed += new ElapsedEventHandler(updateLocation); timer2.Interval = 100; timer2.Enabled = false; iconNum = 204; } unsafe public void Activate() { *(int*)activate = 1; } unsafe public void ChangeIcon() { *(int*)icon = iconNum; } unsafe public void Deactivate() { *(int*)activate = 0; } unsafe public void SetPosition() { *(float*)X = x; *(float*)Y = y; } #endregion } }


Attached Files
.zip   TeamCounter.zip (Size: 2.13 KB / Downloads: 115)
Reply

#2
Nice one! But why there is this code:
Code:
public override void OnAddonFrame() { foreach (ServerClient c in Allies()) { } foreach (ServerClient c in Axis()) { } }


( In AddonFrame, is it necessary? )
C++/Obj-Cdeveloper. Neko engine wip
Steam: Click
Reply

#3
(05-18-2013, 19:30)SailorMoon Wrote: Nice one! But why there is this code:
Code:
public override void OnAddonFrame() { foreach (ServerClient c in Allies()) { } foreach (ServerClient c in Axis()) { } }


( In AddonFrame, is it necessary? )

No, I added it to show an example of how you can use the Allies() or Axis() method
Reply

#4
How change point?
Reply



Possibly Related Threads…
Thread Author Replies Views Last Post
  W@W: Making player spawn with a custom default class. koil 9 7,532 01-13-2013, 12:10
Last Post: koil
  [Request] Disabling Custom Classes NOT CHOOSE CLASS DidUknowiPwn 5 5,349 01-10-2013, 04:32
Last Post: banz
  How to disable "Choose Class"? DidUknowiPwn 8 7,792 10-07-2012, 21:09
Last Post: JariZ
  [News] Black Ops 2 - Create A Class(LEAK) Tomsen1410 5 5,466 09-20-2012, 09:51
Last Post: Tomsen1410
  Mage class Lemon 23 17,798 04-22-2012, 22:46
Last Post: frisky
  Weapon Menu, create ingame custom class Gamemaster20 4 5,466 04-20-2012, 08:13
Last Post: rotceh_dnih
  Class Plugin pollarpart 5 6,286 04-16-2012, 13:40
Last Post: OzonE
  Disable Class Choice for one team kobsen 7 6,640 03-19-2012, 19:04
Last Post: Lemon
Lightbulb [Release] CFGFile class JariZ 7 7,542 01-29-2012, 13:28
Last Post: kokole
  [Release] BF1942 Class Selection Menu Style Yamato 14 12,356 12-30-2011, 18:01
Last Post: GscGunner

Forum Jump:


Users browsing this thread:
1 Guest(s)

Forum Powered By MyBB, Theme by © 2002-2026 Melroy van den Berg.