1. I have some problems in making the tables.. or sth like that.

    My working code looks like:
    Code:
    using System.Collections.Generic;
    using System.Reflection;
    using System;
    using System.Data;
    using UnityEngine;
    using Oxide.Core;namespace Oxide.Plugins
    {
        [Info("Mind Freeze", "PaiN", "1.2.0", ResourceId = 1198)]
        [Description("Allows you to freeze players with a legit way.")]
        public class MindFreeze : RustPlugin
        {
            void Loaded()
            {
            if (!permission.PermissionExists("canmindfreeze")) permission.RegisterPermission("canmindfreeze", this);
                //LoadDefaultConfig(); Maybe gonna add this later.
            }
               
               
            private Timer timerrepeat;
           
            [ChatCommand("freeze")]
            void cmdFreeze(BasePlayer player, string cmd, string[] args)
            {
                string steamId = player.userID.ToString();
                if (permission.UserHasPermission(steamId, "canmindfreeze"))
                {
                    var target = BasePlayer.Find(args[0]);
                    var position = target.transform.position;
                    var configPos = new Vector3(position.x, position.y , position.z);                if(Vector3.Distance(target.transform.position, configPos) < 1)
                    {
                    var timerrepeat = timer.Repeat(1, 0, () => target.ClientRPCPlayer(null, target, "ForcePositionTo", new object[] { configPos }));
                    player.TransformChanged();                }
                }
                else
                    SendReply(player, "You do not have permission to use this command!");
           
            }
            [ChatCommand("unfreeze")]//I will find another way to unfreeze but for now i cant think another way to do it.
            void cmdUnFreeze(BasePlayer player, string command, string[] args)
            {
            timerrepeat.Destroy();   
            }
           
           
            public void Unloaded()
            {
                timerrepeat.Destroy();           
            }
        }}
    I wanna do the thing that @Deicide666ra said:
    If it's the same message you send to everyone, simply have a of targets (List<BasePlayer>()) (global) that you add/remove players to/from. In the timer function loop through them and send the msg.

    As its my first time making this thing i do not fully understand his reply.

    What i tried:
    In void Loaded i added:
    Code:
    List<BasePlayer> isFreezed = new List<BasePlayer>;
    
    but then ?
     
  2. Make that list global (outside a function)... I would rename the list to frozenPlayers for clarity.

    Then you can do:

    frozenPlayers.Add(playerIwannaFreeze);

    if (frozenPlayers.Contains(playerImLookingFor))
    {
    // here you know your player is in the list
    }

    frozenPlayers.Remove(playerIwannaUnfreeze);

    If you want to send a message or do an action on all frozen players:

    foreach(var player in frozenPlayers)
    {
    player.ChatMessage("Sup popsicle!");
    }

    If you want to clear the list:

    frozenPlayers.Clear();

    Read documentation on List for more info on what you can do. Some of these functions are LINQ (Contains) and there are a ton of other things you can do with LINQ (sort, exclude a list of players, merge lists, etc).
     
  3. I just realised that C# is giving some non-sense errors..
    So i'm getting errors like "Unexpected symbol "void" " xD after the chatcommand but i get this because of :
    Code:
    List<BasePlayer> frozenPlayers = new List<BasePlayer> 
    
    Everytime that i move it then it *makes* other lines to give me an error ? Dunno how to explain it..

    My code:
    Code:
    using System.Collections.Generic;
    using System.Reflection;
    using System;
    using System.Data;
    using UnityEngine;
    using Oxide.Core;namespace Oxide.Plugins
    {
        [Info("Mind Freeze", "PaiN", "1.2.0", ResourceId = 1198)]
        [Description("Allows you to freeze players with a legit way.")]
        class MindFreeze : RustPlugin
        {
           
            void Loaded()
            {
            if (!permission.PermissionExists("canmindfreeze")) permission.RegisterPermission("canmindfreeze", this);
                //LoadDefaultConfig(); Maybe gonna add this later.
            }
               
            List<BasePlayer> frozenPlayers = new List<BasePlayer>  
             
            private Timer timerrepeat;
           
            [ChatCommand("freeze")]
            void cmdFreeze(BasePlayer player, string cmd, string[] args)
            {
                var target = BasePlayer.Find(args[0]);
                frozenPlayers.Add(target);
                if (frozenPlayers.Contains(target)) 
                {
                    var position = target.transform.position;
                    var configPos = new Vector3(position.x, position.y , position.z);                if(Vector3.Distance(target.transform.position, configPos) < 1)
                    {
                    var timerrepeat = timer.Repeat(1, 0, () => target.ClientRPCPlayer(null, target, "ForcePositionTo", new object[] { configPos }));
                    target.TransformChanged();                }
                }
            }
           
            [ChatCommand("unfreeze")]
            void cmdUnFreeze(BasePlayer player, string command, string[] args)
            {
                var target = BasePlayer.Find(args[0]);
                if (frozenPlayers.Contains(target)) 
                {
                    frozenPlayers.Remove(target);
                }
                       
            }
           
            [ChatCommand("unfreezeall")]
            void cmdUnFreezeAll(BasePlayer player, string command, string[] args)
            {
                frozenPlayers.Clear();       
            }
           
           
            void Unloaded()
            {
                timerrepeat.Destroy(); 
                frozenPlayers.Clear();
            }
        }}
    
     
  4. Your line wasn't complete, try this:
    List<BasePlayer> frozenPlayers =new List<BasePlayer>();
     
  5. Last edited by a moderator: Jul 4, 2015