Jump to content
  • 0

Question

Posted

Hello, I want to add effect when someone win at casino.

 

For example, someone won at casino I want to do something like firework.

 


 

What about this line?

 

MagicSkillUser msk = new MagicSkillUser(activeChar, 1050, 1, teleportTimer, 0);

 

Thanks!

8 answers to this question

Recommended Posts

  • 0
Posted

Hello, I want to add effect when someone win at casino.

 

For example, someone won at casino I want to do something like firework.

 


 

What about this line?

 

MagicSkillUser msk = new MagicSkillUser(activeChar, 1050, 1, teleportTimer, 0);

 

Thanks!

 

seems fine just add after case if sucess

 

  • 0
Posted

So this code it's working?

 

I have no idea, try this

 

MagicSkillUse  MSU = new MagicSkillUse(player, player, 2024, 1, 1, 0);

 

Anyway, here you go Casino with such effects.

 

### Eclipse Workspace Patch 1.0
#P aCis_gameserver
Index: java/net/sf/l2j/gameserver/model/actor/instance/L2CasinoInstance.java
===================================================================
--- java/net/sf/l2j/gameserver/model/actor/instance/L2CasinoInstance.java	(revision 0)
+++ java/net/sf/l2j/gameserver/model/actor/instance/L2CasinoInstance.java	(revision 0)
@@ -0,0 +1,469 @@
+package net.sf.l2j.gameserver.model.actor.instance;
+
+import javolution.text.TextBuilder;
+
+import net.sf.l2j.gameserver.ai.CtrlIntention;
+import net.sf.l2j.gameserver.network.serverpackets.MagicSkillUse;
+import net.sf.l2j.gameserver.network.serverpackets.NpcHtmlMessage;
+import net.sf.l2j.gameserver.network.serverpackets.SetupGauge;
+import net.sf.l2j.gameserver.network.serverpackets.SocialAction;
+import net.sf.l2j.gameserver.templates.chars.L2NpcTemplate;
+import net.sf.l2j.gameserver.ThreadPoolManager;
+import net.sf.l2j.gameserver.util.Broadcast;
+import net.sf.l2j.util.Rnd;
+
+public class L2CasinoInstance extends L2NpcInstance
+{
+    public String filename;
+
+    public L2CasinoInstance(int objectId, L2NpcTemplate template)
+    {
+        super(objectId, template);
+    }
+
+    @Override
+    public void onBypassFeedback(L2PcInstance player, String command)
+    {
+        if(player == null)
+            return;
+
+        if(command.startsWith("play1") && player.getInventory().getInventoryItemCount(9142, 0) >= 2)
+            Casino1(player);
+        if(command.startsWith("play2") && player.getInventory().getInventoryItemCount(9142, 0) >= 4)
+            Casino2(player);
+        if(command.startsWith("play3") && player.getInventory().getInventoryItemCount(9142, 0) >= 8)
+            Casino3(player);
+        if(command.startsWith("play4") && player.getInventory().getInventoryItemCount(9142, 0) >= 16)
+            Casino4(player);
+        if(command.startsWith("play5") && player.getInventory().getInventoryItemCount(57, 0) >= 500000)
+            Casino5(player);
+        if(command.startsWith("play6") && player.getInventory().getInventoryItemCount(57, 0) >= 1000000)
+            Casino6(player);
+        if(command.startsWith("play7") && player.getInventory().getInventoryItemCount(57, 0) >= 10000000)
+            Casino7(player);
+    }
+
+    public static void displayCongrats(L2PcInstance player)
+    {
+        player.broadcastPacket(new SocialAction(player, 3));
+        MagicSkillUse  MSU = new MagicSkillUse(player, player, 2024, 1, 1, 0);
+        player.broadcastPacket(MSU);
+        player.sendMessage("Congratulations! you won");
+    }
+
+    @Override
+    public void showChatWindow(L2PcInstance player, int val)
+    {
+        filename = (getHtmlPath(getNpcId(), val));
+        NpcHtmlMessage msg = new NpcHtmlMessage(this.getObjectId());
+        msg.setHtml(casinoWindow(player));
+        msg.replace("%objectId%", String.valueOf(this.getObjectId()));
+        player.sendPacket(msg);
+    }
+
+    private String casinoWindow(L2PcInstance player)
+    {
+        TextBuilder tb = new TextBuilder();
+        tb.append("<html><title>Casino Manager</title><body>");
+        tb.append("<center>");
+        tb.append("<br>");
+        tb.append("<font color=\"999999\">Chance to win : 50%</font><br>");
+        tb.append("<img src=\"L2UI.SquareGray\" width=\"200\" height=\"1\"><br>");
+        tb.append("Welcome "+player.getName()+"<br>");
+        tb.append("<tr><td>Double or Nothing ?</td></tr><br>");
+        tb.append("<img src=\"L2UI.SquareGray\" width=\"280\" height=\"1\"></center><br>");
+        tb.append("<center>");
+        tb.append("Place your bets");
+        tb.append("</center>");
+        tb.append("<img src=\"L2UI.SquareGray\" width=\"280\" height=\"1\"></center><br>");
+        tb.append("<br>");
+        tb.append("<center>");
+        tb.append("<tr>");
+        tb.append("<td><button value=\"2 Apiga\" action=\"bypass -h npc_%objectId%_play1\" back=\"L2UI_ch3.bigbutton_over\" fore=\"L2UI_ch3.bigbutton\" width=95 height=21></td>");
+        tb.append("<td><button value=\"4 Apiga\" action=\"bypass -h npc_%objectId%_play2\" back=\"L2UI_ch3.bigbutton_over\" fore=\"L2UI_ch3.bigbutton\" width=95 height=21></td>");
+        tb.append("</tr>");
+        tb.append("<tr>");
+        tb.append("<td><button value=\"8 Apiga\" action=\"bypass -h npc_%objectId%_play3\" back=\"L2UI_ch3.bigbutton_over\" fore=\"L2UI_ch3.bigbutton\" width=95 height=21></td>");
+        tb.append("<td><button value=\"16 Apiga\" action=\"bypass -h npc_%objectId%_play4\" back=\"L2UI_ch3.bigbutton_over\" fore=\"L2UI_ch3.bigbutton\" width=95 height=21></td>");
+        tb.append("</tr>");
+        tb.append("<tr>");
+        tb.append("<td><button value=\"500k\" action=\"bypass -h npc_%objectId%_play5\" back=\"L2UI_ch3.bigbutton_over\" fore=\"L2UI_ch3.bigbutton\" width=95 height=21></td>");
+        tb.append("<td><button value=\"1kk\" action=\"bypass -h npc_%objectId%_play6\" back=\"L2UI_ch3.bigbutton_over\" fore=\"L2UI_ch3.bigbutton\" width=95 height=21></td>");
+        tb.append("</tr>");
+        tb.append("<tr>");
+        tb.append("<td><button value=\"10kk\" action=\"bypass -h npc_%objectId%_play7\" back=\"L2UI_ch3.bigbutton_over\" fore=\"L2UI_ch3.bigbutton\" width=95 height=21></td>");
+        tb.append("</tr>");
+        tb.append("</center>");
+        tb.append("<center><img src=\"L2UI.SquareGray\" width=\"280\" height=\"1\">");
+        tb.append("</body></html>");
+        return tb.toString();
+    }
+
+    public static void Casino1(L2PcInstance player)
+    {
+        int unstuckTimer = 1000;
+        player.setTarget(player);
+        player.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
+        player.disableAllSkills();
+        MagicSkillUse msk = new MagicSkillUse(player, 361, 1, unstuckTimer, 0);
+        Broadcast.toSelfAndKnownPlayersInRadius(player, msk, 810000);
+        SetupGauge sg = new SetupGauge(0, unstuckTimer);
+        player.sendPacket(sg);
+
+        Casino1 ef = new Casino1(player);
+        ThreadPoolManager.getInstance().scheduleGeneral(ef, unstuckTimer);
+    }
+
+    static class Casino1 implements Runnable
+    {
+        private L2PcInstance _player;
+        Casino1(L2PcInstance player)
+        {
+            _player = player;
+        }
+        public void run()
+        {
+            if(_player.isDead())
+                return;
+
+            _player.setIsIn7sDungeon(false);
+            _player.enableAllSkills();
+            int chance = Rnd.get(2);
+
+            if(_player.getInventory().getInventoryItemCount(9142, 0) >= 2)
+            {
+                if(chance == 0)
+                {
+                    displayCongrats(_player);
+                    _player.getInventory().addItem("Adena", 9142, 2, _player, null);
+                }
+                if(chance == 1)
+                {
+                	_player.sendMessage("You lost the bet");
+                    _player.getInventory().destroyItemByItemId("Adena", 9142, 2, _player, null);
+                }
+            }
+            else
+                _player.sendMessage("You do not have eneough items.");
+        }
+    }
+
+    public static void Casino2(L2PcInstance player)
+    {
+        int unstuckTimer = 1000;
+        player.setTarget(player);
+        player.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
+        player.disableAllSkills();
+        MagicSkillUse msk = new MagicSkillUse(player, 361, 1, unstuckTimer, 0);
+        Broadcast.toSelfAndKnownPlayersInRadius(player, msk, 810000);
+        SetupGauge sg = new SetupGauge(0, unstuckTimer);
+        player.sendPacket(sg);
+
+        Casino2 ef = new Casino2(player);
+        ThreadPoolManager.getInstance().scheduleGeneral(ef, unstuckTimer);
+    }
+
+    static class Casino2 implements Runnable
+    {
+        private L2PcInstance _player;
+        Casino2(L2PcInstance player)
+        {
+            _player = player;
+        }
+        public void run()
+        {
+            if(_player.isDead())
+                return;
+
+            _player.setIsIn7sDungeon(false);
+            _player.enableAllSkills();
+            int chance = Rnd.get(3);
+
+            if(_player.getInventory().getInventoryItemCount(9142, 0) >= 4)
+            {
+                if(chance == 0)
+                {
+                    displayCongrats(_player);
+                    _player.getInventory().addItem("Adena", 9142, 4, _player, null);
+                }
+                if(chance == 1)
+                {
+                	_player.sendMessage("You lost the bet");
+                    _player.getInventory().destroyItemByItemId("Adena", 9142, 4, _player, null);
+                }
+                if(chance == 2)
+                {
+                	_player.sendMessage("You lost the bet");
+                    _player.getInventory().destroyItemByItemId("Adena", 9142, 4, _player, null);
+                }
+            }
+            else
+            	_player.sendMessage("You do not have eneough items.");
+        }
+    }
+
+    public static void Casino3(L2PcInstance player)
+    {
+        int unstuckTimer = 1000;
+        player.setTarget(player);
+        player.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
+        player.disableAllSkills();
+        MagicSkillUse msk = new MagicSkillUse(player, 361, 1, unstuckTimer, 0);
+        Broadcast.toSelfAndKnownPlayersInRadius(player, msk, 810000);
+        SetupGauge sg = new SetupGauge(0, unstuckTimer);
+        player.sendPacket(sg);
+
+        Casino3 ef = new Casino3(player);
+        ThreadPoolManager.getInstance().scheduleGeneral(ef, unstuckTimer);
+    }
+
+    static class Casino3 implements Runnable
+    {
+        private L2PcInstance _player;
+        Casino3(L2PcInstance player)
+        {
+            _player = player;
+        }
+        public void run()
+        {
+            if(_player.isDead())
+                return;
+
+            _player.setIsIn7sDungeon(false);
+            _player.enableAllSkills();
+            int chance = Rnd.get(3);
+
+            if(_player.getInventory().getInventoryItemCount(9142, 0) >= 8)
+            {
+                if(chance == 0)
+                {
+                    displayCongrats(_player);
+                    _player.getInventory().addItem("Adena", 9142, 8, _player, null);
+                }
+                if(chance == 1)
+                {
+                	_player.sendMessage("You lost the bet");
+                    _player.getInventory().destroyItemByItemId("Adena", 9142, 8, _player, null);
+                }
+                if(chance == 2)
+                {
+                	_player.sendMessage("You lost the bet");
+                    _player.getInventory().destroyItemByItemId("Adena", 9142, 8, _player, null);
+                }
+            }
+            else
+            	_player.sendMessage("You do not have eneough items.");
+        }
+    }
+
+    public static void Casino4(L2PcInstance player)
+    {
+        int unstuckTimer = 1000;
+        player.setTarget(player);
+        player.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
+        player.disableAllSkills();
+        MagicSkillUse msk = new MagicSkillUse(player, 361, 1, unstuckTimer, 0);
+        Broadcast.toSelfAndKnownPlayersInRadius(player, msk, 810000);
+        SetupGauge sg = new SetupGauge(0, unstuckTimer);
+        player.sendPacket(sg);
+
+        Casino4 ef = new Casino4(player);
+        ThreadPoolManager.getInstance().scheduleGeneral(ef, unstuckTimer);
+    }
+
+    static class Casino4 implements Runnable
+    {
+        private L2PcInstance _player;
+        Casino4(L2PcInstance player)
+        {
+            _player = player;
+        }
+        public void run()
+        {
+            if(_player.isDead())
+                return;
+
+            _player.setIsIn7sDungeon(false);
+            _player.enableAllSkills();
+            int chance = Rnd.get(3);
+
+            if(_player.getInventory().getInventoryItemCount(9142, 0) >= 16)
+            {
+                if(chance == 0)
+                {
+                    displayCongrats(_player);
+                    _player.getInventory().addItem("Adena", 9142, 16, _player, null);
+                }
+                if(chance == 1)
+                {
+                	_player.sendMessage("You lost the bet");
+                    _player.getInventory().destroyItemByItemId("Adena", 9142, 16, _player, null);
+                }
+                if(chance == 2)
+                {
+                	_player.sendMessage("You lost the bet");
+                    _player.getInventory().destroyItemByItemId("Adena", 9142, 16, _player, null);
+                }
+            }
+            else
+            	_player.sendMessage("You do not have eneough items.");
+        }
+    }
+    
+    public static void Casino5(L2PcInstance player)
+    {
+        int unstuckTimer = 1000;
+        player.setTarget(player);
+        player.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
+        player.disableAllSkills();
+        MagicSkillUse msk = new MagicSkillUse(player, 361, 1, unstuckTimer, 0);
+        Broadcast.toSelfAndKnownPlayersInRadius(player, msk, 810000);
+        SetupGauge sg = new SetupGauge(0, unstuckTimer);
+        player.sendPacket(sg);
+
+        Casino5 ef = new Casino5(player);
+        ThreadPoolManager.getInstance().scheduleGeneral(ef, unstuckTimer);
+    }
+
+    static class Casino5 implements Runnable
+    {
+        private L2PcInstance _player;
+        Casino5(L2PcInstance player)
+        {
+            _player = player;
+        }
+        public void run()
+        {
+            if(_player.isDead())
+                return;
+
+            _player.setIsIn7sDungeon(false);
+            _player.enableAllSkills();
+            int chance = Rnd.get(2);
+
+            if(_player.getInventory().getInventoryItemCount(57, 0) >= 500000)
+            {
+                if(chance == 0)
+                {
+                    displayCongrats(_player);
+                    _player.getInventory().addItem("Adena", 57, 500000, _player, null);
+                }
+                if(chance == 1)
+                {
+                	_player.sendMessage("You lost the bet");
+                    _player.getInventory().destroyItemByItemId("Adena", 57, 500000, _player, null);
+                }
+            }
+            else
+            	_player.sendMessage("You do not have eneough items.");
+        }
+    }
+    
+    public static void Casino6(L2PcInstance player)
+    {
+        int unstuckTimer = 1000;
+        player.setTarget(player);
+        player.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
+        player.disableAllSkills();
+        MagicSkillUse msk = new MagicSkillUse(player, 361, 1, unstuckTimer, 0);
+        Broadcast.toSelfAndKnownPlayersInRadius(player, msk, 810000);
+        SetupGauge sg = new SetupGauge(0, unstuckTimer);
+        player.sendPacket(sg);
+
+        Casino6 ef = new Casino6(player);
+        ThreadPoolManager.getInstance().scheduleGeneral(ef, unstuckTimer);
+    }
+
+    static class Casino6 implements Runnable
+    {
+        private L2PcInstance _player;
+        Casino6(L2PcInstance player)
+        {
+            _player = player;
+        }
+        public void run()
+        {
+            if(_player.isDead())
+                return;
+
+            _player.setIsIn7sDungeon(false);
+            _player.enableAllSkills();
+            int chance = Rnd.get(3);
+
+            if(_player.getInventory().getInventoryItemCount(57, 0) >= 1000000)
+            {
+                if(chance == 0)
+                {
+                    displayCongrats(_player);
+                    _player.getInventory().addItem("Adena", 57, 1000000, _player, null);
+                }
+                if(chance == 1)
+                {
+                	_player.sendMessage("You lost the bet");
+                    _player.getInventory().destroyItemByItemId("Adena", 57, 1000000, _player, null);
+                }
+                if(chance == 2)
+                {
+                	_player.sendMessage("You lost the bet");
+                    _player.getInventory().destroyItemByItemId("Adena", 57, 1000000, _player, null);
+                }
+            }
+            else
+            	_player.sendMessage("You do not have eneough items.");
+        }
+    }
+    
+    public static void Casino7(L2PcInstance player)
+    {
+        int unstuckTimer = 1000;
+        player.setTarget(player);
+        player.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
+        player.disableAllSkills();
+        MagicSkillUse msk = new MagicSkillUse(player, 361, 1, unstuckTimer, 0);
+        Broadcast.toSelfAndKnownPlayersInRadius(player, msk, 810000);
+        SetupGauge sg = new SetupGauge(0, unstuckTimer);
+        player.sendPacket(sg);
+
+        Casino7 ef = new Casino7(player);
+        ThreadPoolManager.getInstance().scheduleGeneral(ef, unstuckTimer);
+    }
+
+    static class Casino7 implements Runnable
+    {
+        private L2PcInstance _player;
+        Casino7(L2PcInstance player)
+        {
+            _player = player;
+        }
+        public void run()
+        {
+            if(_player.isDead())
+                return;
+
+            _player.setIsIn7sDungeon(false);
+            _player.enableAllSkills();
+            int chance = Rnd.get(3);
+
+            if(_player.getInventory().getInventoryItemCount(57, 0) >= 10000000)
+            {
+                if(chance == 0)
+                {
+                    displayCongrats(_player);
+                    _player.getInventory().addItem("Adena", 57, 10000000, _player, null);
+                }
+                if(chance == 1)
+                {
+                	_player.sendMessage("You lost the bet");
+                    _player.getInventory().destroyItemByItemId("Adena", 57, 10000000, _player, null);
+                }
+                if(chance == 2)
+                {
+                	_player.sendMessage("You lost the bet");
+                    _player.getInventory().destroyItemByItemId("Adena", 57, 10000000, _player, null);
+                }
+            }
+            else
+            	_player.sendMessage("You do not have eneough items.");
+        }
+    }
+}
\ No newline at end of file

  • 0
Posted

MagicSkillUser msk = new MagicSkillUser(activeChar, 1050, 1, teleportTimer, 0);

 

Forgot to say that this line only creates the packet , then you must send it to the player also , so you will have to add one more line to work fine.

activeChar.sendPacket(msk);

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


×
×
  • 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