Skip to content

Title Color command

Featured Replies

  • Author

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

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.

  • Author
22 minutes ago, Evie Frye said:

 

Yeap and if it works come back and give me 1.000 euro, took me 2 minutes.

hahaha i dont know but didn;t work ;3 ;3 :D but thanks anyways

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!

2 hours ago, Evie Frye said:

...

 

Lets talk about your code :D 

 

  • Why the hell you are using instance.
  • If you want instance use singleton lol but a static way would be the same and less words up on the call
  • Rly now, freya doesnt have intintholder? lol
  • Your new db fields are 'not null' but missing default value... All things will be fucked up (colors are used with integer.decode)
  • where is printstacktrace? 

The only good thing is the try-with-resources but there you could add the PreparedStatement too ( you are not closing it at storeColor)

 

Why you dont just edit the restore_character query and add one more field to be load + 1 line where the player is restoring data

 

reported

 

Gn <3

Edited by melron

43 minutes ago, melron said:

 

Lets talk about your code :D 

 

  • Why the hell you are using instance.
  • If you want instance use singleton lol but a static way would be the same and less words up on the call
  • Rly now, freya doesnt have intintholder? lol
  • Your new db fields are 'not null' but missing default value... All things will be fucked up (colors are used with integer.decode)
  • where is printstacktrace? 

The only good thing is the try-with-resources but there you could add the PreparedStatement too ( you are not closing it at storeColor)

 

Why you dont just edit the restore_character query and add one more field to be load + 1 line where the player is restoring data

 

reported

 

Gn <3

 

I won't even bother answer seriously mostly because wannabes like Nightwolf come and judge someone's code who wrote it in 1-2 minute while playing DotA.

And to be honest i'm done with this forum anyway so that was my last post.

 

Edited by Evie Frye

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

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

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.