Jump to content
  • 0

I Have An Error In My Code, But I Can't Spot It.


Question

Posted

Hello everyone and Happy New Year!

 

I thought of making a voice command for gambling. What it does is by typing .luck a window appears and lets you choose an amount of adenas between 1kk, 10kk and 50kk.

You have 50% chance to double them or lose them. However, when I click on a button nothing happens, while the Cancel button works fine. Here is the code:

Luck.java: http://pastebin.com/1MA2VBEH
HTML buttons: http://pastebin.com/71M50bHV

 

It's coded for L2jFrozen Interlude, latest rev (1004).

Thank you for your time reading this. I apologize for my low Java knowledge.

9 answers to this question

Recommended Posts

  • 0
Posted

The problem is solved. I really thank you all for your time and your help!

 

I modified a code from another voicedcommand, which was used via Powerpak. What I did, was add these to Powerpak.java

Luck luck_handler = new Luck();
VoicedCommandHandler.getInstance().registerVoicedCommandHandler(luck_handler);
CustomBypassHandler.getInstance().registerCustomBypassHandler(luck_handler);
System.out.println("Luck is Enabled.");
			
  • 0
Posted

Thank you for your reply! Unfortunately, I didn't get what you mean... I am sorry but I just started using Java. Would it be easy for you to explain a little more?

 

Once again, thank you very much!

  • 0
Posted (edited)

You must create and "if" here : http://svn.l2jserver.com/trunk/L2J_Server/java/com/l2jserver/gameserver/network/clientpackets/RequestBypassToServer.java

(check how others are made)

and send the info like "Luck.handleCommand(_command, activeChar);" or whatever

note: better move your java file to core-side to be able to import it, or create a new file inside the core-side and move the handleCommand() thingy there, or put it inside the RequestBypassToServer.java but it would be dirty.

Edited by ^Wyatt
  • 0
Posted

hi man... you've read that you did? here say: 

 

        private enum CommandEnum
        {
                luck,
                luck_close_win 

        }

where say custom_luck (html) ... change that for luck, maybe this bad .. but hey try it XD

  • 0
Posted (edited)

So, it's like

+            // Voiced Bypass
+            else if (_command.startsWith("voiced_"))
+            {
+                String command = _command.split(" ")[0];
+                IVoicedCommandHandler ach = VoicedCommandHandler.getInstance().getVoicedCommandHandler(_command.substring(7));
+                
+                if (ach == null)
+                {
+                    activeChar.sendMessage("The command " + command.substring(7) + " does not exist!");
+                    _log.warning("No handler registered for command '" + _command + "'");
+                    return;
+                }
+                ach.useVoicedCommand(_command.substring(7), activeChar, null);
+            }
action = "bypass -h voiced_luck $luck"

So, by this you will call luck(y) command via npc :P

Edited by SweeTs
  • 0
Posted (edited)

Thank you very much for your replies! However, L2jFrozen has already the custom_ handler implemented. There are other NPCs with custom action. It's only mine that doesn't work :P

 

 

This is what already exists:

else if(_command.startsWith("custom_"))
{
    L2PcInstance player = getClient().getActiveChar();
    CustomBypassHandler.getInstance().handleBypass(player, _command);
}
Edited by G-hamsteR
  • 0
Posted

Then, inside your "public void handleCommand()" make some debug lines to see what's going on.

For example, "System.out.println(command+";"+tryLuck+";"+activeChar.getName());" at the start.

Guest
This topic is now closed to further replies.


×
×
  • Create New...