Jump to content

Question

Recommended Posts

  • 0
Posted
Use character_variables Sql table:

INSERT INTO character_variables VALUES (playerObjectId, "CustomTitle", titleValue);

  • 0
Posted

I ment, that's the table where Title Colors can be stored.

 

You can do it in this way:

1. While color is changed, run method(done by you) storeTitleColor(player, newTitle); - player variable should be instance of L2PcInstance class(or however you have it called), newTitle should be String containing new Title(for example "FFFFFF")

2. Create private static void method named storeTitleColor and taking 2 arguments(L2PcInstance and String)

3. Create new Database Connection in the method(look for examples of similar usage in your pack, you can search by key words: "INSERT INTO")

4. Create query, that will insert into character_variables. Also think about the case when title is already stored, then you can delete current record(slower way) or add awesome word to query ON DUPLICATE KEY(look in google to know more, also to use it, you should set charId column and var column as Primary Keys.

5. To complete the query, just add statement.executeUpdate(); like in examples you have found.

 

HF

  • 0
Posted (edited)

Connection con = L2DatabaseFactory.getConnection();

Statement st = con.createStatement();

st.executeUpdate("UPDATE characters SET title_color = x WHERE charId = x");

 

the x are the getters u have to make from the l2PcInstance

 

code handwritten, maybe there are typos

Edited by xdem
  • 0
Guest Elfocrash
Posted

Connection con = L2DatabaseFactory.getConnection();

Statement st = con.createStatement();

st.executeUpdate("UPDATE characters SET title_color = x WHERE charId = x");

 

the x are the getters u have to make from the l2PcInstance

 

code handwritten, maybe there are typos

you obviously need preparedstatement for something like that

  • 0
Posted (edited)

you obviously need preparedstatement for something like that

 

works with statement too, but for this prepared is faster so yes

 

PreparedStatement extends Statement

Edited by xdem
  • 0
Guest Elfocrash
Posted

works with statement too, but for this prepared is faster so yes

 

PreparedStatement extends Statement

Statement cannot support the ?

  • 0
Posted (edited)

Statement cannot support the ?

 

where is the ?

 

both x u have the values from L2PcInstance, st.executeUpdate("UPDATE characters SET title_color = "+player.getAppearance().getTitlteColor()+" WHERE charId = "+player.getObjectId());

 

i was just bored to write the getters into the String

Edited by xdem
  • 0
Guest Elfocrash
Posted

where is the ?

 

both x u have the values from L2PcInstance, st.executeUpdate("UPDATE characters SET title_color = "+player.getAppearance().getTitlteColor()+" WHERE charId = "+player.getObjectId());

 

i was just bored to write the getters into the String

oh i though that you meant that you gonna have ? indicators and 

statement.setString(1, shit);

under the preparedstatement

 

Yeah it can be done as you wrote too, however it is way too unefficient

  • 0
Posted
 

Connection con = L2DatabaseFactory.getConnection();

Statement st = con.createStatement();

st.executeUpdate("UPDATE characters SET title_color = x WHERE charId = x");

 

the x are the getters u have to make from the l2PcInstance

 

code handwritten, maybe there are typos

you obviously need different query for something like that

  • 0
Posted

it works like a charm dude

1. It will change something, only if its previously inserted to character_variables table

2. "title_color" column name is wrong("val" is correct)

3. It will update all values of the character in that table, not only those regarding title.

  • 0
Posted

1. It will change something, only if its previously inserted to character_variables table

2. "title_color" column name is wrong("val" is correct)

3. It will update all values of the character in that table, not only those regarding title.

 

1. no

2. no

3. Nope

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