Help Hud help
#1
any idea why on server load the hud works perfectly, but on mapchange it shows it in centre of screen instead of to the left then goes off after 5/10 seconds?


PHP Code:
using System; using System.Collections.Generic; using Addon; using System.IO; using mw3zombie; namespace MoonShop { public class Shop : CPlugin { public string something = "AHAHHAHAHAHAHAHAHHAHAHA"; public Dictionary<String, String> menus = new Dictionary<String, String>(); public Dictionary<String, bool> isClassed = new Dictionary<String, bool>(); public Dictionary<String, String> Language = new Dictionary<String, String>(); private Dictionary<String, double> justSpawned = new Dictionary<string, double>(); // zoms public Dictionary<String, float> speed = new Dictionary<String, float>(); public Dictionary<String, String> hpzom = new Dictionary<String, String>(); public Dictionary<String, bool> isJug = new Dictionary<string, bool>(); public Dictionary<int, int> Client_HudElem_Shop = new Dictionary<int, int>(); public override ChatType OnSay(string Message, ServerClient Client, bool Teamchat) { int points = getPoints(Client.XUID); ToDo(Client, Message, points); return base.OnSay(Message, Client, Teamchat); } mw3zombie.Statistics stats; int pointstokill = 20; public override int OnPlayerDamaged(ServerClient Attacker, ServerClient Victim, String Weapon, Int32 Damage, String DamageMod, HitLocations HitLocation) { if (Damage >= Victim.Other.Health && Attacker.Team != Victim.Team) { UpdatePoints(pointstokill, Victim); } return base.OnPlayerDamaged(Attacker, Victim, Weapon, Damage); } public override void OnServerLoad() { try { stats = new Statistics(); SV_Shop(); } catch (Exception z) { ServerPrint(string.Format("[mShop - ENG]: I couldn't launch mShop plugin because error happened. {0}", z.Message)); ServerPrint(string.Format("[mShop - RUS]: mShop , . - {0}", z.Message)); } base.OnServerLoad(); } public override void OnAddonFrame() { Update(); base.OnAddonFrame(); } public void UpdatePoints(int inc, ServerClient c) { stats.updatePoints(inc, c); } public int getPoints(String XUID) { return stats.Stats[XUID].Points; } public override void OnPlayerDisconnect(ServerClient client) { isClassed.Remove(client.XUID); Language.Remove(client.XUID); menus.Remove(client.XUID); hpzom.Remove(client.XUID); speed.Remove(client.XUID); isJug.Remove(client.XUID); deleteHUD(client); } public override void OnPlayerConnect(ServerClient client) { // default values Language.Add(client.XUID, "eng"); menus.Add(client.XUID, "0"); speed.Add(client.XUID, 1); isJug.Add(client.XUID, false); // nononononono hpzom.Add(client.XUID, "100"); if (!stats.Stats.ContainsKey(client.XUID)) stats.insertNewPerson(client); // heads up display int clientshop = ShopMenu_HUD(client.ClientNum); if (Client_HudElem_Shop.ContainsKey(client.ClientNum)) Client_HudElem_Shop[client.ClientNum] = clientshop; else Client_HudElem_Shop.Add(client.ClientNum, clientshop); } private int ShopMenu_HUD(int ClientNum) { HudElem hud = CreateNewHudElem(); hud.Type = HudElementTypes.Text; hud.ShowToEnt = ClientNum; hud.HideInMenu = true; hud.Font = HudElementFonts.Default; hud.FontScale = 1.1f; hud.PointType = 81; hud.OriginY = 189f; hud.OriginX = 10f; return hud.HudElementNum; } public void deleteHUD(ServerClient client) { if (Client_HudElem_Shop.ContainsKey(client.ClientNum)) { HudElem kd = GetHudElement(Client_HudElem_Shop[client.ClientNum]); kd.Type = HudElementTypes.None; Client_HudElem_Shop.Remove(client.ClientNum); } } public struct PerkInfo { public string perkname; public string cost; public string num; public string perknamreal; public PerkInfo(string wep, string costs, string numz, string fag) { perkname = wep; cost = costs; num = numz; perknamreal = fag; } } public struct WepInfo { public string wepname; public string cost; public string type; public string num; public string realname; public WepInfo(string wep, string costs, string typez, string numz, string fag) { wepname = wep; cost = costs; type = typez; num = numz; realname = fag; } } public Dictionary<String, WepInfo> shopdata = new Dictionary<string, WepInfo>(); public Dictionary<String, PerkInfo> perkdata = new Dictionary<string, PerkInfo>(); public void SV_Shop() { string init = File.ReadAllText(Directory.GetCurrentDirectory() + "/plugins/items.txt"); string[] lines = init.Split('\n'); foreach (string line in lines) { string[] item = line.Split(','); // 0 - func // 1 - item // 2 - cost // 3 - num // 4 - type if (item[0] == "addwep") { shopdata.Add(item[3], new WepInfo(item[1], item[2], item[4], item[3], item[5])); ServerPrint("mShop: Added " + item[1] + " " + item[2] + " " + item[4] + " " + item[3]); } else if (item[0] == "addperk") perkdata.Add(item[3], new PerkInfo(item[1], item[2], item[3], item[4])); else if (item[0] == "set") { if (item[1] == "xppoint") { pointstokill = Convert.ToInt32(item[2]); } else { ServerPrint("mShop - Unknown parameter " + item[1]); } } } foreach (KeyValuePair<String, WepInfo> it in shopdata) { if (it.Value.type == "smg") smg += "\n!" + it.Value.num + "-" + it.Value.realname + "[" + it.Value.cost + "]"; } foreach (KeyValuePair<String, WepInfo> it in shopdata) { if (it.Value.type == "ass") ass += "\n!" + it.Value.num + "-" + it.Value.realname + "[" + it.Value.cost + "]"; } foreach (KeyValuePair<String, WepInfo> it in shopdata) { if (it.Value.type == "sg") sg += "\n!" + it.Value.num + "-" + it.Value.realname + "[" + it.Value.cost + "]"; } foreach (KeyValuePair<String, WepInfo> it in shopdata) { if (it.Value.type == "snip") snip += "\n!" + it.Value.num + "-" + it.Value.realname + "[" + it.Value.cost + "]"; } foreach (KeyValuePair<String, WepInfo> it in shopdata) { if (it.Value.type == "an") an += "\n!" + it.Value.num + "-" + it.Value.realname + "[" + it.Value.cost + "]"; } foreach (KeyValuePair<String, PerkInfo> it in perkdata) { p += "\n!" + it.Value.num + "-" + it.Value.perknamreal + "[" + it.Value.cost + "]"; } // now tell us! ServerPrint("[ENG]: mShop plugin was successfuly loaded!"); ServerPrint("[ENG#RUS] mShop Plugin - Created by SailorMoon ( itsmods.com )"); ServerPrint("[RUS]: mShop ...."); } string smg = ""; string ass = ""; string sg = ""; string snip = ""; string an = ""; string p = ""; public void Update() { HudElem text; List<ServerClient> clients; clients = GetClients(); if (clients != null) { if (clients.Count > 0) { foreach (ServerClient client in GetClients()) { if (client.Ping == 999) continue; if (client.Other.isAlive == true) { if (client.ConnectionState != ConnectionStates.MapLoading) { if (client.ConnectionState != ConnectionStates.Connecting) { if (client.ConnectionState != ConnectionStates.Zombie) { if (menus[client.XUID] == "1") { if (client.Other.ButtonPressed(Buttons.Reload)) { menus[client.XUID] = "2"; } else if (client.Other.ButtonPressed(Buttons.Prone)) { menus[client.XUID] = "3"; } else if (client.Other.ButtonPressed(Buttons.Activate)) { menus[client.XUID] = "4"; } else if (client.Other.ButtonPressed(Buttons.Knife)) { menus[client.XUID] = "5"; } else if (client.Other.ButtonPressed(Buttons.Crouch)) { menus[client.XUID] = "6"; } else if (client.Other.ButtonPressed(Buttons.Sprint)) { menus[client.XUID] = "7"; } } // 1- allies // 11 - axis if (client.Other.ButtonPressed(Buttons.Equipment)) { if (client.Team == Teams.Allies) { if (menus[client.XUID] == "1") { menus[client.XUID] = "0"; } else { menus[client.XUID] = "1"; } } else if (client.Team == Teams.Axis) { if (menus[client.XUID] == "11") { menus[client.XUID] = "0"; } else { menus[client.XUID] = "11"; } } } text = GetHudElement(Client_HudElem_Shop[client.ClientNum]); switch (menus[client.XUID]) { case "0": // closed if (Language[client.XUID] == "eng") text.SetString("^2Q (equipment) key ^7-^3 Shop"); else if (Language[client.XUID] == "rus") text.SetString("^2Q (.) ^7-^3 "); break; case "1": // choose list if (Language[client.XUID] == "eng") text.SetString("R(reload)-SMG\nC(prone)-Assault\nF(use)-Shotguns\nE(knife)-Snips\nCrouch-Another\nShift-Perks\nQ-Back"); else if (Language[client.XUID] == "rus") text.SetString("R()-\nC()-..\nF(.)-\nE()-.\n-\nShift-\nQ-"); break; // weps case "2": // smg text.SetString(smg + "\nQ - Back"); break; case "3": // assault text.SetString(ass + "\nQ - Back"); //text.SetString("!10 -M4[1000]\n!11 -M16[1100]\n!12 -FAD[1600]\n!13 -ACR[1700]\n!14 -T95[1600]\n!15 -M14[1700]\n!17 -G36[1500]\nQ-Back"); break; case "4": // shotguns text.SetString(sg + "\nQ - Back"); // text.SetString("!21 - KSG[1600]\n!22 - SPAS12[1700]\n!23 - USAS12[1650]\nQ - Back"); break; case "5": // snipers text.SetString(snip + "\nQ - Back"); // text.SetString("!18 - Barrett[900]\n!19 - MSR[1900]\n!20 - L96 [1800]\nQ - Back"); break; case "6": // another text.SetString(an + "\nQ - Back"); // text.SetString("!24 - XM25[4000]\n!26 - Desert Eagle[800]\nQ - Back"); break; case "7": // perks text.SetString(p + "\nQ - Back"); // text.SetString("!26-Marathon[1100]\n!27-Longer Sprint[1000]\n!28-FastReload[1400]\n!29-BulletAccuraty[1300]\nQ - Back"); break; // axis case "11": text.SetString("!31 - Throwing Knife[500]\n!32 - JUGGERNAUT ZOMBIE[6000]\n!33-More speed[1000]\n!34- More HP[200]"); break; } } } } } } } } } public ChatType ToDo(ServerClient Client, string Message, int point) { try { // POINTS int points = point; if (Client.Team == Teams.Allies) { foreach (KeyValuePair<String, WepInfo> it in shopdata) { if (Message == "!" + it.Value.num) { if (getPoints(Client.XUID) >= Convert.ToInt32(it.Value.cost)) { if (it.Value.type != "an") GiveWeaponTo(Client, it.Value.wepname, false); else { GiveWeaponTo(Client, it.Value.wepname, true); } UpdatePoints(-Convert.ToInt32(it.Value.cost), Client); } else { if (Language[Client.XUID] == "eng") { iPrintLnBold("^1No enough points!", Client); } else { iPrintLnBold("^1 !", Client); } } return ChatType.ChatNone; } } foreach (KeyValuePair<String, PerkInfo> it in perkdata) { if (Message == "!" + it.Value.num) { if (getPoints(Client.XUID) >= Convert.ToInt32(it.Value.cost)) { Client.Other.SetPerk(GetPerk(it.Value.perkname)); UpdatePoints(-Convert.ToInt32(it.Value.cost), Client); } else { if (Language[Client.XUID] == "eng") { iPrintLnBold("^1No enough points!", Client); } else { iPrintLnBold("^1 !", Client); } } return ChatType.ChatNone; } } } // -------------------------------------------------------------- // if (Message == "!31") { if (Client.Team == Teams.Axis) { if (getPoints(Client.XUID) >= 500) { Client.Other.SetPerk(GetPerk("throwingknife_mp")); Client.Other.EquipementDisabled = true; Client.Other.EquipmentType = EquipementTypes.ThrowingKnife; Client.Other.Equipment = GetWeapon("throwingknife_mp"); } else { if (Language[Client.XUID] == "eng") iPrintLnBold("^1No enough points :(", Client); else iPrintLnBold("^1 :(", Client); } } return ChatType.ChatNone; } if (Message == "!32") { if (Client.Team == Teams.Axis) { if (getPoints(Client.XUID) >= 6000) { isJug[Client.XUID] = true; // jug Client.Other.SetPlayerModel("mp_fullbody_opforce_juggernaut"); hpzom[Client.XUID] = "1000"; Client.Other.Health = Convert.ToInt32(hpzom[Client.XUID]); Client.Other.MaxHealth = Client.Other.Health; } else { if (Language[Client.XUID] == "eng") iPrintLnBold("^1No enough points :(", Client); else iPrintLnBold("^1 :(", Client); } } return ChatType.ChatNone; } if (Message == "!33") { if (Client.Team == Teams.Axis) { if (getPoints(Client.XUID) >= 1000) { speed[Client.XUID] = 1.2f; Client.Other.SpeedScale = 1.2f; } else { if (Language[Client.XUID] == "eng") iPrintLnBold("^1No enough points :(", Client); else iPrintLnBold("^1 :(", Client); } } return ChatType.ChatNone; } if (Message == "!34") { if (Client.Team == Teams.Axis) { if (getPoints(Client.XUID) >= 2000) { hpzom[Client.XUID] = "210"; Client.Other.Health = Convert.ToInt32(hpzom[Client.XUID]); Client.Other.MaxHealth = Client.Other.Health; } else { if (Language[Client.XUID] == "eng") iPrintLnBold("^1No enough points :(", Client); else iPrintLnBold("^1 :(", Client); } } } // -----------------------------------------------------------------// if (Message == "!info") { iPrintLnBold("Created by SailorMoon ( itsmods.com ), type !mp to get points, type !eng or !rus to toggle languages!", Client); } if (Message == "!rus") { Language[Client.XUID] = "rus"; iPrintLnBold(" .", Client); return ChatType.ChatNone; } if (Message == "!eng") { Language[Client.XUID] = "eng"; iPrintLnBold("Language was switched!", Client); return ChatType.ChatNone; } if (Message == "!mp") { switch (Language[Client.XUID]) { case "rus": iPrintLnBold(string.Format(" {0} !", getPoints(Client.XUID)), Client); return ChatType.ChatNone; break; case "eng": iPrintLnBold(string.Format("You have {0} points!", getPoints(Client.XUID)), Client); return ChatType.ChatNone; break; } } // if (Message == "!ABRA") { // UpdatePoints(1000, Client); } // return ChatType.ChatContinue; } catch (Exception z) { ServerPrint(z.Message); return ChatType.ChatContinue; } return ChatType.ChatContinue; } public void GiveWeaponTo(ServerClient client, string weapon, bool issec) { if (issec == false) { int WepSecID = GetWeapon(weapon); client.Other.SecondaryWeapon = WepSecID; client.Other.CurrentWeapon = WepSecID; int clip = 0; int ammo = 0; //Weapons weap = new Weapons(this); // weap.refill(WepSecID, ref ammo, ref clip); client.Ammo.SecondaryAmmo = ammo; client.Ammo.SecondaryAmmoClip = clip * 2; } else if (issec == true) { int WepPist = GetWeapon(weapon); client.Other.PrimaryWeapon = WepPist; int clipsec = 0; int ammosec = 0; //Weapons weap = new Weapons(this); // weap.refill(WepPist, ref ammosec, ref clipsec); client.Ammo.PrimaryAmmo = ammosec; client.Ammo.PrimaryAmmoClip = clipsec * 2; } } } }
[Image: b_560_95_1.png]


[Image: b_560_95_1.png]

Reply

#2
Don't use fast_restart.

Oh, and add 'DeleteHud()' to onMapChange()
C++/Obj-Cdeveloper. Neko engine wip
Steam: Click
Reply

#3
sorry, where would that be? iv'e tried but this keeps happening, then it disappears after 5 seconds or so.


Attached Files Image(s)
   
[Image: b_560_95_1.png]


[Image: b_560_95_1.png]

Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

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