10-01-2013, 19:40
(This post was last modified: 12-26-2013, 10:01 by xtreme2010.)
Requirements:
1.413 version of Nukem's add-on
1.413 version of Nukem's add-on
CSHARP Code
- using System;
- using System.Collections.Generic;
- using Addon;
-
- namespace ShowAxis
- {
- public class Main : CPlugin
- {
-
- private IntPtr Axis
- {
- get
- {
- return (IntPtr)Convert.ToInt32(28438236);
- }
- }
-
- private IntPtr Allies
- {
- get
- {
- return (IntPtr)Convert.ToInt32(28438240);
- }
- }
-
- private unsafe int GetAxis()
- {
- return *(int*)Axis;
- }
-
- private unsafe int GetAllies()
- {
- return *(int*)Allies;
- }
-
- public override void OnPlayerConnect(ServerClient Client)
- {
- int Allies = CreateHud_Allies(Client.ClientNum);
- if (Client_HudElem_Allies.ContainsKey(Client.ClientNum))
- {
- Client_HudElem_Allies[Client.ClientNum] = Allies;
- }
- else
- {
- Client_HudElem_Allies.Add(Client.ClientNum, Allies);
- }
- int Axis = CreateHud_Axis(Client.ClientNum);
- if (Client_HudElem_Axis.ContainsKey(Client.ClientNum))
- {
- Client_HudElem_Axis[Client.ClientNum] = Axis;
- }
- else
- {
- Client_HudElem_Axis.Add(Client.ClientNum, Axis);
- }
- }
-
- public override void OnPlayerDisconnect(ServerClient Client)
- {
- if (Client_HudElem_Allies.ContainsKey(Client.ClientNum))
- {
- HudElem al = GetHudElement(Client_HudElem_Allies[Client.ClientNum]);
- al.Type = HudElementTypes.None;
- Client_HudElem_Allies.Remove(Client.ClientNum);
- }
- if (Client_HudElem_Axis.ContainsKey(Client.ClientNum))
- {
- HudElem ax = GetHudElement(Client_HudElem_Axis[Client.ClientNum]);
- ax.Type = HudElementTypes.None;
- Client_HudElem_Axis.Remove(Client.ClientNum);
- }
- }
-
- public override void OnAddonFrame()
- {
- List<ServerClient> clients;
- clients = GetClients();
- if (clients != null)
- {
- foreach (ServerClient c in clients)
- {
- if (Client_HudElem_Allies.ContainsKey(c.ClientNum))
- {
- HudElem allies = GetHudElement(Client_HudElem_Allies[c.ClientNum]);
- allies.Value = GetAllies();
- }
- if (Client_HudElem_Axis.ContainsKey(c.ClientNum))
- {
- HudElem axis = GetHudElement(Client_HudElem_Axis[c.ClientNum]);
- axis.Value = GetAxis();
- }
- }
- }
- }
-
- private int CreateHud_Axis(int ClientNum)
- {
- HudElem hud = CreateNewHudElem();
- hud.Type = HudElementTypes.Value;
- hud.ShowToEnt = ClientNum;
- hud.HideInMenu = true;
- hud.Font = HudElementFonts.Default;
- hud.FontScale = 1.3f;
- hud.PointType = 81;
- hud.OriginY = 200f;
- hud.OriginX = 10f;
- hud.SetLabel("^1Axis:^7 ");
- return hud.HudElementNum;
- }
-
- private int CreateHud_Allies(int ClientNum)
- {
- HudElem hud = CreateNewHudElem();
- hud.Type = HudElementTypes.Value;
- hud.ShowToEnt = ClientNum;
- hud.HideInMenu = true;
- hud.Font = HudElementFonts.Default;
- hud.FontScale = 1.3f;
- hud.PointType = 81;
- hud.OriginY = 212f;
- hud.OriginX = 10f;
- hud.SetLabel("^2Allies:^7 ");
- return hud.HudElementNum;
- }
- }
- }
Show Screenshot (Click to View)