Jump to content

Recommended Posts

Posted (edited)

567136f854304129a821319417203fff.png

package com.l2jfresh.gameserver.model.actor.instance;

import java.util.StringTokenizer;
import java.util.NoSuchElementException;

import com.l2jfresh.gameserver.Announcements;
import com.l2jfresh.gameserver.model.actor.L2Npc;
import com.l2jfresh.gameserver.model.actor.template.NpcTemplate;
import com.l2jfresh.gameserver.network.clientpackets.Say2;
import com.l2jfresh.gameserver.network.serverpackets.Dice;
import com.l2jfresh.gameserver.network.serverpackets.ExShowScreenMessage;
import com.l2jfresh.gameserver.network.serverpackets.NpcHtmlMessage;
import com.l2jfresh.gameserver.network.serverpackets.NpcSay;
import com.l2jfresh.gameserver.util.Broadcast;
import com.l2jfresh.util.Rnd;



public class L2CasinoInstance extends L2Npc
{
	//Item Id
    public static int _itemId;
	private String itemname= "None";
    //Ammount Item
    public static int jackpot;
    public static int jackpot2;
    public L2CasinoInstance(int objectId, NpcTemplate template)
    {
        super(objectId, template);
    }
    
	@Override
	public boolean isAttackable()
	{
		return false;
	}
    @Override
    public void onBypassFeedback(L2PcInstance player, String command)
    {
      int ammount = 0;
      if (command.startsWith("play1"))
      {
        StringTokenizer st = new StringTokenizer(command);
        st.nextToken();
        try
        {
          String type = st.nextToken();

          if(type.startsWith("VoteStone"))
          {
        	  _itemId = 9595;
          }
          else if(type.startsWith("FarmCoin"))
          {
        	  _itemId = 9696;
          }
          ammount = Integer.parseInt(st.nextToken());
        }
        catch (NoSuchElementException nse)
        {
        }
        if (ammount >0)
        {
            Dice(player, this, ammount);
        }
        else return;
      }
    }
    
    @Override
    public void showChatWindow(L2PcInstance player)
    {
        NpcHtmlMessage msg = new NpcHtmlMessage(this.getObjectId());
        msg.setHtml(casinoWindow(player));
        msg.replace("%objectId%", String.valueOf(this.getObjectId()));
        player.sendPacket(msg);
    }

    private static String casinoWindow(L2PcInstance player)
    {
    	StringBuilder tb = new StringBuilder();
        tb.append("<html><title>L2Ultimate Casino</title><body>");
        tb.append("<center><img src=\"L2Ultimate.logo\" width=\"300\" height=\"100\"/><br>");
        tb.append("<font color=\"3b8d8d\">Casino Manager</font><br>");
        tb.append("<img src=\"L2UI.SquareGray\" width=\"200\" height=\"1\"><br>");
        tb.append("<table width=290>");
        tb.append("<tr>");
        tb.append("<td align=\"center\"><font color=\"FFCC33\">Hello Sir, i Am Here for Your bets.<font></td></tr>");        
        tb.append("<tr><td align=\"center\"><font color=\"FFCC33\">You got need to Roll Number: 6-6 or 6-5 or 5-5 or 3-3</font></td></tr>");
        tb.append("<tr><td align=\"center\"><font color=\"LEVEL\">But if you are Lucky and you will win the Jackpot ,</font></td></tr>");
        tb.append("<tr><td align=\"center\"><font color=\"FF0000\">Jackpot of Vote Stone: "+jackpot+"</font></td></tr>");	
        tb.append("<tr><td align=\"center\"><font color=\"FF0000\">Jackpot of Farm Coin: "+jackpot2+"</font></td></tr>"); 
        tb.append("<tr></tr>");
        tb.append("</table>");
        tb.append("<center><img src=\"L2UI.SquareGray\" width=\"280\" height=\"1\"><br>");
        tb.append("<table width=290>");
        tb.append("<tr>");
        tb.append("<td align=\"center\"><font color=\"0F92FF\">Select a Currency To Bet:</font></td>");
        tb.append("<td><combobox width=120 height=21 var=\"cb\"list=VoteStone;FarmCoin></td>");
        tb.append("</tr>");
        tb.append("<tr></tr>");
        tb.append("<tr></tr>");
        tb.append("<tr>");
        tb.append("<td align=center><font color=\"0F92FF\">Type an Amount:</font></td>");
        tb.append("<td><edit var=\"qbox\" width=120 height=15></td>");
        tb.append("</table><br>");
        tb.append("<center><img src=\"L2UI.SquareGray\" width=\"280\" height=\"1\"></center><br><br>");
        tb.append("<center><button value=\"Try Your Luck!\" action=\"bypass -h npc_%objectId%_play1 $cb $qbox\" width=134 height=21 back=\"L2UI_ch3.BigButton3_over\" fore=\"L2UI_ch3.BigButton3\"></center>");
        tb.append("</body></html>");
        return tb.toString();
    }
    
    public void Dice(L2PcInstance activeChar,L2Npc npc,int _ammount)
    {
		if(activeChar.getInventory().getInventoryItemCount(_itemId, 0) >= _ammount)
		{
				int number = rollDice();
				int number2 = rollDice2();
				if(number == 6 && number2 == 6 || number == 6 && number2 == 5 || number == 5 && number2 == 5 || number == 3 && number2 == 3)
				{
			        ExShowScreenMessage screen = new ExShowScreenMessage("Congratulations "+activeChar.getName()+" won You got "+number+"-"+number2+" Good!", 6000);
			        String name = activeChar.getName();
			        activeChar.sendPacket(new NpcSay(npc.getObjectId(), Say2.TELL, npc.getNpcId(), "Congratulations "+name+" won You got "+number+"-"+number2+" Good!"));
			        activeChar.sendPacket(screen);
					activeChar.addItem("Consume", _itemId, _ammount, activeChar,true);
					/*if(_itemId == 9595)
					{
				   	  jackpot += _ammount;
					}
					else if(_itemId == 9696)
					{
					  jackpot2 += _ammount;
					}*/
					showChatWindow(activeChar);
					switch(_itemId)
					{
					    case 9595:
						itemname = "Vote Stone";
						break;
					    case 9696:
						itemname = "Look Coin";
						break;
					}
					
					switch(Rnd.get(1,20))
					{
					    case 1:
						break;
					    case 2:
						break;
					    case 3:
						break;
					    case 4:
						break;
					    case 5:
						    if(_itemId == 9595)
						    {
						     activeChar.addItem("Consume", _itemId, jackpot, activeChar,true);
						     activeChar.broadcastUserInfo();
						     Announcements.gameAnnounceToAll("Congratulations "+ activeChar.getName() +" he won "+ jackpot +" Jackpot of "+ itemname +"!");
						     jackpot = 0;
						    }
						    else if(_itemId == 9696)
						    {
						    activeChar.addItem("Consume", _itemId, jackpot2, activeChar,true);
						    activeChar.broadcastUserInfo();
						    Announcements.gameAnnounceToAll("Congratulations "+ activeChar.getName() +" he won "+ jackpot2 +" Jackpot of "+ itemname +"!");
						    jackpot2 = 0;
						    }
						break;
					    case 6:
						break;
					    case 7:
						break;
					    case 8:
						break;
					    case 9:
						break;
					    case 10:
						break;
					    case 11:
					    if(_itemId == 9595)
					    {
					     activeChar.addItem("Consume", _itemId, jackpot, activeChar,true);
					     activeChar.broadcastUserInfo();
					     Announcements.gameAnnounceToAll("Congratulations "+ activeChar.getName() +" he won "+ jackpot +" Jackpot of "+ itemname +"!");
					     jackpot = 0;
					    }
					    else if(_itemId == 9696)
					    {
					    activeChar.addItem("Consume", _itemId, jackpot2, activeChar,true);
					    activeChar.broadcastUserInfo();
					    Announcements.gameAnnounceToAll("Congratulations "+ activeChar.getName() +" he won "+ jackpot2 +" Jackpot of "+ itemname +"!");
					    jackpot2 = 0;
					    }
						break;
					    case 12:
						break;
					    case 13:
						break;
					    case 14:
						break;
					    case 16:
						break;
					    case 17:
						break;
					    case 18:
						break;
					    case 19:
						break;
					    case 20:
						break;
					}
					activeChar.broadcastUserInfo();
				}
				else
				{
			        ExShowScreenMessage screen = new ExShowScreenMessage(""+activeChar.getName()+" Ïops lost again play can be lucky!", 6000);
			        String name = activeChar.getName();
			        activeChar.sendPacket(new NpcSay(npc.getObjectId(),Say2.TELL, npc.getNpcId(), name+" Ïops lost again Play can be Lucky!"));
			        activeChar.sendPacket(screen);
					activeChar.destroyItemByItemId("Consume", _itemId, _ammount, activeChar, true);
					if(_itemId == 9595)
					{
				   	  jackpot += _ammount;
					}
					else if(_itemId == 9696)
					{
					   jackpot2 += _ammount;
					}
					activeChar.broadcastUserInfo();
					showChatWindow(activeChar);
				}
				Broadcast.toSelfAndKnownPlayers(npc, new Dice(npc.getObjectId(), 4625, number, npc.getX() - 30, npc.getY() - 30, npc.getZ()));
				Broadcast.toSelfAndKnownPlayers(npc, new Dice(npc.getObjectId(), 4626, number2, npc.getX() - 22, npc.getY() - 22, npc.getZ()));
			}
			else
			{
				switch(_itemId)
				{
				    case 9595:
					itemname = "Vote Stone";
					break;
				    case 9696:
					itemname = "Look Coin";
					break;
				}
				activeChar.sendMessage("You do not have enough "+itemname+".");
			}
	}
    
	public static int rollDice2()
	{
		return Rnd.get(1, 7);
	}
	
	public static int rollDice()
	{
		return Rnd.get(1, 7);
	}
	
}

code by fofas :)

Edited by Crazyboy*
Posted

lmao, what a bad code.. What's the point of this "dice"? As I see it's normal bet "double or nothing", so I don't relly get it. You only need one Rnd.get(.

Posted

You don't have to add all Cases that are not used in switch lel just the 2 that are used and the default:  that will happen in case none of them is.. 

Devorakoc the dev guy aka MrPRO* BFF

Posted

lmao, what a bad code.. What's the point of this "dice"? As I see it's normal bet "double or nothing", so I don't relly get it. You only need one Rnd.get(.

Shut the fuck up kid, we all know you're jealous of his skills and u can't remake this code.. stop being kid

Posted

Shut the fuck up kid, we all know you're jealous of his skills and u can't remake this code.. stop being kid

:( :( :(

 

You hurt my feelings. But still, its "one code line".

Posted (edited)

You probably can cut the code from 60 to 80% :

  • a chance of 50% (according your HTM) doesn't need 5 different dice rolls, it's a simple Rnd.nextBoolean()
  • HTM content = static HTM to avoid hardcoded HTMs.
  • The bypass can be directly the itemId to avoid string checks.
  • The whole switch is pointless. I don't want to imagine if you were using a Rnd.get(1000)... You would wrote 998 empty cases ? If you don't want a 50% win case, simply write Rnd.get(1000) or 10000 and test 0 and 1 as results. No need your whole fat ugly switch.
  • You lose all jackpot data on server restart. Use GobalVariables (or ServerMemo) to store it.
  • jackpot and jackpot2 is a stupid concept, imagine you want to add or remove currencies. You're fucked up. And static the itemId is also wrong, if 2 players are using 2 different currencies in same time, one of the player can end with the other currency when the other player flipped it.

I don't recommend to use it, being aCis or not.

Edited by Tryskell
Posted

Wow you really have to try very hard to suck at coding such a basic concept.

 

I remember a time where you were coding almost as bad as the OP (your old balancer stats, just to give an exemple of extremely redundant code style). I say that, I say nothing.

 

;D

Posted

I remember a time where you were coding almost as bad as the OP (your old balancer stats, just to give an exemple of extremely redundant code style). I say that, I say nothing.

 

;D

We all begin from something don't we ? :D

Posted (edited)

We all begin from something don't we ? :D

 

So you should be the best to know it's not nice to bash people, while you can explain where are the flaws and how to improve the code. In both case you say the code got issues, but one way is negative while the second is more positive.

 

That was the morale lesson of the day, cya tomorrow for new lessons ! :D

Edited by Tryskell

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


  • Posts

    • 🎉 **OPENING — Lineage 2 x17 MULTIPROF COMFORT SERVER!** 🔥 **October 31, 2025 at 20:00 (MSK)** (OBT starts **October 27, 2025 at 20:00**) 💎 **Multeria** invites you to join the brand-new **Multiprof server** — built with care, balance, and community feedback in mind! ⚔️ **COMFORT RATES:** • EXP ×17 (with PA ×25.5) • SP ×8.5 (with PA ×17) • Drop / Spoil ×1 (with PA ×2.5) • Adena ×1 (with PA ×2) 🚀 **WHAT’S NEW:** • New max level — **100** • **100% Craft System** for armor, weapons, belts (incl. Power Belt), bracelets & talismans • New epic accessory — **Frintezza’s Necklace** • **Mass skills cooldown reduced ×10** (Defense Instinct, Magic Impulse, Fanatic, etc.) • Fair play — HWID limits on global instances and rebirth-based party checks • **New 90+ dungeons** (60/120 min time limits) • **New PvP zones:** Varka, FoG, LoA, Stakato (battle zones active) • **Extra game window** available for in-game currency (Gold Einhasad) 💬 Everything you love about Lineage 2 — **balance, comfort, and fairness**. 🔗 More info: https://hf.multeria.world/
    • Hello everyone, we now have Adena for these projects: l2rebon signature x1 - 1kk = $0.8 l2reborn x10 - 500kk = $3.5 E-Global x Lu4 - 1kk = $1.8 ElmoreLab x5 - 1kk = $1.7 DISCORD - GODDARDSHOP
    • 新品上线! 快来抢购最优质的 GMAIL 账号,享受 超低价格,注册年份范围从 2005–2022! 老版 Gmail.com 账号(已启用 2FA 双重验证) | 使用 MIX IP 注册 | 年份:2005 至 2022(可自行选择) | 账号可能包含邮件 | 格式:email:password:submail | 无需短信验证 | 已启用 IMAP | 附带 Submail | 价格起步:$0.9 我们还提供 Outlook、Firstmail、Rambler、Onet、Gazeta.pl、GMX、Yahoo、Proton、Web.de 等邮箱账号。 立即通过我们的网站或机器人购买! 活跃链接: 数字商品商店(网站):进入 商店 Telegram 机器人:进入 – 通过 Telegram 方便快捷地访问商店。 其他服务: Telegram Stars 购买机器人:进入 – 快速又实惠地购买 Telegram Stars。 SMM 面板:进入 – 推广您的社交媒体账号。 我们为您呈现当前 促销活动 与 特别优惠,适用于购买我们的商品和服务: 1. 优惠码 OCTOBER2025(8% 折扣)适用于九月在我们的商店(网站、机器人)购物!首次购买还可使用优惠码 SOCNET(15% 折扣)。 2. 获取 $1 商店余额或 10–20% 折扣 —— 注册后在我们网站的论坛贴中按照以下格式留言:"SEND ME BONUS, MY USERNAME IS..."。 3. 首次试用 SMM 面板可获得 $1 奖励 —— 只需在网站(Support)中创建名为 “Get Trial Bonus” 的支持工单。 4. 每周在我们的 Telegram 频道和 Stars 购买机器人中举行 Telegram Stars 抽奖活动! 新闻: ➡ Telegram 频道:https://t.me/accsforyou_shop ➡ WhatsApp 频道:https://chat.whatsapp.com/K8rBy500nA73z27PxgaJUw?mode=ems_copy_t ➡ Discord 服务器:https://discord.gg/y9AStFFsrh 联系方式与支持: ➡ Telegram:https://t.me/socnet_support ➡ WhatsApp:https://wa.me/79051904467 ➡ Discord:socnet_support ➡ ✉ 邮箱:solomonbog@socnet.store
    • 新品上线! 快来抢购最优质的 GMAIL 账号,享受 超低价格,注册年份范围从 2005–2022! 老版 Gmail.com 账号(已启用 2FA 双重验证) | 使用 MIX IP 注册 | 年份:2005 至 2022(可自行选择) | 账号可能包含邮件 | 格式:email:password:submail | 无需短信验证 | 已启用 IMAP | 附带 Submail | 价格起步:$0.9 我们还提供 Outlook、Firstmail、Rambler、Onet、Gazeta.pl、GMX、Yahoo、Proton、Web.de 等邮箱账号。 立即通过我们的网站或机器人购买! 活跃链接: 数字商品商店(网站):进入 商店 Telegram 机器人:进入 – 通过 Telegram 方便快捷地访问商店。 其他服务: Telegram Stars 购买机器人:进入 – 快速又实惠地购买 Telegram Stars。 SMM 面板:进入 – 推广您的社交媒体账号。 我们为您呈现当前 促销活动 与 特别优惠,适用于购买我们的商品和服务: 1. 优惠码 OCTOBER2025(8% 折扣)适用于九月在我们的商店(网站、机器人)购物!首次购买还可使用优惠码 SOCNET(15% 折扣)。 2. 获取 $1 商店余额或 10–20% 折扣 —— 注册后在我们网站的论坛贴中按照以下格式留言:"SEND ME BONUS, MY USERNAME IS..."。 3. 首次试用 SMM 面板可获得 $1 奖励 —— 只需在网站(Support)中创建名为 “Get Trial Bonus” 的支持工单。 4. 每周在我们的 Telegram 频道和 Stars 购买机器人中举行 Telegram Stars 抽奖活动! 新闻: ➡ Telegram 频道:https://t.me/accsforyou_shop ➡ WhatsApp 频道:https://chat.whatsapp.com/K8rBy500nA73z27PxgaJUw?mode=ems_copy_t ➡ Discord 服务器:https://discord.gg/y9AStFFsrh 联系方式与支持: ➡ Telegram:https://t.me/socnet_support ➡ WhatsApp:https://wa.me/79051904467 ➡ Discord:socnet_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