Mind Freeze

Allows you to freeze players with a legit way.

Total Downloads: 844 - First Release: Jul 4, 2015 - Last Update: Feb 23, 2017

5/5, 6 likes
  1. no worries
     
  2. I'm sorry for the delay .. i will update it today.

    All these days i'm trying to fix the plugin with some other developers ... finally i'm on the right "road" to finish it.
    I just gave some information. Just to keep you updated.
     
  3. PaiN updated Mind Freeze with a new update entry:

    Massive Update!

     
  4. PaiN updated Mind Freeze with a new update entry:

    small fix

     
  5. Console commands?! xD
     
  6. You need console commands too xD?
    I mean i think its not needed ..
     
  7. just asking! i use a lot, the console ! :D
     
  8. Maybe one day i will make it.. For now i wanna chill with some CSGO or LoL :p
     
  9. :D is not important, i was just asking (for future versions) ! :) Enjoy your CSGO or LoL! :p
    [DOUBLEPOST=1436194675,1436183124][/DOUBLEPOST]Hi! For testing propose, i freeze myself and when i tryed to unfreeze i've got this:
    Error] Failed to call hook 'cmdUnFreeze' on plugin 'Mind Freeze' (NullReferenceException: Object reference not set to an instance of an object)

    I had to unload the plugin! :)
    ??
     
  10. Are you sure ? for me its working.
     
  11. :D
    1st : /freeze myname/mysteamid (i tryed 2nd with my steamid)
    -------------------------------------------------------------------------------------
    2nd: /unfreeze name/mysteamid
    3rd: /unfreeze all
    all this above: [Error] Failed to call hook 'cmdUnFreeze' on plugin 'Mind Freeze' (NullReferenceException: Object reference not set to an instance of an object)
    -------------------------------------------------------------------------------------
    4th: oxide.unload MindFreeze (this worked xD )
     
  12. this plugin works with names not steamid's
    and the command to unfreeze all is "/unfreezeall"
     
  13. 1: Works with steamID! (because i'm freezed right now: /freeze mysteamid)
    2. Unknown command "unfreezeall' (/unfreezeall)
    [DOUBLEPOST=1436196363][/DOUBLEPOST]:))))))))))))))))))))))))))))))))))))))))
    Solved!!!
    I forgot to paste the new version! I used old version 1.3.0! I copied the new version, but never pasted! :))))
    Sorryyyyy my bad!!!!!!!! XD

    Everything is working! Sorry again !
     
    Last edited by a moderator: Jul 6, 2015
  14. I dont know how .. but for me everything is working well. gonna test again in some minutes.. ehhh
     
  15. As you are using the standard rust player finding method, add
    Code:
    if(targetPlayer == null)
    {
        SendReply(player, "Player not found!")
        return;
    }
    that may have been the reason

    EDIT: eventhough it was the reason that the plugin was outdated, its still useful
     
  16. I already done it for the version that i will post in some hours.. but i need to test firstly.
     
  17. or use the methods :p
     
  18. I was like WTF is he talking about xD

    Yep the latest version should work properly but it needs some cleanup and some minor changes (next update)
     
  19. You should use a Dictionary instead of a List... Dictionaries don't allow for duplicate entries.

    Also in the freeze command you don't need these:

    If target is null or player doesn't exist, you'll never get to the "if(target == null) return;"
    Code:
                    if (!target)
                    {
                        SendReply(player, "Player not found!");
                        return;
                    }
                    if (target == null) return;
    
    I would change it to just this...

    Code:
                    if (target == null)
                    {
                        SendReply(player, "Player not found!");
                        return;
                    }
    
    I changed what I think it should be... But I haven't tested it... But essentially I commented out a few things, made it much more simpler... If you like it, use it, if not. Oh well... I tried

    Code:
    using System.Collections.Generic;
    using System.Reflection;
    using System;
    using System.Linq;
    using System.Data;
    using UnityEngine;
    using Oxide.Core;namespace Oxide.Plugins
    {
        [Info("Mind Freeze", "PaiN", "2.1.0", ResourceId = 1198)]
        [Description("Allows you to freeze players with a legit way.")]
        class MindFreeze : RustPlugin
        {
            private Timer _timer;        /*private class FrozenPlayerInfo
            {
                public BasePlayer Player { get; set; }
                public Vector3 FrozenPosition { get; set; }            public FrozenPlayerInfo(BasePlayer player)
                {
                    Player = player;
                    FrozenPosition = player.transform.position;
                }
            }*/        Dictionary<string, Vector3> frozenPlayers = new Dictionary<string, Vector3>();
            //List<FrozenPlayerInfo> frozenPlayers = new List<FrozenPlayerInfo>();        void Loaded()
            {
                if (!permission.PermissionExists("canmindfreeze")) permission.RegisterPermission("canmindfreeze", this);
                //LoadDefaultConfig(); Maybe gonna add this later.
                _timer= timer.Every(1, OnTimer);
            }        [ChatCommand("freeze")]
            void cmdFreeze(BasePlayer player, string cmd, string[] args)
            {
                var target = BasePlayer.Find(args[0]);
                string steamId = Convert.ToString(player.userID);
                if (args.Length == 1)
                {
                    if (!permission.UserHasPermission(steamId, "canmindfreeze"))
                    {
                        SendReply(player, "No Permission!");
                        return;
                    }
                   
                    if (target == null)
                    {
                        SendReply(player, "Player not found!");
                        return;
                    }
                    //if (target == null) return;
                    ulong Tuserid = 0;
                    if (frozenPlayers.TryGetValue(target.userID, out Tuserid))
                    {
                        SendReply(player, "Target player already frozen!");
                        return;
                    }
                    else
                    {
                        frozenPlayers.Add(target.userID.ToString(), target.transform.position);
                        SendReply(target, "You have been frozen by " + player.displayName);
                        SendReply(player, "You have frozen " + target.displayName);
                    }
                    //if (frozenPlayers.Any(t => t.Player == target)) return;
                    //SendReply(target, "You have been frozen by " + player.displayName);
                    //SendReply(player, "You have frozen " + target.displayName);
                }
                else
                {
                    SendReply(player, "Syntax: /freeze \"player\" ");
                    return;
                }
            }
           
                   [ChatCommand("unfreeze")]
            void cmdUnFreeze(BasePlayer player, string cmd, string[] args)
            {
                var target = BasePlayer.Find(args[0]);
                string steamId = Convert.ToString(player.userID);
                if (args.Length == 1)
                {
                    if (!permission.UserHasPermission(steamId, "canmindfreeze"))
                    {
                       SendReply(player, "No Permission!");
                       return;
                    }
                   
                    if (target == null)
                    {
                       SendReply(player, "Player not found!");
                       return;
                    }                if(frozenPlayers.ContainsKey(target.userID.ToString()))
                    {
                        frozenPlayers.Remove(target.userID.ToString());
                       SendReply(target, "You have been unfrozen by " + player.displayName);
                       SendReply(player, "You have unfrozen " + target.displayName);
                    }
                    //frozenPlayers.RemoveAll(t => t.Player == target);
                    //SendReply(target, "You have been unfrozen by " + player.displayName);
                    //SendReply(player, "You have unfrozen " + target.displayName);
                }
                else
                {
                    SendReply(player, "Syntax: /unfreeze \"player\" ");
                    return;
                }   
            }        [ChatCommand("unfreezeall")]
            void cmdUnFreezeAll(BasePlayer player, string cmd, string[] args)
            {
                string steamId = Convert.ToString(player.userID);
                if (permission.UserHasPermission(steamId, "canmindfreeze"))
                {
                    frozenPlayers.Clear();
                    SendReply(player, "All players now unfrozen!");
                }
                else
                {
                    SendReply(player, "No Permission!");
                }
            }        void OnTimer()
            {
                foreach(var FrozenPlayer in frozenPlayers)
                {
                    BasePlayer p = BasePlayer.FindByID(Convert.ToUInt64(FrozenPlayer.Key));
                    if (p == null) return;
                    if (Vector3.Distance(p.transform.position, FrozenPlayer.Value) < 1) continue;
                    p.ClientRPCPlayer(null, p, "ForcePositionTo", new object[] { FrozenPlayer.Value });
                    p.TransformChanged();
                }
                /*
                foreach (FrozenPlayerInfo current in frozenPlayers)
                {
                    if (Vector3.Distance(current.Player.transform.position, current.FrozenPosition) < 1) continue;
                    current.Player.ClientRPCPlayer(null, current.Player, "ForcePositionTo", new object[] { current.FrozenPosition });
                    current.Player.TransformChanged();
                }*/
            }        void Unloaded()
            {
                _timer.Destroy();
                frozenPlayers.Clear();
            }
        }
    }
    
    Also if it doesn't work, let me know the errors and such.

    If it does work, and you don't understand it. I'll be happy to explain more.

    Dictionaries are a good way to avoid writing more code as long as you understand them.
     
    Last edited by a moderator: Jul 6, 2015
  20. I mean its okay that someone helps me with my plugin but i do feel like 100% i did it.

    But nvm

    So an error line 59
    http://screenshot.sh/ouD4nI9PSeshO