Noticias:

No tienes permiso para ver los enlaces. Para poder verlos Registrate o Conectate.

Menú Principal

Bet system (Dev...)

Iniciado por Swarlog, Jul 26, 2025, 10:55 PM

Tema anterior - Siguiente tema

Swarlog

CitarCORE:

/*
 * Copyright (C) 2004-2015 L2J Server
 * 
 * This file is part of L2J Server.
 * 
 * L2J Server 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 3 of the License, or
 * (at your option) any later version.
 * 
 * L2J Server 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, see <http://www.gnu.org/licenses/>.
 */
package com.l2jserver.gameserver.instancemanager.games;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;

import com.l2jserver.L2DatabaseFactory;

/**
 * @author Skoulix
 */

public class OpapGame
{
	protected static final Logger _log = Logger.getLogger(OpapGame.class.getName());
	
	private static final String INSERT_BETS = "INSERT INTO custom_opap(matche_id, matche_teams, assos, xiaraki, diplo) VALUES (?, ?, ?, ?, ?)";
	
	public int _matche_id;
	public String _matche_teams;
	public double _assos;
	public double _xiaraki;
	public double _diplo;
	
	private class startOpap implements Runnable
	{
		protected startOpap()
		{
			try (Connection con = L2DatabaseFactory.getInstance().getConnection();
				PreparedStatement statement = con.prepareStatement(INSERT_BETS))
			{
				statement.setInt(1, getMatcheId());
				statement.setString(2, getMatcheTeams());
				statement.setDouble(3, getAssos());
				statement.setDouble(4, getXiaraki());
				statement.setDouble(5, getDiplo());
				statement.execute();
			}
			catch (SQLException e)
			{
				_log.log(Level.WARNING, "OPAP GAMES: Could not  data: " + e.getMessage(), e);
			}
			
		}
		
		@Override
		public void run()
		{
			try (Connection con = L2DatabaseFactory.getInstance().getConnection();
				PreparedStatement statement = con.prepareStatement(INSERT_BETS))
			{
				statement.setInt(1, getMatcheId());
				statement.setString(2, getMatcheTeams());
				statement.setDouble(3, getAssos());
				statement.setDouble(4, getXiaraki());
				statement.setDouble(5, getDiplo());
				statement.execute();
			}
			catch (SQLException e)
			{
				_log.log(Level.WARNING, "OPAP GAMES: Could not  data: " + e.getMessage(), e);
			}
			
		}
		
		protected int getMatcheId()
		{
			return _matche_id;
		}
		
		protected String getMatcheTeams()
		{
			return _matche_teams;
		}
		
		protected double getAssos()
		{
			return _assos;
		}
		
		protected double getXiaraki()
		{
			return _xiaraki;
		}
		
		protected double getDiplo()
		{
			return _diplo;
		}
		
	}
	
}

CitarDATA:

/*
 * Copyright (C) 2004-2015 L2J DataPack
 * 
 * This file is part of L2J DataPack.
 * 
 * L2J DataPack 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 3 of the License, or
 * (at your option) any later version.
 * 
 * L2J DataPack 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, see <http://www.gnu.org/licenses/>.
 */
package handlers.voicedcommandhandlers;

import com.l2jserver.gameserver.cache.HtmCache;
import com.l2jserver.gameserver.handler.IVoicedCommandHandler;
import com.l2jserver.gameserver.instancemanager.games.OpapGame;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;

/**
 * @author Skoulix
 */
public class Opap implements IVoicedCommandHandler
{
	private static final String[] COMMANDS =
	{
		"opap",
		"opap_close",
		"opap_open",
		"startopap",
		"betopap",
		"checkopap",
		"admin_opap",
		"admin_opapadd"
	};
	
	public static int matchId = 1;
	public static String matcheTeams = "Team1-Team2";
	public static double assos = 1.80; // Never under 1 :P.
	public static double xiaraki = 3;
	public static double diplo = 2.30;
	
	static String htmlBetAdd = "" + "<tr>" + "<th>" + "matchid" + "</th> " + "<th>" + matcheTeams + "</th>" + "<th>" + assos + "</th>" + "<th>" + xiaraki + "</th> " + "<th>" + diplo + "</th> " + "</tr>";
	static String htmlBetBasic = " " + "<table> " + "<tr> " + "<th>Matche ID</th> " + "<th>Matche Teams</th>" + "<th>1</th>" + "<th>X</th> " + "<th>2</th> " + "</tr>" + htmlBetAdd + "</table>";
	
	@Override
	public boolean useVoicedCommand(String command, L2PcInstance activeChar, String params)
	{
		
		if (command.equals("opap"))
		{
			Opap.showOpapPage(activeChar, "opap.htm");
		}
		if (command.equals("opapstart"))
		{
			// Θα μποÏ�οÏ...ν να παÏ�αληψοÏ...ν Ï,,ην opap ενÏ,,ολη αν γνωÏ�ιζοÏ...ν Ï,,ην ενÏ,,ολη .opapstart .
			Opap.showOpapPage(activeChar, "opap-start.htm");
		}
		if (command.equals("betopap"))
		{
			
			Opap.showOpapPage(activeChar, "opap-bet.htm");
		}
		
		if (command.equals("admin_opap"))
		{
			if (activeChar.isGM())
			{
				Opap.showOpapAdminPage(activeChar, "opap-admin.html");
				
			}
			else
			{
				activeChar.sendMessage("You are not administrator for use this commands :-) !!! (_)(_)========D'");
			}
		}
		
		if (command.equals("admin_opapadd"))
		{
			
			if (activeChar.isGM() != true)
			{
				activeChar.sendMessage("You are not administrator for use this commands :-) !!! admin_opapadd");
			}
			else
			{
				addOpapBets(1, "team1vsteam2", 1.50, 3.20, 5.65);
			}
		}// admin_opapadd
		
		return true;
	}
	
	/**
	 * @param activeChar
	 * @param filename
	 * @see showOpapAdminPage. That Method is for show Admins bets.There we add extra info for admins ;).
	 */
	@SuppressWarnings("javadoc")
	private static void showOpapAdminPage(L2PcInstance activeChar, String filename)
	{
		
		String content = HtmCache.getInstance().getHtmForce(activeChar.getHtmlPrefix(), "data/html/opap/" + filename);
		NpcHtmlMessage OpapPanelComment = new NpcHtmlMessage(5);
		
		// That see and players
		OpapPanelComment.setHtml(content);
		OpapPanelComment.replace("%matche_id%", matchId);
		OpapPanelComment.replace("%matche_teams%", matcheTeams);
		OpapPanelComment.replace("%assos%", assos);
		OpapPanelComment.replace("%xiaraki%", xiaraki);
		OpapPanelComment.replace("%diplo%", diplo);
		
		// That see only administrator
		
		activeChar.sendPacket(OpapPanelComment);
	}
	
	public static void showOpapPage(L2PcInstance activeChar, String filename)
	{
		
		String content = HtmCache.getInstance().getHtmForce(activeChar.getHtmlPrefix(), "data/html/opap/" + filename);
		NpcHtmlMessage OpapPanelComment = new NpcHtmlMessage(5);
		
		OpapPanelComment.setHtml(content);
		OpapPanelComment.replace("%matche_id%", 1);
		OpapPanelComment.replace("%matche_teams%", matcheTeams);
		OpapPanelComment.replace("%assos%", assos);
		OpapPanelComment.replace("%xiaraki%", xiaraki);
		OpapPanelComment.replace("%diplo%", diplo);
		
		activeChar.sendPacket(OpapPanelComment);
		
	}
	
	private void addOpapBets(int id, String matcheTeams, double assos, double xiaraki, double diplo)
	{
		OpapGame opap = new OpapGame();
		
		id = opap._matche_id;
		matcheTeams = opap._matche_teams;
		assos = opap._assos;
		xiaraki = opap._xiaraki;
		diplo = opap._diplo;
		
	}
	
	@Override
	public String[] getVoicedCommandList()
	{
		
		return COMMANDS;
	}
	
}

CitarHTML:

<html>
<body scroll="yes">
<center>Welcome Admim/GameMaster to OPAP Games!
<br>
<!-- Skoulix -->
Welcome to bet page:
<br>
<table width=300 border=0 bgcolor="000000">
  <tr>
    <td>ID</td>
    <td>Matche Teams</td>
    <td>1</td>
    <td>X</td>
    <td>2</td>
  </tr>
  <tr>
    <td>%matche_id%</td>
    <td>%matche_teams%</td>
    <td>%assos%</td>
    <td>%xiaraki%</td>
    <td>%diplo%</td>
  </tr>
  <tr>
    <td>%matche_id_2%</td>
    <td>%matche_teams_2%</td>
    <td>%assos_2%</td>
    <td>%xiaraki_2%</td>
    <td>%diplo_2%</td>
 </tr>
<tr>
    <td>%matche_id_3%</td>
    <td>%matche_teams_3%</td>
    <td>%assos_3%</td>
    <td>%xiaraki_3%</td>
    <td>%diplo_3%</td>
 </tr>
 <tr>
    <td>%matche_id_4%</td>
    <td>%matche_teams_4%</td>
    <td>%assos_4%</td>
    <td>%xiaraki_4%</td>
    <td>%diplo_4%</td>
 </tr>
 <tr>
    <td>%matche_id_5%</td>
    <td>%matche_teams_5%</td>
    <td>%assos_5%</td>
    <td>%xiaraki_5%</td>
    <td>%diplo_5%</td>
 </tr>
</table>
<br>
<br>

<table width=300 border=0 bgcolor="000100">
<td></td>
</tr>
<tr>
<td><edit var="matcheId" width=30></td>
<td><edit var="matcheTeams" width=30</td>
<td><edit var="assos" width=30</td>
<td><edit var="xiaraki" width=30</td>
<td><edit var="diplo" width=30</td>



</table>
<button value="Add Bets" action="bypass -h voice admin_opapadd $itemid $itemnum" width=140 height=21 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF">

<!-- End Here -->
</center>
</body>
</html>