Jump to content

Recommended Posts

Posted

The following codes are just some tools i made years ago on the go to help me deal with time consuming shits faster. Code is not perfect, its crap and stupid but still will help you work faster instead of wasting time doing things by hand.

 

1. Add new zones while in game. Just hit //addzone (ID) and put the first zone_id which is going to be put in ur zone_vertice in DB. Once you u hit the command, all the next calls will continue adding routes for the previous ID. If you wanna go for another ID just call the first command again.

 

public class AdminZone implements IAdminCommandHandler
{
	static int _zoneId = -1;
  private static final String[] ADMIN_COMMANDS =
	{
		.
        .
		"admin_addzone"
	};
    .
    .
    .
    
    @Override
	public boolean useAdminCommand(String command, L2PcInstance activeChar)
	{
      	.
        .
        .
          else if (actualCommand.equalsIgnoreCase("admin_addzone"))
		{
			if (st.hasMoreTokens())
			{
				try
				{
					int zoneId = Integer.parseInt(st.nextToken());
					if (!checkIfZoneExists(zoneId))
					{
						// add new field in db
						addNewZone(zoneId, activeChar.getLoc());
						activeChar.sendMessage("New zoneId added!! new zoneId: " + zoneId + ".");
						activeChar.sendMessage("Added new route point. zoneId: " + zoneId + " X: " + activeChar.getLoc().getX() + " Y: " + activeChar.getLoc().getY());
						_zoneId = zoneId;
					}
					else
					{
						// already exists, find last route and add next with route ++
						addNextRoute(zoneId, activeChar.getLoc());
						_zoneId = zoneId;
						activeChar.sendMessage("Next route added for zoneId: " + zoneId + " X: " + activeChar.getLoc().getX() + " Y: " + activeChar.getLoc().getY());
					}
				}
				catch (Exception e)
				{
					activeChar.sendMessage("Incorrect zoneId specified");
					e.printStackTrace();
				}
			}
			else
			{
				try
				{
					if (_zoneId < 0)
					{
						activeChar.sendMessage("ZoneId is negative.");
						return false;
					}
					// already exists, find last route and add next with route ++
					addNextRoute(_zoneId, activeChar.getLoc());
					activeChar.sendMessage("Next route added for zoneId: " + _zoneId + " X: " + activeChar.getLoc().getX() + " Y: " + activeChar.getLoc().getY());
				}
				catch (Exception e)
				{
					activeChar.sendMessage("Incorrect zoneId specified");
					e.printStackTrace();
				}
			}
		}

 

 

2. Add automatically drops to more than 1 monster. (same droplist). Edit the first sql u can select all the monsters/raids you wanna add the same droplists, fill the drops void method with the drops and THE STRUCTURE that ur droplist table follows. Execute the file and get the output(sql code which u can call from an sql query to apply those changes in ur table.

 

package test;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintStream;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;

import net.sf.l2j.L2DatabaseFactory;
import net.sf.l2j.gameserver.datatables.FakePcsTable;

class AddDropRaids
{
	
	public static void main(String args[])
	{
		ArrayList<Integer> raids = new ArrayList<>();
		String RAIDBOSSES = "SELECT boss_id FROM raidboss_spawnlist WHERE `boss_id` IN (SELECT id from npc where `type`='L2RaidBoss' AND `level`>84 AND `level`<90);";
		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
			PreparedStatement st = con.prepareStatement(RAIDBOSSES);
			ResultSet rs = st.executeQuery();)
		{
			if (rs.next())
			{
				raids.add(rs.getInt("id"));
			}
		}
		catch (Exception e)
		{
			e.printStackTrace();
		}
		
		droplist89(raids);
		
	}
	
	public static void droplist89(ArrayList<Integer> raids)
	{
		for (int raid : raids)
		{
			try
			{
				if (FakePcsTable.getInstance().getFakePc(raid) == null)
				{
					PrintStream myconsole = new PrintStream(new File("E://output.txt"));
					System.setOut(myconsole);
					myconsole.println("INSERT INTO `droplist` VALUES ('" + raid + "', '1000002', '1', '1', '17', '100000', '9', '0');");
					myconsole.println("INSERT INTO `droplist` VALUES ('" + raid + "', '1000075', '1', '1', '18', '5000', '0', '0');");
					myconsole.println("INSERT INTO `droplist` VALUES ('" + raid + "', '1000031', '1', '1', '19', '1000', '0', '0');");
					myconsole.println("INSERT INTO `droplist` VALUES ('" + raid + "', '60081', '1', '1', '20', '5000', '0', '0');");
					myconsole.println("INSERT INTO `droplist` VALUES ('" + raid + "', '1000076', '1', '1', '21', '80000', '0', '0');");
					myconsole.println("INSERT INTO `droplist` VALUES ('" + raid + "', '1000070', '1', '1', '22', '150000', '0', '0');");
					myconsole.println("INSERT INTO `droplist` VALUES ('" + raid + "', '98020', '25', '25', '23', '1000000', '10', '0');");
				}
			}
			catch (FileNotFoundException e)
			{
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			
		}
	}
}

 

 

Im sure i got more of such tools. Gunna share with u more in case i discover them.

  • Thanks 3
  • 3 years later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...