Jump to content
  • 0

Can't Save New Data To The Database.


Horse

Question

Hello guys.

 

(Using hi5 latest)

I have the following problem.

 

I made a hide/show accessory voiced command similar to L2 Pride's accD. The command works fine in game without any problems. I also added the necessary lines to the createDB, restore, insert_character/ and update_character in L2PcInstance.

 

However, when i use the command in game and hide the accessories and restart, it does not save it to the DB and stays defualt/ 0. If I set the value in the DB manually to (1=hide both hair/hair2 acce) for exemple. then when i log in the chosen value in the DB takes effect.

 

To me it seems it doesn not save the new value to the new column I made in the characters table.

 

My knowladge is quite lacking in sql which i plan to improve ofc^^, but at the moment I'm kinda stucked with this problem.

 

I'd appreciate some help, thanks in advance.

 

Link to comment
Share on other sites

4 answers to this question

Recommended Posts

  • 0

The voiced command.

	else if (command.equalsIgnoreCase("acctest"))
	{
		byte i = activeChar.getAccDisplay();
		i = (byte) (i + 1);
		if (i > 3)
			i = 0;
		
		activeChar.setAccDisplay(i);
		
		switch (i)
		{
		case 0:
			activeChar.sendMessage("All acc on.");
			break;
		case 1:
			activeChar.sendMessage("All acc off.");
			break;
		case 2:
			activeChar.sendMessage("hair1 on");
			break;
		case 3:
			activeChar.sendMessage("hair 2 on");
			break;
		}
		activeChar.broadcastUserInfo();
		return true;
	}

L2PcInstance:

private byte _accDisplay = 0;



final public byte getAccDisplay()
{
	return _accDisplay;
}
final public void setAccDisplay(final byte val)
{
	_accDisplay = val;
}
    // Character Character SQL String Definitions:
    private static final String INSERT_CHARACTER = "INSERT INTO characters (account_name,charId,char_name,level,maxHp,curHp,maxCp,curCp,maxMp,curMp,face,hairStyle,hairColor,sex,exp,sp,karma,fame,pvpkills,pkkills,clanid,race,classid,deletetime,cancraft,title,title_color,accesslevel,online,isin7sdungeon,clan_privs,wantspeace,base_class,newbie,nobless,power_grade,createDate, acchide) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
    private static final String UPDATE_CHARACTER = "UPDATE characters SET level=?,maxHp=?,curHp=?,maxCp=?,curCp=?,maxMp=?,curMp=?,face=?,hairStyle=?,hairColor=?,sex=?,heading=?,x=?,y=?,z=?,exp=?,expBeforeDeath=?,sp=?,karma=?,fame=?,pvpkills=?,pkkills=?,clanid=?,race=?,classid=?,deletetime=?,title=?,title_color=?,accesslevel=?,online=?,isin7sdungeon=?,clan_privs=?,wantspeace=?,base_class=?,onlinetime=?,newbie=?,nobless=?,power_grade=?,subpledge=?,lvl_joined_academy=?,apprentice=?,sponsor=?,clan_join_expiry_time=?,clan_create_expiry_time=?,char_name=?,death_penalty_level=?,bookmarkslot=?,vitality_points=?,language=?,acchide=? WHERE charId=?";
    private static final String RESTORE_CHARACTER = "SELECT * FROM characters WHERE charId=?";


player.setOnlineTime(rset.getLong("onlinetime"));
player.setNewbie(rset.getInt("newbie"));
player.setNoble(rset.getInt("nobless") == 1);
player.setAccDisplay(rset.getByte("acchide")); // the new line in L2PcInstance restore
ps.setLong(24, getDeleteTimer());
ps.setInt(25, getAccDisplay()); // new line in createDb()
ps.setInt(26, hasDwarvenCraft() ? 1 : 0);
ps.setString(27, getTitle());
ps.setString(49, getLang());
ps.setInt(50, getObjectId());
ps.setByte(51, _accDisplay); //new line in storeCharBase()
ps.execute();

 also added   `acchide` int(1) NOT NULL default '0', to characters.sql and created a new column in the characters table as acchide.

Edited by Horse
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.


×
×
  • Create New...