l2bartdev Posted April 3, 2018 Posted April 3, 2018 hello guys i would like to know if there is a command like this //titlecolor that changes the color of a character's title so i can put it in my project thanks in advance
1 SweeTs Posted April 3, 2018 Posted April 3, 2018 No. It's basically one code line. Create the command on you own.
1 protoftw Posted April 3, 2018 Posted April 3, 2018 (edited) 58 minutes ago, SweeTs said: No. It's basically one code line. Create the command on you own. Fact: I'm not a chef. Example: Basically, all you can do is cook a dish. Create the recipe on your own. I don't think he got any help rather than frustration. Edited April 3, 2018 by protoftw
1 SweeTs Posted April 3, 2018 Posted April 3, 2018 25 minutes ago, protoftw said: Fact: I'm not a chef. Example: Basically, all you can do is cook a dish. Create the recipe on your own. Fact: you have the recipe. Example: as you have the recipe you can cook, at least try. Title change color npc is shared, reuse the code. Admin command set name/title color exists, reuse the code. Voiced, command handlers exists, reuse the code. At least try, take a look, think, experiment. If you don't try, you never learn to cook. Saying "i can't, I won't do it" won't change anything.
1 SweeTs Posted April 3, 2018 Posted April 3, 2018 It's easy, you just have to think and reuse existing code. Okay, then.. - open any command, can be Escape - copy the code, create new file paste it - remove the destroy, teleport, checks and/or whatever part you think is useless - search for "settitle" command - copy the code, mainly the line player.setTitleColor obviously, no need further explanations what's that and other broadcast lines, hello, if those lines are there, you need them as well - I see errors on parse something, well, replace it with static code - but how? Search for gm color config, see how is builded the line and do the same - register the handler, usercommandhandler - enjoy Got errors? Post em here, show that you are trying and you are willing to learn. Otherwise don't bother opening a server, even a local one. Sad but true. ---- You said you tried, show me the code. 1
1 melron Posted April 3, 2018 Posted April 3, 2018 You need 2 database connections. 1st for saving the color and the 2nd to restore it
1 Kara Posted April 3, 2018 Posted April 3, 2018 (edited) 24 minutes ago, l2bartdev said: so i just have to create for ex custom_colors table? and then what inside? :P I made you a quick code, is up to you how to use it e.t.c package com.l2evie.gameserver; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import com.l2evie.L2DatabaseFactory; import com.l2evie.gameserver.model.actor.instance.L2PcInstance; /** * @author Evie Frye */ public class Color { private static Color _instance = null; public static Color getInstance() { if (_instance == null) { _instance = new Color(); } return _instance; } /** * @param objectId * @return */ public void setColor(final L2PcInstance activeChar) { Integer[] holder = null; try(Connection con = L2DatabaseFactory.getInstance().getConnection()) { ResultSet result = con.prepareStatement("SELECT hexName, hexTitle FROM character_color_table WHERE objectId = " + activeChar.getObjectId()).executeQuery(); if (result.next()) { holder = new Integer[]{(Integer.parseInt(result.getString("hexName"))), Integer.parseInt(result.getString("hexTitle"))}; } } catch(SQLException e) { return; } if (holder !=null) { activeChar.getAppearance().setNameColor(holder[0]); activeChar.getAppearance().setTitleColor(holder[1]); activeChar.broadcastUserInfo(); } } /** * * @param objectId */ public void storeColor(final L2PcInstance activeChar) { try(Connection con = L2DatabaseFactory.getInstance().getConnection()) { PreparedStatement statement = con.prepareStatement("INSERT INTO character_color(objectId, hexName, hexTitle) values(?,?,?) ON DUPLICATE KEY UPDATE hexColor=?"); statement.setInt(1, activeChar.getObjectId()); statement.setInt(2, activeChar.getAppearance().getNameColor()); statement.setInt(3, activeChar.getAppearance().getNameColor()); statement.execute(); } catch(SQLException e) { } } } And the SQL: /* MySQL Data Transfer Source Host: localhost Source Database: l2jgs Target Host: localhost Target Database: l2jgs Date: 4/3/2018 9:18:52 PM */ SET FOREIGN_KEY_CHECKS=0; -- ---------------------------- -- Table structure for character_color -- ---------------------------- DROP TABLE IF EXISTS `character_color`; CREATE TABLE `character_color` ( `objectId` int(10) NOT NULL, `hexName` text NOT NULL, `hexTitle` text NOT NULL, PRIMARY KEY (`objectId`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; Consider those should load once upon server start and server shutdown to avoid connection everytime a player login and logout but nowadays with so fast queries and store procedures nobody cares. To use the code just go on EnterWorld and write Color.getInstance().setColor(activeChar); and to store go in L2PcInstance, find cleanMe method and somewhere inside write: Color.getInstance().storeColor(this); Edited April 3, 2018 by Evie Frye
1 Kara Posted April 3, 2018 Posted April 3, 2018 5 minutes ago, l2bartdev said: very kind of you brother thanks a bunch i already did the code i can do the command //titlecolor but when i rr it gets in the normal colors so i can just put the sql and it should work?thanks again. :D Yeap and if it works come back and give me 1.000 euro, took me 2 minutes.
1 camenomat0 Posted April 3, 2018 Posted April 3, 2018 59 minutes ago, Evie Frye said: I made you a quick code, is up to you how to use it e.t.c package com.l2evie.gameserver; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import com.l2evie.L2DatabaseFactory; import com.l2evie.gameserver.model.actor.instance.L2PcInstance; /** * @author Evie Frye */ public class Color { private static Color _instance = null; public static Color getInstance() { if (_instance == null) { _instance = new Color(); } return _instance; } /** * @param objectId * @return */ public void setColor(final L2PcInstance activeChar) { Integer[] holder = null; try(Connection con = L2DatabaseFactory.getInstance().getConnection()) { ResultSet result = con.prepareStatement("SELECT hexName, hexTitle FROM character_color_table WHERE objectId = " + activeChar.getObjectId()).executeQuery(); if (result.next()) { holder = new Integer[]{(Integer.parseInt(result.getString("hexName"))), Integer.parseInt(result.getString("hexTitle"))}; } } catch(SQLException e) { return; } if (holder !=null) { activeChar.getAppearance().setNameColor(holder[0]); activeChar.getAppearance().setTitleColor(holder[1]); activeChar.broadcastUserInfo(); } } /** * * @param objectId */ public void storeColor(final L2PcInstance activeChar) { try(Connection con = L2DatabaseFactory.getInstance().getConnection()) { PreparedStatement statement = con.prepareStatement("INSERT INTO character_color(objectId, hexName, hexTitle) values(?,?,?) ON DUPLICATE KEY UPDATE hexColor=?"); statement.setInt(1, activeChar.getObjectId()); statement.setInt(2, activeChar.getAppearance().getNameColor()); statement.setInt(3, activeChar.getAppearance().getNameColor()); statement.execute(); } catch(SQLException e) { } } } And the SQL: /* MySQL Data Transfer Source Host: localhost Source Database: l2jgs Target Host: localhost Target Database: l2jgs Date: 4/3/2018 9:18:52 PM */ SET FOREIGN_KEY_CHECKS=0; -- ---------------------------- -- Table structure for character_color -- ---------------------------- DROP TABLE IF EXISTS `character_color`; CREATE TABLE `character_color` ( `objectId` int(10) NOT NULL, `hexName` text NOT NULL, `hexTitle` text NOT NULL, PRIMARY KEY (`objectId`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; Consider those should load once upon server start and server shutdown to avoid connection everytime a player login and logout but nowadays with so fast queries and store procedures nobody cares. To use the code just go on EnterWorld and write Color.getInstance().setColor(activeChar); and to store go in L2PcInstance, find cleanMe method and somewhere inside write: Color.getInstance().storeColor(this); best!
1 'Baggos' Posted April 3, 2018 Posted April 3, 2018 5 minutes ago, Evie Frye said: And to be honest i'm done with this forum anyway so that was my last post. We will really miss you! My heart is already beating more and more every time I read your reply.. RIP my net friend.. :D
1 SweeTs Posted April 4, 2018 Posted April 4, 2018 2 hours ago, Evie Frye said: judge someone's code who wrote it in 1-2 minute while playing DotA. Excuses as always, poor code as always :( Code properly, or don't code at all. Kisses my dear not :D
0 l2bartdev Posted April 3, 2018 Author Posted April 3, 2018 how to do this? ;D i am not this experienced with these i know how to add a code but that is a childs game for others now creating a code line gets a bit hard ;D but thanks in advance brother
0 protoftw Posted April 3, 2018 Posted April 3, 2018 I'm not saying that he can't try . You are stating facts that are known to you. Without further due there is no reason to argue. It's pointless and non helpful for him.
0 l2bartdev Posted April 3, 2018 Author Posted April 3, 2018 tried but all i did was fcking up my project and compiled a new one :D :D now i m gonna try again if i get it right this time i'll let u know
0 l2bartdev Posted April 3, 2018 Author Posted April 3, 2018 (edited) I get it brother thanks for the help problem solved u can lock the topic thanks a lot btw Edited April 3, 2018 by l2bartdev thanks sweets
Question
l2bartdev
hello guys i would like to know if there is a command like this //titlecolor that changes the color of a character's title so i can put it in my project thanks in advance
22 answers to this question
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now