Jump to content
  • 0

Give items to all players


Question

Posted

Hello guys so i need a admincommandhandler that will actually give items to all players in the server for example

//giveallplayers 57 1000

 

to give to all players 1000 adena or smt like this "YES I SEARCHED IN FORUM AND I DIDNT FOUND ANYTHING LIKE THIS"

reply only if you know pls

Recommended Posts

  • 0
Posted

let see...

 

else if (command.equals("blabla"))

{

for (L2PcInstance _players : L2World.getInstance().getAllPlayers())

{

 

if (_players == activeChar)

continue;

_players.addItem(String, int, int, L2Object, boolean);

activeChar.sendMessage("blabla");

}

}

 

maybe it work ..

  • 0
Posted

let see...

 

else if (command.equals("blabla"))

{

for (L2PcInstance _players : L2World.getInstance().getAllPlayers())

{

 

if (_players == activeChar)

continue;

_players.addItem(String, int, int, L2Object, boolean);

activeChar.sendMessage("blabla");

}

}

 

maybe it work ..

i am searching for something like //givetoall 57 1000

to be able to specify what i want to give and to be a command not smf like this xD

  • 0
Posted

Above code was just an exemple...

 

/*
* 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.handler.admincommandhandlers;

import java.util.StringTokenizer;

import net.sf.l2j.Config;
import net.sf.l2j.gameserver.datatables.ItemTable;
import net.sf.l2j.gameserver.handler.IAdminCommandHandler;
import net.sf.l2j.gameserver.model.L2World;
import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
import net.sf.l2j.gameserver.serverpackets.ItemList;
import net.sf.l2j.gameserver.templates.L2Item;

/**
* blabla@xAdd
*/
public class AdminGiveToAll implements IAdminCommandHandler
{
private static final String[] ADMIN_COMMANDS =
{
	"admin_givetoall"
};
private static final int REQUIRED_LEVEL = Config.GM_CREATE_ITEM;

public boolean useAdminCommand(String command, L2PcInstance activeChar)
{
	if (!Config.ALT_PRIVILEGES_ADMIN)
	{
		if (!(checkLevel(activeChar.getAccessLevel()) && activeChar.isGM()))
			return false;
	}
	if (command.startsWith("admin_givetoall"))
	{
		try
		{
			String val = command.substring(17);
			StringTokenizer st = new StringTokenizer(val);
			if (st.countTokens() == 2)
			{
				String id = st.nextToken();
				int idval = Integer.parseInt(id);
				String num = st.nextToken();
				int numval = Integer.parseInt(num);
				createItem(activeChar,idval,numval);
			}
			else if (st.countTokens() == 1)
			{
				String id = st.nextToken();
				int idval = Integer.parseInt(id);
				createItem(activeChar,idval,1);
			}
		}
		catch (StringIndexOutOfBoundsException e)
		{
			activeChar.sendMessage("Usage: //givetoall <itemId> <amount>");
		}
		catch (NumberFormatException nfe)
		{
			activeChar.sendMessage("Specify a valid number.");
		}
	}
	return true;
}

private void createItem(L2PcInstance activeChar, int id, int num)
{
	if (num > 20)
	{
		L2Item template = ItemTable.getInstance().getTemplate(id);
		if (!template.isStackable())
		{
			activeChar.sendMessage("This item does not stack");
			return;
		}
	}
	for (L2PcInstance _players : L2World.getInstance().getAllPlayers())
	{
		if (_players == activeChar)
			continue;
		_players.getInventory().addItem("xad", id, num, _players, null);
		activeChar.sendMessage("blabla");
	}
	ItemList il = new ItemList(activeChar, true);
	activeChar.sendPacket(il);
}
public String[] getAdminCommandList()
{
	return ADMIN_COMMANDS;
}

private boolean checkLevel(int level)
{
	return (level >= REQUIRED_LEVEL);
}
}

 

Test it..

  • 0
Posted

Add this in adminCreateItem.java

 

import net.sf.l2j.gameserver.model.L2World;

	"admin_create_item",
+		"admin_mass_create"

else if (command.startsWith("admin_mass_create"))
	{
		try
		{
			String val = command.substring(17);
			StringTokenizer st = new StringTokenizer(val);
			if (st.countTokens()== 2)
			{
				String id = st.nextToken();
				int idval = Integer.parseInt(id);
				String num = st.nextToken();
				int numval = Integer.parseInt(num);
				massCreate(activeChar,idval,numval);
			}
			else if (st.countTokens()== 1)
			{
				String id = st.nextToken();
				int idval = Integer.parseInt(id);
				massCreate(activeChar,idval,1);
			}
		}
		catch (StringIndexOutOfBoundsException e)
		{
			activeChar.sendMessage("Usage: //itemcreate <itemId> [amount]");
		}
		catch (NumberFormatException nfe)
		{
			activeChar.sendMessage("Specify a valid number.");
		}
	}

private void massCreate(L2PcInstance activeChar, int id, int num)
{
	 for (L2PcInstance _players : L2World.getInstance().getAllPlayers())
	 {
		 if (_players == activeChar) continue;
		 _players.getInventory().addItem("Admin", id, num, _players, null);

		 ItemList il = new ItemList(_players, true);
		 _players.sendPacket(il);
	 }

	activeChar.sendMessage("You have spawned " + num + " item(s) number " + id + " in all chars inventory.");
}

  • 0
Posted

Above code was just an exemple...

 

/*
* 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.handler.admincommandhandlers;

import java.util.StringTokenizer;

import net.sf.l2j.Config;
import net.sf.l2j.gameserver.datatables.ItemTable;
import net.sf.l2j.gameserver.handler.IAdminCommandHandler;
import net.sf.l2j.gameserver.model.L2World;
import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
import net.sf.l2j.gameserver.serverpackets.ItemList;
import net.sf.l2j.gameserver.templates.L2Item;

/**
* blabla@xAdd
*/
public class AdminGiveToAll implements IAdminCommandHandler
{
private static final String[] ADMIN_COMMANDS =
{
	"admin_givetoall"
};
private static final int REQUIRED_LEVEL = Config.GM_CREATE_ITEM;

public boolean useAdminCommand(String command, L2PcInstance activeChar)
{
	if (!Config.ALT_PRIVILEGES_ADMIN)
	{
		if (!(checkLevel(activeChar.getAccessLevel()) && activeChar.isGM()))
			return false;
	}
	if (command.startsWith("admin_givetoall"))
	{
		try
		{
			String val = command.substring(17);
			StringTokenizer st = new StringTokenizer(val);
			if (st.countTokens() == 2)
			{
				String id = st.nextToken();
				int idval = Integer.parseInt(id);
				String num = st.nextToken();
				int numval = Integer.parseInt(num);
				createItem(activeChar,idval,numval);
			}
			else if (st.countTokens() == 1)
			{
				String id = st.nextToken();
				int idval = Integer.parseInt(id);
				createItem(activeChar,idval,1);
			}
		}
		catch (StringIndexOutOfBoundsException e)
		{
			activeChar.sendMessage("Usage: //givetoall <itemId> <amount>");
		}
		catch (NumberFormatException nfe)
		{
			activeChar.sendMessage("Specify a valid number.");
		}
	}
	return true;
}

private void createItem(L2PcInstance activeChar, int id, int num)
{
	if (num > 20)
	{
		L2Item template = ItemTable.getInstance().getTemplate(id);
		if (!template.isStackable())
		{
			activeChar.sendMessage("This item does not stack");
			return;
		}
	}
	for (L2PcInstance _players : L2World.getInstance().getAllPlayers())
	{
		if (_players == activeChar)
			continue;
		_players.getInventory().addItem("xad", id, num, _players, null);
		activeChar.sendMessage("blabla");
	}
	ItemList il = new ItemList(activeChar, true);
	activeChar.sendPacket(il);
}
public String[] getAdminCommandList()
{
	return ADMIN_COMMANDS;
}

private boolean checkLevel(int level)
{
	return (level >= REQUIRED_LEVEL);
}
}

 

Test it..

not working

 

Add this in adminCreateItem.java

 

import net.sf.l2j.gameserver.model.L2World;

	"admin_create_item",
+		"admin_mass_create"

else if (command.startsWith("admin_mass_create"))
	{
		try
		{
			String val = command.substring(17);
			StringTokenizer st = new StringTokenizer(val);
			if (st.countTokens()== 2)
			{
				String id = st.nextToken();
				int idval = Integer.parseInt(id);
				String num = st.nextToken();
				int numval = Integer.parseInt(num);
				massCreate(activeChar,idval,numval);
			}
			else if (st.countTokens()== 1)
			{
				String id = st.nextToken();
				int idval = Integer.parseInt(id);
				massCreate(activeChar,idval,1);
			}
		}
		catch (StringIndexOutOfBoundsException e)
		{
			activeChar.sendMessage("Usage: //itemcreate <itemId> [amount]");
		}
		catch (NumberFormatException nfe)
		{
			activeChar.sendMessage("Specify a valid number.");
		}
	}

private void massCreate(L2PcInstance activeChar, int id, int num)
{
	 for (L2PcInstance _players : L2World.getInstance().getAllPlayers())
	 {
		 if (_players == activeChar) continue;
		 _players.getInventory().addItem("Admin", id, num, _players, null);

		 ItemList il = new ItemList(_players, true);
		 _players.sendPacket(il);
	 }

	activeChar.sendMessage("You have spawned " + num + " item(s) number " + id + " in all chars inventory.");
}

got errors in eclipse

  • 0
Posted

not working

got errors in eclipse

 

Hell yeah, great, but maybe tell us what kind of errors (logs) if you still need help.

  • 0
Posted

Hell yeah, great, but maybe tell us what kind of errors (logs) if you still need help.

Add this in adminCreateItem.java

 

import net.sf.l2j.gameserver.model.L2World;

	"admin_create_item",
+		"admin_mass_create"

else if (command.startsWith("admin_mass_create"))
	{
		try
		{
			String val = command.substring(17);
			StringTokenizer st = new StringTokenizer(val);
			if (st.countTokens()== 2)
			{
				String id = st.nextToken();
				int idval = Integer.parseInt(id);
				String num = st.nextToken();
				int numval = Integer.parseInt(num);
				massCreate(activeChar,idval,numval);
			}
			else if (st.countTokens()== 1)
			{
				String id = st.nextToken();
				int idval = Integer.parseInt(id);
				massCreate(activeChar,idval,1);
			}
		}
		catch (StringIndexOutOfBoundsException e)
		{
			activeChar.sendMessage("Usage: //itemcreate <itemId> [amount]");
		}
		catch (NumberFormatException nfe)
		{
			activeChar.sendMessage("Specify a valid number.");
		}
	}

private void massCreate(L2PcInstance activeChar, int id, int num)
{
	 for (L2PcInstance _players : L2World.getInstance().getAllPlayers())
	 {
		 if (_players == activeChar) continue;
		 _players.getInventory().addItem("Admin", id, num, _players, null);

		 ItemList il = new ItemList(_players, true);
		 _players.sendPacket(il);
	 }

	activeChar.sendMessage("You have spawned " + num + " item(s) number " + id + " in all chars inventory.");
}

massCreate(activeChar,idval,1);

massCreate(activeChar,idval,numval);

 

at masscreate

  • 0
Posted

You can make, from configs when they start to server it will starts with money

lol i am not asking for this, i want for example make an event and after event finish reward the players and give to all players that are currently online a price for example

//giveallplayer 57 200000000

to give to everyone that is online 200kk adena

  • 0
Posted

Gx provide a proper error (Details,copy it from the GS) or we'll just stop helping.

Have some consideration for us and so will we.

Guest
This topic is now closed to further replies.


  • Posts

    • [SIZE=4][B]🇨🇦 NEWCANADA40 — 40% OFF VPS in Canada (Toronto)[/B][/SIZE] We are excited to announce the launch of our new location — Toronto, Canada. [B]Promo code:[/B] NEWCANADA40 [B]Discount:[/B] 40% on VPS orders [B]Valid until:[/B] June 7 ✔ New Canadian location ✔ Excellent North American connectivity ✔ Fast server deployment ✔ Suitable for any project [B]How to activate:[/B] — Visit our website — Select Canada (Toronto) as your location — Enter the promo code during checkout 👉 [url=https://bit.hosting]https://bit.hosting[/url] [I]The offer is valid for new Toronto VPS orders until June 7, 2026.</I>
    • Thanks for the collection and the free advertising! These files have been in the public domain for a long time — you just saved people the trouble of searching. A true fan. 😄 Just to clarify for everyone reading: these files have nothing to do with this topic. They are 10+ year old builds, and since various third-party modifications exist in the wild, we cannot guarantee what may have been added or changed in those versions. Use them at your own risk. We have absolutely no judgment toward those who are on a tight budget and can't afford our current builds — these old shared files might genuinely help you get started. Just use them carefully and at your own risk. And please don't judge developers for the mistakes they made early in their careers — every developer goes through stages of growth, and what you see in those old builds is simply a snapshot of where we were back then. We've come a long way since. If you're interested in our older builds, we have a dedicated thread for that with significantly reduced prices — very accessible for any budget. We have also recently resumed full technical support for legacy builds, handled by a separate team that doesn't interfere with our private development direction for larger projects. You can find our legacy builds here: Our OLd L2-scripts Packs Actual revisions Our current private sources are a completely different story — which is exactly what this thread is about. Too bad all your time goes into collecting other people's old code instead of developing your own project. Though judging by "L2MID is currently offline, we will come back soon in 2026" — you clearly have plenty of time on your hands. 😉
    • SHARED alreaxy! Are these files yours? https://fex.net/ru/s/kdop2z4
    • You asked for examples of coping projects, we provided them, you asked for feedback from our clients, some of them wrote their reviews on the same mmodev, what else can I prove to you? you just asked your friends from mmodev to write nasty things, they have never been our customers and never will be, because they are used to downloading only free products and hacking it. You just don't respect the work of others, this is the conclusion that can be drawn from your inflammatory topic on mmodev, where there are many people who once could not buy our assemblies or whom we kicked out of work or for some other reason. But you are completely wrong and you are behaving very lowly. But let it be on your conscience. Good luck, keep busy with your project, and don't interfere with others.
  • Topics

×
×
  • Create New...

Important Information

This community uses essential cookies to function properly. Non-essential cookies and third-party services are used only with your consent. Read our Privacy Policy and We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue..