Jump to content
  • 0

interlude Title Color command


l2bartdev

Question

Recommended Posts

  • 1
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 by protoftw
Link to comment
Share on other sites

  • 1
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. 

Link to comment
Share on other sites

  • 1

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. 

  • Like 1
Link to comment
Share on other sites

  • 1
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 by Evie Frye
Link to comment
Share on other sites

  • 1
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.

Link to comment
Share on other sites

  • 1
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!

Link to comment
Share on other sites

  • 1
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

Link to comment
Share on other sites

  • 1
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

Link to comment
Share on other sites

  • 0

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 

Link to comment
Share on other sites

  • 0

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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...