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.


  • Posts

    • just with this extender that I have shared it is not possible to start with c4 client, you have to make some changes to the extender and it works with c4 client perfectly. regarding the updates in this last revision   🔹dll is not packaged with vmprotect   New custom zone types have been added: 🔹 NO_NOBLESS begin MinX=84638 MaxX=92616 MinY=-87170 MaxY=-82018 MinZ=-6000 MaxZ=0 Type=NO_NOBLESS KickOutPos=83007/148057/-3464 end   ▶️ This zone checks if the character is noble. If it does not meet the condition, it will be automatically kicked to the indicated position (KickOutPos). 🔹 CUSTOM_SPAWN_ZONE begin MinX=77275 MaxX=85704 MinY=10122 MaxY=18066 MinZ=-8000 MaxZ=5000 Type=CUSTOM_SPAWN_ZONE OutPos=83007/148057/-3464 Spawns={{82984/18066/-5256}};{{79275/15147/-5248}};{{82922/14263/-5256}};{{83704/10122/-5288}} end ▶️ This zone allows characters, upon death, to respawn with full buff, CP, HP and MP if they press “Fixed”. They will only be able to revive in one of the positions defined in Spawns. 🔧 Both zones are fully configurable from territorydata.txt
    • Could you tell me what changed in this update?   more one question: Is it possible to log in through the c4 client instead of interlude? That would be great  
    • ➡ Discount for your purchase: JULY2025 (11% discount) ➡ Our Online Shop: https://socnet.store  ➡ Our SMM-Boosting Panel: https://socnet.pro  ➡ Telegram Shop Bot: https://socnet.shop  ➡ Telegram Support: https://t.me/solomon_bog  ➡ Telegram Channel: https://t.me/accsforyou_shop  ➡ Discord Support: @AllSocialNetworksShop  ➡ Discord Server: https://discord.gg/y9AStFFsrh  ➡ WhatsApp Support: https://wa.me/79051904467 ➡ WhatsApp Channel: https://whatsapp.com/channel/0029Vau0CMX002TGkD4uHa2n  ➡ Email Support: solomonbog@socnet.store 
    • ➡ Discount for your purchase: JULY2025 (11% discount) ➡ Our Online Shop: https://socnet.store  ➡ Our SMM-Boosting Panel: https://socnet.pro  ➡ Telegram Shop Bot: https://socnet.shop  ➡ Telegram Support: https://t.me/solomon_bog  ➡ Telegram Channel: https://t.me/accsforyou_shop  ➡ Discord Support: @AllSocialNetworksShop  ➡ Discord Server: https://discord.gg/y9AStFFsrh  ➡ WhatsApp Support: https://wa.me/79051904467 ➡ WhatsApp Channel: https://whatsapp.com/channel/0029Vau0CMX002TGkD4uHa2n  ➡ Email Support: solomonbog@socnet.store 
  • Topics

×
×
  • Create New...

AdBlock Extension Detected!

Our website is made possible by displaying online advertisements to our members.

Please disable AdBlock browser extension first, to be able to use our community.

I've Disabled AdBlock