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

    • Tell a Škoda 1.4 driver that a Škoda 1.8 is faster — and suddenly, you’re riding a mini race car. On the way, they might share random stories — gas prices, the perfect BBQ recipe, or how passengers once called them “just for a minute.” Maybe even how someone left a suitcase full of money in their car once.     The important part? You’ll get there on time, no delays.     Vibe SMS works just as fast — messages fly like that driver who just heard their 1.8 isn’t the fastest.     🌐 https://vibe-sms.net/ 📲 https://t.me/vibe_sms  
    • ⚔️ The Grand Opening Has Arrived! ⚔️ In just a few hours the gate to the eternal battlefield will be open and the war between Order and Chaos will be set once again ! Its time to claim your destiny 🔥 👉 Register now and join the fight today! 🌐 https://l2ovc.com register now : https://l2ovc.com The gates are open the war between Order and Chaos has officially started! 🔥 Join the battlefield NOW and claim your destiny in Order vs Chaos! 💥 Don’t fall behind your faction needs you. ➡️ https://l2ovc.com  
    • Don’t miss the new Telegram gifts with our Telegram Stars purchasing bot! A great opportunity to invest in a stable digital asset at an early stage while the market is still forming. Buy other existing gifts in the official store using Telegram Stars, pay for subscriptions, donate to games and projects, pay for Premium subscriptions, and react to messages in channels! Low prices, multiple payment options, and other cool unique features! ⚡ Try it today — SOCNET STARS BOT ⚡ Active links to SOCNET stores: Digital Goods Store (Website): Go Store Telegram Bot: Go – convenient access to the store via Telegram messenger. ⭐ Telegram Stars Purchase Bot: Go – fast and profitable way to buy stars in Telegram. SMM Panel: Go – promote your social media accounts. We present to you the current list of promotions and special offers for purchasing our products and services: 1️⃣ Promo code OCTOBER2025 (8% discount) for purchases in our store (Website, bot) in October! You can also use the promo code SOCNET (15% discount) for your first purchase. 2️⃣ Get $1 on your store balance or a 10–20% discount — just write your username after registration on our website using the template: "SEND ME BONUS, MY USERNAME IS..." — post it in our forum thread! 3️⃣ Get $1 for your first SMM Panel trial — simply open a ticket titled “Get Trial Bonus” on our website (Support). 4️⃣ Weekly ⭐ Telegram Stars giveaways in our Telegram channel and in our Telegram Stars bot! News: ➡ Telegram Channel: https://t.me/accsforyou_shop ➡ WhatsApp Channel: https://chat.whatsapp.com/K8rBy500nA73z27PxgaJUw?mode=ems_copy_t ➡ Discord Server: https://discord.gg/y9AStFFsrh Contacts and Support: ➡ Telegram: https://t.me/socnet_support ➡ WhatsApp: https://wa.me/79051904467 ➡ Discord: socnet_support ➡ ✉ Email: solomonbog@socnet.store
    • Don’t miss the new Telegram gifts with our Telegram Stars purchasing bot! A great opportunity to invest in a stable digital asset at an early stage while the market is still forming. Buy other existing gifts in the official store using Telegram Stars, pay for subscriptions, donate to games and projects, pay for Premium subscriptions, and react to messages in channels! Low prices, multiple payment options, and other cool unique features! ⚡ Try it today — SOCNET STARS BOT ⚡ Active links to SOCNET stores: Digital Goods Store (Website): Go Store Telegram Bot: Go – convenient access to the store via Telegram messenger. ⭐ Telegram Stars Purchase Bot: Go – fast and profitable way to buy stars in Telegram. SMM Panel: Go – promote your social media accounts. We present to you the current list of promotions and special offers for purchasing our products and services: 1️⃣ Promo code OCTOBER2025 (8% discount) for purchases in our store (Website, bot) in October! You can also use the promo code SOCNET (15% discount) for your first purchase. 2️⃣ Get $1 on your store balance or a 10–20% discount — just write your username after registration on our website using the template: "SEND ME BONUS, MY USERNAME IS..." — post it in our forum thread! 3️⃣ Get $1 for your first SMM Panel trial — simply open a ticket titled “Get Trial Bonus” on our website (Support). 4️⃣ Weekly ⭐ Telegram Stars giveaways in our Telegram channel and in our Telegram Stars bot! News: ➡ Telegram Channel: https://t.me/accsforyou_shop ➡ WhatsApp Channel: https://chat.whatsapp.com/K8rBy500nA73z27PxgaJUw?mode=ems_copy_t ➡ Discord Server: https://discord.gg/y9AStFFsrh Contacts and Support: ➡ Telegram: https://t.me/socnet_support ➡ WhatsApp: https://wa.me/79051904467 ➡ Discord: socnet_support ➡ ✉ Email: 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