L2JMobius

Free Users => Work in Progress => Topic started by: oRiGiNaL on February 15, 2021, 10:52:16 PM

Title: Subclass/community board
Post by: oRiGiNaL on February 15, 2021, 10:52:16 PM
Hello everyone. Today i decide to do something interesting. I want to add on community board when player have subclass, to display there.
and the code it is like that.
Code: [Select]
returnHtml = returnHtml.replace("%subclass%", ClassListData.getInstance().getClass(player.getSubClasses().get(1).getClassId()).getClientCode());All good untill now, but when player doesn`t have subclass, he can't open cb and i get error on gameserver:
https://ibb.co/FKz1Hkx (https://ibb.co/FKz1Hkx)
Can someone tell em how and where i can add !=null ?
Greetings !!
Title: Re: Subclass/community board
Post by: felipeafa on February 16, 2021, 03:00:15 PM
Hello everyone. Today i decide to do something interesting. I want to add on community board when player have subclass, to display there.
and the code it is like that.
Code: [Select]
returnHtml = returnHtml.replace("%subclass%", ClassListData.getInstance().getClass(player.getSubClasses().get(1).getClassId()).getClientCode());All good untill now, but when player doesn`t have subclass, he can't open cb and i get error on gameserver:
https://ibb.co/FKz1Hkx (https://ibb.co/FKz1Hkx)
Can someone tell em how and where i can add !=null ?
Greetings !!
Quote
replace("%subclass%", ClassListData.getInstance().getClass(player.getSubClasses().get(1).getClassId()).getClientCode() != null ? player.getActiveClass() : null);
maybe it work...
Title: Re: Subclass/community board
Post by: oRiGiNaL on February 16, 2021, 04:09:57 PM
I get this code by Excellence
Code: [Select]
for (int i = 0; i < player.getSubClasses().size(); i++)
{
final String subName = ClassListData.getInstance().getClass(player.getSubClasses().get(i).getClassId()).getClientCode();
returnHtml = returnHtml.replace("%subclass" + i + "%", subName);
}
But it doesn't work. I want to do this for max 3 subclasses. I tryes %subclass1%/%subclass2%/%subclass3%. NOthing happend. In game, i see just %subclass1%/%subclass2%/%subclass3%. Not the subclasses. Help please?
Title: Re: Subclass/community board
Post by: Pirsys on February 16, 2021, 04:12:25 PM
And if instead of trying to call that data through core code ... you will use the data that you have in the database, it would be more practical it seems to me.
Title: Re: Subclass/community board
Post by: oRiGiNaL on February 16, 2021, 05:04:22 PM
I really don't know how to do that.

Title: Re: Subclass/community board
Post by: oRiGiNaL on February 16, 2021, 07:42:55 PM

(https://ibb.co/JR34Ybt) Fixed. Thank you!