[Fab] Tag + Gift Command

Posts 1–15 of 19 · Page 1 of 2
[Fab] Tag + Gift Command
Creds: Me and Caeser1928

Tag Command, players can buy a tag, I havent really bothered to put protection on the command (character limit, preventing specific keywords like "Admin" "Donor" etc. and curse words as well lol), all I did was in the sendhelp make some simple tag rules)
If you want to change the price it costs (CURRENTLY 50) just change all "50"'s to the new price.. but don't accidentally erase the - in -50 in the db.UpdateCredit(player.Client.Account, -50); line, that is so it subtracts their gold when they give themselves a tag.

Code:
        internal class TagCommand : Command
        {
            public TagCommand() : base("tag") {}
            protected override bool Process(Player player, RealmTime time, string[] args)
            {
                if (string.IsNullOrEmpty(args[0]))
                {
                    player.SendHelp("******************************************************************");
                    player.SendHelp("Usage: /tag <TagYouWant>");
                    player.SendHelp("8 Character Limit");
                    player.SendHelp("No Spaces, Ex: ''My Tag'', but ''MyTag'' is fine.");
                    player.SendHelp("No Profanity");
                    player.SendHelp("No tags relating/similar to a staff/donator tag");
                    player.SendHelp("******************************************************************");
                    return false;
                }
                if (args.Length == 1)
                {
                    if (player.Client.Account.Credits < 50)
                    {
                        player.SendError("Not enough credits. Credits needed: 50 or above.");
                        return false;
                    }
                    if (player.Client.Account.Credits >= 50)
                    {
                        player.Manager.Database.DoActionAsync(db =>
                        {
                            player.Name = "[" + args[0] + "] " + player.Client.Account.Name;
                            player.Credits = db.UpdateCredit(player.Client.Account, -50);
                            player.UpdateCount++;
                        });
                        int credits = player.Client.Account.Credits - 50;
                        player.SendInfo("Your tag is now: " + args[0]);
                        player.SendInfo("You now have " + credits + " gold!");
                        return true;
                    }
                }
                return true;
            }
        }

Gift command

This one is simple, just like /give, but instead you do /gift {PLAYER} {ITEM} and it will give the given player, the given item, it well say on their screen "You've received {ITEM NAME} from {GIVER}" and the {ITEM} will automatically get sent to their next open slot in their inventory.

Player = You
Plr = Other player

Code:
        internal class GiftCommand : Command
        {
            public GiftCommand()
                : base("gift", "Gift Command - This is used to gift other players items, the item is placed in their inventory", permLevel: 2)
            {
            }
            protected override bool Process(Player player, RealmTime time, string[] args)
            {
                if (args.Length == 1)
                {
                    player.SendHelp("Usage: /gift <Playername> <Itemname>");
                    return false;
                }
                string name = string.Join(" ", args.Skip(1).ToArray()).Trim();
                var plr = player.Manager.FindPlayer(args[0]);
                ushort objType;
                Dictionary<string, ushort> icdatas = new Dictionary<string, ushort>(player.Manager.GameData.IdToObjectType,
                    StringComparer.OrdinalIgnoreCase);
                if (!icdatas.TryGetValue(name, out objType))
                {
                    player.SendError("Item not found, perhaps a spelling error?");
                    return false;
                }
                if (!player.Manager.GameData.Items[objType].Secret || player.Client.Account.Rank >= 4)
                {
                    for (int i = 0; i < plr.Inventory.Length; i++)
                        if (plr.Inventory[i] == null)
                        {
                            plr.Inventory[i] = player.Manager.GameData.Items[objType];
                            plr.UpdateCount++;
                            plr.SaveToCharacter();
                            player.SendInfo("Success sending " + name + " to " + plr.Name);
                            plr.SendInfo("You got a " + name + " from " + player.Name);
                            break;
                        }
                }
                else
                {
                    player.SendError("Item failed sending to " + plr.Name + ", make sure you spelt the command right, and their name!");
                    return false;
                }
                return true;
            }
        }
- - - Updated - - -

I will soon post a tutorial on how to add tags in database (like in Seraphs Dominion for example) so you can edit the players tag in their account row in the database via HeidiSQL or whatever you use, along with an updated /tag command since it will only be slightly different.
Caesar1928 aka Fangobango aka Dante
all i need now is a /take command... :3
Quote Originally Posted by jone112233 View Post
all i need now is a /take command... :3
Ill do that, like "/take playername 1" will clear their first inv slot, along with maybe a command to return whats in their inv like "/inv playername" will send you a message "1- Itemname, 2- itemname, etc." or something similar to that.
Quote Originally Posted by R1S3 View Post
Ill do that, like "/take playername 1" will clear their first inv slot, along with maybe a command to return whats in their inv like "/inv playername" will send you a message "1- Itemname, 2- itemname, etc." or something similar to that.
i was thinking something more like the /take in clubs source where it opens up a trade windows and you can just take stuff
@krazyshank Can you remove the description next to the command name in the gift command, will give people errors, I forgot to remove that and I can't edit post anymore, it's there because I added description in command.cs with CommandName and PermissionLevel, and as you can tell, just gives a description of the command in the quotes, was originally added for a new /help command sorta thing.
Great commands! Can't wait for the Tags in the database tutorial.
Quote Originally Posted by OmegaBM View Post
Great commands! Can't wait for the Tags in the database tutorial.
Honestly I don't know how I would post a tut without copying it word for word from SD's code xD just look there to see how its done, just add tag in the struct, and then copy it and add the database.cs and models.cs and I believe there is also code in the text handler and chatmanager.cs
I got one error.. Help please. Named argument 'permLevel' specifies a parameter for which a positional argument has already been given.
@The 7th Hokage

Did you get that in the /gift command one? If so, try removing
Code:
"Gift Command - This is used to gift other players items, the item is placed in their inventory"
from the line
Code:
: base("gift", "Gift Command - This is used to gift other players items, the item is placed in their inventory", permLevel: 2)
so it looks like
Code:
: base("gift", permLevel: 2)
I forgot to remove that when releasing because I added a description in the command.cs and I had to put it in my command for something secret atm, but yeah.
Also if you got that because you're using SD instead of fabiano, try making the line just
Code:
: base("gift", 2)
i think
If Anyone is having the problem where in game it says you dont have permisson it happened to me just change the code : base("gift", permLevel: 2) and make it : base("gift", permLevel: 1) it worked for me and regs couldnt do it
Can you please add me on skype and help me with adding this, where should i add them??
BTW Thisll mess up pm's to you
Posts 1–15 of 19 · Page 1 of 2

Post a Reply

Similar Threads

Tags for this Thread

None

Need help?