Jump to content
  • 0

[help]Short code


Question

Posted

hey..i want 3 lines code.if sb is aio set [aio] near his name and get full rec

for ex klara ~~~> [AIO]kalara

if(!player.isAio()) {.changeName("[AIO]", targ);]

but this is not right.

9 answers to this question

Recommended Posts

  • 0
Posted

At player restore :

if(player.isAio())
      player.setName("[AIO]" + player.getName());

 

The name is probably stored like that, you shouldn't change name, or do something weird like:

 

if(player.isAio() && !player.getName().contains("[AIO]"))
      player.setName("[AIO]" + player.getName());

 

Added to that, and depending of your pack, you can have issues like problem to invite ppl in your party, friendlist, or PM.

  • 0
Posted

At player restore :

if(player.isAio())
      player.setName("[AIO]" + player.getName());

 

The name is probably stored like that, you shouldn't change name, or do something weird like:

 

if(player.isAio() && !player.getName().contains("[AIO]"))
      player.setName("[AIO]" + player.getName());

 

Added to that, and depending of your pack, you can have issues like problem to invite ppl in your party, friendlist, or PM.

 

where exactly i have to place it? :/

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

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

import com.l2jfrozen.Config;
import com.l2jfrozen.gameserver.datatables.GmListTable;
import com.l2jfrozen.gameserver.handler.IAdminCommandHandler;
import com.l2jfrozen.gameserver.model.L2World;
import com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance;
import com.l2jfrozen.gameserver.network.serverpackets.EtcStatusUpdate;
import com.l2jfrozen.util.CloseUtil;
import com.l2jfrozen.util.database.L2DatabaseFactory;

/**
* Give / Take Status Aio to Player
* Changes name color and title color if enabled
*
* Uses:
* setaio [<player_name>] [<time_duration in days>]
* removeaio [<player_name>]
*
* If <player_name> is not specified, the current target player is used.
*
*
* @author KhayrusS
*
*/
public class AdminAio implements IAdminCommandHandler
{   
private final static Logger _log = Logger.getLogger(AdminAio.class.getName());

private static String[] _adminCommands =
{
	"admin_setaio", "admin_removeaio"
};

private enum CommandEnum
{
	admin_setaio,
	admin_removeaio
}

@Override
public boolean useAdminCommand(String command, L2PcInstance activeChar)
{   
	/*
	if(!AdminCommandAccessRights.getInstance().hasAccess(command, activeChar.getAccessLevel())){
		return false;
	}

	if(Config.GMAUDIT)
	{
		Logger _logAudit = Logger.getLogger("gmaudit");
		LogRecord record = new LogRecord(Level.INFO, command);
		record.setParameters(new Object[]
		                                {
				"GM: " + activeChar.getName(), " to target [" + activeChar.getTarget() + "] "
		                                });
		_logAudit.log(record);
	}
	*/

	StringTokenizer st = new StringTokenizer(command);

	CommandEnum comm = CommandEnum.valueOf(st.nextToken());

	if(comm == null)
		return false;

	switch(comm){
		case admin_setaio:{

			boolean no_token = false;

			if(st.hasMoreTokens()){ //char_name not specified

				String char_name = st.nextToken();

				L2PcInstance player = L2World.getInstance().getPlayer(char_name);
[color=red]if(player.isAio() && !player.getName().contains("[AIO]"))
				      player.setName("[AIO]" + player.getName());[/color]

				if(player != null){

					if (st.hasMoreTokens()) //time
					{
						String time = st.nextToken();

						try{
							int value = Integer.parseInt(time);

							if(value>0){

								doAio(activeChar, player, char_name, time);

								if(player.isAio())
									return true;

							}else{
								activeChar.sendMessage("Time must be bigger then 0!");
								return false;
							}

						}catch(NumberFormatException e){
							activeChar.sendMessage("Time must be a number!");
							return false;
						}

					}else{
						no_token = true;
					}

				}else{
					activeChar.sendMessage("Player must be online to set AIO status");
					no_token = true;
				}

			}else{

				no_token=true;

			}

			if(no_token){
				activeChar.sendMessage("Usage: //setaio <char_name> [time](in days)");
				return false;
			}

		}

		case admin_removeaio:{

			boolean no_token = false;

			if(st.hasMoreTokens()){ //char_name

				String char_name = st.nextToken();

				L2PcInstance player = L2World.getInstance().getPlayer(char_name);
[color=red]if(player.isAio() && !player.getName().contains("[AIO]"))
				      player.setName("[AIO]" + player.getName());[/color]

				if(player!=null){

					removeAio(activeChar, player, char_name);

					if(!player.isAio())
						return true;   

				}else{

					activeChar.sendMessage("Player must be online to remove AIO status");
					no_token = true;
				}

			}else{
				no_token = true;
			}

			if(no_token){
				activeChar.sendMessage("Usage: //removeaio <char_name>");
				return false;
			}


		}
	}

	return true;

}

public void doAio(L2PcInstance activeChar, L2PcInstance _player, String _playername, String _time)
{
	int days = Integer.parseInt(_time);
	if (_player == null)
	{
		activeChar.sendMessage("not found char" + _playername);
		return;
	}

	if(days > 0)
	{
		_player.setAio(true);
		_player.setEndTime("aio", days);
		_player.getStat().addExp(_player.getStat().getExpForLevel(81));

		Connection connection = null;
		try
		{
			connection = L2DatabaseFactory.getInstance().getConnection(false);               

			PreparedStatement statement = connection.prepareStatement("UPDATE characters SET aio=1, aio_end=? WHERE obj_id=?");
			statement.setLong(1, _player.getAioEndTime());
			statement.setInt(2, _player.getObjectId());
			statement.execute();
			statement.close();
			connection.close();

			if(Config.ALLOW_AIO_NCOLOR && activeChar.isAio())
				_player.getAppearance().setNameColor(Config.AIO_NCOLOR);

			if(Config.ALLOW_AIO_TCOLOR && activeChar.isAio())
				_player.getAppearance().setTitleColor(Config.AIO_TCOLOR);

			_player.rewardAioSkills();
			_player.broadcastUserInfo();
			_player.sendPacket(new EtcStatusUpdate(_player));
			_player.sendSkillList();
			GmListTable.broadcastMessageToGMs("GM "+ activeChar.getName()+ " set Aio stat for player "+ _playername + " for " + _time + " day(s)");
			_player.sendMessage("You are now an Aio, Congratulations!");
			_player.broadcastUserInfo();
		}
		catch (Exception e)
		{
			if(Config.DEBUG)
				e.printStackTrace();

			_log.log(Level.WARNING,"could not set Aio stats to char:", e);
		}
		finally
		{
			CloseUtil.close(connection);
		}
	}
	else
	{
		removeAio(activeChar, _player, _playername);
	}
}

public void removeAio(L2PcInstance activeChar, L2PcInstance _player, String _playername)
{
	_player.setAio(false);
	_player.setAioEndTime(0);

	Connection connection = null;
	try
	{
		connection = L2DatabaseFactory.getInstance().getConnection(false);               

		PreparedStatement statement = connection.prepareStatement("UPDATE characters SET Aio=0, Aio_end=0 WHERE obj_id=?");
		statement.setInt(1, _player.getObjectId());
		statement.execute();
		statement.close();
		connection.close();

		_player.lostAioSkills();
		_player.getAppearance().setNameColor(0xFFFFFF);
		_player.getAppearance().setTitleColor(0xFFFFFF);
		_player.broadcastUserInfo();
		_player.sendPacket(new EtcStatusUpdate(_player));
		_player.sendSkillList();
		GmListTable.broadcastMessageToGMs("GM "+activeChar.getName()+" remove Aio stat of player "+ _playername);
		_player.sendMessage("Now You are not an Aio..");
		_player.broadcastUserInfo();
	}
	catch (Exception e)
	{
		if(Config.DEBUG)
			e.printStackTrace();

		_log.log(Level.WARNING,"could not remove Aio stats of char:", e);
	}
	finally
	{
		CloseUtil.close(connection);
	}
}

@Override
public String[] getAdminCommandList()
{
	return _adminCommands;
}
}

EDIT:i test it..i have no errors eclipse,console but it dont work ingame. read the code above to see where i place it

  • 0
Posted

In your pcinstance.

 

in method,setAio(or whatever you named it).

loolol the code is alrady applied!!!

L2PcInstance player = L2World.getInstance().getPlayer(char_name);
				if(player.isAio() && !player.getName().contains("[AIO]"))
				      player.setName("[AIO]" + player.getName());
				if(player != null){

but why id doesnt work??? this is the config

# -----------------------------------------
#  Aio System                             -
# -----------------------------------------
# Enable / Disable Aion System
EnableAioSystem = True
# Enable / Disable Name Color
AllowAioNameColor = True
AioNameColor = FFFF00
# Enable / Disable Title Color
AllowAioTitleColor = True
AioTitleColor = 88AA88
# List of Aio Skills
# Format : skillid,skilllvl;skillid2,skilllvl2;....skillidn,skilllvln
AioSkills = 1085,3;1304,3;1087,3;1354,1;1062,2;1005,3;1243,6;1045,6;1048,6;\
1311,6;168,3;213,8;1007,3;1309,3;1552,3;1006,3;1229,15;1308,3;1253,3;1284,3;\
1009,3;1310,4;1363,1;1362,1;1397,3;1292,6;1078,6;307,1;276,1;309,1;274,1;275,1;\
272,1;277,1;273,1;311,1;366,1;365,1;310,1;271,1;1242,3;1257,3;1353,3;1391,3;\
1352,1;229,7;228,3;1077,3;1218,33;1059,3;1219,33;1217,33;1388,3;1389,3;1240,3;\
1086,2;1032,3;1073,2;1036,2;1035,4;1068,3;1003,3;1282,2;1356,1;1355,1;1357,33;\
1044,3;1182,3;1191,3;1033,3;1189,3;1259,4;1306,6;234,23;1040,3;364,1;264,1;306,1;\
269,1;270,1;265,1;363,1;349,1;308,1;305,1;304,1;267,1;266,1;268,1;1390,3;1303,2;\
1204,2;1268,4;1413,1;4699,8;4700,8;4703,8
# Aio Buffers can use GK?
AllowAioUseGk = false
# Aio Buffers can speak to Class Master?
AllowAioUseClassMaster = false

  • 0
Posted

This mean i m bored to search lets create ? xd

hmmm let me see....YES IT IS!i will type aio buff player will have full rec name and [AIO] in front of his name and i will find at least 5000kkk pages related to this..dont think so.... ;D

  • 0
Posted

loolol the code is alrady applied!!!

L2PcInstance player = L2World.getInstance().getPlayer(char_name);
				if(player.isAio() && !player.getName().contains("[AIO]"))
				      player.setName("[AIO]" + player.getName());
				if(player != null){

but why id doesnt work??? this is the config

# -----------------------------------------
#  Aio System                             -
# -----------------------------------------
# Enable / Disable Aion System
EnableAioSystem = True
# Enable / Disable Name Color
AllowAioNameColor = True
AioNameColor = FFFF00
# Enable / Disable Title Color
AllowAioTitleColor = True
AioTitleColor = 88AA88
# List of Aio Skills
# Format : skillid,skilllvl;skillid2,skilllvl2;....skillidn,skilllvln
AioSkills = 1085,3;1304,3;1087,3;1354,1;1062,2;1005,3;1243,6;1045,6;1048,6;\
1311,6;168,3;213,8;1007,3;1309,3;1552,3;1006,3;1229,15;1308,3;1253,3;1284,3;\
1009,3;1310,4;1363,1;1362,1;1397,3;1292,6;1078,6;307,1;276,1;309,1;274,1;275,1;\
272,1;277,1;273,1;311,1;366,1;365,1;310,1;271,1;1242,3;1257,3;1353,3;1391,3;\
1352,1;229,7;228,3;1077,3;1218,33;1059,3;1219,33;1217,33;1388,3;1389,3;1240,3;\
1086,2;1032,3;1073,2;1036,2;1035,4;1068,3;1003,3;1282,2;1356,1;1355,1;1357,33;\
1044,3;1182,3;1191,3;1033,3;1189,3;1259,4;1306,6;234,23;1040,3;364,1;264,1;306,1;\
269,1;270,1;265,1;363,1;349,1;308,1;305,1;304,1;267,1;266,1;268,1;1390,3;1303,2;\
1204,2;1268,4;1413,1;4699,8;4700,8;4703,8
# Aio Buffers can use GK?
AllowAioUseGk = false
# Aio Buffers can speak to Class Master?
AllowAioUseClassMaster = false

fs..

 

in the method which is responsible for setting a player to aio.

 

model/actor/instance/l2pcinstance.

Guest
This topic is now closed to further replies.


×
×
  • Create New...

AdBlock Extension Detected!

Our website is made possible by displaying online advertisements to our members.

Please disable AdBlock browser extension first, to be able to use our community.

I've Disabled AdBlock