ItsMods

Full Version: Hud help
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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<StringStringmenus = new Dictionary<StringString>();
        public 
Dictionary<StringboolisClassed = new Dictionary<Stringbool>();

        public 
Dictionary<StringStringLanguage = new Dictionary<StringString>();
        private 
Dictionary<StringdoublejustSpawned = new Dictionary<stringdouble>();

        
// zoms
        
public Dictionary<Stringfloatspeed = new Dictionary<Stringfloat>();
        public 
Dictionary<StringStringhpzom = new Dictionary<StringString>();
        public 
Dictionary<StringboolisJug = new Dictionary<stringbool>();

        public 
Dictionary<intintClient_HudElem_Shop = new Dictionary<intint>();

        public 
override ChatType OnSay(string MessageServerClient Clientbool Teamchat)
        {
            
int points getPoints(Client.XUID);
            
ToDo(ClientMessagepoints);

            return 
base.OnSay(MessageClientTeamchat);
        }

        
mw3zombie.Statistics stats;
        
int pointstokill 20;

        public 
override int OnPlayerDamaged(ServerClient AttackerServerClient VictimString WeaponInt32 DamageString DamageModHitLocations HitLocation)
        {
            if (
Damage >= Victim.Other.Health && Attacker.Team != Victim.Team)
            {
                
UpdatePoints(pointstokillVictim);
            }

            return 
base.OnPlayerDamaged(AttackerVictimWeaponDamage);
        }


        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 incServerClient c)
        {
            
stats.updatePoints(incc);
        }

        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.XUID1);
            
isJug.Add(client.XUIDfalse); // 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.ClientNumclientshop);
        }


        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 wepstring costsstring numzstring 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 wepstring costsstring typezstring numzstring fag)
            {
                
wepname wep;
                
cost costs;
                
type typez;
                
num numz;
                
realname fag;
            }
        }

        public 
Dictionary<StringWepInfoshopdata = new Dictionary<stringWepInfo>();
        public 
Dictionary<StringPerkInfoperkdata = new Dictionary<stringPerkInfo>();
        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<StringWepInfoit in shopdata)
            {
                if (
it.Value.type == "smg")
                    
smg += "\n!" it.Value.num "-" it.Value.realname "[" it.Value.cost "]";
            }

            foreach (
KeyValuePair<StringWepInfoit in shopdata)
            {
                if (
it.Value.type == "ass")
                    
ass += "\n!" it.Value.num "-" it.Value.realname "[" it.Value.cost "]";
            }

            foreach (
KeyValuePair<StringWepInfoit in shopdata)
            {
                if (
it.Value.type == "sg")
                    
sg += "\n!" it.Value.num "-" it.Value.realname "[" it.Value.cost "]";
            }

            foreach (
KeyValuePair<StringWepInfoit in shopdata)
            {
                if (
it.Value.type == "snip")
                    
snip += "\n!" it.Value.num "-" it.Value.realname "[" it.Value.cost "]";
            }

            foreach (
KeyValuePair<StringWepInfoit in shopdata)
            {
                if (
it.Value.type == "an")
                    
an += "\n!" it.Value.num "-" it.Value.realname "[" it.Value.cost "]";
            }

            foreach (
KeyValuePair<StringPerkInfoit in perkdata)
            {
                
+= "\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<
ServerClientclients;

            
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("\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 Clientstring Messageint point)
        {
            try
            {

                
// POINTS
                
int points point;

                if (
Client.Team == Teams.Allies)
                {
                    foreach (
KeyValuePair<StringWepInfoit in shopdata)
                    {
                        if (
Message == "!" it.Value.num)
                        {
                            if (
getPoints(Client.XUID) >= Convert.ToInt32(it.Value.cost))
                            {
                                if (
it.Value.type != "an")
                                    
GiveWeaponTo(Clientit.Value.wepnamefalse);
                                else
                                {
                                    
GiveWeaponTo(Clientit.Value.wepnametrue);
                                }

                                
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<StringPerkInfoit 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 clientstring weaponbool 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;
            }
        }

    }

Don't use fast_restart.

Oh, and add 'DeleteHud()' to onMapChange()
sorry, where would that be? iv'e tried but this keeps happening, then it disappears after 5 seconds or so.