Jump to content

[Share] Lock players, disable them from exchanging items (all ways included).


Recommended Posts

Posted

Hello guys, this is another small share of mine, some of you might find it pretty handy. Well the truth is i coded this one long ago and i don't need it any longer. So while i was removing that from my source, i thought why not to share it with you?

 

What is this actually doing? You can lock a character and he won't be able to trade his items, all the ways are blocked, he can't even get pk and even if he does he won't drop any item. To sum up, he can't drop / request - answer a trade / get karma / set a private store / deposit items at wh (including freight). The character is being saved at the db as locked, so at each login or server restart you won't have to do it again.

 

You can set a player as locked by targeting the player and typing //lock and unlock him by typing //unlock (so obvious xd)

 

CORE PART:

Index: I:/workspace/L2_GameServer/java/com/l2jserver/gameserver/network/clientpackets/TradeRequest.java
===================================================================
--- I:/workspace/L2_GameServer/java/com/l2jserver/gameserver/network/clientpackets/TradeRequest.java	(revision 4250)
+++ I:/workspace/L2_GameServer/java/com/l2jserver/gameserver/network/clientpackets/TradeRequest.java	(working copy)
@@ -53,9 +53,9 @@
		if (player == null)
			return;

-		if (!player.getAccessLevel().allowTransaction())
+		if (!player.getAccessLevel().allowTransaction() || player.isLocked())
		{
-			player.sendMessage("Transactions are disable for your Access Level");
+			player.sendMessage("Your character is locked. Transactions are disabled.");
			sendPacket(ActionFailed.STATIC_PACKET);
			return;
		}
Index: I:/workspace/L2_GameServer/java/com/l2jserver/gameserver/network/clientpackets/AddTradeItem.java
===================================================================
--- I:/workspace/L2_GameServer/java/com/l2jserver/gameserver/network/clientpackets/AddTradeItem.java	(revision 4250)
+++ I:/workspace/L2_GameServer/java/com/l2jserver/gameserver/network/clientpackets/AddTradeItem.java	(working copy)
@@ -82,9 +82,9 @@
			return;
		}

-		if (!player.getAccessLevel().allowTransaction())
+		if (!player.getAccessLevel().allowTransaction() || player.isLocked())
		{
-			player.sendMessage("Transactions are disable for your Access Level");
+			player.sendPacket(new SystemMessage(SystemMessageId.YOU_ARE_NOT_AUTHORIZED_TO_DO_THAT));
			player.cancelActiveTrade();
			return;
		}
Index: I:/workspace/L2_GameServer/java/com/l2jserver/gameserver/network/clientpackets/SetPrivateStoreListBuy.java
===================================================================
--- I:/workspace/L2_GameServer/java/com/l2jserver/gameserver/network/clientpackets/SetPrivateStoreListBuy.java	(revision 4250)
+++ I:/workspace/L2_GameServer/java/com/l2jserver/gameserver/network/clientpackets/SetPrivateStoreListBuy.java	(working copy)
@@ -89,9 +89,9 @@
			return;
		}

-		if (!player.getAccessLevel().allowTransaction())
+		if (!player.getAccessLevel().allowTransaction() || player.isLocked())
		{
-			player.sendPacket(new SystemMessage(SystemMessageId.YOU_ARE_NOT_AUTHORIZED_TO_DO_THAT));
+			player.sendMessage("Your character is locked. Transactions are disabled.");
			return;
		}

Index: I:/workspace/L2_GameServer/java/com/l2jserver/gameserver/network/clientpackets/RequestPrivateStoreSell.java
===================================================================
--- I:/workspace/L2_GameServer/java/com/l2jserver/gameserver/network/clientpackets/RequestPrivateStoreSell.java	(revision 4250)
+++ I:/workspace/L2_GameServer/java/com/l2jserver/gameserver/network/clientpackets/RequestPrivateStoreSell.java	(working copy)
@@ -110,9 +110,9 @@
		if (storeList == null)
			return;

-		if (!player.getAccessLevel().allowTransaction())
+		if (!player.getAccessLevel().allowTransaction() || player.isLocked())
		{
-			player.sendMessage("Transactions are disable for your Access Level");
+			player.sendMessage("Your character is locked. Transactions are disabled.");
			sendPacket(ActionFailed.STATIC_PACKET);
			return;
		}
Index: I:/workspace/L2_GameServer/java/com/l2jserver/gameserver/network/clientpackets/RequestDropItem.java
===================================================================
--- I:/workspace/L2_GameServer/java/com/l2jserver/gameserver/network/clientpackets/RequestDropItem.java	(revision 4250)
+++ I:/workspace/L2_GameServer/java/com/l2jserver/gameserver/network/clientpackets/RequestDropItem.java	(working copy)
@@ -112,9 +112,9 @@
			return;			
		}

-		if (!activeChar.getAccessLevel().allowTransaction())
+		if (!activeChar.getAccessLevel().allowTransaction() || activeChar.isLocked())
		{
-			activeChar.sendMessage("Transactions are disable for your Access Level");
+            activeChar.sendMessage("Your character is locked. Transactions are disabled.");
			activeChar.sendPacket(new SystemMessage(SystemMessageId.NOTHING_HAPPENED));
			return;
		}
Index: I:/workspace/L2_GameServer/java/com/l2jserver/gameserver/network/clientpackets/RequestGiveItemToPet.java
===================================================================
--- I:/workspace/L2_GameServer/java/com/l2jserver/gameserver/network/clientpackets/RequestGiveItemToPet.java	(revision 4250)
+++ I:/workspace/L2_GameServer/java/com/l2jserver/gameserver/network/clientpackets/RequestGiveItemToPet.java	(working copy)
@@ -58,6 +58,12 @@
			player.sendMessage("You give items to pet too fast.");
			return;
		}
+		
+		if (player.isLocked())
+		{
+			player.sendMessage("Your character is locked. Transactions are disabled.");
+			return;
+		}

		if (player.getActiveEnchantItem() != null)
        	return;
Index: I:/workspace/L2_GameServer/java/com/l2jserver/gameserver/network/clientpackets/TradeDone.java
===================================================================
--- I:/workspace/L2_GameServer/java/com/l2jserver/gameserver/network/clientpackets/TradeDone.java	(revision 4250)
+++ I:/workspace/L2_GameServer/java/com/l2jserver/gameserver/network/clientpackets/TradeDone.java	(working copy)
@@ -77,10 +77,10 @@
			if (trade.getOwner().getActiveEnchantItem() != null || trade.getPartner().getActiveEnchantItem() != null)
				return;

-			if (!player.getAccessLevel().allowTransaction())
+			if (!player.getAccessLevel().allowTransaction() || player.isLocked())
			{
				player.cancelActiveTrade();
-				player.sendPacket(new SystemMessage(SystemMessageId.YOU_ARE_NOT_AUTHORIZED_TO_DO_THAT));
+				player.sendMessage("Your character is locked. Transactions are disabled.");
				return;
			}

Index: I:/workspace/L2_GameServer/java/com/l2jserver/gameserver/network/clientpackets/SendWareHouseDepositList.java
===================================================================
--- I:/workspace/L2_GameServer/java/com/l2jserver/gameserver/network/clientpackets/SendWareHouseDepositList.java	(revision 4250)
+++ I:/workspace/L2_GameServer/java/com/l2jserver/gameserver/network/clientpackets/SendWareHouseDepositList.java	(working copy)
@@ -100,9 +100,9 @@
				|| !manager.canInteract(player)) && !player.isGM())
			return;

-		if (!isPrivate && !player.getAccessLevel().allowTransaction())
+		if (!isPrivate && !player.getAccessLevel().allowTransaction() || player.isLocked())
		{
-			player.sendMessage("Transactions are disable for your Access Level");
+			player.sendMessage("Your character is locked. Transactions are disabled.");
			return;
		}

Index: I:/workspace/L2_GameServer/java/com/l2jserver/gameserver/network/clientpackets/AnswerTradeRequest.java
===================================================================
--- I:/workspace/L2_GameServer/java/com/l2jserver/gameserver/network/clientpackets/AnswerTradeRequest.java	(revision 4250)
+++ I:/workspace/L2_GameServer/java/com/l2jserver/gameserver/network/clientpackets/AnswerTradeRequest.java	(working copy)
@@ -46,7 +46,7 @@
		if (player == null)
			return;

-		if (!player.getAccessLevel().allowTransaction())
+		if (!player.getAccessLevel().allowTransaction() || player.isLocked())
		{
			player.sendPacket(new SystemMessage(SystemMessageId.YOU_ARE_NOT_AUTHORIZED_TO_DO_THAT));
			sendPacket(ActionFailed.STATIC_PACKET);
Index: I:/workspace/L2_GameServer/java/com/l2jserver/gameserver/network/clientpackets/SetPrivateStoreListSell.java
===================================================================
--- I:/workspace/L2_GameServer/java/com/l2jserver/gameserver/network/clientpackets/SetPrivateStoreListSell.java	(revision 4250)
+++ I:/workspace/L2_GameServer/java/com/l2jserver/gameserver/network/clientpackets/SetPrivateStoreListSell.java	(working copy)
@@ -84,9 +84,9 @@
			return;
		}

-		if (!player.getAccessLevel().allowTransaction())
+		if (!player.getAccessLevel().allowTransaction() || player.isLocked())
		{
-			player.sendPacket(new SystemMessage(SystemMessageId.YOU_ARE_NOT_AUTHORIZED_TO_DO_THAT));
+			player.sendMessage("Your character is locked. Transactions are disabled.");
			return;
		}

Index: I:/workspace/L2_GameServer/java/com/l2jserver/gameserver/network/clientpackets/AttackRequest.java
===================================================================
--- I:/workspace/L2_GameServer/java/com/l2jserver/gameserver/network/clientpackets/AttackRequest.java	(revision 4250)
+++ I:/workspace/L2_GameServer/java/com/l2jserver/gameserver/network/clientpackets/AttackRequest.java	(working copy)
@@ -17,6 +17,7 @@
import com.l2jserver.gameserver.model.L2Object;
import com.l2jserver.gameserver.model.L2World;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
+import com.l2jserver.gameserver.model.actor.instance.L2SummonInstance;
import com.l2jserver.gameserver.network.serverpackets.ActionFailed;

/**
@@ -63,6 +64,25 @@
		if (target == null)
			return;

+		if (target instanceof L2PcInstance)
+		{
+			if (((L2PcInstance)target).getPvpFlag() == 0 && activeChar.isLocked())
+			{
+				activeChar.sendMessage("Your character is locked, you cannot attack a non flagged player.");
+				sendPacket(ActionFailed.STATIC_PACKET);
+				return;
+			}
+		}
+		else if (target instanceof L2SummonInstance)
+		{
+			if (((L2SummonInstance)target).getPvpFlag() == 0 && activeChar.isLocked())
+			{
+				activeChar.sendMessage("Your character is locked, you cannot attack a non flagged summon.");
+				sendPacket(ActionFailed.STATIC_PACKET);
+				return;
+			}
+		}
+		
		// Players can't attack objects in the other instances
		// except from multiverse
		if (target.getInstanceId() != activeChar.getInstanceId()
Index: I:/workspace/L2_GameServer/java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java
===================================================================
--- I:/workspace/L2_GameServer/java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java	(revision 4250)
+++ I:/workspace/L2_GameServer/java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java	(working copy)
@@ -274,8 +274,8 @@

	// Character Character SQL String Definitions:
    private static final String INSERT_CHARACTER = "INSERT INTO characters (account_name,charId,char_name,level,maxHp,curHp,maxCp,curCp,maxMp,curMp,face,hairStyle,hairColor,sex,exp,sp,karma,fame,pvpkills,pkkills,clanid,race,classid,deletetime,cancraft,title,title_color,accesslevel,online,isin7sdungeon,clan_privs,wantspeace,base_class,newbie,nobless,power_grade,last_recom_date,createTime) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
-	private static final String UPDATE_CHARACTER = "UPDATE characters SET level=?,maxHp=?,curHp=?,maxCp=?,curCp=?,maxMp=?,curMp=?,face=?,hairStyle=?,hairColor=?,sex=?,heading=?,x=?,y=?,z=?,exp=?,expBeforeDeath=?,sp=?,karma=?,fame=?,pvpkills=?,pkkills=?,rec_have=?,rec_left=?,clanid=?,race=?,classid=?,deletetime=?,title=?,title_color=?,accesslevel=?,online=?,isin7sdungeon=?,clan_privs=?,wantspeace=?,base_class=?,onlinetime=?,punish_level=?,punish_timer=?,newbie=?,nobless=?,power_grade=?,subpledge=?,last_recom_date=?,lvl_joined_academy=?,apprentice=?,sponsor=?,varka_ketra_ally=?,clan_join_expiry_time=?,clan_create_expiry_time=?,char_name=?,death_penalty_level=?,bookmarkslot=?,vitality_points=?,language=? WHERE charId=?";
-    private static final String RESTORE_CHARACTER = "SELECT account_name, charId, char_name, level, maxHp, curHp, maxCp, curCp, maxMp, curMp, face, hairStyle, hairColor, sex, heading, x, y, z, exp, expBeforeDeath, sp, karma, fame, pvpkills, pkkills, clanid, race, classid, deletetime, cancraft, title, title_color, rec_have, rec_left, accesslevel, online, char_slot, lastAccess, clan_privs, wantspeace, base_class, onlinetime, isin7sdungeon, punish_level, punish_timer, newbie, nobless, power_grade, subpledge, last_recom_date, lvl_joined_academy, apprentice, sponsor, varka_ketra_ally,clan_join_expiry_time,clan_create_expiry_time,death_penalty_level,bookmarkslot,vitality_points,createTime,language FROM characters WHERE charId=?";
+	private static final String UPDATE_CHARACTER = "UPDATE characters SET level=?,maxHp=?,curHp=?,maxCp=?,curCp=?,maxMp=?,curMp=?,face=?,hairStyle=?,hairColor=?,sex=?,heading=?,x=?,y=?,z=?,exp=?,expBeforeDeath=?,sp=?,karma=?,fame=?,pvpkills=?,pkkills=?,rec_have=?,rec_left=?,clanid=?,race=?,classid=?,deletetime=?,title=?,title_color=?,accesslevel=?,online=?,isin7sdungeon=?,clan_privs=?,wantspeace=?,base_class=?,onlinetime=?,punish_level=?,punish_timer=?,newbie=?,nobless=?,power_grade=?,subpledge=?,last_recom_date=?,lvl_joined_academy=?,apprentice=?,sponsor=?,varka_ketra_ally=?,clan_join_expiry_time=?,clan_create_expiry_time=?,char_name=?,death_penalty_level=?,bookmarkslot=?,vitality_points=?,language=?,locked=? WHERE charId=?";
+    private static final String RESTORE_CHARACTER = "SELECT account_name, charId, char_name, level, maxHp, curHp, maxCp, curCp, maxMp, curMp, face, hairStyle, hairColor, sex, heading, x, y, z, exp, expBeforeDeath, sp, karma, fame, pvpkills, pkkills, clanid, race, classid, deletetime, cancraft, title, title_color, rec_have, rec_left, accesslevel, online, char_slot, lastAccess, clan_privs, wantspeace, base_class, onlinetime, isin7sdungeon, punish_level, punish_timer, newbie, nobless, power_grade, subpledge, last_recom_date, lvl_joined_academy, apprentice, sponsor, varka_ketra_ally,clan_join_expiry_time,clan_create_expiry_time,death_penalty_level,bookmarkslot,vitality_points,createTime,language,locked FROM characters WHERE charId=?";

    // Character Teleport Bookmark:
    private static final String INSERT_TP_BOOKMARK = "INSERT INTO character_tpbookmark (charId,Id,x,y,z,icon,tag,name) values (?,?,?,?,?,?,?,?)";
@@ -391,6 +391,8 @@
	protected int _activeClass;
	protected int _classIndex = 0;

+	private int _locked;
+	
	/** data for mounted pets */
	private int _controlItemId;
	private L2PetData _data;
@@ -5629,7 +5631,7 @@
			int dropLimit           = 0;
			int dropPercent         = 0;

-			if (getKarma() > 0 && getPkKills() >= pkLimit)
+			if (getKarma() > 0 && getPkKills() >= pkLimit && !isLocked())
			{
				isKarmaDrop = true;
				dropPercent = Config.KARMA_RATE_DROP;
@@ -7352,6 +7354,9 @@

				// Language
				player.setLang(rset.getString("language"));
+				
+				// Lock
+				player.setLock(rset.getInt("locked"));

				// Retrieve the name and ID of the other characters assigned to this account.
				PreparedStatement stmt = con.prepareStatement("SELECT charId, char_name FROM characters WHERE account_name=? AND charId<>?");
@@ -7703,7 +7708,8 @@
			statement.setInt(53, getBookMarkSlot());
			statement.setInt(54, getVitalityPoints());
			statement.setString(55, getLang());
-            statement.setInt(56, getObjectId());
+			statement.setInt(56, getLock());
+            statement.setInt(57, getObjectId());

			statement.execute();
			statement.close();
@@ -10783,7 +10789,7 @@
		}
	}

-    public boolean isLocked()
+    public boolean isSubclassLocked()
    {
    	return _subclassLock.isLocked();
    }
@@ -14356,7 +14362,7 @@

	public boolean isAllowedToEnchantSkills()
	{
-		if (isLocked())
+		if (isSubclassLocked())
			return false;
		if (isTransformed())
			return false;
@@ -14703,4 +14709,19 @@

		return result;
	}
+	
+	public int getLock() 
+	{
+		return _locked;
+	}
+	
+	public void setLock(int locked) 
+	{
+		_locked = locked;
+	}
+	
+	public boolean isLocked()
+	{
+		return getLock() == 1;
+	}
}

 

DP PART:

Index: I:/workspace/datapack_development/data/scripts/handlers/MasterHandler.java
===================================================================
--- I:/workspace/datapack_development/data/scripts/handlers/MasterHandler.java	(revision 7453)
+++ I:/workspace/datapack_development/data/scripts/handlers/MasterHandler.java	(working copy)
@@ -105,6 +105,7 @@
		AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminKick());
		AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminKill());
		AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminLevel());
+		AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminLock());
		AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminLogin());
		AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminMammon());
		AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminManor());
Index: I:/workspace/datapack_development/data/scripts/handlers/admincommandhandlers/AdminLock.java
===================================================================
--- I:/workspace/datapack_development/data/scripts/handlers/admincommandhandlers/AdminLock.java	(revision 7453)
+++ I:/workspace/datapack_development/data/scripts/handlers/admincommandhandlers/AdminLock.java	(working copy)
@@ -0,0 +1,70 @@
+/*
+ * 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.
+ *
+ * [url]http://www.gnu.org/copyleft/gpl.html[/url]
+ */
+package handlers.admincommandhandlers;
+
+import com.l2jserver.gameserver.handler.IAdminCommandHandler;
+import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
+
+/**
+ * @author Fakoykas
+ */
+public class AdminLock implements IAdminCommandHandler
+{
+	private static final String[] ADMIN_COMMANDS = {"admin_lock", "admin_unlock"};
+	
+	public boolean useAdminCommand(String command, L2PcInstance activeChar)
+	{
+		if (!(activeChar.getTarget() instanceof L2PcInstance) || activeChar.getTarget() == null)
+			return false;
+		
+		L2PcInstance target = (L2PcInstance)activeChar.getTarget();
+		
+		if (command.startsWith("admin_lock"))
+		{
+			if (target.isLocked())
+			{
+				activeChar.sendMessage(target+" is already locked!");
+				return false;
+			}
+			
+			target.setLock(1);
+			target.sendMessage("Your character has been locked. Transactions are disabled.");
+			activeChar.sendMessage(target.getName()+" is now locked. Transactions are disabled.");
+		}
+		else if (command.startsWith("admin_unlock"))
+		{
+			if (!target.isLocked())
+			{
+				activeChar.sendMessage(target+" is not locked!");
+				return false;
+			}
+			
+			target.setLock(0);
+			target.sendMessage("Your character has been unlocked. All the fuctions are enabled.");
+			activeChar.sendMessage(target.getName()+" is now unlocked. All the fuctions are enabled.");
+		}
+		
+		return true;
+	}
+	
+	public String[] getAdminCommandList()
+	{
+		return ADMIN_COMMANDS;
+	}
+}
+

 

SQL:

INSERT INTO `admin_command_access_rights` VALUES ('admin_lock', '1');
INSERT INTO `admin_command_access_rights` VALUES ('admin_unlock', '1');

also at characters table create that field

`locked` int(2) NOT NULL DEFAULT '0'

 

Adapted to IL By KraShGr

http://www.maxcheaters.com/forum/index.php?topic=151096.msg1094035#msg1094035

 

I hope you like it.

Best Regards.

Posted

It coded for epilogue , but it can be used for all client with some changes.

ah ok , thank you.

i will find the way to use it

thanks again.

 

Posted

ah ok , thank you.

i will find the way to use it

thanks again.

 

For which client you need it , i'll adapt it for you tommorow.
Posted

Interlude if you can =)

It's really simple, change some imports and some other little details.

Posted

It's really simple, change some imports and some other little details.

i am really really really newbie java user.

really.

better to wait to krash ~ 1 week

:)

Posted

This is more a guide ;D

 

Anyway it is a simple think and usefull for newbies ;)

thing*

 

I do not understand the idea, why I should to block a player ?

 

 

Posted

@Krash, you dawg how is your mother dude ? :)

@Versus, nice work m8, i never seen an epilogue share from you :P you was interlude addicted what happened ? :D

keep it up !

Posted

@Web say hello to your mum^^

Interlude Patch

### Eclipse Workspace Patch 1.0
#P L2_GameServer_It
Index: java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java
===================================================================
--- java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java	(revision 4256)
+++ java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java	(working copy)
@@ -215,8 +215,8 @@
	private static final String RESTORE_SKILL_SAVE = "SELECT skill_id,skill_level,effect_count,effect_cur_time, reuse_delay FROM character_skills_save WHERE char_obj_id=? AND class_index=? AND restore_type=? ORDER BY buff_index ASC";
	private static final String DELETE_SKILL_SAVE = "DELETE FROM character_skills_save WHERE char_obj_id=? AND class_index=?";

-    private static final String UPDATE_CHARACTER = "UPDATE characters SET level=?,maxHp=?,curHp=?,maxCp=?,curCp=?,maxMp=?,curMp=?,str=?,con=?,dex=?,_int=?,men=?,wit=?,face=?,hairStyle=?,hairColor=?,heading=?,x=?,y=?,z=?,exp=?,expBeforeDeath=?,sp=?,karma=?,pvpkills=?,pkkills=?,rec_have=?,rec_left=?,clanid=?,maxload=?,race=?,classid=?,deletetime=?,title=?,accesslevel=?,online=?,isin7sdungeon=?,clan_privs=?,wantspeace=?,base_class=?,onlinetime=?,in_jail=?,jail_timer=?,newbie=?,nobless=?,power_grade=?,subpledge=?,last_recom_date=?,lvl_joined_academy=?,apprentice=?,sponsor=?,varka_ketra_ally=?,clan_join_expiry_time=?,clan_create_expiry_time=?,char_name=?,death_penalty_level=? WHERE obj_id=?";
-    private static final String RESTORE_CHARACTER = "SELECT account_name, obj_Id, char_name, level, maxHp, curHp, maxCp, curCp, maxMp, curMp, acc, crit, evasion, mAtk, mDef, mSpd, pAtk, pDef, pSpd, runSpd, walkSpd, str, con, dex, _int, men, wit, face, hairStyle, hairColor, sex, heading, x, y, z, movement_multiplier, attack_speed_multiplier, colRad, colHeight, exp, expBeforeDeath, sp, karma, pvpkills, pkkills, clanid, maxload, race, classid, deletetime, cancraft, title, rec_have, rec_left, accesslevel, online, char_slot, lastAccess, clan_privs, wantspeace, base_class, onlinetime, isin7sdungeon, in_jail, jail_timer, newbie, nobless, power_grade, subpledge, last_recom_date, lvl_joined_academy, apprentice, sponsor, varka_ketra_ally,clan_join_expiry_time,clan_create_expiry_time,death_penalty_level FROM characters WHERE obj_id=?";
+    private static final String UPDATE_CHARACTER = "UPDATE characters SET level=?,maxHp=?,curHp=?,maxCp=?,curCp=?,maxMp=?,curMp=?,str=?,con=?,dex=?,_int=?,men=?,wit=?,face=?,hairStyle=?,hairColor=?,heading=?,x=?,y=?,z=?,exp=?,expBeforeDeath=?,sp=?,karma=?,pvpkills=?,pkkills=?,rec_have=?,rec_left=?,clanid=?,maxload=?,race=?,classid=?,deletetime=?,title=?,accesslevel=?,online=?,isin7sdungeon=?,clan_privs=?,wantspeace=?,base_class=?,onlinetime=?,in_jail=?,jail_timer=?,newbie=?,nobless=?,power_grade=?,subpledge=?,last_recom_date=?,lvl_joined_academy=?,apprentice=?,sponsor=?,varka_ketra_ally=?,clan_join_expiry_time=?,clan_create_expiry_time=?,char_name=?,death_penalty_level=?,locked=? WHERE obj_id=?";
+    private static final String RESTORE_CHARACTER = "SELECT account_name, obj_Id, char_name, level, maxHp, curHp, maxCp, curCp, maxMp, curMp, acc, crit, evasion, mAtk, mDef, mSpd, pAtk, pDef, pSpd, runSpd, walkSpd, str, con, dex, _int, men, wit, face, hairStyle, hairColor, sex, heading, x, y, z, movement_multiplier, attack_speed_multiplier, colRad, colHeight, exp, expBeforeDeath, sp, karma, pvpkills, pkkills, clanid, maxload, race, classid, deletetime, cancraft, title, rec_have, rec_left, accesslevel, online, char_slot, lastAccess, clan_privs, wantspeace, base_class, onlinetime, isin7sdungeon, in_jail, jail_timer, newbie, nobless, power_grade, subpledge, last_recom_date, lvl_joined_academy, apprentice, sponsor, varka_ketra_ally,clan_join_expiry_time,clan_create_expiry_time,death_penalty_level,locked FROM characters WHERE obj_id=?";
     private static final String RESTORE_CHAR_SUBCLASSES = "SELECT class_id,exp,sp,level,class_index FROM character_subclasses WHERE char_obj_id=? ORDER BY class_index ASC";
     private static final String ADD_CHAR_SUBCLASS = "INSERT INTO character_subclasses (char_obj_id,class_id,exp,sp,level,class_index) VALUES (?,?,?,?,?,?)";
     private static final String UPDATE_CHAR_SUBCLASS = "UPDATE character_subclasses SET exp=?,sp=?,level=?,class_id=? WHERE char_obj_id=? AND class_index =?";
@@ -331,6 +331,8 @@
	protected int _baseClass;
	protected int _activeClass;
	protected int _classIndex = 0;
+	
+	private int _locked;

	/** The list of sub-classes this character has. */
     private Map<Integer, SubClass> _subClasses;
@@ -4281,7 +4283,7 @@
			int dropLimit           = 0;
			int dropPercent         = 0;

-			if (getKarma() > 0 && getPkKills() >= pkLimit)
+			if (getKarma() > 0 && getPkKills() >= pkLimit && !isLocked())
			{
				isKarmaDrop = true;
				dropPercent = Config.KARMA_RATE_DROP;
@@ -5523,7 +5525,8 @@
			statement.setInt(54, isNewbie() ? 1 : 0);
			statement.setInt(55, isNoble() ? 1 :0);
			statement.setLong(56, 0);
-			statement.setLong(57,System.currentTimeMillis());
+			statement.setInt(57, getLock());
+			statement.setLong(58,System.currentTimeMillis());
			statement.executeUpdate();
			statement.close();
		}
@@ -5597,6 +5600,9 @@
				player.setOnlineTime(rset.getLong("onlinetime"));
				player.setNewbie(rset.getInt("newbie")==1);
				player.setNoble(rset.getInt("nobless")==1);
+				
+				// Lock
+				player.setLock(rset.getInt("locked"));

				player.setClanJoinExpiryTime(rset.getLong("clan_join_expiry_time"));
				if (player.getClanJoinExpiryTime() < System.currentTimeMillis())
@@ -10215,4 +10221,19 @@
	{
		_forceBuff = fb;
	}
+	
+	public int getLock() 
+	{
+		return _locked;
+	}
+		
+	public void setLock(int locked) 
+	{
+		_locked = locked;
+	}
+		
+	public boolean isLocked()
+	{
+		return getLock() == 1;
+	}
}
Index: java/net/sf/l2j/gameserver/clientpackets/SetPrivateStoreListSell.java
===================================================================
--- java/net/sf/l2j/gameserver/clientpackets/SetPrivateStoreListSell.java	(revision 4256)
+++ java/net/sf/l2j/gameserver/clientpackets/SetPrivateStoreListSell.java	(working copy)
@@ -76,9 +76,9 @@
		L2PcInstance player = getClient().getActiveChar();
		if (player == null) return;

-        if (Config.GM_DISABLE_TRANSACTION && player.getAccessLevel() >= Config.GM_TRANSACTION_MIN && player.getAccessLevel() <= Config.GM_TRANSACTION_MAX)
+        if (Config.GM_DISABLE_TRANSACTION && player.getAccessLevel() >= Config.GM_TRANSACTION_MIN && player.getAccessLevel() <= Config.GM_TRANSACTION_MAX || player.isLocked())
         {
-            player.sendMessage("Transactions are disable for your Access Level");
+        	player.sendMessage("Your character is locked. Transactions are disabled.");
             return;
         }

Index: java/net/sf/l2j/gameserver/clientpackets/TradeDone.java
===================================================================
--- java/net/sf/l2j/gameserver/clientpackets/TradeDone.java	(revision 4256)
+++ java/net/sf/l2j/gameserver/clientpackets/TradeDone.java	(working copy)
@@ -71,10 +71,10 @@
	        }

	        if (Config.GM_DISABLE_TRANSACTION && player.getAccessLevel() >= Config.GM_TRANSACTION_MIN
-	            && player.getAccessLevel() <= Config.GM_TRANSACTION_MAX)
+	            && player.getAccessLevel() <= Config.GM_TRANSACTION_MAX || player.isLocked())
	        {
	            player.cancelActiveTrade();
-	            player.sendMessage("Transactions are disable for your Access Level");
+	            player.sendMessage("Your character is locked. Transactions are disabled.");
	            return;
	        }
	        trade.confirm();
Index: java/net/sf/l2j/gameserver/clientpackets/TradeRequest.java
===================================================================
--- java/net/sf/l2j/gameserver/clientpackets/TradeRequest.java	(revision 4256)
+++ java/net/sf/l2j/gameserver/clientpackets/TradeRequest.java	(working copy)
@@ -54,9 +54,9 @@
		L2PcInstance player = getClient().getActiveChar();
         if (player == null) return;

-        if (Config.GM_DISABLE_TRANSACTION && player.getAccessLevel() >= Config.GM_TRANSACTION_MIN && player.getAccessLevel() <= Config.GM_TRANSACTION_MAX)
+        if (Config.GM_DISABLE_TRANSACTION && player.getAccessLevel() >= Config.GM_TRANSACTION_MIN && player.getAccessLevel() <= Config.GM_TRANSACTION_MAX || player.isLocked())
         {
-        	player.sendMessage("Transactions are disable for your Access Level");
+        	player.sendMessage("Your character is locked. Transactions are disabled.");
             sendPacket(new ActionFailed());
             return;
         }
Index: java/net/sf/l2j/gameserver/clientpackets/RequestPrivateStoreSell.java
===================================================================
--- java/net/sf/l2j/gameserver/clientpackets/RequestPrivateStoreSell.java	(revision 4256)
+++ java/net/sf/l2j/gameserver/clientpackets/RequestPrivateStoreSell.java	(working copy)
@@ -101,9 +101,9 @@
		TradeList storeList = storePlayer.getBuyList();
		if (storeList == null) return;

-        if (Config.GM_DISABLE_TRANSACTION && player.getAccessLevel() >= Config.GM_TRANSACTION_MIN && player.getAccessLevel() <= Config.GM_TRANSACTION_MAX)
+        if (Config.GM_DISABLE_TRANSACTION && player.getAccessLevel() >= Config.GM_TRANSACTION_MIN && player.getAccessLevel() <= Config.GM_TRANSACTION_MAX || player.isLocked())
         {
-        	player.sendMessage("Transactions are disable for your Access Level");
+        	player.sendMessage("Your character is locked. Transactions are disabled.");
             sendPacket(new ActionFailed());
             return;
         }
Index: java/net/sf/l2j/gameserver/clientpackets/AddTradeItem.java
===================================================================
--- java/net/sf/l2j/gameserver/clientpackets/AddTradeItem.java	(revision 4256)
+++ java/net/sf/l2j/gameserver/clientpackets/AddTradeItem.java	(working copy)
@@ -81,9 +81,9 @@
         }

         if (Config.GM_DISABLE_TRANSACTION && player.getAccessLevel() >= Config.GM_TRANSACTION_MIN
-            && player.getAccessLevel() <= Config.GM_TRANSACTION_MAX)
+            && player.getAccessLevel() <= Config.GM_TRANSACTION_MAX || player.isLocked())
         {
-            player.sendMessage("Transactions are disable for your Access Level");
+        	player.sendPacket(new SystemMessage(SystemMessageId.YOU_ARE_NOT_AUTHORIZED_TO_DO_THAT));
             player.cancelActiveTrade();
             return;
         }
Index: java/net/sf/l2j/gameserver/clientpackets/AnswerTradeRequest.java
===================================================================
--- java/net/sf/l2j/gameserver/clientpackets/AnswerTradeRequest.java	(revision 4256)
+++ java/net/sf/l2j/gameserver/clientpackets/AnswerTradeRequest.java	(working copy)
@@ -50,7 +50,7 @@
		L2PcInstance player = getClient().getActiveChar();
         if (player == null) return;

-        if (Config.GM_DISABLE_TRANSACTION && player.getAccessLevel() >= Config.GM_TRANSACTION_MIN && player.getAccessLevel() <= Config.GM_TRANSACTION_MAX)
+        if (Config.GM_DISABLE_TRANSACTION && player.getAccessLevel() >= Config.GM_TRANSACTION_MIN && player.getAccessLevel() <= Config.GM_TRANSACTION_MAX || player.isLocked())
         {
         	player.sendMessage("Transactions are disable for your Access Level");
             sendPacket(new ActionFailed());
Index: java/net/sf/l2j/gameserver/clientpackets/SendWareHouseDepositList.java
===================================================================
--- java/net/sf/l2j/gameserver/clientpackets/SendWareHouseDepositList.java	(revision 4256)
+++ java/net/sf/l2j/gameserver/clientpackets/SendWareHouseDepositList.java	(working copy)
@@ -86,9 +86,9 @@
		L2FolkInstance manager = player.getLastFolkNPC();
         if ((manager == null || !player.isInsideRadius(manager, L2NpcInstance.INTERACTION_DISTANCE, false, false)) && !player.isGM()) return;

-        if ((warehouse instanceof ClanWarehouse) && Config.GM_DISABLE_TRANSACTION && player.getAccessLevel() >= Config.GM_TRANSACTION_MIN && player.getAccessLevel() <= Config.GM_TRANSACTION_MAX)
+        if ((warehouse instanceof ClanWarehouse) && Config.GM_DISABLE_TRANSACTION && player.getAccessLevel() >= Config.GM_TRANSACTION_MIN && player.getAccessLevel() <= Config.GM_TRANSACTION_MAX || player.isLocked())
         {
-            player.sendMessage("Transactions are disable for your Access Level");
+        	player.sendMessage("Your character is locked. Transactions are disabled.");
             return;
         }

Index: java/net/sf/l2j/gameserver/clientpackets/RequestGiveItemToPet.java
===================================================================
--- java/net/sf/l2j/gameserver/clientpackets/RequestGiveItemToPet.java	(revision 4256)
+++ java/net/sf/l2j/gameserver/clientpackets/RequestGiveItemToPet.java	(working copy)
@@ -60,6 +60,12 @@
             player.sendMessage("Cannot exchange items while trading");
             return;
         }
+        
+        if (player.isLocked())
+        {
+        	player.sendMessage("Your character is locked. Transactions are disabled.");
+        	return;
+        }

         L2PetInstance pet = (L2PetInstance)player.getPet();
		if (pet.isDead())
Index: java/net/sf/l2j/gameserver/clientpackets/SetPrivateStoreListBuy.java
===================================================================
--- java/net/sf/l2j/gameserver/clientpackets/SetPrivateStoreListBuy.java	(revision 4256)
+++ java/net/sf/l2j/gameserver/clientpackets/SetPrivateStoreListBuy.java	(working copy)
@@ -73,9 +73,9 @@
         L2PcInstance player = getClient().getActiveChar();
     	if (player == null) return;

-        if (Config.GM_DISABLE_TRANSACTION && player.getAccessLevel() >= Config.GM_TRANSACTION_MIN && player.getAccessLevel() <= Config.GM_TRANSACTION_MAX)
+        if (Config.GM_DISABLE_TRANSACTION && player.getAccessLevel() >= Config.GM_TRANSACTION_MIN && player.getAccessLevel() <= Config.GM_TRANSACTION_MAX || player.isLocked())
         {
-            player.sendMessage("Transactions are disable for your Access Level");
+        	player.sendMessage("Your character is locked. Transactions are disabled.");
             return;
         }

Index: java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminLock.java
===================================================================
--- java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminLock.java	(revision 0)
+++ java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminLock.java	(revision 0)
@@ -0,0 +1,70 @@
+/*
+ * 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.
+ *
+ * [url]http://www.gnu.org/copyleft/gpl.html[/url]
+ */
+package net.sf.l2j.gameserver.handler.admincommandhandlers;
+
+import net.sf.l2j.gameserver.handler.IAdminCommandHandler;
+import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
+
+/**
+ * @author Fakoykas
+ */
+public class AdminLock implements IAdminCommandHandler
+{
+	private static final String[] ADMIN_COMMANDS = {"admin_lock", "admin_unlock"};
+	
+	public boolean useAdminCommand(String command, L2PcInstance activeChar)
+	{
+		if (!(activeChar.getTarget() instanceof L2PcInstance) || activeChar.getTarget() == null)
+			return false;
+		
+		L2PcInstance target = (L2PcInstance)activeChar.getTarget();
+		
+		if (command.startsWith("admin_lock"))
+		{
+			if (target.isLocked())
+			{
+				activeChar.sendMessage(target+" is already locked!");
+				return false;
+			}
+			
+			target.setLock(1);
+			target.sendMessage("Your character has been locked. Transactions are disabled.");
+			activeChar.sendMessage(target.getName()+" is now locked. Transactions are disabled.");
+		}
+		else if (command.startsWith("admin_unlock"))
+		{
+			if (!target.isLocked())
+			{
+				activeChar.sendMessage(target+" is not locked!");
+				return false;
+			}
+			
+			target.setLock(0);
+			target.sendMessage("Your character has been unlocked. All the fuctions are enabled.");
+			activeChar.sendMessage(target.getName()+" is now unlocked. All the fuctions are enabled.");
+		}
+		
+		return true;
+	}
+	
+	public String[] getAdminCommandList()
+	{
+		return ADMIN_COMMANDS;
+	}
+}
\ No newline at end of file
Index: java/net/sf/l2j/gameserver/GameServer.java
===================================================================
--- java/net/sf/l2j/gameserver/GameServer.java	(revision 4256)
+++ java/net/sf/l2j/gameserver/GameServer.java	(working copy)
@@ -94,6 +94,7 @@
import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminKick;
import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminKill;
import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminLevel;
+import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminLock;
import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminLogin;
import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminMammon;
import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminManor;
@@ -568,6 +569,7 @@
         _adminCommandHandler.registerAdminCommandHandler(new AdminGeoEditor());
         _adminCommandHandler.registerAdminCommandHandler(new AdminManor());
         _adminCommandHandler.registerAdminCommandHandler(new AdminTvTEvent());
+        _adminCommandHandler.registerAdminCommandHandler(new AdminLock());
         //_adminCommandHandler.registerAdminCommandHandler(new AdminRadar());
         _log.config("AdminCommandHandler: Loaded " + _adminCommandHandler.size() + " handlers.");

Index: java/config/command-privileges.properties
===================================================================
--- java/config/command-privileges.properties	(revision 4256)
+++ java/config/command-privileges.properties	(working copy)
@@ -372,6 +372,13 @@
admin_reset_petitions = 100
admin_view_petition = 75
admin_view_petitions = 75
+
+#####################
+### Lock Settings ###
+#####################
+
+admin_lock = 100
+admin_unlock = 100
  
###################
### GM SETTINGS ###
Index: java/net/sf/l2j/gameserver/clientpackets/RequestDropItem.java
===================================================================
--- java/net/sf/l2j/gameserver/clientpackets/RequestDropItem.java	(revision 4256)
+++ java/net/sf/l2j/gameserver/clientpackets/RequestDropItem.java	(working copy)
@@ -106,9 +106,9 @@
         }


-        if (Config.GM_DISABLE_TRANSACTION && activeChar.getAccessLevel() >= Config.GM_TRANSACTION_MIN && activeChar.getAccessLevel() <= Config.GM_TRANSACTION_MAX)
+        if (Config.GM_DISABLE_TRANSACTION && activeChar.getAccessLevel() >= Config.GM_TRANSACTION_MIN && activeChar.getAccessLevel() <= Config.GM_TRANSACTION_MAX || activeChar.isLocked())
         {
-            activeChar.sendMessage("Transactions are disable for your Access Level");
+        	activeChar.sendMessage("Your character is locked. Transactions are disabled.");
             activeChar.sendPacket(new SystemMessage(SystemMessageId.NOTHING_HAPPENED));
             return;
         }
Index: java/net/sf/l2j/gameserver/clientpackets/AttackRequest.java
===================================================================
--- java/net/sf/l2j/gameserver/clientpackets/AttackRequest.java	(revision 4256)
+++ java/net/sf/l2j/gameserver/clientpackets/AttackRequest.java	(working copy)
@@ -21,6 +21,7 @@
import net.sf.l2j.gameserver.model.L2Object;
import net.sf.l2j.gameserver.model.L2World;
import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
+import net.sf.l2j.gameserver.model.actor.instance.L2SummonInstance;
import net.sf.l2j.gameserver.serverpackets.ActionFailed;

/**
@@ -65,6 +66,24 @@
		else
			target = L2World.getInstance().findObject(_objectId);
		if (target == null) return;
+		
+		if (target instanceof L2PcInstance)
+		{
+			if (((L2PcInstance)target).getPvpFlag() == 0 && activeChar.isLocked())
+				activeChar.sendMessage("Your character is locked, you cannot attack a non flagged player.");
+			    sendPacket(new ActionFailed());
+			    return;
+		}
+		else if (target instanceof L2SummonInstance)
+		{
+			if (((L2SummonInstance)target).getPvpFlag() == 0 && activeChar.isLocked())
+		{
+				 activeChar.sendMessage("Your character is locked, you cannot attack a non flagged summon.");
+				 sendPacket(new ActionFailed());
+				 return;
+		}
+	}
+		
		if (activeChar.getTarget() != target)
		{
			target.onAction(activeChar);

For dp part just do this part

Open navicat right click on characters click design press "+" and add this settings

`locked` int(2) NOT NULL DEFAULT '0'

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...