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
Also feel free to edit the code for HUD location etc.
EDIT: forgot to add the .dll
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.
CSHARP Code
- using System;
- using System.Collections.Generic;
- using System.Text;
- using Addon;
-
- namespace ClassLibrary1
- {
- public class Class1:CPlugin
- {
-
- 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