Ejemplo n.º 1
0
        public static void Players_f(edict_t ent)
        {
            Int32  i;
            Int32  count;
            String small;
            String large;

            Int32[] index = new Int32[256];
            count = 0;
            for (i = 0; i < GameBase.maxclients.value; i++)
            {
                if (GameBase.game.clients[i].pers.connected)
                {
                    index[count] = i;
                    count++;
                }
            }

            index = index.OrderBy(p => p, Cmd.PlayerSort).ToArray();

            large = "";
            for (i = 0; i < count; i++)
            {
                small = GameBase.game.clients[index[i]].ps.stats[Defines.STAT_FRAGS] + " " + GameBase.game.clients[index[i]].pers.netname + "\\n";
                if (small.Length + large.Length > 1024 - 100)
                {
                    large += "...\\n";
                    break;
                }

                large += small;
            }

            SV_GAME.PF_cprintfhigh(ent, large + "\\n" + count + " players\\n");
        }
Ejemplo n.º 2
0
        /**
         * Cmd_Drop_f
         *
         * Drop an inventory item.
         */
        public static void Drop_f(edict_t ent)
        {
            int     index;
            gitem_t it;
            string  s;

            s  = Cmd.Args();
            it = GameItems.FindItem(s);

            if (it == null)
            {
                SV_GAME.PF_cprintfhigh(ent, "unknown item: " + s + "\n");

                return;
            }

            if (it.drop == null)
            {
                SV_GAME.PF_cprintf(ent, Defines.PRINT_HIGH, "Item is not dropable.\n");

                return;
            }

            index = GameItems.ITEM_INDEX(it);

            if (0 == ent.client.pers.inventory[index])
            {
                SV_GAME.PF_cprintfhigh(ent, "Out of item: " + s + "\n");

                return;
            }

            it.drop.drop(ent, it);
        }
Ejemplo n.º 3
0
        public static void Use_f(edict_t ent)
        {
            Int32   index;
            gitem_t it;
            String  s;

            s  = Cmd.Args();
            it = GameItems.FindItem(s);
            Com.Dprintln("using:" + s);
            if (it == null)
            {
                SV_GAME.PF_cprintfhigh(ent, "unknown item: " + s + "\\n");
                return;
            }

            if (it.use == null)
            {
                SV_GAME.PF_cprintfhigh(ent, "Item is not usable.\\n");
                return;
            }

            index = GameItems.ITEM_INDEX(it);
            if (0 == ent.client.pers.inventory[index])
            {
                SV_GAME.PF_cprintfhigh(ent, "Out of item: " + s + "\\n");
                return;
            }

            it.use.Use(ent, it);
        }
Ejemplo n.º 4
0
        public static void PlayerList_f(edict_t ent)
        {
            Int32   i;
            String  st;
            String  text;
            edict_t e2;

            text = "";
            for (i = 0; i < GameBase.maxclients.value; i++)
            {
                e2 = GameBase.g_edicts[1 + i];
                if (!e2.inuse)
                {
                    continue;
                }
                st = "" + (GameBase.level.framenum - e2.client.resp.enterframe) / 600 + ":" + ((GameBase.level.framenum - e2.client.resp.enterframe) % 600) / 10 + " " + e2.client.ping + " " + e2.client.resp.score + " " + e2.client.pers.netname + " " + (e2.client.resp.spectator ? " (spectator)" : "") + "\\n";
                if (text.Length + st.Length > 1024 - 50)
                {
                    text += "And more...\\n";
                    SV_GAME.PF_cprintfhigh(ent, "" + text + "");
                    return;
                }

                text += st;
            }

            SV_GAME.PF_cprintfhigh(ent, text);
        }
Ejemplo n.º 5
0
        /**
         * Cmd_Wave_f
         */
        public static void Wave_f(edict_t ent)
        {
            int i;

            i = Lib.atoi(Cmd.Argv(1));

            // can't wave when ducked
            if ((ent.client.ps.pmove.pm_flags & pmove_t.PMF_DUCKED) != 0)
            {
                return;
            }

            if (ent.client.anim_priority > Defines.ANIM_WAVE)
            {
                return;
            }

            ent.client.anim_priority = Defines.ANIM_WAVE;

            switch (i)
            {
            case 0:
                SV_GAME.PF_cprintfhigh(ent, "flipoff\n");
                ent.s.frame         = M_Player.FRAME_flip01 - 1;
                ent.client.anim_end = M_Player.FRAME_flip12;

                break;

            case 1:
                SV_GAME.PF_cprintfhigh(ent, "salute\n");
                ent.s.frame         = M_Player.FRAME_salute01 - 1;
                ent.client.anim_end = M_Player.FRAME_salute11;

                break;

            case 2:
                SV_GAME.PF_cprintfhigh(ent, "taunt\n");
                ent.s.frame         = M_Player.FRAME_taunt01 - 1;
                ent.client.anim_end = M_Player.FRAME_taunt17;

                break;

            case 3:
                SV_GAME.PF_cprintfhigh(ent, "wave\n");
                ent.s.frame         = M_Player.FRAME_wave01 - 1;
                ent.client.anim_end = M_Player.FRAME_wave11;

                break;

            case 4:
            default:
                SV_GAME.PF_cprintfhigh(ent, "point\n");
                ent.s.frame         = M_Player.FRAME_point01 - 1;
                ent.client.anim_end = M_Player.FRAME_point12;

                break;
            }
        }
Ejemplo n.º 6
0
        /**
         * Cmd_Players_f
         */
        public static void Players_f(edict_t ent)
        {
            int    i;
            int    count;
            string small;
            string large;

            var index = new int[256];

            count = 0;

            for (i = 0; i < GameBase.maxclients.value; i++)
            {
                if (GameBase.game.clients[i].pers.connected)
                {
                    index[count] = i;
                    count++;
                }
            }

            // sort by frags
            Array.Sort(index, 0, count - 1, Cmd.PlayerSort);

            // print information
            large = "";

            for (i = 0; i < count; i++)
            {
                small = GameBase.game.clients[index[i]].ps.stats[Defines.STAT_FRAGS] + " " + GameBase.game.clients[index[i]].pers.netname + "\n";

                if (small.Length + large.Length > 1024 - 100)
                {
                    // can't print all of them in one packet
                    large += "...\n";

                    break;
                }

                large += small;
            }

            SV_GAME.PF_cprintfhigh(ent, large + "\n" + count + " players\n");
        }
Ejemplo n.º 7
0
        public static void InvDrop_f(edict_t ent)
        {
            gitem_t it;

            Cmd.ValidateSelectedItem(ent);
            if (ent.client.pers.selected_item == -1)
            {
                SV_GAME.PF_cprintfhigh(ent, "No item to drop.\\n");
                return;
            }

            it = GameItemList.itemlist[ent.client.pers.selected_item];
            if (it.drop == null)
            {
                SV_GAME.PF_cprintfhigh(ent, "Item is not dropable.\\n");
                return;
            }

            it.drop.Drop(ent, it);
        }
Ejemplo n.º 8
0
        public static void Notarget_f(edict_t ent)
        {
            String msg;

            if (GameBase.deathmatch.value != 0 && GameBase.sv_cheats.value == 0)
            {
                SV_GAME.PF_cprintfhigh(ent, "You must run the server with '+set cheats 1' to enable this command.\\n");
                return;
            }

            ent.flags ^= Defines.FL_NOTARGET;
            if (0 == (ent.flags & Defines.FL_NOTARGET))
            {
                msg = "notarget OFF\\n";
            }
            else
            {
                msg = "notarget ON\\n";
            }
            SV_GAME.PF_cprintfhigh(ent, msg);
        }
Ejemplo n.º 9
0
        public static void God_f(edict_t ent)
        {
            String msg;

            if (GameBase.deathmatch.value != 0 && GameBase.sv_cheats.value == 0)
            {
                SV_GAME.PF_cprintfhigh(ent, "You must run the server with '+set cheats 1' to enable this command.\\n");
                return;
            }

            ent.flags ^= Defines.FL_GODMODE;
            if (0 == (ent.flags & Defines.FL_GODMODE))
            {
                msg = "godmode OFF\\n";
            }
            else
            {
                msg = "godmode ON\\n";
            }
            SV_GAME.PF_cprintf(ent, Defines.PRINT_HIGH, msg);
        }
Ejemplo n.º 10
0
        public static void Noclip_f(edict_t ent)
        {
            String msg;

            if (GameBase.deathmatch.value != 0 && GameBase.sv_cheats.value == 0)
            {
                SV_GAME.PF_cprintfhigh(ent, "You must run the server with '+set cheats 1' to enable this command.\\n");
                return;
            }

            if (ent.movetype == Defines.MOVETYPE_NOCLIP)
            {
                ent.movetype = Defines.MOVETYPE_WALK;
                msg          = "noclip OFF\\n";
            }
            else
            {
                ent.movetype = Defines.MOVETYPE_NOCLIP;
                msg          = "noclip ON\\n";
            }

            SV_GAME.PF_cprintfhigh(ent, msg);
        }
Ejemplo n.º 11
0
        /**
         * Cmd_Give_f
         *
         * Give items to a client.
         */
        public static void Give_f(edict_t ent)
        {
            string  name;
            gitem_t it;
            int     index;
            int     i;
            bool    give_all;
            edict_t it_ent;

            if (GameBase.deathmatch.value != 0 && GameBase.sv_cheats.value == 0)
            {
                SV_GAME.PF_cprintfhigh(ent, "You must run the server with '+set cheats 1' to enable this command.\n");

                return;
            }

            name = Cmd.Args();

            if (0 == Lib.Q_stricmp(name, "all"))
            {
                give_all = true;
            }
            else
            {
                give_all = false;
            }

            if (give_all || 0 == Lib.Q_stricmp(Cmd.Argv(1), "health"))
            {
                if (Cmd.Argc() == 3)
                {
                    ent.health = Lib.atoi(Cmd.Argv(2));
                }
                else
                {
                    ent.health = ent.max_health;
                }

                if (!give_all)
                {
                    return;
                }
            }

            if (give_all || 0 == Lib.Q_stricmp(name, "weapons"))
            {
                for (i = 1; i < GameBase.game.num_items; i++)
                {
                    it = GameItemList.itemlist[i];

                    if (null == it.pickup)
                    {
                        continue;
                    }

                    if (0 == (it.flags & Defines.IT_WEAPON))
                    {
                        continue;
                    }

                    ent.client.pers.inventory[i] += 1;
                }

                if (!give_all)
                {
                    return;
                }
            }

            if (give_all || 0 == Lib.Q_stricmp(name, "ammo"))
            {
                for (i = 1; i < GameBase.game.num_items; i++)
                {
                    it = GameItemList.itemlist[i];

                    if (null == it.pickup)
                    {
                        continue;
                    }

                    if (0 == (it.flags & Defines.IT_AMMO))
                    {
                        continue;
                    }

                    GameItems.Add_Ammo(ent, it, 1000);
                }

                if (!give_all)
                {
                    return;
                }
            }

            if (give_all || Lib.Q_stricmp(name, "armor") == 0)
            {
                gitem_armor_t info;

                it = GameItems.FindItem("Jacket Armor");
                ent.client.pers.inventory[GameItems.ITEM_INDEX(it)] = 0;

                it = GameItems.FindItem("Combat Armor");
                ent.client.pers.inventory[GameItems.ITEM_INDEX(it)] = 0;

                it   = GameItems.FindItem("Body Armor");
                info = (gitem_armor_t)it.info;
                ent.client.pers.inventory[GameItems.ITEM_INDEX(it)] = info.max_count;

                if (!give_all)
                {
                    return;
                }
            }

            if (give_all || Lib.Q_stricmp(name, "Power Shield") == 0)
            {
                it               = GameItems.FindItem("Power Shield");
                it_ent           = GameUtil.G_Spawn();
                it_ent.classname = it.classname;
                GameItems.SpawnItem(it_ent, it);
                GameItems.Touch_Item.touch(it_ent, ent, GameBase.dummyplane, null);

                if (it_ent.inuse)
                {
                    GameUtil.G_FreeEdict(it_ent);
                }

                if (!give_all)
                {
                    return;
                }
            }

            if (give_all)
            {
                for (i = 1; i < GameBase.game.num_items; i++)
                {
                    it = GameItemList.itemlist[i];

                    if (it.pickup != null)
                    {
                        continue;
                    }

                    if ((it.flags & (Defines.IT_ARMOR | Defines.IT_WEAPON | Defines.IT_AMMO)) != 0)
                    {
                        continue;
                    }

                    ent.client.pers.inventory[i] = 1;
                }

                return;
            }

            it = GameItems.FindItem(name);

            if (it == null)
            {
                name = Cmd.Argv(1);
                it   = GameItems.FindItem(name);

                if (it == null)
                {
                    SV_GAME.PF_cprintf(ent, Defines.PRINT_HIGH, "unknown item\n");

                    return;
                }
            }

            if (it.pickup == null)
            {
                SV_GAME.PF_cprintf(ent, Defines.PRINT_HIGH, "non-pickup item\n");

                return;
            }

            index = GameItems.ITEM_INDEX(it);

            if ((it.flags & Defines.IT_AMMO) != 0)
            {
                if (Cmd.Argc() == 3)
                {
                    ent.client.pers.inventory[index] = Lib.atoi(Cmd.Argv(2));
                }
                else
                {
                    ent.client.pers.inventory[index] += it.quantity;
                }
            }
            else
            {
                it_ent           = GameUtil.G_Spawn();
                it_ent.classname = it.classname;
                GameItems.SpawnItem(it_ent, it);
                GameItems.Touch_Item.touch(it_ent, ent, GameBase.dummyplane, null);

                if (it_ent.inuse)
                {
                    GameUtil.G_FreeEdict(it_ent);
                }
            }
        }
Ejemplo n.º 12
0
 /**
  * Command to print the players own position.
  */
 public static void ShowPosition_f(edict_t ent)
 {
     SV_GAME.PF_cprintfhigh(ent, "pos=" + Lib.vtofsbeaty(ent.s.origin) + "\n");
 }
Ejemplo n.º 13
0
        public static void Say_f(edict_t ent, Boolean team, Boolean arg0)
        {
            Int32     i, j;
            edict_t   other;
            String    text;
            gclient_t cl;

            if (Cmd.Argc() < 2 && !arg0)
            {
                return;
            }
            if (0 == (( Int32 )(GameBase.dmflags.value) & (Defines.DF_MODELTEAMS | Defines.DF_SKINTEAMS)))
            {
                team = false;
            }
            if (team)
            {
                text = "(" + ent.client.pers.netname + "): ";
            }
            else
            {
                text = "" + ent.client.pers.netname + ": ";
            }
            if (arg0)
            {
                text += Cmd.Argv(0);
                text += " ";
                text += Cmd.Args();
            }
            else
            {
                if (Cmd.Args().StartsWith("\\\""))
                {
                    text += Cmd.Args().Substring(1, Cmd.Args().Length - 1);
                }
                else
                {
                    text += Cmd.Args();
                }
            }

            if (text.Length > 150)
            {
                text = text.Substring(0, 150);
            }
            text += "\\n";
            if (GameBase.flood_msgs.value != 0)
            {
                cl = ent.client;
                if (GameBase.level.time < cl.flood_locktill)
                {
                    SV_GAME.PF_cprintfhigh(ent, "You can't talk for " + ( Int32 )(cl.flood_locktill - GameBase.level.time) + " more seconds\\n");
                    return;
                }

                i = ( Int32 )(cl.flood_whenhead - GameBase.flood_msgs.value + 1);
                if (i < 0)
                {
                    i = (10) + i;
                }
                if (cl.flood_when[i] != 0 && GameBase.level.time - cl.flood_when[i] < GameBase.flood_persecond.value)
                {
                    cl.flood_locktill = GameBase.level.time + GameBase.flood_waitdelay.value;
                    SV_GAME.PF_cprintf(ent, Defines.PRINT_CHAT, "Flood protection:  You can't talk for " + ( Int32 )GameBase.flood_waitdelay.value + " seconds.\\n");
                    return;
                }

                cl.flood_whenhead = (cl.flood_whenhead + 1) % 10;
                cl.flood_when[cl.flood_whenhead] = GameBase.level.time;
            }

            if (Globals.dedicated.value != 0)
            {
                SV_GAME.PF_cprintf(null, Defines.PRINT_CHAT, "" + text + "");
            }
            for (j = 1; j <= GameBase.game.maxclients; j++)
            {
                other = GameBase.g_edicts[j];
                if (!other.inuse)
                {
                    continue;
                }
                if (other.client == null)
                {
                    continue;
                }
                if (team)
                {
                    if (!GameUtil.OnSameTeam(ent, other))
                    {
                        continue;
                    }
                }

                SV_GAME.PF_cprintf(other, Defines.PRINT_CHAT, "" + text + "");
            }
        }