Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
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

CSHARP Code
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using Addon;
  5. using System.Timers;
  6.  
  7. namespace Point
  8. {
  9. #region VecClass
  10. public class VecXY
  11. {
  12. public float xVec;
  13. public float yVec;
  14. public int Icon;
  15.  
  16. public VecXY(float x, float y, int icon)
  17. {
  18. xVec = x;
  19. yVec = y;
  20. Icon = icon;
  21. }
  22. }
  23. #endregion
  24.  
  25. public class main :TeamCounter.Counter
  26. {
  27. Timer timer = new Timer();
  28. Timer timer2 = new Timer();
  29.  
  30. public void checking(object s, ElapsedEventArgs e)
  31. {
  32.  
  33. if (Count(_Team.Allies) == 1)
  34. {
  35. timer2.Enabled = true;
  36. }
  37. }
  38.  
  39. public void updateLocation(object s, ElapsedEventArgs e)
  40. {
  41. if (GetLastAlive() != null)
  42. {
  43. Activate();
  44. x = GetLastAlive().OriginX;
  45. y = GetLastAlive().OriginY;
  46. ChangeIcon();
  47. SetPosition();
  48. }
  49. else
  50. {
  51. Deactivate();
  52. timer2.Enabled = false;
  53. }
  54. }
  55.  
  56. public override void OnAddonFrame()
  57. {
  58. foreach (ServerClient c in Allies())
  59. {
  60.  
  61. }
  62. foreach (ServerClient c in Axis())
  63. {
  64.  
  65. }
  66. }
  67.  
  68. #region PointStuff
  69. IntPtr activate, icon, X, Y;
  70.  
  71. public static int iconNum;
  72. public static float x;
  73. public static float y;
  74.  
  75. public override void OnServerLoad()
  76. {
  77. activate = (IntPtr)Convert.ToInt32(0x01B1EE9C);
  78. icon = (IntPtr)Convert.ToInt32(0x01B1EEBC);
  79. X = (IntPtr)Convert.ToInt32(0x01B1EEA0);
  80. Y = (IntPtr)Convert.ToInt32(0x01B1EEA4);
  81.  
  82. timer.Elapsed += new ElapsedEventHandler(checking);
  83. timer.Interval = 2000;
  84. timer.Enabled = true;
  85.  
  86. timer2.Elapsed += new ElapsedEventHandler(updateLocation);
  87. timer2.Interval = 100;
  88. timer2.Enabled = false;
  89.  
  90. iconNum = 204;
  91. }
  92.  
  93. unsafe public void Activate()
  94. {
  95. *(int*)activate = 1;
  96. }
  97. unsafe public void ChangeIcon()
  98. {
  99.  
  100. *(int*)icon = iconNum;
  101. }
  102. unsafe public void Deactivate()
  103. {
  104.  
  105. *(int*)activate = 0;
  106. }
  107. unsafe public void SetPosition()
  108. {
  109.  
  110. *(float*)X = x;
  111. *(float*)Y = y;
  112.  
  113. }
  114. #endregion
  115. }
  116. }


Attached Files
.zip   TeamCounter.zip (Size: 2.13 KB / Downloads: 70)
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 5,107 01-13-2013, 12:10
Last Post: koil
  [Request] Disabling Custom Classes NOT CHOOSE CLASS DidUknowiPwn 5 3,387 01-10-2013, 04:32
Last Post: banz
  How to disable "Choose Class"? DidUknowiPwn 8 5,108 10-07-2012, 21:09
Last Post: JariZ
  [News] Black Ops 2 - Create A Class(LEAK) Tomsen1410 5 3,798 09-20-2012, 09:51
Last Post: Tomsen1410
  Mage class Lemon 23 11,603 04-22-2012, 22:46
Last Post: frisky
  Weapon Menu, create ingame custom class Gamemaster20 4 3,516 04-20-2012, 08:13
Last Post: rotceh_dnih
  Class Plugin pollarpart 5 3,867 04-16-2012, 13:40
Last Post: OzonE
  Disable Class Choice for one team kobsen 7 4,562 03-19-2012, 19:04
Last Post: Lemon
Lightbulb [Release] CFGFile class JariZ 7 5,129 01-29-2012, 13:28
Last Post: kokole
  [Release] BF1942 Class Selection Menu Style Yamato 14 8,499 12-30-2011, 18:01
Last Post: GscGunner

Forum Jump:


Users browsing this thread:
1 Guest(s)

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