Ok well as the title says I am trying to set characters noblesse from the moment they are created.
I don't want to just do a simple enterworld check so I am trying to set them noblesse from creation.
Here is what I have coded so far:
In charactercreate.java:
//SWS FACTION MOD
if (Config.FACTION_SYSTEM_NEW_CHAR_NOBLE)
{
newChar.setNoble(true);
}
So its just a simple config check and execute parameter. About as simple as code gets.
So i went ingame to test if it worked and it set my character noblesse. I checked from the database there is a 1 in the noblesse column
But i got this error at gameserver when i created the new character:
storeSkill() couldn't store new skill. It's null type.
Here is my whole charactercreate.java:
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* http://www.gnu.org/copyleft/gpl.html
*/
package net.sf.l2j.gameserver.network.clientpackets;
import java.util.logging.Logger;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;
import net.sf.l2j.Config;
import net.sf.l2j.gameserver.datatables.CharNameTable;
import net.sf.l2j.gameserver.datatables.CharTemplateTable;
import net.sf.l2j.gameserver.datatables.SkillTable;
import net.sf.l2j.gameserver.datatables.SkillTreeTable;
import net.sf.l2j.gameserver.idfactory.IdFactory;
import net.sf.l2j.gameserver.model.L2ItemInstance;
import net.sf.l2j.gameserver.model.L2ShortCut;
import net.sf.l2j.gameserver.model.L2SkillLearn;
import net.sf.l2j.gameserver.model.L2World;
import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
import net.sf.l2j.gameserver.network.L2GameClient;
import net.sf.l2j.gameserver.network.serverpackets.CharCreateFail;
import net.sf.l2j.gameserver.network.serverpackets.CharCreateOk;
import net.sf.l2j.gameserver.network.serverpackets.CharSelectInfo;
import net.sf.l2j.gameserver.templates.chars.L2PcTemplate;
import net.sf.l2j.gameserver.templates.item.L2Item;
import net.sf.l2j.gameserver.util.Util;
public final class CharacterCreate extends L2GameClientPacket
{
private static final String _C__0B_CHARACTERCREATE = "[C] 0B CharacterCreate";
private static Logger _log = Logger.getLogger(CharacterCreate.class.getName());
// cSdddddddddddd
private String _name;
//private int _race;
private byte _sex;
private int _classId;
//private int _int;
//private int _str;
//private int _con;
//private int _men;
//private int _dex;
//private int _wit;
private byte _hairStyle;
private byte _hairColor;
private byte _face;
@Override
protected void readImpl()
{
_name = readS();
/*_race = */readD();
_sex = (byte)readD();
_classId = readD();
/*_int = */readD();
/*_str = */readD();
/*_con = */readD();
/*_men = */readD();
/*_dex = */readD();
/*_wit = */readD();
_hairStyle = (byte)readD();
_hairColor = (byte)readD();
_face = (byte)readD();
}
@Override
protected void runImpl()
{
if ((_name.length() < 1) || (_name.length() > 16) || !Util.isAlphaNumeric(_name) || !isValidName(_name))
{
if (Config.DEBUG)
_log.fine("Character Creation Failure: name " + _name + " is invalid. Creation have failed.");
sendPacket(new CharCreateFail(CharCreateFail.REASON_16_ENG_CHARS));
return;
}
if (_face > 2 || _face < 0)
{
_log.warning("Character Creation Failure: Character face " + _face + " is invalid. Possible client hack: "+getClient());
sendPacket(new CharCreateFail(CharCreateFail.REASON_CREATION_FAILED));
return;
}
if (_hairStyle < 0 || (_sex == 0 && _hairStyle > 4) || (_sex != 0 && _hairStyle > 6))
{
_log.warning("Character Creation Failure: Character hair style " + _hairStyle + " is invalid. Possible client hack: "+getClient());
sendPacket(new CharCreateFail(CharCreateFail.REASON_CREATION_FAILED));
return;
}
if (_hairColor > 3 || _hairColor < 0)
{
_log.warning("Character Creation Failure: Character hair color " + _hairColor + " is invalid. Possible client hack: "+getClient());
sendPacket(new CharCreateFail(CharCreateFail.REASON_CREATION_FAILED));
return;
}
L2PcInstance newChar = null;
L2PcTemplate template = null;
/*
* DrHouse: Since checks for duplicate names are done using SQL, lock must be held until data is written to DB as well.
*/
synchronized (CharNameTable.getInstance())
{
if (CharNameTable.getInstance().accountCharNumber(getClient().getAccountName()) >= 7)
{
if (Config.DEBUG)
_log.fine("Max number of characters reached. Creation failed.");
sendPacket(new CharCreateFail(CharCreateFail.REASON_TOO_MANY_CHARACTERS));
return;
}
else if (CharNameTable.getInstance().doesCharNameExist(_name))
{
if (Config.DEBUG)
_log.fine("Character Creation Failure: "+ _name + " already exists. Creation have failed.");
sendPacket(new CharCreateFail(CharCreateFail.REASON_NAME_ALREADY_EXISTS));
return;
}
template = CharTemplateTable.getInstance().getTemplate(_classId);
if (template == null || template.classBaseLevel > 1)
{
sendPacket(new CharCreateFail(CharCreateFail.REASON_CREATION_FAILED));
return;
}
int objectId = IdFactory.getInstance().getNextId();
newChar = L2PcInstance.create(objectId, template, getClient().getAccountName(), _name, _hairStyle, _hairColor, _face, _sex!=0);
}
newChar.setCurrentHp(template.baseHpMax);
newChar.setCurrentCp(template.baseCpMax);
newChar.setCurrentMp(template.baseMpMax);
// send acknowledgement
sendPacket(new CharCreateOk());
initNewChar(getClient(), newChar);
}
private boolean isValidName(String text)
{
boolean result = true;
String test = text;
Pattern pattern;
try
{
pattern = Pattern.compile(Config.CNAME_TEMPLATE);
}
catch (PatternSyntaxException e) // case of illegal pattern
{
_log.warning("ERROR : Character name pattern of config is wrong!");
pattern = Pattern.compile(".*");
}
Matcher regexp = pattern.matcher(test);
if (!regexp.matches())
result = false;
return result;
}
private void initNewChar(L2GameClient client, L2PcInstance newChar)
{
if (Config.DEBUG)
_log.fine("Character init start");
L2World.getInstance().storeObject(newChar);
L2PcTemplate template = newChar.getTemplate();
newChar.addAdena("Init", Config.STARTING_ADENA, null, false);
//SWS FACTION MOD
if (Config.FACTION_SYSTEM_NEW_CHAR_ALLOW_ALT_SPAWN)
{
newChar.setXYZInvisible(Config.FACTION_SYSTEM_NEW_CHAR_SPAWN_X, Config.FACTION_SYSTEM_NEW_CHAR_SPAWN_Y , Config.FACTION_SYSTEM_NEW_CHAR_SPAWN_Z);
}
//SWS FACTION MOD
if (Config.FACTION_SYSTEM_ENABLE_NEW_CHAR_TITLE)
{
newChar.setTitle(Config.FACTION_SYSTEM_SET_NEW_CHAR_TITLE);
}
//SWS FACTION MOD
if (Config.FACTION_SYSTEM_NEW_CHAR_NOBLE)
{
newChar.setNoble(true);
}
//SWS FACTION MOD
if (Config.FACTION_SYSTEM_ENABLE_SET_NEW_CHAR_LEVEL)
{
newChar.getStat().addLevel((byte)(Config.FACTION_SYSTEM_SET_NEW_CHAR_LEVEL-1));
}
newChar.registerShortCut(new L2ShortCut(0,0,3,2,-1,1)); // attack shortcut
newChar.registerShortCut(new L2ShortCut(3,0,3,5,-1,1)); // take shortcut
newChar.registerShortCut(new L2ShortCut(10,0,3,0,-1,1)); // sit shortcut
L2Item[] items = template.getItems();
for (int i = 0; i < items.length; i++)
{
L2ItemInstance item = newChar.getInventory().addItem("Init", items[i].getItemId(), 1, newChar, null);
// tutbook shortcut
if (item.getItemId()==5588)
newChar.registerShortCut(new L2ShortCut(11,0,1,item.getObjectId(),-1,1));
if (item.isEquipable())
{
if (newChar.getActiveWeaponItem() == null || !(item.getItem().getType2() != L2Item.TYPE2_WEAPON))
newChar.getInventory().equipItemAndRecord(item);
}
}
for (L2SkillLearn skill : SkillTreeTable.getInstance().getAvailableSkills(newChar, newChar.getClassId()))
{
newChar.addSkill(SkillTable.getInstance().getInfo(skill.getId(), skill.getLevel()), true);
if (skill.getId() == 1001 || skill.getId() == 1177)
newChar.registerShortCut(new L2ShortCut(1,0,2,skill.getId(),1,1));
if (skill.getId()==1216)
newChar.registerShortCut(new L2ShortCut(10,0,2,skill.getId(),1,1));
if (Config.DEBUG)
_log.fine("adding starter skill:" + skill.getId()+ " / "+ skill.getLevel());
}
newChar.setOnlineStatus(true, false);
newChar.deleteMe();
CharSelectInfo cl = new CharSelectInfo(client.getAccountName(), client.getSessionId().playOkID1);
client.getConnection().sendPacket(cl);
client.setCharSelection(cl.getCharInfo());
if (Config.DEBUG)
_log.fine("Character init end");
}
@Override
public String getType()
{
return _C__0B_CHARACTERCREATE;
}
}
Added: a brand-new default dashboard template.
You can now add multiple game/login server builds.
Full support for running both PTS & L2J servers simultaneously, with switching between them.
Payment systems: added OmegaPay and Pally (new PayPal-style API).
Account history now stores everything: donations, items delivered to characters, referrals, transfers between game accounts, and coin transfers to another master account.
Personal Promo Code System: you can create a promo code and assign it to a user or promoter. When donating, a player can enter this promo code to receive bonus coins, and the promo code owner also receives a bonus — all fully configurable in the admin panel.
Look demo site: demo
🚀 **TOMORROW – GRAND OPENING!** 🚀
📅 **Grand Opening Date:** 5 December 2025
⏰ **Time:** 20:00 GMT+2
🎫 **BONUS CODE:** `WELCOME-TO-L2MID`
⚠️ Limited to the **first 100 players** only!
🖥️ **Server Info:**
- 🕒 The server will open **1 hour earlier (19:00 GMT+2)** so you can create your characters.
- 🧍 All important **NPCs will appear at 20:00 GMT+2** for the official **GRAND OPENING**.
💡 **How to redeem the bonus code:**
- After you create your character, log in to the **L2Mid Panel** and redeem your bonus here:
🔗 https://l2mid.com/account.php#dash-promocode
🎁 **BONUS CODE REWARDS:**
🧪 Mana Drug × 50
🛡️ Greater CP Potion × 50
❤️ Greater Healing Potion × 50
📜 Blessed Scroll of Escape × 5
⭐ Bonus Rune – 3 Hours × 1
⚔️ Get ready for the start of your new adventure on **L2Mid**!
Question
SlyWhiteSheep
Ok well as the title says I am trying to set characters noblesse from the moment they are created.
I don't want to just do a simple enterworld check so I am trying to set them noblesse from creation.
Here is what I have coded so far:
In charactercreate.java:
//SWS FACTION MOD if (Config.FACTION_SYSTEM_NEW_CHAR_NOBLE) { newChar.setNoble(true); }So its just a simple config check and execute parameter. About as simple as code gets.
So i went ingame to test if it worked and it set my character noblesse. I checked from the database there is a 1 in the noblesse column
But i got this error at gameserver when i created the new character:
storeSkill() couldn't store new skill. It's null type.
Here is my whole charactercreate.java:
/* * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA * 02111-1307, USA. * * http://www.gnu.org/copyleft/gpl.html */ package net.sf.l2j.gameserver.network.clientpackets; import java.util.logging.Logger; import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.regex.PatternSyntaxException; import net.sf.l2j.Config; import net.sf.l2j.gameserver.datatables.CharNameTable; import net.sf.l2j.gameserver.datatables.CharTemplateTable; import net.sf.l2j.gameserver.datatables.SkillTable; import net.sf.l2j.gameserver.datatables.SkillTreeTable; import net.sf.l2j.gameserver.idfactory.IdFactory; import net.sf.l2j.gameserver.model.L2ItemInstance; import net.sf.l2j.gameserver.model.L2ShortCut; import net.sf.l2j.gameserver.model.L2SkillLearn; import net.sf.l2j.gameserver.model.L2World; import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance; import net.sf.l2j.gameserver.network.L2GameClient; import net.sf.l2j.gameserver.network.serverpackets.CharCreateFail; import net.sf.l2j.gameserver.network.serverpackets.CharCreateOk; import net.sf.l2j.gameserver.network.serverpackets.CharSelectInfo; import net.sf.l2j.gameserver.templates.chars.L2PcTemplate; import net.sf.l2j.gameserver.templates.item.L2Item; import net.sf.l2j.gameserver.util.Util; public final class CharacterCreate extends L2GameClientPacket { private static final String _C__0B_CHARACTERCREATE = "[C] 0B CharacterCreate"; private static Logger _log = Logger.getLogger(CharacterCreate.class.getName()); // cSdddddddddddd private String _name; //private int _race; private byte _sex; private int _classId; //private int _int; //private int _str; //private int _con; //private int _men; //private int _dex; //private int _wit; private byte _hairStyle; private byte _hairColor; private byte _face; @Override protected void readImpl() { _name = readS(); /*_race = */readD(); _sex = (byte)readD(); _classId = readD(); /*_int = */readD(); /*_str = */readD(); /*_con = */readD(); /*_men = */readD(); /*_dex = */readD(); /*_wit = */readD(); _hairStyle = (byte)readD(); _hairColor = (byte)readD(); _face = (byte)readD(); } @Override protected void runImpl() { if ((_name.length() < 1) || (_name.length() > 16) || !Util.isAlphaNumeric(_name) || !isValidName(_name)) { if (Config.DEBUG) _log.fine("Character Creation Failure: name " + _name + " is invalid. Creation have failed."); sendPacket(new CharCreateFail(CharCreateFail.REASON_16_ENG_CHARS)); return; } if (_face > 2 || _face < 0) { _log.warning("Character Creation Failure: Character face " + _face + " is invalid. Possible client hack: "+getClient()); sendPacket(new CharCreateFail(CharCreateFail.REASON_CREATION_FAILED)); return; } if (_hairStyle < 0 || (_sex == 0 && _hairStyle > 4) || (_sex != 0 && _hairStyle > 6)) { _log.warning("Character Creation Failure: Character hair style " + _hairStyle + " is invalid. Possible client hack: "+getClient()); sendPacket(new CharCreateFail(CharCreateFail.REASON_CREATION_FAILED)); return; } if (_hairColor > 3 || _hairColor < 0) { _log.warning("Character Creation Failure: Character hair color " + _hairColor + " is invalid. Possible client hack: "+getClient()); sendPacket(new CharCreateFail(CharCreateFail.REASON_CREATION_FAILED)); return; } L2PcInstance newChar = null; L2PcTemplate template = null; /* * DrHouse: Since checks for duplicate names are done using SQL, lock must be held until data is written to DB as well. */ synchronized (CharNameTable.getInstance()) { if (CharNameTable.getInstance().accountCharNumber(getClient().getAccountName()) >= 7) { if (Config.DEBUG) _log.fine("Max number of characters reached. Creation failed."); sendPacket(new CharCreateFail(CharCreateFail.REASON_TOO_MANY_CHARACTERS)); return; } else if (CharNameTable.getInstance().doesCharNameExist(_name)) { if (Config.DEBUG) _log.fine("Character Creation Failure: "+ _name + " already exists. Creation have failed."); sendPacket(new CharCreateFail(CharCreateFail.REASON_NAME_ALREADY_EXISTS)); return; } template = CharTemplateTable.getInstance().getTemplate(_classId); if (template == null || template.classBaseLevel > 1) { sendPacket(new CharCreateFail(CharCreateFail.REASON_CREATION_FAILED)); return; } int objectId = IdFactory.getInstance().getNextId(); newChar = L2PcInstance.create(objectId, template, getClient().getAccountName(), _name, _hairStyle, _hairColor, _face, _sex!=0); } newChar.setCurrentHp(template.baseHpMax); newChar.setCurrentCp(template.baseCpMax); newChar.setCurrentMp(template.baseMpMax); // send acknowledgement sendPacket(new CharCreateOk()); initNewChar(getClient(), newChar); } private boolean isValidName(String text) { boolean result = true; String test = text; Pattern pattern; try { pattern = Pattern.compile(Config.CNAME_TEMPLATE); } catch (PatternSyntaxException e) // case of illegal pattern { _log.warning("ERROR : Character name pattern of config is wrong!"); pattern = Pattern.compile(".*"); } Matcher regexp = pattern.matcher(test); if (!regexp.matches()) result = false; return result; } private void initNewChar(L2GameClient client, L2PcInstance newChar) { if (Config.DEBUG) _log.fine("Character init start"); L2World.getInstance().storeObject(newChar); L2PcTemplate template = newChar.getTemplate(); newChar.addAdena("Init", Config.STARTING_ADENA, null, false); //SWS FACTION MOD if (Config.FACTION_SYSTEM_NEW_CHAR_ALLOW_ALT_SPAWN) { newChar.setXYZInvisible(Config.FACTION_SYSTEM_NEW_CHAR_SPAWN_X, Config.FACTION_SYSTEM_NEW_CHAR_SPAWN_Y , Config.FACTION_SYSTEM_NEW_CHAR_SPAWN_Z); } //SWS FACTION MOD if (Config.FACTION_SYSTEM_ENABLE_NEW_CHAR_TITLE) { newChar.setTitle(Config.FACTION_SYSTEM_SET_NEW_CHAR_TITLE); } //SWS FACTION MOD if (Config.FACTION_SYSTEM_NEW_CHAR_NOBLE) { newChar.setNoble(true); } //SWS FACTION MOD if (Config.FACTION_SYSTEM_ENABLE_SET_NEW_CHAR_LEVEL) { newChar.getStat().addLevel((byte)(Config.FACTION_SYSTEM_SET_NEW_CHAR_LEVEL-1)); } newChar.registerShortCut(new L2ShortCut(0,0,3,2,-1,1)); // attack shortcut newChar.registerShortCut(new L2ShortCut(3,0,3,5,-1,1)); // take shortcut newChar.registerShortCut(new L2ShortCut(10,0,3,0,-1,1)); // sit shortcut L2Item[] items = template.getItems(); for (int i = 0; i < items.length; i++) { L2ItemInstance item = newChar.getInventory().addItem("Init", items[i].getItemId(), 1, newChar, null); // tutbook shortcut if (item.getItemId()==5588) newChar.registerShortCut(new L2ShortCut(11,0,1,item.getObjectId(),-1,1)); if (item.isEquipable()) { if (newChar.getActiveWeaponItem() == null || !(item.getItem().getType2() != L2Item.TYPE2_WEAPON)) newChar.getInventory().equipItemAndRecord(item); } } for (L2SkillLearn skill : SkillTreeTable.getInstance().getAvailableSkills(newChar, newChar.getClassId())) { newChar.addSkill(SkillTable.getInstance().getInfo(skill.getId(), skill.getLevel()), true); if (skill.getId() == 1001 || skill.getId() == 1177) newChar.registerShortCut(new L2ShortCut(1,0,2,skill.getId(),1,1)); if (skill.getId()==1216) newChar.registerShortCut(new L2ShortCut(10,0,2,skill.getId(),1,1)); if (Config.DEBUG) _log.fine("adding starter skill:" + skill.getId()+ " / "+ skill.getLevel()); } newChar.setOnlineStatus(true, false); newChar.deleteMe(); CharSelectInfo cl = new CharSelectInfo(client.getAccountName(), client.getSessionId().playOkID1); client.getConnection().sendPacket(cl); client.setCharSelection(cl.getCharInfo()); if (Config.DEBUG) _log.fine("Character init end"); } @Override public String getType() { return _C__0B_CHARACTERCREATE; } }2 answers to this question
Recommended Posts