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.