/temprank

/temprank

Postby toystory_justin » 22 Feb 2013, 13:06

Hello, I was just wondering if there was a /temprank command on McDzienny, McForge has this, and it looks good cause people keep asking for ranks on servers. I wish the /temprank command consists the following commands:

/temprank [name] [rank] - gives temprank a player with the specified time
/temprankremove [name] - removes temprank from player
/temprankclearall - removes all given tempranks

Thanks,
Hope this would be a good command for the software. :D
toystory_justin
 
Posts: 224
Joined: 11 Nov 2012, 07:12
Location: On a dark place

Re: /temprank

Postby HelloWorldCool » 22 Feb 2013, 21:47

Already requested several times, from multiple people, including me.

I feel that /temprank (for every indiv. rank) will not be useful for server owners that use the "money rank system" to promote players. Players can already be promoted (get ranks) through buying.
Download fCraft maps! - viewtopic.php?f=25&t=3012!



Note: The Developer(s) of MCDzienny have resigned and the software is no longer supported.
Errors are bound to occur and Mojang has not attempted to resolve them.
User avatar
HelloWorldCool
 
Posts: 867
Joined: 18 Oct 2011, 00:19
Location: MCDzienny Forums, HelloWorldCool Forums

Re: /temprank

Postby SS_Legend » 22 Feb 2013, 22:17

HelloWorldCool wrote:Already requested several times, from multiple people, including me.

I feel that /temprank (for every indiv. rank) will not be useful for server owners that use the "money rank system" to promote players. Players can already be promoted (get ranks) through buying.

Though you're right about buying the ranks and whatnot, but what if you wanted to promote someone to OP for a amount of time?
Owner of [LS] Servers

Lava Survival: Image
Zombie Survival: Image
Website: http://legendservers.enjin.com/
SS_Legend
 
Posts: 116
Joined: 24 Feb 2012, 00:54

Re: /temprank

Postby ismellike » 22 Feb 2013, 23:06

I made the temprank for you guys from lawl source <3

/temprank [name][rank][time]
^time is in seconds

*updated, now you can use it on yourself for experimenting.

Code: Select all
/*
   Copyright 2010 MCSharp team (Modified for use with MCZall/MCLawl) Licensed under the
   Educational Community License, Version 2.0 (the "License"); you may
   not use this file except in compliance with the License. You may
   obtain a copy of the License at
   
   http://www.osedu.org/licenses/ECL-2.0
   
   Unless required by applicable law or agreed to in writing,
   software distributed under the License is distributed on an "AS IS"
   BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
   or implied. See the License for the specific language governing
   permissions and limitations under the License.
*/
//Edited by pro ismellike <3 for my lovers
using System;
using System.Threading;

namespace MCDzienny
{
    public class CmdTemprank : Command
    {
        public override string name { get { return "temprank"; } }
        public override string shortcut { get { return "tr"; } }
        public override string type { get { return "mod"; } }
        public override bool museumUsable { get { return true; } }
        public override LevelPermission defaultRank { get { return LevelPermission.Admin; } }

        public override void Use(Player p, string message)
        {
              if (message.Split(' ').Length < 3) { Help(p); return; }
            Player who = Player.Find(message.Split(' ')[0]);
            Group newRank = Group.Find(message.Split(' ')[1]);
         int msg = Convert.ToInt32(message.Split(' ')[2]);
       Group oldGroup = Group.findPlayerGroup(who.name);
         int time=msg*1000;

            if (newRank == null) { Player.SendMessage(p, "Could not find specified rank."); return; }

            Group bannedGroup = Group.findPerm(LevelPermission.Banned);
            if (who == null)
            {
                if (Group.findPlayerGroup(who.name) == bannedGroup || newRank == bannedGroup)
                {
                    Player.SendMessage(p, "Cannot change the rank to or from \"" + bannedGroup.name + "\".");
                    return;
                }

                if (p != null)
                {
                    if (Group.findPlayerGroup(who.name).Permission >= p.group.Permission || newRank.Permission >= p.group.Permission)
                    {
               if(p.group.Permission<=LevelPermission.Admin){
                        Player.SendMessage(p, "Cannot change the rank of someone equal or higher than you"); return;}
                    }
                }

                oldGroup.playerList.Remove(who.name);
                oldGroup.playerList.Save();

                newRank.playerList.Add(who.name);
                newRank.playerList.Save();

                Player.GlobalMessage(who.name + " &f(offline)" + Server.DefaultColor + "'s rank was set to " + newRank.color + newRank.name);
            }
            else if (who == p&&p.group.Permission<=LevelPermission.Admin)
            {
                Player.SendMessage(p, "Cannot change your own rank."); return;
         }
            else
            {
                if (p != null)
                {
                    if (who.group == bannedGroup || newRank == bannedGroup)
                    {
                        Player.SendMessage(p, "Cannot change the rank to or from \"" + bannedGroup.name + "\".");
                        return;
                    }

                    if (who.group.Permission >= p.group.Permission || newRank.Permission >= p.group.Permission)
                    {
               if(p.group.Permission<=LevelPermission.Admin){
                        Player.SendMessage(p, "Cannot change the rank of someone equal or higher to yourself."); return;
                  }
                    }
                }

                who.group.playerList.Remove(who.name);
                who.group.playerList.Save();
            Player.GlobalMessage(who.color+who.name+" %eis temporarily ranked for "+msg.ToString()+" seconds");
                newRank.playerList.Add(who.name);
                newRank.playerList.Save();

                Player.GlobalChat(who, who.color + who.name + Server.DefaultColor + "'s rank was set to " + newRank.color + newRank.name, false);
                who.group = newRank;
                who.color = who.group.color;
                Player.GlobalDie(who, false);
                who.SendMessage("You are now ranked " + newRank.color + newRank.name + Server.DefaultColor + ", type /help for your new set of commands.");
            }
         Thread.Sleep(time);
         Player.GlobalMessage(who.color+who.name+" %ewas reverted to their original rank.");
                         who.group = oldGroup;
                who.color = oldGroup.color;
                Player.GlobalDie(who, false);
                         newRank.playerList.Remove(who.name);
                newRank.playerList.Save();
            
         who.group.playerList.Add(who.name);
                who.group.playerList.Save();

                oldGroup.playerList.Add(who.name);
                oldGroup.playerList.Save();
        }
        public override void Help(Player p)
        {
            Player.SendMessage(p, "/temprank <player> <rank> <time> - Sets or returns a players rank temporarily.");
            Player.SendMessage(p, "You may use /tr as a shortcut");
        }
    }
}

What a beast...
User avatar
ismellike
Coder
 
Posts: 731
Joined: 31 Oct 2012, 04:04
Location: Kansas

Re: /temprank

Postby toystory_justin » 22 Feb 2013, 23:51

Thank you isme,cyour the best! :D
toystory_justin
 
Posts: 224
Joined: 11 Nov 2012, 07:12
Location: On a dark place

Re: /temprank

Postby HelloWorldCool » 23 Feb 2013, 00:28

Lol, not to be mister obvious, but that was quick.
Download fCraft maps! - viewtopic.php?f=25&t=3012!



Note: The Developer(s) of MCDzienny have resigned and the software is no longer supported.
Errors are bound to occur and Mojang has not attempted to resolve them.
User avatar
HelloWorldCool
 
Posts: 867
Joined: 18 Oct 2011, 00:19
Location: MCDzienny Forums, HelloWorldCool Forums

Re: /temprank

Postby ismellike » 23 Feb 2013, 00:32

Yeah i just had to change some stuff from the /setrank source code.
What a beast...
User avatar
ismellike
Coder
 
Posts: 731
Joined: 31 Oct 2012, 04:04
Location: Kansas

Re: /temprank

Postby Conor » 24 Feb 2013, 13:30

That is an interesting edit of /setrank, but there is a limitation here you must combat. What happens if the player leaves before your Thread has finished sleeping? They keep their new (temporary) rank. To combat this you can simply create a string variable which holds the players name, which you can then use after the Thread has finished sleeping to demote the player. For example,

Code: Select all
string oldRank = Player.group.name;
string playerName = Player.PublicName;

// Do the promotion and Thread.Sleep here
// After the time has ended:

Command.all.Find("setrank").Use(null, playerName + " " + oldRank);
if (Player != null)
{
   Player.SendMessage(Player, "You have reached the time limit for your time rank and have been demoted.");
}
Conor (Conanza121)
User avatar
Conor
Coder
 
Posts: 390
Joined: 10 Oct 2012, 21:36
Location: @21Conor

Re: /temprank

Postby Conor » 24 Feb 2013, 13:42

Also there is one more thing I noticed which you may edit to avoid errors:
Code: Select all
int msg = Convert.ToInt32(message.Split(' ')[2]);


You need to make sure you check that the string can be parsed to an int variable (i.e. they type numbers not letters). You can use int.TryParse or the 'try catch statement'. I prefer the latter:

Code: Select all
try
{
   int.Parse(message.Split(' ')[2]);
}
catch
{
   Player.SendMessage(p, "Invalid time.");
   return;
}
int msg = int.Parse(message.Split(' ')[2]);
Conor (Conanza121)
User avatar
Conor
Coder
 
Posts: 390
Joined: 10 Oct 2012, 21:36
Location: @21Conor

Re: /temprank

Postby ismellike » 26 Feb 2013, 16:48

Ok this fixes some stuff like names being added 2x and some of what Conor said above.

Code: Select all
/*
   Copyright 2010 MCSharp team (Modified for use with MCZall/MCLawl) Licensed under the
   Educational Community License, Version 2.0 (the "License"); you may
   not use this file except in compliance with the License. You may
   obtain a copy of the License at
   
   http://www.osedu.org/licenses/ECL-2.0
   
   Unless required by applicable law or agreed to in writing,
   software distributed under the License is distributed on an "AS IS"
   BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
   or implied. See the License for the specific language governing
   permissions and limitations under the License.
*/
//Edited by pro ismellike <3 for my lovers
using System;
using System.Threading;

namespace MCDzienny
{
    public class CmdTemprank : Command
    {
        public override string name { get { return "temprank"; } }
        public override string shortcut { get { return "tr"; } }
        public override string type { get { return "mod"; } }
        public override bool museumUsable { get { return true; } }
        public override LevelPermission defaultRank { get { return LevelPermission.Admin; } }

        public override void Use(Player p, string message)
        {
              if (message.Split(' ').Length < 3) { Help(p); return; }
            Player who = Player.Find(message.Split(' ')[0]);
            Group newRank = Group.Find(message.Split(' ')[1]);
      try{Convert.ToInt32(message.Split(' ')[2]);}
      catch{Player.SendMessage(p, message.Split(' ')[2]+" is definantly not a number...");
      return;}
      int msg = Convert.ToInt32(message.Split(' ')[2]);
       Group oldGroup = Group.findPlayerGroup(who.name);
         int time=msg*1000;

            if (newRank == null) { Player.SendMessage(p, "Could not find specified rank."); return; }

            Group bannedGroup = Group.findPerm(LevelPermission.Banned);
            if (who == null)
            {
                if (Group.findPlayerGroup(who.name) == bannedGroup || newRank == bannedGroup)
                {
                    Player.SendMessage(p, "Cannot change the rank to or from \"" + bannedGroup.name + "\".");
                    return;
                }
                if (who.group.Permission < LevelPermission.Operator)
                {
                    Player.SendMessage(p, "%aDon't give power to noobs."); return;
                }
                if (p != null)
                {
                    if (Group.findPlayerGroup(who.name).Permission >= p.group.Permission || newRank.Permission >= p.group.Permission)
                    {
                        if (p.group.Permission <= LevelPermission.Admin)
                        {
                            Player.SendMessage(p, "Cannot change the rank of someone equal or higher than you"); return;
                        }
                    }
                }

                oldGroup.playerList.Remove(who.name);
                oldGroup.playerList.Save();

                newRank.playerList.Add(who.name);
                newRank.playerList.Save();

                Player.GlobalMessage(who.name + " &f(offline)" + Server.DefaultColor + "'s rank was set to " + newRank.color + newRank.name);
            }
            else if (who == p && p.group.Permission <= LevelPermission.Admin)
            {
                Player.SendMessage(p, "Cannot change your own rank."); return;
            }
            else
            {
                if (p != null)
                {
                    if (who.group == bannedGroup || newRank == bannedGroup)
                    {
                        Player.SendMessage(p, "Cannot change the rank to or from \"" + bannedGroup.name + "\".");
                        return;
                    }

                    if (who.group.Permission >= p.group.Permission || newRank.Permission >= p.group.Permission)
                    {
                        if (p.group.Permission <= LevelPermission.Admin)
                        {
                            Player.SendMessage(p, "Cannot change the rank of someone equal or higher to yourself."); return;
                        }
                    }
                }
                if (who.group.Permission < LevelPermission.Operator)
                {
                    Player.SendMessage(p, "%aDon't give power to noobs."); return;
                }
                who.group.playerList.Remove(who.name);
                who.group.playerList.Save();
                Player.GlobalMessage(who.color + who.name + " %eis temporarily ranked for " + msg.ToString() + " seconds");
                newRank.playerList.Add(who.name);
                newRank.playerList.Save();

                Player.GlobalChat(who, who.color + who.name + Server.DefaultColor + "'s rank was set to " + newRank.color + newRank.name, false);
                who.group = newRank;
                who.color = who.group.color;
                Player.GlobalDie(who, false);
                who.SendMessage("You are now ranked " + newRank.color + newRank.name + Server.DefaultColor + ", type /help for your new set of commands.");
            }
         Thread.Sleep(time);
         Player.GlobalMessage(who.color+who.name+" %awas reverted to their original rank.");
                         who.group = oldGroup;
                who.color = oldGroup.color;
                        
             newRank.playerList.Remove(who.name);
                newRank.playerList.Save();
            

                oldGroup.playerList.Add(who.name);
                oldGroup.playerList.Save();
        }
        public override void Help(Player p)
        {
            Player.SendMessage(p, "/temprank <player> <rank> <time> - Sets or returns a players rank temporarily.");
            Player.SendMessage(p, "You may use /tr as a shortcut");
        }
    }
}

What a beast...
User avatar
ismellike
Coder
 
Posts: 731
Joined: 31 Oct 2012, 04:04
Location: Kansas

Next

Return to Requests for Addon

Who is online

Users browsing this forum: No registered users and 9 guests

cron