HelpCommand rank [Fabiano]

Posts 1–14 of 14 · Page 1 of 1
Command rank [Fabiano]
How can I change the minimum rank needed to use certain command? I've tried some stuff tho I get Unknown Command, can anyone help?
Oi! Eu posso te ajudar, eu descobri como resolve isso mas eu estou com erro no meu e eu queria saber se você nao quer tentar resolver cmg, o meu skype é skatista.pro me add la falando que vc é desse forum
This is very easy. This is an example command. Where it says : base("give", 1), the 1 means admin only and 0 means everyone can use the command.

Code:
internal class GiveCommand : Command
    {
        public GiveCommand()
            : base("give", 1)
        {
        }

        protected override bool Process(Player player, RealmTime time, string[] args)
        {
            if (args.Length == 0)
            {
                player.SendHelp("Usage: /give <Itemname>");
                return false;
            }
            string name = string.Join(" ", args.ToArray()).Trim();
            ushort objType;
            //creates a new case insensitive dictionary based on the XmlDatas
            Dictionary<string, ushort> icdatas = new Dictionary<string, ushort>(player.Manager.GameData.IdToObjectType,
                StringComparer.OrdinalIgnoreCase);
            if (!icdatas.TryGetValue(name, out objType))
            {
                player.SendError("Unknown type!");
                return false;
            }
            if (!player.Manager.GameData.Items[objType].Secret || player.Client.Account.Rank >= 4)
            {
                for (int i = 0; i < player.Inventory.Length; i++)
                    if (player.Inventory[i] == null)
                    {
                        player.Inventory[i] = player.Manager.GameData.Items[objType];
                        player.UpdateCount++;
                        player.SaveToCharacter();
                        player.SendInfo("Success!");
                        break;
                    }
            }
            else
            {
                player.SendError("Item cannot be given!");
                return false;
            }
            return true;
        }
    }
Quote Originally Posted by toby2449 View Post
This is very easy. This is an example command. Where it says : base("give", 1), the 1 means admin only and 0 means everyone can use the command.

Code:
internal class GiveCommand : Command
    {
        public GiveCommand()
            : base("give", 1)
        {
        }

        protected override bool Process(Player player, RealmTime time, string[] args)
        {
            if (args.Length == 0)
            {
                player.SendHelp("Usage: /give <Itemname>");
                return false;
            }
            string name = string.Join(" ", args.ToArray()).Trim();
            ushort objType;
            //creates a new case insensitive dictionary based on the XmlDatas
            Dictionary<string, ushort> icdatas = new Dictionary<string, ushort>(player.Manager.GameData.IdToObjectType,
                StringComparer.OrdinalIgnoreCase);
            if (!icdatas.TryGetValue(name, out objType))
            {
                player.SendError("Unknown type!");
                return false;
            }
            if (!player.Manager.GameData.Items[objType].Secret || player.Client.Account.Rank >= 4)
            {
                for (int i = 0; i < player.Inventory.Length; i++)
                    if (player.Inventory[i] == null)
                    {
                        player.Inventory[i] = player.Manager.GameData.Items[objType];
                        player.UpdateCount++;
                        player.SaveToCharacter();
                        player.SendInfo("Success!");
                        break;
                    }
            }
            else
            {
                player.SendError("Item cannot be given!");
                return false;
            }
            return true;
        }
    }
What if I want rank 2 to be able to use certain command? considering rank 3 is Admin
Sure I guess you could try that.
Quote Originally Posted by toby2449 View Post
Sure I guess you could try that.
But how do I do it? the number 1 is from the Command file where it checks if the account is Rank 3 and returns 1, but how do I do it to rank 2?
Quote Originally Posted by imSHIELD View Post
But how do I do it?
Change the number to the rank that you desire.
Quote Originally Posted by toby2449 View Post
Change the number to the rank that you desire.
That number is not the rank, doesn't work
Quote Originally Posted by imSHIELD View Post
That number is not the rank, doesn't work
Whoops! The number of the rank is here:

if (!player.Manager.GameData.Items[objType].Secret || player.Client.Account.Rank >= 4) <---- THERE
Quote Originally Posted by toby2449 View Post
Whoops! The number of the rank is here:

if (!player.Manager.GameData.Items[objType].Secret || player.Client.Account.Rank >= 4) <---- THERE
Also not working '-'
Quote Originally Posted by imSHIELD View Post
Also not working '-'
You're not rebuilding because thats the answer.
Quote Originally Posted by toby2449 View Post
You're not rebuilding because thats the answer.
Considering I've added maps, changed behaviors, added, etc I think I rebuilded quite alot of times '-'
If you set it to 0 then any player can use command, if its 1 that means its for admins only and admin is any rank bigger then 1 if i'm right.
@ossimc82 let me know if im wrong (Used that source only once :P)
Quote Originally Posted by ~V~ View Post
If you set it to 0 then any player can use command, if its 1 that means its for admins only and admin is any rank bigger then 1 if i'm right.
@ossimc82 let me know if im wrong (Used that source only once :P)
You're right but if u check Command.cs there's a code that checks the account rank:
private static int GetPermissionLevel(Player player)
{
if (player.Client.Account.Rank == 3)
return 1;
return 0;
}
These codes are all in the (Command) class, I tried adding another thing (DCommand) that checks account.rank == 2, created (DCommandManager) for (DCommand) and when making a new command I had to do this:

internal class DGiveCommand : DCommand
But when I go inside the game, It says Non-existing command, but there's no errors on any coding since VB doesn't give any, and I don't really see what's wrong
Posts 1–14 of 14 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Talk with us