Gxz Posted February 20, 2010 Posted February 20, 2010 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
0 xAddytzu Posted February 20, 2010 Posted February 20, 2010 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 Gxz Posted February 20, 2010 Author Posted February 20, 2010 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 xAddytzu Posted February 20, 2010 Posted February 20, 2010 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 down Posted February 20, 2010 Posted February 20, 2010 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 Gxz Posted February 20, 2010 Author Posted February 20, 2010 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 Matim Posted February 21, 2010 Posted February 21, 2010 not working got errors in eclipse Hell yeah, great, but maybe tell us what kind of errors (logs) if you still need help.
0 Gxz Posted February 21, 2010 Author Posted February 21, 2010 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 Horus Posted February 21, 2010 Posted February 21, 2010 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.
0 down Posted February 21, 2010 Posted February 21, 2010 did u add this, too ? import net.sf.l2j.gameserver.model.L2World;
0 Gxz Posted February 21, 2010 Author Posted February 21, 2010 is there any other java code for this?
0 Ghouls Posted February 21, 2010 Posted February 21, 2010 You can make, from configs when they start to server it will starts with money
0 Gxz Posted February 21, 2010 Author Posted February 21, 2010 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 Matim Posted February 21, 2010 Posted February 21, 2010 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.
Question
Gxz
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
24 answers to this question
Recommended Posts