Results 1 to 1 of 1
  1. #1
    qwerty939's Avatar
    Join Date
    Dec 2012
    Gender
    male
    Posts
    4
    Reputation
    10
    Thanks
    1

    qczm script help

    why this code with errors?
    Code:
    // QCZM IW5 - TheApadayo & DidUknowiPwn 2012
    // main mod module
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Runtime.InteropServices;
    using InfinityScript;
    
    namespace DUKIP
    {
        public class ZombieMod : BaseScript
        {
            private Random _rng = new Random();
    
            private bool _isIntermission;
            private bool _isGrace;
            private HudElem info;
            private HudElem countdown;
            //private static int hudUpdateRate = 500;
    
            public ZombieMod()
                : base()
            {
                changeGametype("QCZM");
                _isGrace = true;
                Call("setdvar", "motd", "Welcome to ^0QCZM ^7by ^1TheApadayo^7 and ^5DidUknowiPwn^7! Scroll through the shop with " +
                    "^3[{+smoke}] ^7and ^3[{+actionslot 1}]^7. Report all glitches on the 4D1 forums to either ^1TheApadayo^7 or ^5DidUknowiPwn^7.");
                createServerHud();
                Utilities.SetDropItemEnabled(false);
                _rng = new Random();
                string env = getMapEnv(Call<string>("getdvar", "mapname"));
                Call("setdvar", "env1", env);
                Call("precachemodel", "mp_body_ally_ghillie_" + env + "_sniper");
                // viewmodel is different from playermodel on outpost
                if (Call<string>("getdvar", "mapname").Equals("mp_radar"))
                    env = "arctic";
                Call("setdvar", "env2", env);
                Call("precachemodel", "viewhands_iw5_ghillie_" + env);
    
                // zombies won or all zombies left
                OnInterval(5000, () =>
                {
                    if (_isGrace || _isIntermission)
                        return true;
                    if (getTeamCount("allies") == 0 || getTeamCount("axis") == 0)
                    {
                        AfterDelay(3000, () =>
                        {
                            // check again because someone might have been respawning
                            if (getTeamCount("allies") == 0 || getTeamCount("axis") == 0)
                            {
                                CallOnPlayers(entity => doIntermission(entity));
                                doCredits();
                                AfterDelay(3000, () =>
                                {
                                    doGrace(60);
                                });
                            }
                        });
                    }
                    return true;
                });
    
                PlayerConnected += new Action<Entity>(entity =>
                {
                    // dvar shit
                    entity.SetField("connected", 1); // for getplayers func
                    Call("setdvar", "g_TeamName_Allies", "Humans");
                    Call("setdvar", "g_TeamIcon_Allies", "cardicon_comic_price"); //need to change
                    Call("setdvar", "g_TeamName_Axis", "Zombies");
                    Call("setdvar", "g_teamIcon_Axis", "cardicon_skull_black");
                    Call("precacheshader", "cardicon_skull_black");
                    Call("precacheshader", "cardicon_league_magnum");
                    Call("setdvar", "g_ScoresColor_Spectator", ".25 .25 .25");
                    Call("setdvar", "g_ScoresColor_Free", ".76 .78 .10");
                    Call("setdvar", "g_teamColor_MyTeam", ".6 .8 .6");
                    Call("setdvar", "g_teamColor_EnemyTeam", "1 .45 .5");
                    Call("setdvar", "g_teamTitleColor_MyTeam", ".6 .8 .6");
                    Call("setdvar", "g_teamTitleColor_EnemyTeam", "1 .45 .5");
                    Call("setdvar", "ui_allow_teamchange", "0");
                    Call(42, "lowAmmoWarningNoAmmoColor1", 0, 0, 0, 0);
                    Call(42, "lowAmmoWarningNoAmmoColor2", 0, 0, 0, 0);
                    Call(42, "lowAmmoWarningColor1", 0, 0, 0, 0);
                    Call(42, "lowAmmoWarningColor2", 0, 0, 0, 0);
                    Call(42, "lowAmmoWarningNoReloadColor1", 0, 0, 0, 0);
                    Call(42, "lowAmmoWarningNoReloadColor1", 0, 0, 0, 0);
    
                    // custom fields init
                    entity.SetField("lives", 0);
                    entity.SetField("maxhp", 100);
                    entity.SetField("maxhealth", 100);
                    entity.SetField("cash", 0);
                    entity.SetField("credits", 0);
                    entity.SetField("camo", 0);
                    entity.SetField("reticle", 0);
                    entity.SetField("round_zomkills", 0);
                    entity.SetField("round_playerkills", 0);
                    entity.SetField("round_deaths", 0);
                    entity.SetField("totalkills", 0);
                    entity.SetField("hasoverlay", 0);
                    entity.SetField("lethal", "frag_grenade_mp");
                    entity.SetField("zombie_alpha", 0);
                    entity.SetField("zombie_stalker", 0);
                    entity.SetField("zombie_quieter", 0);
                    entity.SetField("zombie_falldamage", 0);
                    entity.SetField("player_thething", 0);
                    entity.SetField("player_antialpha", 0);
                    entity.SetField("movespeed", 1f);
                    GameStore.createStoreHUD(entity);
                    createScorePopup(entity);
                    entity.SpawnedPlayer += new Action(() =>
                    {
                        // should fix the invincible player glitch
                        // caused by a sesionteam/team of ""
                        // also disables spectators... neat
                        if(entity.GetField<string>("sessionteam") != "axis" && entity.GetField<string>("sessionteam") != "allies")
                        {
                            setPlayerTeam(entity, "axis");
                            entity.Call("suicide");
                            return;
                        }
                        entity.TakeAllWeapons();
                        entity.Call("clearPerks");
                        string smg = WeaponUtils.getRandomSMG();
                        entity.AfterDelay(100, player =>
                        {
                            player.SwitchToWeaponImmediate(smg);
                        });
                        if (!entity.HasField("firstspawn"))
                        {
                            createPlayerHud(entity);
                            doPlayerStore(entity);
                            doZombieStore(entity);
                            doCreditStore(entity);
                            entity.SetField("firstspawn", 1);
                        }
                        if (entity.GetField<string>("sessionteam") == "axis")
                        {
                            if (_isGrace)
                            {
                                // switch all players from zombies team during grace
                                setPlayerTeam(entity, "allies");
                                entity.Call("suicide");
                                return;
                            }
                            else
                            {
                                spawnZombie(entity);
                            }
                        }
                        else if (entity.GetField<string>("sessionteam") == "allies")
                        {
                            if (!_isGrace)
                            {
                                if (entity.GetField<int>("lives") > 0 && entity.GetField<int>("zombie_alpha") != 1)
                                {
                                    entity.SetField("lives", entity.GetField<int>("lives") - 1);
                                    entity.Call("iprintlnbold", "Used Life!");
                                }
                                else
                                {
                                    setPlayerTeam(entity, "axis");
                                    entity.SetField("round_deaths", 0); // reset deaths on team change
                                    entity.Call("suicide");
                                    return;
                                }
                            }
                            spawnPlayer(entity);
                        }
                    });
    
                    // skip start menu
                    entity.OnNotify("joined_team", player =>
                    {
                        entity.Call("closePopupMenu");
                        entity.Call("closeIngameMenu");
                        entity.Notify("menuresponse", "changeclass", "class0");
                        // hide the default xp popup
                        // need a field id number
                        // entity.GetField<HudElem>("hud_xpPointsPopup").SetPoint("TOPLEFT", "TOPLEFT", -200);
                    });
    
                    // disable changeclass menu
                    entity.OnNotify("menuresponse", (player, menu, response) =>
                    {
                        if (men*****String().Equals("class") && response.ToString().Equals("changeclass_marines"))
                        {
                            AfterDelay(100, () =>
                            {
                                entity.Notify("menuresponse", "changeclass", "back");
                            });
                        }
                    });
    
                    entity.Notify("menuresponse", "team_marinesopfor", "allies");
    
                    // handle speed changes
                    OnInterval(100, () =>
                    {
                        entity.Call("setmovespeedscale", new Parameter(entity.GetField<float>("movespeed")));
                        return true;
                    });
                });
                OnNotify("prematch_done", () =>
                {
                    doGrace(60);
                });
            }
    
            public override void OnSay(Entity player, string name, string message)
            {
                if (!(Call<int>("getdvarint", "mapedit_allowcheats") == 1 && (player.GetField<string>("name") == "TheApadayo" || player.GetField<string>("name") == "DidUknowiPwn")))
                    return;
                if (message.Equals("endround"))
                {
                    CallOnPlayers(entity => doIntermission(entity));
                    doCredits();
                    AfterDelay(3000, () =>
                    {
                        doGrace(60);
                    });
                }
            }
    
            private void spawnZombie(Entity entity)
            {
                if (entity.GetField<int>("zombie_alpha") == 1)
                {
                    entity.SetField("cash", 50);
                    entity.SetField("maxhp", 150);
                    entity.SetField("zombie_alpha", 0);
                }
                if (entity.GetField<int>("zombie_quieter") == 1)
                {
                    entity.SetPerk("specialty_quieter", true, false);
                }
                if (entity.GetField<int>("zombie_stalker") == 1)
                {
                    entity.SetPerk("specialty_stalker", true, false);
                }
                if (entity.GetField<int>("zombie_falldamage") == 1)
                {
                    entity.SetPerk("zombie_falldamage", true, false);
                }
                entity.Call("setmodel", "mp_body_ally_ghillie_" + Call<string>("getdvar", "env1") + "_sniper");
                entity.Call("setviewmodel", "viewhands_iw5_ghillie_" + Call<string>("getdvar", "env2"));
                entity.Call("closePopupMenu");
                entity.Call("closeIngameMenu");
                entity.TakeWeapon("frag_grenade_mp");
                entity.Call("giveweapon", "iw5_usp45_mp_tactical");
                entity.Call("setWeaponAmmoClip", "iw5_usp45_mp_tactical", "0");
                entity.Call("setWeaponAmmoStock", "iw5_usp45_mp_tactical", "0");
                entity.SetPerk("specialty_lightweight", true, true);
                entity.SetPerk("specialty_longersprint", true, true);
                entity.Call("visionsetnakedforplayer", "ac130_thermal_mp", 0);
                entity.SetField("maxhealth", entity.GetField<int>("maxhp"));
                entity.Health = entity.GetField<int>("maxhp");
                entity.AfterDelay(1, player =>
                {
                    player.SwitchToWeaponImmediate("iw5_usp45_mp_tactical");
                });
                if (entity.GetField<int>("hasoverlay") == 1)
                {
                    entity.Call("ThermalVisionFOFOverlayOn"); // in case they bought it
                }
                entity.SetField("movespeed", 1.14f); //give them a slight speed increase
    
                // custom scoring part 2
                AfterDelay(1, () =>
                {
                    int kills = entity.GetField<int>("round_zomkills");
                    entity.SetField("score", kills * 100);
                    entity.SetField("deaths", entity.GetField<int>("round_deaths"));
                    entity.SetField("kills", kills);
                });
            }
            private void spawnPlayer(Entity entity)
            {
                entity.Call("closePopupMenu");
                entity.Call("closeIngameMenu");
                //entity.Notify("menuresponse", "changeclass", "class1"); <- Was fucking up the give weapon on spawn >_>
                entity.TakeAllWeapons();
                int camo = entity.GetField<int>("camo");
                int reticle = entity.GetField<int>("reticle");
                string smg = WeaponUtils.getRandomSMG(camo, reticle);
                entity.Call("giveweapon", smg);
                entity.Call("giveMaxAmmo", smg);
                string shotgun = WeaponUtils.getRandomShotgun(camo, reticle);
                entity.Call("giveweapon", shotgun);
                entity.Call("giveMaxAmmo", shotgun);
                string pistol = WeaponUtils.getRandomPistol(camo, reticle);
                entity.Call("giveweapon", pistol);
                entity.Call("giveMaxAmmo", pistol);
                entity.Call("giveweapon", entity.GetField<string>("lethal"));
                entity.SetField("fragcount", 5);
                entity.Call("setweaponammoclip", entity.GetField<string>("lethal"), 0);
                if (_isGrace) // if player respawned during game (with lives) dont reset their cash
                    entity.SetField("cash", 0);
                    //entity.Call("visionsetnaked", "cobra_sunset3", true);
                entity.SetField("movespeed", 1f); // make sure they have normal speed
                entity.AfterDelay(100, player =>
                {
                    player.SwitchToWeaponImmediate(smg);
                });
                OnNotify("prematch_done", () =>
                {
                    entity.SwitchToWeaponImmediate(smg);
                });
                entity.OnInterval(100, player =>
                {
                    if (_isGrace) return true;
                    if (entity.Call<int>("getammocount", entity.GetField<string>("lethal")) == 0 && entity.GetField<int>("fragcount") > 0)
                    {
                        entity.Call("setweaponammoclip", entity.GetField<string>("lethal"), 1);
                        entity.SetField("fragcount", entity.GetField<int>("fragcount") - 1);
                    }
                    return true;
                });
    
                // custom scoring part 2
                AfterDelay(1, () =>
                {
                    int kills = entity.GetField<int>("round_playerkills");
                    entity.SetField("score", 0);
                    entity.SetField("deaths", entity.GetField<int>("round_deaths"));
                    entity.SetField("kills", kills);
                });
            }
    
            public override void OnPlayerKilled(Entity player, Entity inflictor, Entity attacker, int damage, string mod, string weapon, Vector3 dir, string hitLoc)
            {
                string playerWeapon = player.CurrentWeapon;
                // cleanup weapons
                OnInterval(100, () =>
                {
                    Entity ent = Call<Entity>("getent", "weapon_" + playerWeapon, "classname");
                    if (ent != null)
                    {
                        ent.Call("delete");
                        return false;
                    }
                    else
                    {
                        return true;
                    }
                });
                // custom score part 1
                if (attacker != null)
                {
                    if (attacker.IsPlayer && attacker.IsAlive)
                    {
                        if (attacker.GetField<string>("sessionteam") == "allies")
                        {
                            // do custom scoring
                            AfterDelay(1, () =>
                            {
                                int kills = attacker.GetField<int>("round_playerkills");
                                attacker.SetField("score", kills * 100);
                                attacker.SetField("deaths", 0);
                                attacker.SetField("kills", kills);
                                kills = player.GetField<int>("round_zomkills");
                                player.SetField("score", kills * 100);
                                player.SetField("deaths", player.GetField<int>("round_deaths"));
                                player.SetField("kills", kills);
                            });
                        }
                        else
                        {
                            AfterDelay(1, () =>
                            {
                                int kills = attacker.GetField<int>("round_zomkills");
                                attacker.SetField("score", kills * 100);
                                attacker.SetField("deaths", player.GetField<int>("round_deaths"));
                                attacker.SetField("kills", kills);
                                player.SetField("score", 0);
                                player.SetField("deaths", 0);
                                player.SetField("kills", 0);
                            });
                        }
                    }
                }
    
                // stuff after only happens when in game
                if (_isIntermission || _isGrace) return;
                // game called suicide... ignore these
                if (player == inflictor && inflictor == attacker) return;
    
                // award score
                if (attacker != null)
                {
                    if (attacker.IsPlayer && attacker.IsAlive)
                    {
                        if (attacker.GetField<string>("sessionteam") == "allies")
                        {
                            if (mod == "MOD_MELEE")
                            {
                                attacker.SetField("cash", attacker.GetField<int>("cash") + 200);
                                //attacker.Call("iprintlnbold", "Melee Kill! ^1+200");
                                doScorePopUp(attacker, "Melee Kill! ^1+{0}", 200);
                                attacker.SetField("round_playerkills", attacker.GetField<int>("round_playerkills") + 1);
                            }
                            else
                            {
                                attacker.SetField("cash", attacker.GetField<int>("cash") + 50);
                                //attacker.Call("iprintlnbold", "Killed Zombie. ^1+50");
                                doScorePopUp(attacker, "Killed Zombie. ^1+{0}", 50);
                                attacker.SetField("round_playerkills", attacker.GetField<int>("round_playerkills") + 1);
                            }
                            player.SetField("cash", player.GetField<int>("cash") + 50);
                            player.SetField("round_deaths", player.GetField<int>("round_deaths") + 1);
                            //player.Call("iprintlnbold", "Died! ^1+50");
                            doScorePopUp(player, "Died! ^1+{0}", 50);
                        }
                        else
                        {
                            attacker.SetField("cash", attacker.GetField<int>("cash") + 100);
                            //attacker.Call("iprintlnbold", "Killed Human! ^1+100");
                            doScorePopUp(attacker, "Killed Human! ^1+{0}", 100);
                            attacker.SetField("round_zomkills", attacker.GetField<int>("round_zomkills") + 1);
                            player.SetField("round_deaths", player.GetField<int>("round_deaths") + 1);
                        }
                    }
                }
            }
    
            private void doIntermission(Entity entity)
            {
                _isIntermission = true;
                entity.Call("freezecontrols", true);
                Call("visionsetnaked", "blacktest", 2);
                info.SetText("^1Round is over. ^7Prepare for the next round");
                AfterDelay(1500, () =>
                {
                    info.Call("destroy");
                });
                AfterDelay(3000, () =>
                {
                    entity.Call("freezecontrols", false);
                    Call("visionsetnaked", Call<string>("getdvar", "mapname"));
                    entity.Call("ThermalVisionFOFOverlayOff"); // in case they bought it
                    entity.Call("suicide");
                    _isIntermission = false;
                    MapEdit.runOnUsable((center) =>
                    {
                        center.Call(33399, new Parameter(center.GetField<Vector3>("open")), 1); // moveto
                        center.SetField("state", "open");
                        center.SetField("hp", center.GetField<int>("maxhp"));
                        return true;
                    }, "door");
                    //doGrace(60);
                });
            }
    
            private void doCredits()
            {
                List<Entity> players = getPlayers(false).ToList<Entity>();
                List<Entity> zombies = new List<Entity>();
                players.Sort(delegate(Entity e1, Entity e2)
                {
                    return e1.GetField<int>("round_playerkills").CompareTo(e2.GetField<int>("round_playerkills"));
                });
                players.Reverse();
                int playercount = (int)(players.Count * 0.3);
                //print("top 30 percent is {0}", playercount);
                int i = 0;
    
                if (playercount > players.Count)
                    playercount = players.Count;
    
                foreach (Entity p in players)
                {
                    if (i < playercount)
                    {
                        p.Call("iprintlnbold", "You were rank ^3" + (i + 1) + "^7 as a human. You get " + (p.GetField<int>("round_playerkills") * 50) + " Credits!");
                        p.SetField("credits", p.GetField<int>("credits") + (p.GetField<int>("round_playerkills") * 50));
                        //print("Player {0} placed {1} with {2} kills", i, p.GetField<string>("name"), p.GetField<int>("round_playerkills"));
                    }
                    else
                    {
                        p.Call("iprintlnbold", "You did not place this round");
                        //print("Player {0} did not place {1} with {2} kills", i, p.GetField<string>("name"), p.GetField<int>("round_playerkills"));
                        zombies.Add(p);
                    }
                    p.SetField("round_playerkills", 0);
                    p.SetField("round_deaths", 0);
                    i++;
                }
    
                if (playercount > zombies.Count)
                    playercount = zombies.Count;
    
                zombies.Sort(delegate(Entity e1, Entity e2)
                {
                    return e1.GetField<int>("round_zomkills").CompareTo(e2.GetField<int>("round_zomkills"));
                });
                zombies.Reverse();
                i = 0;
                foreach (Entity p in zombies)
                {
                    if (i < playercount)
                    {
                        p.Call("iprintlnbold", "You were rank ^1" + (i + 1) + "^7 as a zombie. You get " + (p.GetField<int>("round_zomkills") * 50) + " Credits!");
                        p.SetField("credits", p.GetField<int>("credits") + (p.GetField<int>("round_zomkills") * 200));
                        //print("Zombie {0} placed {1} with {2} kills", i, p.GetField<string>("name"), p.GetField<int>("round_zomkills"));
                    }
                    else
                    {
                        p.Call("iprintlnbold", "You did not place this round"); 
                        //print("Zombie {0} did not place {1} with {2} kills", i, p.GetField<string>("name"), p.GetField<int>("round_zomkills"));
                    }
                    p.SetField("round_zomkills", 0);
                    i++;
                }
            }
    
            private void doGrace(int seconds)
            {
                //info.SetText("^2Prepare for ^1Alphas!");
                print("began grace period for {0} seconds", seconds);
                _isGrace = true;
                int waited = seconds;
                // reset perks
                CallOnPlayers((ent) =>
                {
                    ent.SetField("zombie_stalker", 0);
                    ent.SetField("zombie_quieter", 0);
                    //ent.SetField("zombie_falldamage", 0);
                    ent.SetField("hasoverlay", 0);
                });
                OnInterval(1000, () =>
                {
                    if (waited == 0)
                    {
                        return false;
                    }
                    countdown.SetText("^3" + waited.ToString() + " seconds remaining until round begins.");
                    if (waited < 11)
                    {
                        // ticking
                        // ui_mp_suitcasebomb_timer
                        CallOnPlayers((ent) => ent.Call("playlocalsound", "ui_mp_nukebomb_timer"));
                    }
                    waited--;
                    return true;
                });
                AfterDelay(seconds * 1000, () =>
                {
                    info.SetText("^2Alphas ^7Have Spawned!");
                    countdown.SetText("");
                    _isGrace = false;
                    doAlpha(); // call after _isGrace is false so when people die they respawn as zombies.
                    OnInterval(100, () => // fade out text
                    {
                        if (info.Alpha == 0)
                        {
                            info.SetText("");
                            info.Alpha = 1;
                            return false;
                        }
                        info.Alpha -= 0.02f; // should last 5 seconds
                        return true;
                    });
                    // shouldnt crash now as it checkes for lethal existing as well as 
                    // player list not including those without conencted....
                    CallOnPlayers(entity =>
                    {
                        if (!entity.HasField("lethal")) return; // connecting
                        entity.Call("setweaponammoclip", entity.GetField<string>("lethal"), 1);
                        entity.Call("playlocalsound", "mp_war_objective_taken");
                        Call("visionsetnaked", "cobra_sunset3", true);
                    });
                });
            }
    
            private void doAlpha()
            {
                List<Entity> players = getPlayers(false).ToList<Entity>();
                for (int i = 0; i < players.Count; i++)
                {
                    if (players.ElementAt(i).GetField<string>("sessionteam").Equals("spectator"))
                    {
                        players.RemoveAt(i);
                        i--;
                    }
                }
                AfterDelay(3000, () =>
                {
                    info.Call("destroy");
                });
                // no one on server, just do grace period
                if (players.Count == 0)
                {
                    _isIntermission = true;
                    print("no players found in server, redoing grace period.");
                    doGrace(60);
                    return;
                }
                int alphas = 0;
                int[] alphaindex = { -1, -1, -1 };
                _rng = new Random();
                if (players.Count < 5)
                {
                    alphaindex[0] = _rng.Next(players.Count - 1);
                    alphas = 1;
                }
                else if (players.Count < 14)
                {
                    alphaindex[0] = _rng.Next(players.Count - 1);
    
                    alphaindex[1] = _rng.Next(players.Count - 1);
                    while(alphaindex[0] == alphaindex[1])
                        alphaindex[1] = _rng.Next(players.Count - 1);
    
                    alphas = 2;
                }
                else
                {
                    alphaindex[0] = _rng.Next(players.Count - 1);
    
                    alphaindex[1] = _rng.Next(players.Count - 1);
                    while (alphaindex[0] == alphaindex[1])
                        alphaindex[1] = _rng.Next(players.Count - 1);
                    
                    alphaindex[2] = _rng.Next(players.Count - 1);
                    while (alphaindex[0] == alphaindex[2] || alphaindex[1] == alphaindex[2])
                        alphaindex[2] = _rng.Next(players.Count - 1);
    
                    alphas = 3;
                }
                print("there are {0} players in server... chosing {1} alphas", players.Count, alphas);
    
                for (int i = 0; i < alphas; i++)
                {
                    players[alphaindex[i]].Call("suicide");
                    players[alphaindex[i]].SetField("zombie_alpha", 1);
                }
            }
    
            private void createServerHud()
            {
                info = HudElem.CreateServerFontString("hudbig", 1f);
                info.SetPoint("CENTER", "CENTER", 0, -200);
                info.HideWhenInMenu = true;
                info.SetText("");
    
                countdown = HudElem.CreateServerFontString("hudbig", 0.8f);
                countdown.SetPoint("CENTER", "CENTER", 0, -180);
                countdown.HideWhenInMenu = true;
                countdown.SetText("");
    
                HudElem motd = HudElem.CreateServerFontString("boldFont", 1f);
                motd.SetPoint("CENTER", "BOTTOM", 0, -19);
                motd.Foreground = true;
                motd.HideWhenInMenu = true;
                OnInterval(25000, () =>
                {
                    motd.SetText(Call<string>("getdvar", "motd"));
                    motd.SetPoint("CENTER", "BOTTOM", 1100, -10);
                    motd.Call("moveovertime", 25);
                    motd.X = -700;
                    return true;
                });
            }
    
            private void createPlayerHud(Entity player)
            {
                HudElem health = HudElem.CreateFontString(player, "hudbig", 0.9f);
                health.SetPoint("TOP RIGHT", "TOP RIGHT", -10, 0);
                health.HideWhenInMenu = true;
    
                HudElem healthtext = HudElem.CreateFontString(player, "hudbig", 0.9f);
                healthtext.SetPoint("TOP RIGHT", "TOP RIGHT", -50, 0);
                healthtext.HideWhenInMenu = true;
    
                HudElem money = HudElem.CreateFontString(player, "hudbig", 0.9f);
                money.SetPoint("TOP RIGHT", "TOP RIGHT", -10, 15); //25 original
                money.HideWhenInMenu = true;
    
                HudElem moneytext = HudElem.CreateFontString(player, "hudbig", 0.9f);
                moneytext.SetPoint("TOP RIGHT", "TOP RIGHT", -50, 15); //25 original
                moneytext.HideWhenInMenu = true;
    
                HudElem lives = HudElem.CreateFontString(player, "hudbig", 0.9f);
                lives.SetPoint("TOP RIGHT", "TOP RIGHT", -10, 30); //50 original
                lives.HideWhenInMenu = true;
    
                HudElem livestext = HudElem.CreateFontString(player, "hudbig", 0.9f);
                livestext.SetPoint("TOP RIGHT", "TOP RIGHT", -50, 30); //50 original
                livestext.HideWhenInMenu = true;
    
                OnInterval(100, () =>
                {
                    health.Call("setvalue", player.Health);
                    healthtext.Call("settext", "^1Health: ^7");
    
                    if (!_isGrace)
                    {
                        moneytext.SetText("^2Cash: ^7");
                        money.Call("setvalue", player.GetField<int>("cash"));
                    }
                    else
                    {
                        moneytext.SetText("^2Credits: ^7");
                        money.Call("setvalue", player.GetField<int>("credits"));
                    }
                    livestext.SetText("^3Lives: ^7");
                    lives.Call("setvalue", player.GetField<int>("lives"));
                    return true;
                });
            }
    
            private void doPlayerStore(Entity player)
            {
                GameStore store = new GameStore(player);
                store.doStoreWhen(() =>
                {
                    return (player.GetField<string>("sessionteam") == "allies" && !_isGrace);
                });
    
                GameStore.StoreEntry entry = new GameStore.StoreEntry();
                entry.name = "Buy ammo for current weapon";
                entry.price = 100;
                entry.action = new Func<string>(() =>
                {
                    if (player.CurrentWeapon.Equals("defaultweapon_mp")) return "Cannot buy ammo for the Door repair tool!";
                    player.Call("givemaxammo", player.CurrentWeapon);
                   // player.Call("iprintlnbold", "Bought Max Ammo");
                   // ScorePopUp(player, "Derpies");
                    return "";
                });
                entry.remainingbuys = -1;
                store.addEntry(entry);
    
                entry = new GameStore.StoreEntry();
                entry.name = "Upgrade Weapon";
                entry.price = 150;
                entry.action = new Func<string>(() =>
                {
                    return upgradeWeapon(player);
                });
                entry.remainingbuys = 3;
                store.addEntry(entry);
    
                entry = new GameStore.StoreEntry();
                entry.name = "Buy Riotshield";
                entry.price = 250;
                entry.action = new Func<string>(() =>
                {
                    player.GiveWeapon("riotshield_mp");
                    player.SwitchToWeaponImmediate("riotshield_mp");
                    player.Call("iprintlnbold", "Bought Riotshield");
                    return "";
                });
                entry.remainingbuys = 1;
                store.addEntry(entry);
    
                entry = new GameStore.StoreEntry();
                entry.name = "Upgrade to Akimbo";
                entry.price = 150;
                entry.action = new Func<string>(() =>
                {
                    return giveAttachment(player, "akimbo");
                });
                entry.remainingbuys = -1;
                store.addEntry(entry);
    
                entry = new GameStore.StoreEntry();
                entry.name = "Upgrade to XMags";
                entry.price = 150;
                entry.action = new Func<string>(() =>
                {
                    return giveAttachment(player, "xmags");
                });
                entry.remainingbuys = -1;
                store.addEntry(entry);
    
                entry = new GameStore.StoreEntry();
                entry.name = "Upgrade to Red Dot";
                entry.price = 50;
                entry.action = new Func<string>(() =>
                {
                    return giveAttachment(player, "reflex");
                });
                entry.remainingbuys = -1;
                store.addEntry(entry);
    
                entry = new GameStore.StoreEntry();
                entry.name = "Buy Sleight of Hand";
                entry.price = 100;
                entry.action = new Func<string>(() =>
                {
                    /*if (player.Call<int>("hasperk", "specialty_fastreload") > 0)
                    {
                        player.SetPerk("specialty_quickswap", true, false);
                        player.Call("iprintlnbold", "Bought ^2Sleight of Hand Pro!");
                        return "";
                    }*/
                    player.SetPerk("specialty_fastreload", true, false);
                    player.Call("iprintlnbold", "Bought ^2Sleight of Hand!");
                    return "";
                });
                entry.remainingbuys = 1;
                /*entry.formatName = new Func<string>(() =>
                {
                    if (player.Call<int>("hasperk", "specialty_fastreload") > 0)
                        return entry.name + " Pro - " + entry.price;
                    else
                        return entry.name + " - " + entry.price;
                });*/
                store.addEntry(entry);
    
                entry = new GameStore.StoreEntry();
                entry.name = "Buy Sitrep";
                entry.price = 100;
                entry.action = new Func<string>(() =>
                {
                    /*if (player.Call<int>("hasperk", "specialty_detectexplosive") > 0)
                    {
                        player.SetPerk("specialty_selectivehearing", true, false);
                        player.Call("iprintlnbold", "Bought ^2Sitrep Pro!");
                        return "";
                    }*/
                    player.SetPerk("specialty_detectexplosive", true, false);
                    player.Call("iprintlnbold", "Bought ^2Sitrep!");
                    return "";
                });
                entry.remainingbuys = 1;
                /*entry.formatName = new Func<string>(() =>
                {
                    if (player.Call<int>("hasperk", "specialty_detectexplosive") > 0)
                        return entry.name + " Pro - " + entry.price;
                    else
                        return entry.name + " - " + entry.price;
                });*/
                store.addEntry(entry);
    
                entry = new GameStore.StoreEntry();
                entry.name = "Buy Steady Aim";
                entry.price = 100;
                entry.action = new Func<string>(() =>
                {
                    /*if (player.Call<int>("hasperk", "specialty_bulletaccuracy") > 0)
                    {
                        player.SetPerk("specialty_fastsprintrecovery", true, false);
                        player.Call("iprintlnbold", "Bought ^2Steady Aim Pro!");
                        return "";
                    }*/
                    player.SetPerk("specialty_bulletaccuracy", true, false);
                    player.Call("iprintlnbold", "Bought ^4Steady Aim!");
                    return "";
                });
                entry.remainingbuys = 1;
                /*entry.formatName = new Func<string>(() =>
                {
                    if (player.Call<int>("hasperk", "specialty_bulletaccuracy") > 0)
                        return entry.name + " Pro - " + entry.price;
                    else
                        return entry.name + " - " + entry.price;
                });*/
                store.addEntry(entry);
    
                entry = new GameStore.StoreEntry();
                entry.name = "Buy Scavenger";
                entry.price = 100;
                entry.action = new Func<string>(() =>
                {
                    /*if (player.Call<int>("hasperk", "specialty_scavenger") > 0)
                    {
                        player.SetPerk("specialty_extraammo", true, false);
                        player.Call("iprintlnbold", "Bought ^2Scavenger Pro!");
                        return "";
                    }*/
                    player.SetPerk("specialty_scavenger", true, false);
                    player.Call("iprintlnbold", "Bought ^5Scavenger!");
                    return "";
                });
                entry.remainingbuys = 1;
                /*entry.formatName = new Func<string>(() =>
                {
                    if (player.Call<int>("hasperk", "specialty_scavenger") > 0)
                        return entry.name + " Pro - " + entry.price;
                    else
                        return entry.name + " - " + entry.price;
                });*/
                store.addEntry(entry);
    
                entry = new GameStore.StoreEntry();
                entry.name = "Buy Dead Silence";
                entry.price = 100;
                entry.action = new Func<string>(() =>
                {
                    /*if (player.Call<int>("hasperk", "specialty_quieter") > 0)
                    {
                        player.SetPerk("specialty_falldamage", true, false);
                        player.Call("iprintlnbold", "Bought ^8Dead Silence Pro!");
                        return "";
                    }*/
                    player.SetPerk("specialty_quieter", true, false);
                    player.Call("iprintlnbold", "Bought ^8Dead Silence!");
                    return "";
                });
                entry.remainingbuys = 1;
                /* entry.formatName = new Func<string>(() =>
                 {
                     if (player.Call<int>("hasperk", "specialty_quieter") > 0)
                         return entry.name + " Pro - " + entry.price;
                     else
                         return entry.name + " - " + entry.price;
                 });*/
                store.addEntry(entry);
    
                entry = new GameStore.StoreEntry();
                entry.name = "Buy Stalker";
                entry.price = 100;
                entry.action = new Func<string>(() =>
                {
                    /*if (player.Call<int>("hasperk", "specialty_stalker") > 0)
                    {
                        player.SetPerk("specialty_delaymine", true, false);
                        player.Call("iprintlnbold", "Bought ^6Stalker Pro!");
                        return "";
                    }*/
                    player.SetPerk("specialty_stalker", true, false);
                    player.Call("iprintlnbold", "Bought ^6Stalker!");
                    return "";
                });
                entry.remainingbuys = 1;
                /*entry.formatName = new Func<string>(() =>
                {
                    if (player.Call<int>("hasperk", "specialty_stalker") > 0)
                        return entry.name + " Pro - " + entry.price;
                    else
                        return entry.name + " - " + entry.price;
                });*/
                store.addEntry(entry);
    
                entry = new GameStore.StoreEntry();
                entry.name = "Buy Marksman";
                entry.price = 100;
                entry.action = new Func<string>(() =>
                {
                    /*if (player.Call<int>("hasperk", "specialty_marksman") > 0)
                    {
                        player.SetPerk("specialty_holdbreath", true, false);
                        player.Call("iprintlnbold", "Bought ^7Marksman Pro!");
                        return "";
                    }*/
                    player.SetPerk("specialty_marksman", true, false);
                    player.Call("iprintlnbold", "Bought ^7Marksman!");
                    return "";
                });
                entry.remainingbuys = 1;
                /*entry.formatName = new Func<string>(() =>
                {
                    if (player.Call<int>("hasperk", "specialty_marksman") > 0)
                        return entry.name + " Pro - " + entry.price;
                    else
                        return entry.name + " - " + entry.price;
                });*/
                store.addEntry(entry);
    
                // meh... actually fixed it
                entry = new GameStore.StoreEntry();
                entry.name = "Buy Door Repair Tool";
                entry.price = 250;
                entry.action = new Func<string>(() =>
                {
                    player.GiveWeapon("defaultweapon_mp");
                    AfterDelay(100, () => player.SwitchToWeaponImmediate("defaultweapon_mp"));
                    player.SetField("repairsleft", 10);
                    player.Call("iprintlnbold", "Bought ^7Door Repair Tool!");
                    return "";
                });
                entry.remainingbuys = 1;
                store.addEntry(entry);
    
                entry = new GameStore.StoreEntry();
                entry.name = "Buy The Thing";
                entry.price = 100;
                entry.action = new Func<string>(() =>
                {
                    if (player.GetField<int>("player_thething") != 1)
                        return "[Locked]";
                    player.Call("iprintlnbold", "Bought ^1The Thing!");
                    player.Call("giveweapon", "iw5_deserteagle_mp"); //iw5_m60jugg_mp
                    doCustomWeapon(player, "iw5_deserteagle", "ac130_25mm_mp");
                    player.AfterDelay(100, entity =>
                    {
                        player.SwitchToWeaponImmediate("iw5_deserteagle_mp"); //iw5_m60jugg_mp
                    });
                    /*OnInterval(100, () =>
                    {
                        if(player.CurrentWeapon.Equals("iw5_desertagle_mp"))
                         {
                            player.Call("recoilscaleon", 0f);
                            return true;
                         }
                        return false;
                    });*/ //Still being stupid I see.
                    return "";
                });
                entry.remainingbuys = 1;
                entry.formatName = new Func<string>(() =>
                {
                    if (player.GetField<int>("player_thething") != 1)
                        return "Locked";
                    return "Buy The Thing - 100";
                });
                store.addEntry(entry);
    
                entry = new GameStore.StoreEntry();
                entry.name = "Suicide";
                entry.price = 0;
                entry.action = new Func<string>(() =>
                {
                    player.Call("suicide");
                    return "";
                });
                entry.remainingbuys = -1;
                entry.formatName = new Func<string>(() =>
                {
                    return "Suicide";
                });
                store.addEntry(entry);
            }
    
            private void doZombieStore(Entity player)
            {
                GameStore store = new GameStore(player);
                store.doStoreWhen(() =>
                {
                    return (player.GetField<string>("sessionteam") == "axis" && !_isGrace);
                });
    
                GameStore.StoreEntry entry = new GameStore.StoreEntry();
                entry.name = "Increase Max Health";
                entry.price = 50;
                entry.action = new Func<string>(() =>
                {
                    if (player.GetField<int>("maxhp") == 1500)
                    {
                        return "Maximum health cannot be increased more!";
                    }
                    player.SetField("maxhp", player.GetField<int>("maxhp") + 50);
                    player.SetField("maxhealth", player.GetField<int>("maxhp"));
                    player.Health = player.GetField<int>("maxhp");
                    player.Call("iprintlnbold", "Increased Max Health");
                    return "";
                });
                entry.remainingbuys = -1;
                store.addEntry(entry);
    
                /*entry = new GameStore.StoreEntry();
                entry.name = "View Health";
                entry.price = 0;
                entry.action = new Func<string>(() =>
                {
                    player.Call("iprintlnbold", "Health is at: ^1" + player.Health + "^0/^1" + player.GetField<int>("maxhp"));
                    return "";
                });
                entry.remainingbuys = -1;
                store.addEntry(entry);*/
    
                entry = new GameStore.StoreEntry();
                entry.name = "Buy Thermal Overlay";
                entry.price = 200;
                entry.action = new Func<string>(() =>
                {
                    player.Call("ThermalVisionFOFOverlayOn");
                    player.SetField("hasoverlay", 1);
                    player.Call("iprintlnbold", "Bought Thermal Overlay");
                    return "";
                });
                entry.remainingbuys = 1;
                store.addEntry(entry);
    
                entry = new GameStore.StoreEntry();
                entry.name = "Buy Throwing Knife";
                entry.price = 300;
                entry.action = new Func<string>(() =>
                {
                    player.Call("SetOffhandPrimaryClass", "throwingknife");
                    player.GiveWeapon("throwingknife_mp");
                    player.Call("setweaponammoclip", "throwingknife_mp", 1);
                    player.Call("iprintlnbold", "Bought a Throwing Knife");
                    return "";
                });
                entry.remainingbuys = -1;
                store.addEntry(entry);
    
                entry = new GameStore.StoreEntry();
                entry.name = "Buy Stalker";
                entry.price = 200;
                entry.action = new Func<string>(() =>
                {
                    player.SetPerk("specialty_stalker", true, true);
                    player.SetField("zombie_stalker", 1);
                    player.Call("iprintlnbold", "Bought Stalker!");
                    return "";
                });
                entry.remainingbuys = 1;
                store.addEntry(entry);
    
                entry = new GameStore.StoreEntry();
                entry.name = "Buy Dead Silence";
                entry.price = 200;
                entry.action = new Func<string>(() =>
                {
                    player.SetPerk("specialty_quieter", true, true);
                    player.SetField("zombie_quieter", 1);
                    player.Call("iprintlnbold", "Bought Dead Silence!");
                    return "";
                });
                entry.remainingbuys = 1;
                store.addEntry(entry);
    
              /*  entry = new GameStore.StoreEntry();
                entry.name = "Buy No Fall Damage";
                entry.price = 300;
                entry.action = new Func<string>(() =>
                    {
                        player.SetPerk("specialty_falldamage", true, true);
                        player.SetField("zombie_falldamage", 1);
                        player.Call("iprintlnbold", "Bought No Fall Damage!");
                        return "";
                    });
                entry.remainingbuys = 1;
                store.addEntry(entry);*/ //Not working for some reason.
               
                entry = new GameStore.StoreEntry();
                entry.name = "Buy Increased Speed";
                entry.price = 300;
                entry.action = new Func<string>(() =>
                {
                   // if (player.GetField<int>("movespeed") == 1.5f)
                     //   return "Already Bought!";
                    player.Call("iprintlnbold", "Bought Increased Speed!");
                    player.SetField("movespeed", 1.5f);
                    return "";
                });
                entry.remainingbuys = 1;
                store.addEntry(entry);
    
                entry = new GameStore.StoreEntry();
                entry.name = "Suicide";
                entry.price = 0;
                entry.action = new Func<string>(() =>
                {
                    player.Call("suicide");
                    return "";
                });
                entry.remainingbuys = -1;
                entry.formatName = new Func<string>(() =>
                {
                    return "Suicide";
                });
                store.addEntry(entry);
    
            }
    
            private void doCreditStore(Entity player)
            {
                GameStore store = new GameStore(player);
                store.doStoreWhen(() =>
                {
                    return _isGrace;
                });
                store.setCurrencyField("credits");
    
                GameStore.StoreEntry entry = new GameStore.StoreEntry();
                entry.name = "Buy A Life";
                entry.price = 250;
                entry.action = new Func<string>(() =>
                {
                    player.SetField("lives", player.GetField<int>("lives") + 1);
                    player.Call("iprintlnbold", "Bought a Life");
                    return "";
                });
                entry.remainingbuys = -1;
                store.addEntry(entry);
    
                entry = new GameStore.StoreEntry();
                entry.name = "";
                entry.formatName = new Func<string>(() =>
                {
                    string upgradeto = "";
                    switch (player.GetField<string>("lethal"))
                    {
                        case "frag_grenade_mp":
                            upgradeto = "Semtex";
                            break;
                        case "semtex_mp":
                            upgradeto = "Claymore";
                            break;
                        case "claymore_mp":
                            upgradeto = "C4";
                            break;
                        case "c4_mp":
                            upgradeto = "Bouncing Betty";
                            break;
                        default:
                            return "Cannot Upgrade Equipment Further!";
                    }
                    return string.Format("Upgrade Equipment to {0} - 250", upgradeto);
                });
                entry.price = 250;
                entry.action = new Func<string>(() =>
                {
                    switch(player.GetField<string>("lethal"))
                    {
                        case "frag_grenade_mp":
                            player.SetField("lethal", "semtex_mp");
                            player.Call("iprintlnbold", "Upgraded to Semtex");
                            player.Call("giveweapon", player.GetField<string>("lethal"));
                            player.Call("setweaponammoclip", player.GetField<string>("lethal"), 0);
                            entry.name = "Upgrade to Claymore";
                            break;
                        case "semtex_mp":
                            player.SetField("lethal", "claymore_mp");
                            player.Call("iprintlnbold", "Upgraded to Claymore");
                            player.Call("giveweapon", player.GetField<string>("lethal"));
                            player.Call("setweaponammoclip", player.GetField<string>("lethal"), 0);
                            entry.name = "Upgrade to C4";
                            break;
                        case "claymore_mp":
                            player.SetField("lethal", "c4_mp");
                            player.Call("iprintlnbold", "Upgraded to C4");
                            player.Call("giveweapon", player.GetField<string>("lethal"));
                            player.Call("setweaponammoclip", player.GetField<string>("lethal"), 0);
                            entry.name = "Upgrade to Bouncing Betty";
                            break;
                        case "c4_mp":
                            player.SetField("lethal", "bouncingbetty_mp");
                            player.Call("iprintlnbold", "Upgraded to Bouncing Betty");
                            player.Call("giveweapon", player.GetField<string>("lethal"));
                            player.Call("setweaponammoclip", player.GetField<string>("lethal"), 0);
                            entry.name = "Cannot Upgrade Equipment!";
                            break;
                        default:
                            return "Cannot Upgrade Equipment Further!";
                    }
                    return "";
                });
                entry.remainingbuys = 1;
                store.addEntry(entry);
    
    
                entry = new GameStore.StoreEntry();
                entry.name = "Unlock The Thing";
                entry.price = 750;
                entry.action = new Func<string>(() =>
                {
                    if (player.GetField<int>("player_thething") == 1)
                        return "Already Bought!";
                    player.SetField("player_thething", 1);
                    player.Call("iprintlnbold", "Unlocked The Thing!");
                    return "";
                });
                entry.remainingbuys = 1;
                entry.formatName = new Func<string>(() =>
                {
                    if (player.GetField<int>("player_thething") == 1)
                        return "Purchased!";
                    return "Unlock The Thing - 750";
                });
                store.addEntry(entry);
    
                /*entry = new GameStore.StoreEntry();
                entry.name = "Buy Anti-Alpha";
                entry.price = 600;
                entry.action = new Func<string>(() =>
                {
                    if (player.GetField<int>("player_antialpha") == 1)
                        return "Already Bought!";
                    player.SetField("player_antialpha", 1);
                    player.Call("iprintlnbold", "Bought Anti-Alpha!");
                    return "";
                });
                entry.remainingbuys = 1;
                entry.formatName = new Func<string>(() =>
                {
                    if (player.GetField<int>("player_antialpha") == 1)
                        return "Bought!";
                    return "Buy Anti-Alpha - 600";
                });
                store.addEntry(entry);*/
    
                entry = new GameStore.StoreEntry();
                entry.name = "Change Camo";
                entry.price = 0;
                entry.action = new Func<string>(() =>
                {
                    player.SetField("camo", player.GetField<int>("camo") + 1);
                    if (player.GetField<int>("camo") == 13)
                    {
                        player.SetField("camo", 0);
                    }
                    return "";
                });
                entry.remainingbuys = -1;
                entry.formatName = new Func<string>(() =>
                {
                    return string.Format("Change Camo [Cur: {0}]", WeaponUtils._camoList[player.GetField<int>("camo")]);
                });
                store.addEntry(entry);
    
                entry = new GameStore.StoreEntry();
                entry.name = "Change Reticule";
                entry.price = 0;
                entry.action = new Func<string>(() =>
                {
                    player.SetField("reticle", player.GetField<int>("reticle") + 1);
                    if (player.GetField<int>("reticle") == 6)
                    {
                        player.SetField("reticle", 0);
                    }
                    return "";
                });
                entry.remainingbuys = -1;
                entry.formatName = new Func<string>(() =>
                {
                    return string.Format("Change Reticle [Cur: {0}]", player.GetField<int>("reticle"));
                });
                store.addEntry(entry);
    
                entry = new GameStore.StoreEntry();
                entry.name = "Suicide";
                entry.price = 0;
                entry.action = new Func<string>(() =>
                {
                    player.Call("suicide");
                    return "";
                });
                entry.remainingbuys = -1;
                entry.formatName = new Func<string>(() =>
                {
                    return "Suicide";
                });
                store.addEntry(entry);
            }
    
            public void doCustomWeapon(Entity player, string name, string bullet)
            {
                player.OnNotify("weapon_fired", (p, weaponName) =>
                {
                    if (((string)weaponName).Contains(name))
                    {
                        Call("magicbullet", bullet, // bullet name
                            new Parameter(player.Call<Vector3>("getTagOrigin", "tag_weapon_left")), // start point
                            new Parameter(Call<Vector3>("anglestoforward", player.Call<Vector3>("getPlayerAngles")) * 1000000), // end point
                            new Parameter(player)); // ignore entity
                    }
                });
            }
    
            private string upgradeWeapon(Entity player)
            {
                string weapon = player.CurrentWeapon;
                string basenewweapon = "";
                string basename = WeaponUtils.weapon_getBasename(weapon);
                int camo = player.GetField<int>("camo");
                int reticle = player.GetField<int>("reticle");
                if (Array.IndexOf(WeaponUtils._smgList, basename) > 0)
                {
                    player.TakeWeapon(weapon);
                    basenewweapon = WeaponUtils.getRandomAR(camo, reticle);
                }
                else if (Array.IndexOf(WeaponUtils._arList, basename) > 0)
                {
                    player.TakeWeapon(weapon);
                    basenewweapon = WeaponUtils.getRandomLMG(camo, reticle);
                }
                else if (Array.IndexOf(WeaponUtils._pistolList, basename) > 0)
                {
                    player.TakeWeapon(weapon);
                    basenewweapon = WeaponUtils.getRandomAutoPistol(camo, reticle);
                }
                else
                {
                    return "You cannot upgrade this weapon!";
                }
                string[] newattach = WeaponUtils.weapon_getAttachments(weapon);
                string newweapon = WeaponUtils.weapon_getWeaponName(basenewweapon, newattach, player.GetField<int>("camo"), player.GetField<int>("reticle"));
                player.GiveWeapon(newweapon);
                player.AfterDelay(100, entity =>
                {
                    player.SwitchToWeaponImmediate(newweapon);
                    player.Call("iprintlnbold", "Upgraded Weapon!");
                });
    
                return "";
            }
    
            private string giveAttachment(Entity player, string attachment)
            {
                string oldweapon = player.CurrentWeapon;
                string[] attach = WeaponUtils.weapon_getAttachments(oldweapon);
                if (attach.Contains(attachment)) return "You already own this attachment!";
                Array.Resize(ref attach, attach.Length + 1);
                attach[attach.Length - 1] = attachment;
                if (!WeaponUtils.checkAttachments(oldweapon, attachment)) return "You cannot upgrade this weapon with that attachment!";
                string newweapon = WeaponUtils.weapon_getWeaponName(WeaponUtils.weapon_getBasename(oldweapon), attach, player.GetField<int>("camo"), player.GetField<int>("reticle"));
                player.GiveWeapon(newweapon);
                player.Call("setweaponammoclip", newweapon, player.GetWeaponAmmoClip(newweapon));
                player.Call("setweaponammostock", newweapon, player.GetWeaponAmmoStock(newweapon));
                player.TakeWeapon(oldweapon);
                player.SwitchToWeaponImmediate(newweapon);
                return "";
            }
    
            private Entity[] getPlayers(bool isalive=false)
            {
                List<Entity> players = new List<Entity>();
                for (int i = 0; i < 17; i++)
                {
                    Entity entity = Call<Entity>("getentbynum", i);
                    if (entity != null)
                    {
                        if (entity.IsPlayer)
                        {
                            if (!(isalive && !entity.IsAlive) && entity.HasField("connected"))
                                players.Add(entity);
                        }
                    }
                }
                return players.ToArray();
            }
    
            private void setPlayerTeam(Entity player, string team)
            {
                // need to be able to change max team count or player.pers["team"] to get this to work
                player.Notify("menuresponse", "team_marinesopfor", team);
            }
    
            private int getTeamCount(string team)
            {
                Entity[] players = getPlayers(false);
                int count = 0;
                foreach (Entity p in players)
                {
                    if (p.HasField("sessionteam"))
                    {
                        if (p.GetField<string>("sessionteam") == team)
                            count++;
                    }
                }
                return count;
            }
    
            private void CallOnPlayers(Action<Entity> action)
            {
                // dont know why I didnt update this when I wrote getPlayers
                Entity[] ents = getPlayers(false);
                foreach (Entity entity in ents)
                {
                    action.Invoke(entity);
                }
            }
    
            /*private void fadeInText(HudElem elem, int milliseconds)
            {
                OnInterval(100, () => // fade in text
                {
                    if (elem.Alpha >= 1)
                    {
                        return false;
                    }
                    elem.Alpha += (float)0.1 / (milliseconds / 1000);
                    return true;
                });
            }
    
            private void fadeOutText(HudElem elem, int milliseconds)
            {
                elem.Alpha = 1;
                OnInterval(100, () => // fade in text
                {
                    if (elem.Alpha <= 0)
                    {
                        return false;
                    }
                    elem.Alpha -= (float)0.1 / (milliseconds / 1000);
                    return true;
                });
                AfterDelay(milliseconds, () =>
                {
                    elem.Alpha = 1;
                    elem.SetText("");
                });
            }*/
    
            public string getMapEnv(string mapname)
            {
                switch (mapname)
                {
                    case "mp_alpha":
                    case "mp_bootleg":
                    case "mp_exchange":
                    case "mp_hardhat":
                    case "mp_interchange":
                    case "mp_mogadishu":
                    case "mp_paris":
                    case "mp_plaza2":
                    case "mp_underground":
                    case "mp_cement":
                    case "mp_hillside_ss":
                    case "mp_overwatch":
                    case "mp_terminal_cls":
                    case "mp_aground_ss":
                    case "mp_courtyard_ss":
                    case "mp_meteora":
                    case "mp_morningwood":
                    case "mp_qadeem":
                    case "mp_crosswalk_ss":
                    case "mp_italy":
                    case "mp_boardwalk":
                    case "mp_roughneck":
                    case "mp_nola":
                        return "urban";
                    case "mp_dome":
                    case "mp_radar":
                    case "mp_restrepo_ss":
                    case "mp_burn_ss":
                    case "mp_seatown":
                    case "mp_shipbreaker":
                    case "mp_moab":
                        return "desert";
                    case "mp_bravo":
                    case "mp_carbon":
                    case "mp_park":
                    case "mp_six_ss":
                    case "mp_village":
                    case "mp_lambeth":
                        return "woodland";
                }
                return "";
            }
    
            /*private void protectDvar<T>(string dvar, T value)
            {
                OnInterval(100, () =>
                {
                    if (!Call<T>("getdvar", dvar).Equals(value))
                        Call("setdvar", dvar, new Parameter(value));
                    return true;
                });
            }*/ //Not used
    
            private static void print(string format, params object[] p)
            {
                Log.Write(LogLevel.All, format, p);
            }
    
            [DllImport("kernel32.dll", SetLastError = true)]
            static extern IntPtr VirtualAlloc(IntPtr lpAddress, UIntPtr dwSize, uint flAllocationType, uint flProtect);
            [DllImport("kernel32.dll", SetLastError = true)]
            static extern bool VirtualFree(IntPtr lpAddress, UIntPtr dwSize, uint dwFreeType);
            public IntPtr alloc(int size)
            {
                return VirtualAlloc(IntPtr.Zero, (UIntPtr)size, 0x3000, 0x40);
            }
            public bool unalloc(IntPtr address, int size)
            {
                return VirtualFree(address, (UIntPtr)size, 0x8000);
            }
    
    	    bool _changed = false;
            IntPtr memory;
            private unsafe void changeGametype(string gametype)
            {
                byte[] gametypestring;
                if (_changed)
                {
                    gametypestring = new System.Text.UTF8Encoding().GetBytes(gametype);
                    if (gametypestring.Length >= 64) gametypestring[64] = 0x0; // null terminate if too large
                    Marshal.Copy(gametypestring, 0, memory, gametype.Length > 64 ? 64 : gametype.Length);
                    return;
                }
                memory = alloc(64);
                gametypestring = new System.Text.UTF8Encoding().GetBytes(gametype);
                if (gametypestring.Length >= 64) gametypestring[64] = 0x0; // null terminate if too large
                Marshal.Copy(gametypestring, 0, memory, gametype.Length > 64 ? 64 : gametype.Length);
                *(byte*)0x4EB983 = 0x68; // mov eax, 575D928h -> push stringloc
                *(int*)0x4EB984 = (int)memory;
                *(byte*)0x4EB988 = 0x90; // mov ecx, [eax+0Ch] -> nop
                *(byte*)0x4EB989 = 0x90; 
                *(byte*)0x4EB98A = 0x90; 
                *(byte*)0x4EB98B = 0x90; // push edx -> nop
                _changed = true;
            }
    
            private void createScorePopup(Entity player)
            {
                HudElem PopUp = HudElem.CreateFontString(player, "hudsmall", 1f);
                PopUp.SetPoint("center", "center", 100, 40);
                PopUp.Alpha = 1f;
                PopUp.SetText("");
                player.SetField("hud_scorepopup", new Parameter(PopUp));
                player.SetField("hud_scorepopup_ammount", 0);
            }
    
            private void doScorePopUp(Entity player, string text, int amount)
            {
                HudElem PopUp = player.GetField<HudElem>("hud_scorepopup");
                int lastamt = player.GetField<int>("hud_scorepopup_ammount");
                // fades over 3 seconds
                PopUp.Alpha = 1f;
                PopUp.SetText(String.Format(text, (amount + lastamt)));
                player.SetField("hud_scorepopup_ammount", lastamt + amount);
                PopUp.Call("fadeovertime", 3f);
                PopUp.Alpha = 0;
                AfterDelay(3000, () =>
                {
                    PopUp.SetText("");
                    PopUp.Alpha = 1f;
                    lastamt = player.GetField<int>("hud_scorepopup_ammount");
                    if(lastamt - amount == 0)
                        player.SetField("hud_scorepopup_ammount", 0);
                });
            }
        }
    }
    
    //TO-DO List:
    //Add an expfogtest like from IW4
    //Implement teleporting TK from QCZM v2 our version
    //Mmm fix-shop up.
    //Add setfields to all shop items so once it's bought we can disable it from a 2nd purchase.
    //Something is broken with ScorePopUp, as in it won't c
    made 2 file class library needed and added them there

    here's the code of these files

    GameStore:

    Code:
    // QCZM IW5 - TheApadayo & DidUknowiPwn 2012
    // in game store module
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    
    using InfinityScript;
    
    namespace DUKIP
    {
        class GameStore : BaseScript
        {
            private Func<bool> _doStore;
            private List<StoreEntry> _storeEntries;
            private int _entryCount;
            private int _curPage;
            private int _pages;
            private string _currencyField;
    
            public class StoreEntry
            {
                public string name;
                public int price;
                public Func<string> formatName;
                public Func<string> action;
                public int remainingbuys;
            }
    
            public GameStore(Entity player)
            {
                _storeEntries = new List<StoreEntry>();
                _doStore = new Func<bool>(() =>
                {
                    return true;
                });
                _curPage = 0;
                _pages = 0;
                _entryCount = 0;
                _currencyField = "cash";
    
                HudElem label = player.GetField<HudElem>("storeHud_label");
                HudElem[] items = player.GetField<HudElem[]>("storeHud_items");
    
                player.OnInterval(100, (entity) =>
                {
                    if (!_doStore()) return true;
                    label.SetText("^:Page:^2 " + (_curPage + 1) + "^7/^2" + _pages + " ^7press ^3[{+smoke}]^7 to go forward and ^3[{+actionslot 1}]^7 to go back through pages.");
                    // note to self. when formatting strings... localized things like [{+melee}] will screw it up
                    // this loop makes no sense but trust me... it works
    
                    for (int i = 0; i < 3; i++)
                    {
                        if (_storeEntries.Count <= _curPage * 3 + i)
                        {
                            items[i].SetText("");
                            continue;
                        }
                        int action = 3;
                        if (i == 1) action = 4;
                        if (i == 2) action = 5;
                        StoreEntry entry = _storeEntries.ElementAt(_curPage * 3 + i);
                        // this screws up badly... still dont know why
                        // just do it manually for now
                        /*if (entry.remainingbuys == 0)
                        {
                            items[i].SetText("[{+actionslot " + action + "}]: Bought");
                        }
                        else
                        {*/
                            items[i].SetText("[{+actionslot " + action + "}]: " + entry.formatName());
                        //entry.remainingbuys--;
                        //}
                    }
                    return true;
                });
                player.Call("notifyonplayercommand", "nextpage", "+actionslot 1");
                player.Call("notifyonplayercommand", "prevpage", "+smoke");
                player.Call("notifyonplayercommand", "buy1", "+actionslot 3");
                player.Call("notifyonplayercommand", "buy2", "+actionslot 4");
                player.Call("notifyonplayercommand", "buy3", "+actionslot 5");
    
                player.OnNotify("nextpage", (entity) =>
                {
                    if (!_doStore()) return;
                    _curPage++;
                    if (_curPage == _pages)
                        _curPage = 0;
                });
                player.OnNotify("prevpage", (entity) =>
                {
                    if (!_doStore()) return;
                    _curPage--;
                    if (_curPage < 0)
                        _curPage = _pages - 1;
                });
    
                player.OnNotify("buy1", (entity) =>
                {
                    if (!_doStore()) return;
                    string error = "";
                    if (_storeEntries.Count <= _curPage * 3) return;
                    StoreEntry entry = _storeEntries.ElementAt(_curPage * 3);
                    if (player.GetField<int>(_currencyField) >= entry.price)
                    {
                        error = entry.action();
                        if (error == "")
                        {
                            player.SetField(_currencyField, player.GetField<int>(_currencyField) - entry.price);
                        }
                        else
                        {
                            player.Call("iprintlnbold", error);
                        }
                    }
                    else
                    {
                        entity.Call("iprintlnbold", "Not enough ^1cash!");
                    }
                });
    
                player.OnNotify("buy2", (entity) =>
                {
                    if (!_doStore()) return;
                    string error = "";
                    if (_storeEntries.Count <= _curPage * 3 + 1) return;
                    StoreEntry entry = _storeEntries.ElementAt(_curPage * 3 + 1);
                    if (player.GetField<int>(_currencyField) >= entry.price)
                    {
                        error = entry.action();
                        if (error == "")
                        {
                            player.SetField(_currencyField, player.GetField<int>(_currencyField) - entry.price);
                        }
                        else
                        {
                            player.Call("iprintlnbold", error);
                        }
                    }
                    else
                    {
                        entity.Call("iprintlnbold", "Not enough ^1cash!");
                    }
                });
    
                player.OnNotify("buy3", (entity) =>
                {
                    if (!_doStore()) return;
                    string error = "";
                    if (_storeEntries.Count <= _curPage * 3 + 2) return;
                    StoreEntry entry = _storeEntries.ElementAt(_curPage * 3 + 2);
                    if (player.GetField<int>(_currencyField) >= entry.price)
                    {
                        error = entry.action();
                        if (error == "")
                        {
                            player.SetField(_currencyField, player.GetField<int>(_currencyField) - entry.price);
                        }
                        else
                        {
                            player.Call("iprintlnbold", error);
                        }
                    }
                    else
                    {
                        entity.Call("iprintlnbold", "Not enough ^1cash!");
                    }
                });
            }
    
            public void setCurrencyField(string name)
            {
                _currencyField = name;
            }
    
            public void setRemainingBuys(int entry, int buys)
            {
                _storeEntries.ElementAt(entry).remainingbuys = buys;
            }
    
            public void addEntry(StoreEntry entry)
            {
                if (entry.formatName == null)
                {
                    entry.formatName = new Func<string>(() =>
                    {
                        return entry.name + " - " + entry.price;
                    });
                }
                _storeEntries.Add(entry);
                _entryCount++;
                _pages = (_entryCount + 2) / 3; // round up
            }
    
            public void doStoreWhen(Func<bool> func)
            {
                _doStore = func;
            }
            public static void createStoreHUD(Entity player)
            {
                HudElem label = HudElem.CreateFontString(player, "boldFont", 1.3f);
                label.SetPoint("BOTTOM", "BOTTOM", 0, -90);
                label.HideWhenInMenu = true;
                player.SetField("storeHud_label", new Parameter(label));
                label.SetField("glowcolor", new Vector3(1f, 0f, 0f));
                label.GlowAlpha = 1.1f;
    
                HudElem item1 = HudElem.CreateFontString(player, "boldFont", 1.2f);
                item1.SetPoint("BOTTOM", "BOTTOM", 0, -70);
                item1.HideWhenInMenu = true;
                item1.SetField("glowcolor", new Vector3(0f, 0f, 1f));
                item1.GlowAlpha = 1.3f;
    
                HudElem item2 = HudElem.CreateFontString(player, "boldFont", 1.2f);
                item2.SetPoint("BOTTOM", "BOTTOM", 0, -50);
                item2.HideWhenInMenu = true;
                item2.SetField("glowcolor", new Vector3(0f, 0f, 1f));
                item2.GlowAlpha = 1.3f;
    
                HudElem item3 = HudElem.CreateFontString(player, "boldFont", 1.2f);
                item3.SetPoint("BOTTOM", "BOTTOM", 0, -30);
                item3.HideWhenInMenu = true;
                item3.SetField("glowcolor", new Vector3(0f, 0f, 1f));
                item3.GlowAlpha = 1.3f;
    
                player.SetField("storeHud_items", new Parameter(new HudElem[] { item1, item2, item3 }));
            }
            private static void print(string format, params object[] p)
            {
                Log.Write(LogLevel.All, format, p);
            }
        }
    }
    WeaponUtils:

    Code:
    // QCZM IW5 - TheApadayo & DidUknowiPwn 2012
    // weapon utilities
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Text.RegularExpressions;
    using InfinityScript;
    
    namespace DUKIP
    {
        class WeaponUtils
        {
            private static Random _rng = new Random();
    
            public static string weapon_getBasename(string weapon)
            {
                string[] split = weapon.Split('_');
                if (split.Length < 2) return "";
                return split[0] + "_" + split[1];
            }
    
            public static string[] weapon_getAttachments(string weapon)
            {
                string[] split = weapon.Split('_');
                if (split.Length < 4) return new string[1];
                string[] attachments = new string[5];
                int attach = 0;
                int i = 3;
                while(split.Length > i && attach < 5)
                {
                    if (!split[i].Contains("camo") && !split[i].Contains("ret") && !split[i].Contains("scope"))
                    {
                        attachments[attach] = split[i];
                        attachments[attach] = attachments[attach].Replace("smg", "");
                        attachments[attach] = attachments[attach].Replace("lmg", "");
                        attach++;
                    }
                    i++;
                }
                Array.Resize<string>(ref attachments, attach);
                return attachments;
            }
    
            // neither of these really work
            public static int weapon_getcamo(string weapon)
            {
                string[] split = weapon.Split('_');
                for (int i = 0; i < split.Length; i++)
                {
                    if (split[i].Contains("camo"))
                    {
                        return int.Parse(split[i].Split('0')[1]);
                    }
                }
                return 0;
            }
    
            public static int weapon_getReticle(string weapon)
            {
                string[] split = weapon.Split('_');
                for (int i = 0; i < split.Length; i++)
                {
                    if (split[i].Contains("ret"))
                    {
                        return int.Parse(split[i].Split('t')[1]);
                    }
                }
                return 0;
            }
    
            public static string[] GetDesiredAttachments()
            {
                var attachmentTypes = new[]
                {
                    "none",
                    "sight",
                    "sight",
                    "sight",
                    "sight",
                    "sight",
                    "other",
                    "other",
                    "other",
                    "final"
                };
    
                switch (attachmentTypes[_rng.Next(0, attachmentTypes.Length)])
                {
                    case "none":
                        return new string[0];
                    case "sight":
                        return new[]
                        {
                            "acog",
                            "reflex",
                            "hamrhybrid",
                            "hybrid",
                            "zoomscope",
                            "eotech",
                            "vzscope"
                        };
                    case "other":
                        return new[]
                        {
                            "silencer",
                            "silencer02",
                            "silencer03",
                            "grip",
                            "gl",
                            "gp25",
                            "m320",
                            "shotgun"
                        };
                    case "final":
                        return new[]
                        {
                            "thermal",
                            "heartbeat"
                        };
                }
    
                return new string[0];
            }
    
            public static string getRandomPistol(int camo=-1, int reticle=-1)
            {
                if (camo == -1) camo = _rng.Next(14);
                if (reticle == -1) reticle = _rng.Next(7);
                return Utilities.BuildWeaponName(_pistolList[_rng.Next(_pistolList.Length)], "", "none", camo, reticle);
            }
            public static string getRandomAutoPistol(int camo = -1, int reticle = -1)
            {
                if (camo == -1) camo = _rng.Next(14);
                if (reticle == -1) reticle = _rng.Next(7);
                return Utilities.BuildWeaponName(_autoPistolList[_rng.Next(_autoPistolList.Length)], "", "none", camo, reticle);
            }
            public static string getRandomSMG(int camo = -1, int reticle = -1)
            {
                if (camo == -1) camo = _rng.Next(14);
                if (reticle == -1) reticle = _rng.Next(7);
                return Utilities.BuildWeaponName(_smgList[_rng.Next(_smgList.Length)], "", "none", camo, reticle);
            }
            public static string getRandomAR(int camo = -1, int reticle = -1)
            {
                if (camo == -1) camo = _rng.Next(14);
                if (reticle == -1) reticle = _rng.Next(7);
                return Utilities.BuildWeaponName(_arList[_rng.Next(_arList.Length)], "", "none", camo, reticle);
            }
            public static string getRandomShotgun(int camo = -1, int reticle = -1)
            {
                if (camo == -1) camo = _rng.Next(14);
                if (reticle == -1) reticle = _rng.Next(7);
                return Utilities.BuildWeaponName(_shotgunList[_rng.Next(_shotgunList.Length)], "", "none", camo, reticle);
            }
            public static string getRandomSniper(int camo = -1, int reticle = -1)
            {
                if (camo == -1) camo = _rng.Next(14);
                if (reticle == -1) reticle = _rng.Next(7);
                return Utilities.BuildWeaponName(_sniperList[_rng.Next(_sniperList.Length)], "", "none", camo, reticle);
            }
            public static string getRandomLMG(int camo = -1, int reticle = -1)
            {
                if (camo == -1) camo = _rng.Next(14);
                if (reticle == -1) reticle = _rng.Next(7);
                return Utilities.BuildWeaponName(_lmgList[_rng.Next(_lmgList.Length)], "", "none", camo, reticle);
            }
            public static string getRandomLauncher(int camo = -1, int reticle = -1)
            {
                if (camo == -1) camo = _rng.Next(14);
                if (reticle == -1) reticle = _rng.Next(7);
                return Utilities.BuildWeaponName(_launcherList[_rng.Next(_launcherList.Length)], "", "none", camo, reticle);
            }
    
            public static string getRandomWeapon(int camo = -1, int reticle = -1)
            {
                switch(_rng.Next(7))
                {
                    case 0:
                        return getRandomPistol(camo, reticle);
                    case 1:
                        return getRandomSMG(camo, reticle);
                    case 2:
                        return getRandomAR(camo, reticle);
                    case 3:
                        return getRandomShotgun(camo, reticle);
                    case 4:
                        return getRandomSniper(camo, reticle);
                    case 5:
                        return getRandomLMG(camo, reticle);
                    default:
                        return getRandomLauncher(camo, reticle);
                }
            }
    
            private static void print(string format, params object[] p)
            {
                Log.Write(LogLevel.All, format, p);
            }
            
            public static string weapon_getWeaponName(string baseName, string []attachments, int camo, int reticle)
            {
                Function.SetEntRef(-1);
                bool _usesRet = false;
                for (int i = 0; i < attachments.Length; i++)
                {
                    // why does this matter?
                    if (GetAttachmentType(attachments[i]) == "rail")
                    {
                        _usesRet = true;
                    }
    
                    // just map them... should get ignored if they arent scopes
                    if (GetAttachmentType(attachments[i]) == "rail")
                    {
                        attachments[i] = AttachmentMap(attachments[i], baseName);
                    }
                }
                if(_usesRet && reticle > 0)
                {
                    reticle = 0;
                }
    
                var bareWeaponName = "";
                var weaponName = "";
    
                if (baseName.Contains("iw5_"))
                {
                    weaponName = baseName + "_mp";
                    bareWeaponName = baseName.Substring(4);
                }
                else
                {
                    weaponName = baseName;
                }
    
                bool _hasScope = false;
                if (GetWeaponClass(baseName) == "weapon_sniper")
                {
                    for(int i=0; i<attachments.Length;i++)
                    {
                        if (GetAttachmentType(attachments[i]) == "rail" && attachments[i] == "zoomscope")
                        {
                            _hasScope = true;
                        }
                    }
                    if(!_hasScope)
                        attachments[attachments.Length + 1] = bareWeaponName + "scope";
                }
    
                for(int i=0; i<attachments.Length; i++)
                {
                    if (attachments[i] == "vzscope")
                    {
                        attachments[i] = bareWeaponName + "scopevz";
                    }
                }
    
                attachments = attachments.OrderBy(attachment => attachment ?? "zz").ToArray();
    
                foreach (var attachment in attachments)
                {
                    if (string.IsNullOrEmpty(attachment))
                    {
                        continue;
                    }
    
                    weaponName += "_" + attachment;
                }
    
                var weaponClass = GetWeaponClass(baseName);
    
                if (weaponName.Contains("iw5_"))
                {
                    if (weaponClass != "weapon_pistol" && weaponClass != "weapon_machine_pistol" && weaponClass != "weapon_projectile")
                    {
                        weaponName = BuildWeaponNameCamo(weaponName, camo);
                    }
    
                    weaponName = BuildWeaponNameReticle(weaponName, reticle);
    
                    return weaponName;
                }
                else
                {
                    if (weaponClass != "weapon_pistol" && weaponClass != "weapon_machine_pistol" && weaponClass != "weapon_projectile")
                    {
                        weaponName = BuildWeaponNameCamo(weaponName, camo);
                    }
    
                    weaponName = BuildWeaponNameReticle(weaponName, reticle);
    
                    return weaponName + "_mp";
                }
            }
    
            private static string BuildWeaponNameCamo(string weaponName, int camo)
            {
                if (camo <= 0)
                {
                    return weaponName;
                }
    
                if (camo < 10)
                {
                    weaponName += "_camo0";
                }
                else
                {
                    weaponName += "_camo";
                }
    
                weaponName += camo.ToString();
    
                return weaponName;
            }
    
            private static string BuildWeaponNameReticle(string weaponName, int reticle)
            {
                if (reticle <= 0)
                {
                    return weaponName;
                }
    
                return weaponName + "_scope" + reticle.ToString();
            }
    
            public static string GetWeaponClass(string weapon)
            {
                Function.SetEntRef(-1);
    
                var tokens = weapon.Split('_');
                var weaponClass = "";
    
                if (tokens[0] == "iw5")
                {
                    var concatName = tokens[0] + "_" + tokens[1];
                    weaponClass = Function.Call<string>("tableLookup", "mp/statstable.csv", 4, concatName, 2);
                }
                else if (tokens[0] == "alt")
                {
                    var concatName = tokens[1] + "_" + tokens[2];
                    weaponClass = Function.Call<string>("tableLookup", "mp/statstable.csv", 4, concatName, 2);
                }
                else
                {
                    weaponClass = Function.Call<string>("tableLookup", "mp/statstable.csv", 4, tokens[0], 2);
                }
    
                if (weaponClass == "")
                {
                    weapon = Regex.Replace(weapon, "_mp$", "");
    
                    weaponClass = Function.Call<string>("tableLookup", "mp/statstable.csv", 4, weapon, 2);
                }
    
                if (weapon == "none" || weaponClass == "")
                {
                    weaponClass = "other";
                }
    
                return weaponClass;
            }
    
            public static string GetAttachmentType(string attachmentName)
            {
                Function.SetEntRef(-1);
                return Function.Call<string>("tableLookup", "mp/attachmenttable.csv", 4, attachmentName, 2);
            }
    
            public static string AttachmentMap(string attachmentName, string weaponName)
            {
                Function.SetEntRef(-1);
    
                var weaponClass = GetWeaponClass(weaponName);
    
                switch (weaponClass)
                {
                    case "weapon_smg":
                        if (attachmentName == "reflex")
                            return "reflexsmg";
                        else if (attachmentName == "eotech")
                            return "eotechsmg";
                        else if (attachmentName == "acog")
                            return "acogsmg";
                        else if (attachmentName == "thermal")
                            return "thermalsmg";
    
                        return attachmentName;
                    case "weapon_lmg":
                        if (attachmentName == "reflex")
                            return "reflexlmg";
                        else if (attachmentName == "eotech")
                            return "eotechlmg";
    
                        return attachmentName;
                    case "weapon_machine_pistol":
                        if (attachmentName == "reflex")
                            return "reflexsmg";
                        else if (attachmentName == "eotech")
                            return "eotechsmg";
    
                        return attachmentName;
                    default:
                        return attachmentName;
                }
            }
    
            public static bool checkAttachments(string weapon, string attach)
            {
                string basename = weapon_getBasename(weapon);
                if (attach == "akimbo")
                {
                    if (GetWeaponClass(basename) != "weapon_machine_pistol" && GetWeaponClass(basename) != "weapon_pistol")
                    {
                        return false;
                    }
                }
                if (GetAttachmentType(attach) == "rail" && GetWeaponClass(basename) == "weapon_sniper")
                {
                    return false;
                }
                return true;
            }
            public static string[] _pistolList = new[]
            {
                "iw5_44magnum",
                "iw5_usp45",
                "iw5_mp412",
                "iw5_p99",
                "iw5_fnfiveseven"
            };
    
            public static string[] _autoPistolList = new[]
            {
                "iw5_fmg9",
                "iw5_skorpion",
                "iw5_mp9",
                "iw5_g18"
            };
    
            public static string[] _smgList = new[]
            {
                "iw5_mp5",
                "iw5_m9",
                "iw5_p90",
                "iw5_pp90m1",
                "iw5_ump45",
                "iw5_mp7"
            };
            public static string[] _arList = new[]
            {
                "iw5_ak47",
                "iw5_m16",
                "iw5_m4",
                "iw5_fad",
                "iw5_acr",
                "iw5_type95",
                "iw5_mk14",
                "iw5_scar",
                "iw5_g36c",
                "iw5_cm901"
            };
            public static string[] _launcherList = new[]
            {
                "rpg",
                "iw5_smaw",
                "xm25"
            };
            public static string[] _sniperList = new[]
            {
                "iw5_dragunov",
                "iw5_msr",
                "iw5_barrett",
                "iw5_rsass",
                "iw5_as50",
                "iw5_l96a1",
                "iw5_ksg"
            };
            public static string[] _shotgunList = new[]
            {
                "iw5_1887",
                "iw5_striker",
                "iw5_aa12",
                "iw5_usas12",
                "iw5_spas12"
            };
            public static string[] _lmgList = new[]
            {
                "iw5_m60",
                "iw5_mk46",
                "iw5_pecheneg",
                "iw5_sa80",
                "iw5_mg36",
            };
            public static string[] _camoList = new[]
            {
                "None",
                "Classic",
                "Snow",
                "Multicam",
                "Digital",
                "Hex",
                "Choco",
                "Snake",
                "Blue",
                "Red",
                "Autumn",
                "Gold",
                "Marine"
            };
        }
    }
    
    /*
     * Weapons: iw5_usp45, iw5_mp412, iw5_44magnum, iw5_deserteagle, iw5_p99, iw5_fnfiveseven, 
     * iw5_acr, iw5_type95, iw5_m4, iw5_ak47, iw5_m16, iw5_mk14, iw5_g36c, iw5_scar, iw5_fad, iw5_cm901, 
     * iw5_mp5, iw5_m9, iw5_p90, iw5_pp90m1, iw5_ump45, iw5_mp7, iw5_fmg9, iw5_g18, iw5_mp9, iw5_skorpion, 
     * iw5_spas12, iw5_aa12, iw5_striker, iw5_1887, iw5_usas12, iw5_ksg, iw5_m60, iw5_mk46, iw5_pecheneg, 
     * iw5_sa80, iw5_mg36, iw5_barrett, iw5_msr, iw5_rsass, iw5_dragunov, iw5_as50, iw5_l96a1, rpg, javelin, 
     * stinger, iw5_smaw, m320, riotshield, xm25, iw5_m60jugg_mp
    
     * Attachments:
     * reflex, acog, grip, akimbo, thermal, shotgun, heartbeat, xmags, rof, eotech, tactical, vzscope, gl, 
     * gp25, m320, silencer, silencer02, silencer03, hamrhybrid, hybrid
    
     * Red Dots: (referenced as numbers 0-5 and if none specefied default dot)
     * Target Dot, Delta, U-Dot, Mil-Dot, Omega, Lambada
    
     * Camos: (referenced as numbers 0-13)
     * None, Classic, Snow, Multicam, Digital, Hex, Choco, Snake, Blue, Red, Autumn, Gold, Marine
    
     * Tactical:
     * flash_grenade_mp, concussion_grenade_mp, specialty_scrambler, emp_grenade_mp, smoke_grenade_mp, 
     * trophy_mp, specialty_tacticalinsertion, specialty_portable_radar
    
     * Lethal:
     * bouncingbetty_mp, frag_grenade_mp, semtex_mp, throwingknife_mp, claymore_mp, c4_mp
    
     * Killstreaks:
     * uav, airdrop_assault, ims, predator_missile, airdrop_sentry_minigun, precision_airstrike, helicopter, 
     * littlebird_flock, littlebird_support, remote_mortar, airdrop_remote_tank, ac130, helicopter_flares, 
     * airdrop_juggernaut, osprey_gunner
    
     * uav_support, counter_uav, deployable_vest, sam_turret, remote_uav, airdrop_trap, triple_uav, 
     * remote_mg_turret, emp, stealth_airstrike, airdrop_juggernaut_recon, escort_airdrop
    
     * specialty_longersprint_ks, specialty_fastreload_ks, specialty_scavenger_ks, specialty_blindeye_ks, 
     * specialty_paint_ks, specialty_hardline_ks, specialty_coldblooded_ks, specialty_quickdraw_ks, 
     * _specialty_blastshield_ks, specialty_detectexplosive_ks, specialty_autospot_ks, 
     * specialty_bulletaccuracy_ks, specialty_quieter_ks, specialty_stalker_ks
    
     * Deathstreaks:
     * specialty_juiced, specialty_revenge, specialty_finalstand, specialty_grenadepulldeath, 
     * specialty_c4death, specialty_stopping_power
    
     * Perks:
     * specialty_paint, specialty_fastreload, specialty_blindeye, specialty_longersprint, specialty_scavenger 
     * specialty_quickdraw, _specialty_blastshield, specialty_hardline, specialty_coldblooded, 
     * specialty_twoprimaries specialty_autospot, specialty_stalker, specialty_detectexplosive, 
     * specialty_bulletaccuracy, specialty_quieter
     
     * Perks Pro:
     * specialty_fastmantle *Extreme Conditoning Pro, specialty_quickswap *sleight of hand Pro*, specialty_extraammo *scavenger pro*, specialty_fasterlockon *Blind Eye Pro Part 1*, specialty_armorpiercing *Blind Eye Pro part 2*, specialty_paint_pro *Recon Pro*, 
     * specialty_rollover *Hardline Pro Part 1*, specialty_assists *Hardline Pro part 2*, specialty_spygame *Assassin Pro Part 1*, specialty_empimmune *Assassin Pro Part 2*, specialty_fastoffhand *Quickdraw Pro*, specialty_overkillpro *Overkill Pro duh*, specialty_stun_resistance *Blastshield Pro*
     * specialty_holdbreath *Marksman pro*, specialty_selectivehearing *Sitrep Pro*, specialty_fastsprintrecovery *Steady Aim Pro*, specialty_falldamage *Dead Silence Pro*, specialty_delaymine *Stalker Pro* 
    
     * Proficiencies:
     * specialty_marksman, specialty_bulletpenetration, specialty_bling, specialty_sharp_focus, 
     * specialty_holdbreathwhileads, specialty_reducedsway, specialty_longerrange, specialty_fastermelee,
     * specialty_lightweight, specialty_moredamage
    
    */
    How do I create this script?

    error is always on and Gamestore WeaponUtils
    Last edited by qwerty939; 02-15-2013 at 02:15 PM.

Similar Threads

  1. [Help Request] Simple Autoit Script help
    By dalehohn13 in forum MapleStory Help
    Replies: 4
    Last Post: 08-09-2013, 12:49 AM
  2. [Help Request] C++ Script Help - Garry's Mod - Forcing r_drawothermodels 2
    By Kai13shadow in forum C++/C Programming
    Replies: 3
    Last Post: 12-08-2012, 01:16 PM
  3. [Help Request] JetBot script help (Two boss maps).
    By Z4ck in forum Vindictus Help
    Replies: 0
    Last Post: 02-20-2012, 08:19 AM
  4. [SOLVED] Anti Camp script help!!!
    By adyson_19 in forum Call of Duty Modern Warfare 2 Help
    Replies: 11
    Last Post: 08-21-2010, 01:50 AM
  5. MPGH Login Script(Help)
    By ShadowPwnz in forum Visual Basic Programming
    Replies: 7
    Last Post: 02-21-2010, 08:16 AM