How to make (...)

byEvanthe

Пляшущий с бубном
Участник
Сообщения
86
Розыгрыши
0
Репутация
0
Реакции
5
Баллы
210
Хроники
  1. Chaotic Throne: High Five
Исходники
Присутствуют
Сборка
L2jSunrise
Hello folks, how can I make this check "link/command off". If the command are enabled, to display button, if the command it's disabled by admin, to display "Command Off"

L2Npc

JavaScript:
 html.replace("%disableOnlineCommand%", Config.ENABLE_COMMAND_ONLINE ? "<font color=ff0000>Command Off</font>" : "<a action=\"bypass voice .online\">Online < /a>");

OnlineVCmd

JavaScript:
 @Override
    public boolean useVoicedCommand(String command, L2PcInstance activeChar, String target)
    {

        if (Config.ENABLE_COMMAND_ONLINE)
        {
            activeChar.sendMessage("Command is disabled by admin");
        }

        if (command.startsWith("online"))
        {
            showPlayers(activeChar, target);
        }
        return true;
    }
 
First of all i would swap the results, since if you call it "ENABLE_COMMAND_LINE" i expect to show "online" when it's true, not the other way around.
Second, you should return here, or people can bypass it:
if (!Config.ENABLE_COMMAND_ONLINE)
{
activeChar.sendMessage("Command is disabled by admin");
return false;
}

Third, what is the question? XD
Your code doesn't work or you need to ask where to apply it?
Sorry bad englesh
 
I want to display to on npc if the command it's disabled or enabled.

But not, even if the command it's enabled, i saw on npc command off as you see
 
Does it change anything if you turn the command off instead?
Also I would invert the two results because it makes more sense:

Config.ENABLE_COMMAND_ONLINE ? "<font color=ff0000>Command Off</font>" : "<a action=\"bypass voice .online\">Online < /a>");