rust跳舞插件:Dance.cs

rust跳舞插件:Dance.cs 通过输入代码,开始跳舞。

给所有玩家跳舞权限:oxide.grant group default dance.use
指令:
跳舞:/tw 1-3
三种类型舞蹈

代码:

using System;
using System.Collections.Generic;

namespace Oxide.Plugins
{
    [Info("Dance", "senyaa", "1.2.0")]
    [Description("This plugin allows players to dance, even if they don't own a VoiceProps DLC")]
    class Dance : RustPlugin
    {
        #region Configuration
        private class PluginConfig
        {
            public uint[] gestureIds;
        }
        PluginConfig config;

        protected override void LoadDefaultConfig()
        {
            Config.WriteObject(GetDefaultConfig(), true);
        }

        private PluginConfig GetDefaultConfig()
        {
            return new PluginConfig
            {
                gestureIds = new uint[] {478760625, 1855420636, 1702547860}
            };
        }

        #endregion

        #region Localization
        protected override void LoadDefaultMessages()
        {
            lang.RegisterMessages(new Dictionary<string, string>
            {
                ["notAllowed"] = "不允许使用此命令",
                ["usage"] = "用法:/tw 1-3"
            }, this, "en");

            lang.RegisterMessages(new Dictionary<string, string>
            {
                ["notAllowed"] = "У вас нет доступа к этой команде",
                ["usage"] = "Используйте: /dance 1/2/3"
            }, this, "ru");
            
        }
        #endregion

        private void Init()
        {
            permission.RegisterPermission("dance.use", this);
            config = Config.ReadObject<PluginConfig>();
        }
		
        private bool? CanUseGesture(BasePlayer player, GestureConfig gesture)
        {
            if (config.gestureIds.Contains(gesture.gestureId) && player.IPlayer.HasPermission("dance.use"))
                return true;
            return null;
        }
		
        [ChatCommand("tw")]
        private void DanceCommand(BasePlayer player, string command, string[] args)
        {
            if(args.Length != 1 || args[0].Length != 1 || !("123".Contains(args[0]))) {
				
                player.IPlayer.Reply(lang.GetMessage("usage", this, player.IPlayer.Id));
                return;
            }

            if (!player.IPlayer.HasPermission("dance.use"))
            {
                player.IPlayer.Reply(lang.GetMessage("notAllowed", this, player.IPlayer.Id));
                return;
            }
            
            foreach (var gesture in player.gestureList.AllGestures)
            {
                if (gesture.gestureId == config.gestureIds[Convert.ToInt64(args[0]) - 1])
                {
                    player.Server_StartGesture(gesture);
                }
            }
        }
    }
}
© 版权声明
THE END
苦逼小编求支持
点赞14赞赏 分享
相关推荐
评论 抢沙发
头像
欢迎您留下宝贵的见解!
提交
头像

昵称

取消
昵称表情代码图片

    暂无评论内容