Перейти к содержанию
Авторизация  
BBMAXI

[manual] Казино-лотерея

Рекомендуемые сообщения

Скрипт Casino(лотерея)

Подходите к НПС, даёте ему 100кк и либо оставляете их у него, либо у Вас 200кк.

Пойдет под любой l2j сервер. Удачи.

 

/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* <http://www.gnu.org/copyleft/gpl.html>
*/
package net.sf.l2j.gameserver.model.actor.instance;

import net.sf.l2j.gameserver.GameTimeController;
import net.sf.l2j.gameserver.ThreadPoolManager;
import net.sf.l2j.gameserver.ai.CtrlIntention;
import net.sf.l2j.gameserver.network.serverpackets.ExShowScreenMessage;
import net.sf.l2j.gameserver.network.serverpackets.MagicSkillUser;
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.L2NpcTemplate;
import net.sf.l2j.gameserver.util.Broadcast;
import net.sf.l2j.util.Rnd;
import javolution.text.TextBuilder;


public class L2CasinoInstance extends L2NpcInstance
{
private String filename;
public L2CasinoInstance(int objectId, L2NpcTemplate template)
{
	super(objectId, template);
}

@Override
public void onBypassFeedback(L2PcInstance player, String command) {

	if(player == null || player.getLastFolkNPC() == null
			|| player.getLastFolkNPC().getObjectId() != this.getObjectId()) {
		return;
	}

	if(command.startsWith("play1"))
		Casino1(player);
	if(command.startsWith("play2"))
		Casino2(player);
	if(command.startsWith("play3"))
		Casino3(player);
	if(command.startsWith("play4"))
		Casino4(player);
}

public static void displayCongrats(L2PcInstance player)
{
	player.broadcastPacket(new SocialAction(player.getObjectId(), 3));//Victory Social Action.
	MagicSkillUser  MSU = new MagicSkillUser(player, player, 2024, 1, 1, 0);//Fireworks Display
	player.broadcastPacket(MSU);
	ExShowScreenMessage screen = new ExShowScreenMessage("Congratulations "+player.getName()+"! You won!", 15000);
	player.sendPacket(screen);
}

public static void displayCongrats2(L2PcInstance player)
{
	ExShowScreenMessage screen = new ExShowScreenMessage(""+player.getName()+"! You lost!", 15000);
	player.sendPacket(screen);
}

@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 replyMSG = new TextBuilder();
	 replyMSG.append("<html><title>Casino Manager</title><body>");
	  replyMSG.append("<center>");
	  replyMSG.append("<br>");
	  replyMSG.append("<font color=\"999999\">Chance to win : 50%</font><br>");
	  replyMSG.append("<img src=\"L2UI.SquareGray\" width=\"200\" height=\"1\"><br>");
	  replyMSG.append("Welcome "+player.getName()+"<br>");
	  replyMSG.append("<tr><td>Double or Nothing ?</td></tr><br>");
	  replyMSG.append("<img src=\"L2UI.SquareGray\" width=\"280\" height=\"1\"></center><br>");
	  replyMSG.append("<center>");
	  replyMSG.append("Place your bets");
	  replyMSG.append("</center>");
	  replyMSG.append("<img src=\"L2UI.SquareGray\" width=\"280\" height=\"1\"></center><br>");
	  replyMSG.append("<br>");
	  replyMSG.append("<center>");
	  replyMSG.append("<tr>");
	  replyMSG.append("<td><button value= 100KK action=\"bypass -h npc_%objectId%_play1\" width=130 height=25 back = sek.cbui94 fore = sek.cbui92></td>");
	  replyMSG.append("<td><button value= 300KK action=\"bypass -h npc_%objectId%_play2\" width=130 height=25 back = sek.cbui94 fore = sek.cbui92></td>");
	  replyMSG.append("</tr>");
	  replyMSG.append("<tr>");
	  replyMSG.append("<td><button value= 500KK action=\"bypass -h npc_%objectId%_play3\" width=130 height=25 back = sek.cbui94 fore = sek.cbui92></td>");
	  replyMSG.append("<td><button value= 1KKK action=\"bypass -h npc_%objectId%_play4\" width=130 height=25 back = sek.cbui94 fore = sek.cbui92></td>");
	  replyMSG.append("</tr>");
	  replyMSG.append("</center>");

	  replyMSG.append("<center><img src=\"L2UI.SquareGray\" width=\"280\" height=\"1\">");
	  replyMSG.append("</body></html>");
	return replyMSG.toString();
}
public static void Casino1(L2PcInstance player)
{
	int unstuckTimer = (1*1000 );
	player.setTarget(player);
	player.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
	player.disableAllSkills();
	MagicSkillUser msk = new MagicSkillUser(player, 361, 1, unstuckTimer, 0);
	Broadcast.toSelfAndKnownPlayersInRadius(player, msk, 810000);
	SetupGauge sg = new SetupGauge(0, unstuckTimer);
	player.sendPacket(sg);

	Casino1 ef = new Casino1(player);
	player.setSkillCast(ThreadPoolManager.getInstance().scheduleGeneral(ef, unstuckTimer));
	player.setSkillCastEndTime(10+GameTimeController.getGameTicks()+unstuckTimer/GameTimeController.MILLIS_IN_TICK);
}
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.isNoble() && _player.getInventory().getInventoryItemCount(57, 0) >= 100000000)
		{
				if(chance == 0) {
					displayCongrats(_player);
					_player.getInventory().addItem("Adena", 57, 100000000, _player, null);
								}
				if (chance == 1)
				{
					displayCongrats2(_player);
					_player.getInventory().destroyItemByItemId("Adena", 57, 100000000, _player, null);
				}
		}
		 else
		{
			 _player.sendMessage("You do not have eneough items.");
		}
	}
}

public static void Casino2(L2PcInstance player)
{
	int unstuckTimer = (1*1000 );
	player.setTarget(player);
	player.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
	player.disableAllSkills();
	MagicSkillUser msk = new MagicSkillUser(player, 361, 1, unstuckTimer, 0);
	Broadcast.toSelfAndKnownPlayersInRadius(player, msk, 810000);
	SetupGauge sg = new SetupGauge(0, unstuckTimer);
	player.sendPacket(sg);

	Casino2 ef = new Casino2(player);
	player.setSkillCast(ThreadPoolManager.getInstance().scheduleGeneral(ef, unstuckTimer));
	player.setSkillCastEndTime(10+GameTimeController.getGameTicks()+unstuckTimer/GameTimeController.MILLIS_IN_TICK);
}
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.isNoble() && _player.getInventory().getInventoryItemCount(57, 0) >= 300000000)
		{
				if(chance == 0) {
					displayCongrats(_player);
					_player.getInventory().addItem("Adena", 57, 300000000, _player, null);
								}
				if (chance == 1)
				{
					displayCongrats2(_player);
					_player.getInventory().destroyItemByItemId("Adena", 57, 300000000, _player, null);
				}
				if (chance == 2)
				{
					displayCongrats2(_player);
					_player.getInventory().destroyItemByItemId("Adena", 57, 300000000, _player, null);
				}
		}
		 else
		{
			 _player.sendMessage("You do not have eneough items.");
		}
	}
}

public static void Casino3(L2PcInstance player)
{
	int unstuckTimer = (1*1000 );
	player.setTarget(player);
	player.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
	player.disableAllSkills();
	MagicSkillUser msk = new MagicSkillUser(player, 361, 1, unstuckTimer, 0);
	Broadcast.toSelfAndKnownPlayersInRadius(player, msk, 810000);
	SetupGauge sg = new SetupGauge(0, unstuckTimer);
	player.sendPacket(sg);

	Casino3 ef = new Casino3(player);
	player.setSkillCast(ThreadPoolManager.getInstance().scheduleGeneral(ef, unstuckTimer));
	player.setSkillCastEndTime(10+GameTimeController.getGameTicks()+unstuckTimer/GameTimeController.MILLIS_IN_TICK);
}
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.isNoble() && _player.getInventory().getInventoryItemCount(57, 0) >= 500000000)
		{
				if(chance == 0) {
					displayCongrats(_player);
					_player.getInventory().addItem("Adena", 57, 500000000, _player, null);
								}
				if (chance == 1)
				{
					displayCongrats2(_player);
					_player.getInventory().destroyItemByItemId("Adena", 57, 500000000, _player, null);
				}
				if (chance == 2)
				{
					displayCongrats2(_player);
					_player.getInventory().destroyItemByItemId("Adena", 57, 500000000, _player, null);
				}
		}
		 else
		{
			 _player.sendMessage("You do not have eneough items.");
		}
}
}

public static void Casino4(L2PcInstance player)
{
	int unstuckTimer = (1*1000 );
	player.setTarget(player);
	player.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
	player.disableAllSkills();
	MagicSkillUser msk = new MagicSkillUser(player, 361, 1, unstuckTimer, 0);
	Broadcast.toSelfAndKnownPlayersInRadius(player, msk, 810000);
	SetupGauge sg = new SetupGauge(0, unstuckTimer);
	player.sendPacket(sg);

	Casino4 ef = new Casino4(player);
	player.setSkillCast(ThreadPoolManager.getInstance().scheduleGeneral(ef, unstuckTimer));
	player.setSkillCastEndTime(10+GameTimeController.getGameTicks()+unstuckTimer/GameTimeController.MILLIS_IN_TICK);
}
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.isNoble() && _player.getInventory().getInventoryItemCount(57, 0) >= 1000000000)
		{
				if(chance == 0) {
					displayCongrats(_player);
					_player.getInventory().addItem("Adena", 57, 1000000000, _player, null);
								}
				if (chance == 1)
				{
					displayCongrats2(_player);
					_player.getInventory().destroyItemByItemId("Adena", 57, 1000000000, _player, null);
				}
				if (chance == 2)
				{
					displayCongrats2(_player);
					_player.getInventory().destroyItemByItemId("Adena", 57, 1000000000, _player, null);
				}
		}
		 else
		{
			 _player.sendMessage("You do not have eneough items.");
		}
	}
}
}

Поделиться сообщением


Ссылка на сообщение
Поделиться на другие сайты

Пихай в ...../data/scripts/events/"имя эвета"/__init__.py

В файл "__init__.py" вписывай код-который написан в первом посте.

 

Вот тока как этот эвент прикрутить к НПЦ (да-да тут еще и НПЦ нужно будет в базу вписать), пока еще не разобрался.

Но как говорится помогоаю в меру того-что знаю.

Поделиться сообщением


Ссылка на сообщение
Поделиться на другие сайты

Для публикации сообщений создайте учётную запись или авторизуйтесь

Вы должны быть пользователем, чтобы оставить комментарий

Создать учетную запись

Зарегистрируйте новую учётную запись в нашем сообществе. Это очень просто!

Регистрация нового пользователя

Войти

Уже есть аккаунт? Войти в систему.

Войти
Авторизация  

  • Последние посетители   0 пользователей онлайн

    Ни одного зарегистрированного пользователя не просматривает данную страницу

×
×
  • Создать...