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



Forum Jump:


Users browsing this thread:
1 Guest(s)

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