Dye/Cloth changing command

Posts 1–15 of 30 · Page 1 of 2
Dye/Cloth changing command
Edits your actual dye (1 is the body one, 2 is the accessory) on the DB and on char (no need to nexus). You need to enter the value "Tex#" (#=1/2) in the dyes/cloths XMLs.
Just add this to the commands:
Code:
else if (cmd.Equals("dye1", StringComparison.OrdinalIgnoreCase))
            {
                int converted = dyes_hextointmod.hextoint(args[0].ToString(), false);
                using (var db1 = new Database())
                {
                    using (var mysqlcommand = db1.CreateQuery())
                    {
                        mysqlcommand.CommandText = "UPDATE characters SET tex1 = @tex1 WHERE accId=@accId AND charId=@charId AND charId=@charId;";
                        mysqlcommand.Parameters.AddWithValue("@accId", psr.Account.AccountId);
                        mysqlcommand.Parameters.AddWithValue( @tex1", converted);
                        mysqlcommand.Parameters.AddWithValue("@charId", psr.Character.CharacterId);
                        if (mysqlcommand.ExecuteNonQuery() > 0)
                            psr.SendPacket(new TextPacket()
                            {
                                BubbleTime = 0,
                                Stars = -1,
                                Name = "",
                                Text = "Modified dye!"
                            });
                        else if (mysqlcommand.ExecuteNonQuery() == -1)
                            psr.SendPacket(new TextPacket()
                            {
                                BubbleTime = 0,
                                Stars = -1,
                                Name = "",
                                Text = "Modified dye!"
                            });
                        else
                            psr.SendPacket(new TextPacket()
                            {
                                BubbleTime = 0,
                                Stars = -1,
                                Name = "",
                                Text = "Error!"
                            });
                    }
                };
                psr.Player.Texture1 = converted;
                UpdateCount++;
            }
            else if (cmd.Equals("cloth1", StringComparison.OrdinalIgnoreCase))
            {
                int converted = dyes_hextointmod.hextoint(args[0].ToString(), true);
                using (var db1 = new Database())
                {
                    using (var mysqlcommand = db1.CreateQuery())
                    {
                        mysqlcommand.CommandText = "UPDATE characters SET tex1 = @tex1 WHERE accId=@accId AND charId=@charId AND charId=@charId;";
                        mysqlcommand.Parameters.AddWithValue("@accId", psr.Account.AccountId);
                        mysqlcommand.Parameters.AddWithValue( @tex1", converted);
                        mysqlcommand.Parameters.AddWithValue("@charId", psr.Character.CharacterId);
                        if (mysqlcommand.ExecuteNonQuery() > 0)
                            psr.SendPacket(new TextPacket()
                            {
                                BubbleTime = 0,
                                Stars = -1,
                                Name = "",
                                Text = "Modified cloth!"
                            });
                        else if (mysqlcommand.ExecuteNonQuery() == -1)
                            psr.SendPacket(new TextPacket()
                            {
                                BubbleTime = 0,
                                Stars = -1,
                                Name = "",
                                Text = "Modified cloth!"
                            });
                        else
                            psr.SendPacket(new TextPacket()
                            {
                                BubbleTime = 0,
                                Stars = -1,
                                Name = "",
                                Text = "Error!"
                            });
                    }
                };
                psr.Player.Texture1 = converted;
                UpdateCount++;
            }
            else if (cmd.Equals("dye2", StringComparison.OrdinalIgnoreCase))
            {
                int converted = dyes_hextointmod.hextoint(args[0].ToString(), false);
                using (var db1 = new Database())
                {
                    using (var mysqlcommand = db1.CreateQuery())
                    {
                        mysqlcommand.CommandText = "UPDATE characters SET tex2 = @tex2 WHERE accId=@accId AND charId=@charId;";
                        mysqlcommand.Parameters.AddWithValue("@accId", psr.Account.AccountId);
                        mysqlcommand.Parameters.AddWithValue( @tex2", converted);
                        mysqlcommand.Parameters.AddWithValue("@charId", psr.Character.CharacterId);
                        if (mysqlcommand.ExecuteNonQuery() > 0)
                            psr.SendPacket(new TextPacket()
                            {
                                BubbleTime = 0,
                                Stars = -1,
                                Name = "",
                                Text = "Modified dye!"
                            });
                        else if (mysqlcommand.ExecuteNonQuery() == -1)
                            psr.SendPacket(new TextPacket()
                            {
                                BubbleTime = 0,
                                Stars = -1,
                                Name = "",
                                Text = "Modified dye!"
                            });
                        else
                            psr.SendPacket(new TextPacket()
                            {
                                BubbleTime = 0,
                                Stars = -1,
                                Name = "",
                                Text = "Error!"
                            });
                    }
                };
                psr.Player.Texture2 = converted;
                UpdateCount++;
            }
            else if (cmd.Equals("cloth2", StringComparison.OrdinalIgnoreCase))
            {
                int converted = dyes_hextointmod.hextoint(args[0].ToString(), true);
                using (var db1 = new Database())
                {
                    using (var mysqlcommand = db1.CreateQuery())
                    {
                        mysqlcommand.CommandText = "UPDATE characters SET tex2 = @tex2 WHERE accId=@accId AND charId=@charId;";
                        mysqlcommand.Parameters.AddWithValue("@accId", psr.Account.AccountId);
                        mysqlcommand.Parameters.AddWithValue( @tex2", converted);
                        mysqlcommand.Parameters.AddWithValue("@charId", psr.Character.CharacterId);
                        if (mysqlcommand.ExecuteNonQuery() > 0)
                            psr.SendPacket(new TextPacket()
                            {
                                BubbleTime = 0,
                                Stars = -1,
                                Name = "",
                                Text = "Modified cloth!"
                            });
                        else if (mysqlcommand.ExecuteNonQuery() == -1)
                            psr.SendPacket(new TextPacket()
                            {
                                BubbleTime = 0,
                                Stars = -1,
                                Name = "",
                                Text = "Modified cloth!"
                            });
                        else
                            psr.SendPacket(new TextPacket()
                            {
                                BubbleTime = 0,
                                Stars = -1,
                                Name = "",
                                Text = "Error!"
                            });
                    }
                };
                psr.Player.Texture2 = converted;
                UpdateCount++;
            }
You will need that new class too (Rightclick on project>Add Item>Class>call it dyes_hextointmod), copypaste that code:
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace db
{
    static public class dyes_hextointmod
    {
        public static int hextoint(String hex, bool cloth)
        {
            int converted = 0;
            if (hex.StartsWith("0x"))
            {
                hex = hex.Substring(2);
                if (cloth == true)
                    hex = "0" + hex;
                converted = Convert.ToInt32(hex, 16);
            }
            else
                if (cloth == true)
                    hex = "0" + hex;
                converted = Convert.ToInt32(hex, 16);
            return converted;
        }
    }
}
What is the command for this ?
Quote Originally Posted by Axeall View Post
What is the command for this ?
Do /dye1, /cloth1, /dye2, or /cloth2.
1 is for the body, 2 is for accessory.
For example, a red body:
/dye1 Red (I think)
Quote Originally Posted by Owlupus View Post
Do /dye1, /cloth1, /dye2, or /cloth2.
1 is for the body, 2 is for accessory.
For example, a red body:
/dye1 Red (I think)
No, you have to enter the hex RGB color for dyes, and hex ID for cloths. Both can be found in the XMLs, just search for dyes/cloths and copypaste the tex1/2 value.

Quote Originally Posted by JJhackz View Post
what program are you using to build this and edit the coding?
Visual C# Professional (you can use the Express version, it's free).
Help me please. when i rebuild wServer . i have 46 Errors. Please help

(sry bad grammar )
Noob question what program are you using to build this and edit the coding?
Awesome work Trapped! Keep it up!
I have 1 Question what files do i have to edit?
Quote Originally Posted by Trapped View Post
Just add this to the commands
@nicknameGER For this, edit wServer>realm>entities>player>Player.Chat.cs. For the other thing, just follow the instructions.
Quote Originally Posted by Trapped View Post
@nicknameGER For this, edit wServer>realm>entities>player>Player.Chat.cs. For the other thing, just follow the instructions.
Where i have to put the class file?
Sry im new here o:
Trapped can u answer please where i have to put the other class file and if i recompile Player.Chats.cs i get 31 Errors
Just download the server files from trappeds github, its easier.
@abi97 Nice work. You are awesome. (referring to your post)
So i can only change my dye to white?... How do I do other colors?
Also is there a permission fix? I saw it once and I can't fine it now.
Posts 1–15 of 30 · Page 1 of 2
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Need help?