Release LocationHUD
#1
Hey, I saw many people got problems with getting locations for flags and other stuff. This is a plugin which shows you your location in a HUD.

Commands
Code:
!printloc - printing the location in your console !lochud - toggle HUD on and off

Also feel free to edit the code for HUD location etc.
Code:
using System; using System.Collections.Generic; using System.Text; using Addon; namespace ClassLibrary1 { public class Class1:CPlugin { Dictionary<int, int> HudElem = new Dictionary<int, int>(); string locX = ""; string locY = ""; string locZ = ""; bool hudOn = true; int interval = 10; public override void OnServerLoad() { ServerPrint("LocationHUD loaded"); } public override ChatType OnSay(string Message, ServerClient Client) { if (Message.ToLower().StartsWith("!printloc")) { ServerPrint(Client.OriginX+ "," +Client.OriginY+ "," + Client.OriginZ); return ChatType.ChatNone; } else if (Message.ToLower().StartsWith("!lochud")) { if (hudOn == true) { hudOn = false; HudElem hud2 = GetHudElement(HudElem[Client.ClientNum]); hud2.Type = HudElementTypes.None; HudElem.Remove(Client.ClientNum); } else { hudOn = true; int HudElem1 = CreateHud(Client.ClientNum); if (HudElem.ContainsKey(Client.ClientNum)) HudElem[Client.ClientNum] = HudElem1; else HudElem.Add(Client.ClientNum, HudElem1); } return ChatType.ChatNone; } return ChatType.ChatContinue; } public override void OnAddonFrame() { foreach (ServerClient c in GetClients()) { if (hudOn != false) { HudElem hud = GetHudElement(HudElem[c.ClientNum]); interval--; if (interval <= 0) //for slower updating { locX = c.OriginX.ToString(); locY = c.OriginY.ToString(); locZ = c.OriginZ.ToString(); string location = string.Format("X:^1 {0}^7 Y:^1 {1} ^7Z:^1 {2}", locX, locY, locZ); hud.SetString(location); interval = 2; } } } } private int CreateHud(int ClientNum) { HudElem hud = CreateNewHudElem(); hud.Type = HudElementTypes.Text; hud.ShowToEnt = ClientNum; hud.HideInMenu = true; hud.Font = HudElementFonts.Default; hud.FontScale = 1.4f; hud.PointType = 0; hud.OriginY = 0f; hud.OriginX = 0f; hud.SetString(""); return hud.HudElementNum; } public override void OnPlayerDisconnect(ServerClient Client) { if (HudElem.ContainsKey(Client.ClientNum)) { HudElem hud2 = GetHudElement(HudElem[Client.ClientNum]); hud2.Type = HudElementTypes.None; HudElem.Remove(Client.ClientNum); } } public override void OnPlayerConnect(ServerClient Client) { int HudElem1 = CreateHud(Client.ClientNum); if (HudElem.ContainsKey(Client.ClientNum)) HudElem[Client.ClientNum] = HudElem1; else HudElem.Add(Client.ClientNum, HudElem1); } } }

EDIT: forgot to add the .dll


Attached Files
.zip   LocationHUD.zip (Size: 2.84 KB / Downloads: 131)
Reply

#2
So if you walk around with hudelement on, it updates and you see the coords? cool
[Image: b_560_95_1.png]
[Image: hax0r3ez.gif]
Reply

#3
(01-21-2013, 19:51)99IRock Wrote: So if you walk around with hudelement on, it updates and you see the coords? cool

ye if u walk the coordinates will follow you Smile
Reply

#4
Instead of using OnAddonFrame , a timer would be a better alternative
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

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