当前位置: 首页>>代码示例>>C#>>正文


C# TSPlayer.GiveItem方法代码示例

本文整理汇总了C#中TShockAPI.TSPlayer.GiveItem方法的典型用法代码示例。如果您正苦于以下问题:C# TSPlayer.GiveItem方法的具体用法?C# TSPlayer.GiveItem怎么用?C# TSPlayer.GiveItem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TShockAPI.TSPlayer的用法示例。


在下文中一共展示了TSPlayer.GiveItem方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: giveItems

        public void giveItems(TSPlayer ply)
        {
            foreach (KitItem i in items)
            {
                Item item = TShock.Utils.GetItemById(i.id);
                int amount = Math.Min(item.maxStack, i.amt);
                if (item != null)
                    ply.GiveItem(item.type, item.name, item.width, item.height, amount);
            }

            ply.SendMessage(String.Format("{0} kit given. Enjoy!", name), Color.Green);
        }
开发者ID:stevenh,项目名称:Essentials-SignCommands,代码行数:12,代码来源:scKits.cs

示例2: giveItems

        public void giveItems( TSPlayer ply)
        {
            foreach( KitItem i in items )
            {
                List<Item> itemList = TShock.Utils.GetItemByIdOrName(i.id);
                if (itemList.Count == 0)
                {
                    Log.ConsoleError(String.Format("The specified item does not exist: {0}", i.id) );
                    continue;
                }
                else if( itemList.Count > 1 )
                {
                    Log.ConsoleError(String.Format("The specified item has multiple entries: {0}.\n Using the first item.", i.id));
                }

                Item item = itemList[0];

                int amount = Math.Min(item.maxStack, i.amt);
                if( item != null )
                    ply.GiveItem(item.type, item.name, item.width, item.height, amount);
            }

            ply.SendMessage( String.Format("{0} kit given. Enjoy!", name), Color.Green );
        }
开发者ID:Olink,项目名称:Kits,代码行数:24,代码来源:Kit.cs

示例3: drawing

        public static void drawing()
        {
            int r, winner, t;
            string item;
            Random rand, rand2;

            rand=new Random();
            rand2 = new Random();

            r = rand.Next(Lotto.playerindex.Count);
            winner=Lotto.playerindex[r];

            t = rand.Next(Lotto.items.Count);
            item = Lotto.items[t];

            if (removewinner)
            {
                Lotto.playerindex.Remove(winner);
            }

            var winneritem = TShock.Utils.GetItemByIdOrName(item);
            var wwitem = winneritem[0];
            TSPlayer plr = new TSPlayer(winner);

            plr.GiveItem(wwitem.type, wwitem.name, wwitem.width, wwitem.height, 1);
            TSPlayer.All.SendMessage(string.Format("{0} just won a {1} in the lottery!",plr.Name,wwitem.name));
        }
开发者ID:darkvengance,项目名称:tshock-lottery,代码行数:27,代码来源:lotto.cs

示例4: Update

        public void Update(TSPlayer player)
        {
            if ((DateTime.Now - lastDisabled).TotalSeconds > 10)
            {
                disabled = false;
                lastDisabled = DateTime.Now;
            }

            bool bypassFlag = BypassFlag(player);

            bool warning = ((DateTime.Now - lastWarned).TotalSeconds > 1);
            if (regionStorage.flags.Contains("HEAL"))
            {
                if (regionStorage.healinterval < 0 || regionStorage.healamount < 0)
                    return;
                if ((DateTime.Now - lastHealUpdate).TotalSeconds >= regionStorage.healinterval)
                {
                    lastHealUpdate = DateTime.Now;
                    player.Heal(regionStorage.healamount);
                }
            }
            if (regionStorage.flags.Contains("MANA"))
            {
                if (regionStorage.manainterval < 0 || regionStorage.healamount < 0)
                    return;
                if ((DateTime.Now - lastManaUpdate).TotalSeconds >= regionStorage.manainterval)
                {
                    lastManaUpdate = DateTime.Now;
                    var matches = TShock.Utils.GetItemByIdOrName("184");
                    Item star = matches[0];
                    player.GiveItem(star.netID, star.name, star.width, star.height, regionStorage.healamount);
                }
            }
            if (regionStorage.flags.Contains("PRIVATE") && !bypassFlag)
            {
                if (!gotWarnMessage)
                {
                    player.Teleport(lastPos.X, lastPos.Y, 1);
                    player.SendErrorMessage("No permission to enter private region!");
                    gotWarnMessage = true;
                }
            }
            if (regionStorage.flags.Contains("PVP") && !bypassFlag)
            {
                if (!player.TPlayer.hostile)
                {
                    player.SendSuccessMessage("PVP arena entered, pvp enabled.");
                    player.TPlayer.hostile = true;
                    NetMessage.SendData((int)PacketTypes.TogglePvp, -1, -1, "", player.Index);
                }
            }
            if (regionStorage.flags.Contains("NOPVP") && !bypassFlag)
            {
                if (player.TPlayer.hostile)
                {
                    player.SendSuccessMessage("PVP arena entered, pvp disabled.");
                    player.TPlayer.hostile = false;
                    NetMessage.SendData((int)PacketTypes.TogglePvp, -1, -1, "", player.Index);
                }
            }
            if (regionStorage.flags.Contains("TEMPGROUP") && !bypassFlag)
            {
                if (!groupset)
                {
                    player.tempGroup = regionStorage.tempgroup;
                    player.SendSuccessMessage("Your group has been temporarily set to \"{0}\"!", regionStorage.tempgroup.Name);
                    groupset = true;
                }
            }
            if (regionStorage.flags.Contains("DEATH") && !bypassFlag)
            {
                if (!killed)
                {
                    player.DamagePlayer(1200);
                    player.SendErrorMessage("You entered a death zone! RIP");
                    killed = true;
                }
            }
            if (regionStorage.flags.Contains("HURT") && !bypassFlag)
            {
                if (regionStorage.damageinterval < 0 || regionStorage.damageamount< 0)
                    return;
                if ((DateTime.Now - lastDamageUpdate).TotalSeconds >= regionStorage.damageinterval)
                {
                    lastDamageUpdate = DateTime.Now;
                    player.DamagePlayer(regionStorage.damageamount);
                }
            }
            if (regionStorage.flags.Contains("COMMAND") && !bypassFlag)
            {
                if (!executedcommand)
                {
                    if (regionStorage.command != null && regionStorage.command != "")
                    {
                        Commands.HandleCommand(TSPlayer.Server, "/" + regionStorage.command);
                        executedcommand = true;
                    }
                }
            }
            if (regionStorage.flags.Contains("PROMOTE") && !bypassFlag)
//.........这里部分代码省略.........
开发者ID:loohney,项目名称:RegionEvent,代码行数:101,代码来源:PlayerStorage.cs

示例5: DoCommand

        public static void DoCommand(int id, string cmd, TSPlayer tplayer)
        {
            scPlayer doplay = GetscPlayerByID(tplayer.Index);
            Sign sign = Main.sign[id];
            cmd = cmd.ToLower();
            if (tplayer == null || doplay == null || sign == null) return;

            #region Check permissions
            bool stime = tplayer.Group.HasPermission("usesigntime");
            bool sheal = tplayer.Group.HasPermission("usesignheal");
            bool smsg = tplayer.Group.HasPermission("usesignmessage");
            bool sdmg = tplayer.Group.HasPermission("usesigndamage");
            bool sboss = tplayer.Group.HasPermission("usesignspawnboss");
            bool smob = tplayer.Group.HasPermission("usesignspawnmob");
            bool swarp = tplayer.Group.HasPermission("usesignwarp");
            bool sitem = tplayer.Group.HasPermission("usesignitem");
            bool sbuff = tplayer.Group.HasPermission("usesignbuff");
            bool skit = tplayer.Group.HasPermission("usesignkit");
            bool scmd = tplayer.Group.HasPermission("usesigndocommand");
            bool nocool = tplayer.Group.HasPermission("nosccooldown");
            #endregion

            #region Time
            if (cmd.StartsWith("time") && stime && (nocool || ((getConfig.GlobalTimeCooldown && GlobalTimeCooldown <= 0) || (!getConfig.GlobalTimeCooldown && doplay.CooldownTime <= 0))))
            {
                bool done = false;
                if (cmd.StartsWith("time day"))
                {
                    TSPlayer.Server.SetTime(true, 150.0);
                    done = true;
                }
                else if (cmd.StartsWith("time night"))
                {
                    TSPlayer.Server.SetTime(false, 0.0);
                    done = true;
                }
                else if (cmd.StartsWith("time dusk"))
                {
                    TSPlayer.Server.SetTime(false, 0.0);
                    done = true;
                }
                else if (cmd.StartsWith("time noon"))
                {
                    TSPlayer.Server.SetTime(true, 27000.0);
                    done = true;
                }
                else if (cmd.StartsWith("time midnight"))
                {
                    TSPlayer.Server.SetTime(false, 16200.0);
                    done = true;
                }
                else if (cmd.StartsWith("time fullmoon"))
                {
                    TSPlayer.Server.SetFullMoon(true);
                    done = true;
                }
                else if (cmd.StartsWith("time bloodmoon"))
                {
                    TSPlayer.Server.SetBloodMoon(true);
                    done = true;
                }

                if (done)
                {
                    if (!nocool && getConfig.GlobalTimeCooldown)
                        GlobalTimeCooldown = getConfig.TimeCooldown;
                    else
                        doplay.CooldownTime = getConfig.TimeCooldown;
                }
            }
            else if (doplay.toldperm <= 0 && !stime && cmd.StartsWith("time "))
            {
                tplayer.SendMessage("You do not have permission to use this sign command!", Color.IndianRed);
                doplay.toldperm = 5;
            }
            else if (doplay.toldcool <= 0 && stime && (!nocool && (!getConfig.GlobalTimeCooldown && doplay.CooldownTime > 0)) && cmd.StartsWith("time "))
            {
                tplayer.SendMessage("You have to wait another " + doplay.CooldownTime + " seconds before using this sign", Color.IndianRed);
                doplay.toldcool = 5;
            }
            else if (doplay.toldcool <= 0 && stime && (!nocool && (getConfig.GlobalTimeCooldown && GlobalTimeCooldown > 0)) && cmd.StartsWith("time "))
            {
                tplayer.SendMessage("Everyone has to wait another " + GlobalTimeCooldown + " seconds before using this sign", Color.IndianRed);
                doplay.toldcool = 5;
            }
            #endregion

            #region Heal
            if (cmd.StartsWith("heal") && sheal && (nocool || doplay.CooldownHeal <= 0))
            {
                Item heart = TShock.Utils.GetItemById(58);
                Item star = TShock.Utils.GetItemById(184);
                for (int ic = 0; ic < 20; ic++)
                    tplayer.GiveItem(heart.type, heart.name, heart.width, heart.height, heart.maxStack);
                for (int ic = 0; ic < 10; ic++)
                    tplayer.GiveItem(star.type, star.name, star.width, star.height, star.maxStack);
                doplay.CooldownHeal = getConfig.HealCooldown;
            }
            else if (doplay.toldperm <= 0 && !sheal && cmd.StartsWith("heal"))
            {
//.........这里部分代码省略.........
开发者ID:SnirkImmington,项目名称:Essentials-SignCommands,代码行数:101,代码来源:scMain.cs


注:本文中的TShockAPI.TSPlayer.GiveItem方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。