Jump to content
  • 0

restriction for TVT aCis


Question

Posted

Hello, I would like help because I do not understand very well, I made a restriction so that players of the same team do not kill themselves more players who do not participate can kill the participants.

 

diff --git a/aCis_gameserver/java/net/sf/l2j/gameserver/model/actor/Player.java b/aCis_gameserver/java/net/sf/l2j/gameserver/model/actor/Player.java
index 70589d9..ba98048 100644
--- a/aCis_gameserver/java/net/sf/l2j/gameserver/model/actor/Player.java
+++ b/aCis_gameserver/java/net/sf/l2j/gameserver/model/actor/Player.java
@@ -133,6 +133,7 @@
 import net.sf.l2j.gameserver.model.entity.Castle;
 import net.sf.l2j.gameserver.model.entity.Duel.DuelState;
 import net.sf.l2j.gameserver.model.entity.events.Event;
+import net.sf.l2j.gameserver.model.entity.events.TvTEvent;
 import net.sf.l2j.gameserver.model.entity.Siege;
 import net.sf.l2j.gameserver.model.group.CommandChannel;
 import net.sf.l2j.gameserver.model.group.Party;
@@ -2899,6 +2900,12 @@
 	@Override
 	public void onAction(Player player)
 	{	
+		if (!TvTEvent.getInstance().canTarget(this, player))
+		{
+			player.sendPacket(ActionFailed.STATIC_PACKET);
+			return;
+		}
+		
 		// Set the target of the player
 		if (player.getTarget() != this)
 			player.setTarget(this);
  diff --git a/aCis_gameserver/java/net/sf/l2j/gameserver/model/entity/events/TvTEvent.java b/aCis_gameserver/java/net/sf/l2j/gameserver/model/entity/events/TvTEvent.java
index 017c0d5..70c66e4 100644
--- a/aCis_gameserver/java/net/sf/l2j/gameserver/model/entity/events/TvTEvent.java
+++ b/aCis_gameserver/java/net/sf/l2j/gameserver/model/entity/events/TvTEvent.java
@@ -523,6 +523,18 @@
 	}
 	
 	@Override
+	public boolean canTarget(Player player, Player target)
+	{
+		if (player.getTeam() == TeamType.BLUE && target.getTeam() == TeamType.BLUE)
+			return false;
+
+		if (player.getTeam() == TeamType.RED && target.getTeam() == TeamType.RED)
+			return false;
+		
+		return true;
+	}
+	
+	@Override
 	public void onRevive(Creature killer)
 	{
 		if (killer == null)

 

I define my teams by TeamType, BLUE and RED

 

I added this check for players without a team it works, unregistered players can't kill registered players and RED and Azul team players can't kill themselves what did I do wrong?

 

  


    @Override
    public boolean canTarget(Player player, Player target)
    {
  +      if (player.getTeam().getId() > 0 && player.getTeam() == target.getTeam())
  +         return false;
  +      
        if (player.getTeam() == TeamType.BLUE && target.getTeam() == TeamType.BLUE)
            return false;

        if (player.getTeam() == TeamType.RED && target.getTeam() == TeamType.RED)
            return false;
        
        return true;
    }
    

4 answers to this question

Recommended Posts

  • 0
Posted (edited)
	
public boolean canTarget(Player player, Player target)
{
	// if they are not registered on the event they can kill each other
	if (player.getTeam() == TeamType.NONE && target.getTeam() == TeamType.NONE)
		return true; 
	
	// kill each other only if the teams are not the same.
	return player.getTeam() != target.getTeam();
}

 

Edited by melron
  • 0
Posted (edited)

 

24 minutes ago, melron said:

	
public boolean canTarget(Player player, Player target)
{
	// if they are not registered on the event they can kill each other
	if (player.getTeam() == TeamType.NONE && target.getTeam() == TeamType.NONE)
		return true; 
	
	// kill each other only if the teams are not the same.
	return player.getTeam() != target.getTeam();
}

 

 

already tried it does not work

Edited by Williams
  • 0
Posted (edited)

Why you mess with canTarget and onAction methods, lul. That's stupid way and will avoid heal of team mates. That's just plain wrong. Just avoid hitting.

Edited by SweeTs
  • 0
Posted
On 3/14/2020 at 3:32 PM, SweeTs said:

Why you mess with canTarget and onAction methods, lul. That's stupid way and will avoid heal of team mates. That's just plain wrong. Just avoid hitting.

 

You are right, I did as you say more, the players use the CTRL to attack the same team. And yet non-participating players attack participating players.

 

what you told me to do ?

diff --git a/aCis_gameserver/java/net/sf/l2j/gameserver/model/L2Skill.java b/aCis_gameserver/java/net/sf/l2j/gameserver/model/L2Skill.java
index 224fed7..747e01d 100644
--- a/aCis_gameserver/java/net/sf/l2j/gameserver/model/L2Skill.java
+++ b/aCis_gameserver/java/net/sf/l2j/gameserver/model/L2Skill.java
@@ -1633,12 +1633,6 @@
 						if ((obj.getAllyId() == 0 || obj.getAllyId() != player.getAllyId()) && (obj.getClan() == null || obj.getClanId() != player.getClanId()))
 							continue;
 
+						if (obj.getTeam().getId() > 0)
+						{
+							if (player.getTeam() != obj.getTeam())
+								continue;
+						}
+
 						if (player.isInDuel())
 						{
 							if (player.getDuelId() != obj.getDuelId())
@@ -1744,12 +1738,6 @@
 							if (obj == null || obj == player)
 								continue;
 
-							if (obj	.getTeam().getId() > 0)
-							{
-								if (player.getTeam() != obj.getTeam())
-									continue;
-							}
-
 							if (player.isInDuel())
 							{
 								if (player.getDuelId() != obj.getDuelId())
@@ -2068,12 +2056,6 @@
 				if (player.getParty().getCommandChannel() != null && player.getParty().getCommandChannel() == targetPlayer.getParty().getCommandChannel())
 					return false;
 			}
+
+			if (player.getTeam().getId() > 0)
+			{
+				if (player.getTeam() == targetPlayer.getTeam())
+					return false;
+			}
 			
 			if (!sourceInArena && !(targetPlayer.isInsideZone(ZoneId.PVP) && !targetPlayer.isInsideZone(ZoneId.SIEGE)))
 			{
diff --git a/aCis_gameserver/java/net/sf/l2j/gameserver/model/actor/Player.java b/aCis_gameserver/java/net/sf/l2j/gameserver/model/actor/Player.java
index fc8ae4e..b061496 100644
--- a/aCis_gameserver/java/net/sf/l2j/gameserver/model/actor/Player.java
+++ b/aCis_gameserver/java/net/sf/l2j/gameserver/model/actor/Player.java
@@ -6241,15 +6241,6 @@
 				return false;
 			}
 			
+			// Check if attacker is in event
+			if (cha.getEvent() != null && cha.getEvent() == getEvent())
+			{
+				if (cha.getTeam().getId() > 0 && cha.getTeam() == getTeam())
+					return false;
+				
+				return true;
+			}
+			
 			// is AutoAttackable if both players are in the same duel and the duel is still going on
 			if (getDuelState() == DuelState.DUELLING && getDuelId() == cha.getDuelId())
 				return true;
@@ -2901,12 +2901,6 @@
 	@Override
 	public void onAction(Player player)
 	{	
-		if (!TvTEvent.getInstance().canTarget(this, player))
-		{
-			player.sendPacket(ActionFailed.STATIC_PACKET);
-			return;
-		}
-		
 		// Set the target of the player
 		if (player.getTarget() != this)
 			player.setTarget(this);
@@ -2949,12 +2943,6 @@
 	@Override
 	public void onActionShift(Player player)
 	{
-		if (!TvTEvent.getInstance().canTarget(this, player))
-		{
-			player.sendPacket(ActionFailed.STATIC_PACKET);
-			return;
-		}
-		
 		if (player.isGM())
 			AdminEditChar.showCharacterInfo(player, this);
diff --git a/aCis_gameserver/java/net/sf/l2j/gameserver/model/actor/instance/Cubic.java b/aCis_gameserver/java/net/sf/l2j/gameserver/model/actor/instance/Cubic.java
index 524e44a..f3bcb7f 100644
--- a/aCis_gameserver/java/net/sf/l2j/gameserver/model/actor/instance/Cubic.java
+++ b/aCis_gameserver/java/net/sf/l2j/gameserver/model/actor/instance/Cubic.java
@@ -23,7 +23,6 @@
 import net.sf.l2j.gameserver.model.actor.Playable;
 import net.sf.l2j.gameserver.model.actor.Player;
 import net.sf.l2j.gameserver.model.actor.Summon;
-import net.sf.l2j.gameserver.model.entity.events.Event;
 import net.sf.l2j.gameserver.model.group.Party;
 import net.sf.l2j.gameserver.network.SystemMessageId;
 import net.sf.l2j.gameserver.network.serverpackets.MagicSkillUse;
@@ -257,21 +256,6 @@
 			return;
 		}
 
+		// Events
+		Event event = _owner.getEvent();
+		if (event != null && event.isStarted())
+		{
+			final Player target = ownerTarget.getActingPlayer();
+			if (target != null && target.getEvent() == event && (_owner.getTeam().getId() == 0 || _owner.getTeam() != target.getTeam()))
+			{
+				_target = (Creature)ownerTarget;
+				// Dead target
+				if (_target.isDead())
+					_target = null;
+			}
+			return;
+		}
+
 		// Olympiad targeting
 		if (_owner.isInOlympiadMode())
 		{

 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


  • Posts

    • Dear friends! We are constantly growing and developing, and we are finally ready to offer you the opportunity to integrate advertising across all SOCNET projects! Our service provides the opportunity to place ads on the website socnet.store, in our SMM panel socnet.pro, in Telegram bots socnet.shop and socnet.cc (celebrity bot), as well as in another new (currently secret) project. Each platform provides detailed analytics and information about available ad banners. The document below contains all detailed information in two languages — Russian and English. Here you will find answers to frequently asked questions about exact ad placement locations, integration costs, purchasing process, restrictions, and many other details. The document also contains a table with the current advertising placement queue in our projects. Document with detailed information: https://docs.google.com/document/d/1u4ro3fLkjfyvcp1Eu64rkgQy2Xl5lj87_1W25cVsqPM/edit?usp=sharing Thank you for your attention and support! Sincerely, the SOCNET team. Active project links: Digital Goods Store (Website): Go Store Telegram Bot: Go – convenient access to the store through Telegram messenger. Telegram Bot for purchasing Telegram Stars: Go – fast and profitable purchase of stars in Telegram. SMM Panel: Go – promotion of your social media accounts. We would like to present to you the current list of promotions and special offers for purchasing goods and services from our platform: 1. Promo code OCTOBER2025 (8% discount) for purchases in our store (Website, Bot) during October! You can also use the promo code for your first purchase: SOCNET (15% discount) 2. Get $1 credited to your store balance or a 10–20% discount — simply post your username after registration on our website using the following format: "SEND ME BONUS, MY USERNAME IS..." — post it in our forum thread! 3. Get $1 for your first SMM Panel trial — just open a ticket titled "Get Trial Bonus" on our website (Support). 4. Weekly Telegram Stars giveaways in our Telegram channel and in our Stars purchasing bot! News: ➡ Telegram Channel: https://t.me/accsforyou_shop ➡ WhatsApp Channel: https://chat.whatsapp.com/K8rBy500nA73z27PxgaJUw?mode=ems_copy_t ➡ Discord Server: https://discord.gg/y9AStFFsrh Contacts and Support: ➡ Telegram: https://t.me/socnet_support ➡ WhatsApp: https://wa.me/79051904467 ➡ Discord: socnet_support ➡ ✉ Email: solomonbog@socnet.store
    • Dear friends! We are constantly growing and developing, and we are finally ready to offer you the opportunity to integrate advertising across all SOCNET projects! Our service provides the opportunity to place ads on the website socnet.store, in our SMM panel socnet.pro, in Telegram bots socnet.shop and socnet.cc (celebrity bot), as well as in another new (currently secret) project. Each platform provides detailed analytics and information about available ad banners. The document below contains all detailed information in two languages — Russian and English. Here you will find answers to frequently asked questions about exact ad placement locations, integration costs, purchasing process, restrictions, and many other details. The document also contains a table with the current advertising placement queue in our projects. Document with detailed information: https://docs.google.com/document/d/1u4ro3fLkjfyvcp1Eu64rkgQy2Xl5lj87_1W25cVsqPM/edit?usp=sharing Thank you for your attention and support! Sincerely, the SOCNET team. Active project links: Digital Goods Store (Website): Go Store Telegram Bot: Go – convenient access to the store through Telegram messenger. Telegram Bot for purchasing Telegram Stars: Go – fast and profitable purchase of stars in Telegram. SMM Panel: Go – promotion of your social media accounts. We would like to present to you the current list of promotions and special offers for purchasing goods and services from our platform: 1. Promo code OCTOBER2025 (8% discount) for purchases in our store (Website, Bot) during October! You can also use the promo code for your first purchase: SOCNET (15% discount) 2. Get $1 credited to your store balance or a 10–20% discount — simply post your username after registration on our website using the following format: "SEND ME BONUS, MY USERNAME IS..." — post it in our forum thread! 3. Get $1 for your first SMM Panel trial — just open a ticket titled "Get Trial Bonus" on our website (Support). 4. Weekly Telegram Stars giveaways in our Telegram channel and in our Stars purchasing bot! News: ➡ Telegram Channel: https://t.me/accsforyou_shop ➡ WhatsApp Channel: https://chat.whatsapp.com/K8rBy500nA73z27PxgaJUw?mode=ems_copy_t ➡ Discord Server: https://discord.gg/y9AStFFsrh Contacts and Support: ➡ Telegram: https://t.me/socnet_support ➡ WhatsApp: https://wa.me/79051904467 ➡ Discord: socnet_support ➡ ✉ Email: solomonbog@socnet.store
    • Dear friends! We are constantly growing and developing, and we are finally ready to offer you the opportunity to integrate advertising across all SOCNET projects! Our service provides the opportunity to place ads on the website socnet.store, in our SMM panel socnet.pro, in Telegram bots socnet.shop and socnet.cc (celebrity bot), as well as in another new (currently secret) project. Each platform provides detailed analytics and information about available ad banners. The document below contains all detailed information in two languages — Russian and English. Here you will find answers to frequently asked questions about exact ad placement locations, integration costs, purchasing process, restrictions, and many other details. The document also contains a table with the current advertising placement queue in our projects. Document with detailed information: https://docs.google.com/document/d/1u4ro3fLkjfyvcp1Eu64rkgQy2Xl5lj87_1W25cVsqPM/edit?usp=sharing Thank you for your attention and support! Sincerely, the SOCNET team. Active project links: Digital Goods Store (Website): Go Store Telegram Bot: Go – convenient access to the store through Telegram messenger. Telegram Bot for purchasing Telegram Stars: Go – fast and profitable purchase of stars in Telegram. SMM Panel: Go – promotion of your social media accounts. We would like to present to you the current list of promotions and special offers for purchasing goods and services from our platform: 1. Promo code OCTOBER2025 (8% discount) for purchases in our store (Website, Bot) during October! You can also use the promo code for your first purchase: SOCNET (15% discount) 2. Get $1 credited to your store balance or a 10–20% discount — simply post your username after registration on our website using the following format: "SEND ME BONUS, MY USERNAME IS..." — post it in our forum thread! 3. Get $1 for your first SMM Panel trial — just open a ticket titled "Get Trial Bonus" on our website (Support). 4. Weekly Telegram Stars giveaways in our Telegram channel and in our Stars purchasing bot! News: ➡ Telegram Channel: https://t.me/accsforyou_shop ➡ WhatsApp Channel: https://chat.whatsapp.com/K8rBy500nA73z27PxgaJUw?mode=ems_copy_t ➡ Discord Server: https://discord.gg/y9AStFFsrh Contacts and Support: ➡ Telegram: https://t.me/socnet_support ➡ WhatsApp: https://wa.me/79051904467 ➡ Discord: socnet_support ➡ ✉ Email: solomonbog@socnet.store
    • Dear friends! We are constantly growing and developing, and we are finally ready to offer you the opportunity to integrate advertising across all SOCNET projects! Our service provides the opportunity to place ads on the website socnet.store, in our SMM panel socnet.pro, in Telegram bots socnet.shop and socnet.cc (celebrity bot), as well as in another new (currently secret) project. Each platform provides detailed analytics and information about available ad banners. The document below contains all detailed information in two languages — Russian and English. Here you will find answers to frequently asked questions about exact ad placement locations, integration costs, purchasing process, restrictions, and many other details. The document also contains a table with the current advertising placement queue in our projects. Document with detailed information: https://docs.google.com/document/d/1u4ro3fLkjfyvcp1Eu64rkgQy2Xl5lj87_1W25cVsqPM/edit?usp=sharing Thank you for your attention and support! Sincerely, the SOCNET team. Active project links: Digital Goods Store (Website): Go Store Telegram Bot: Go – convenient access to the store through Telegram messenger. Telegram Bot for purchasing Telegram Stars: Go – fast and profitable purchase of stars in Telegram. SMM Panel: Go – promotion of your social media accounts. We would like to present to you the current list of promotions and special offers for purchasing goods and services from our platform: 1. Promo code OCTOBER2025 (8% discount) for purchases in our store (Website, Bot) during October! You can also use the promo code for your first purchase: SOCNET (15% discount) 2. Get $1 credited to your store balance or a 10–20% discount — simply post your username after registration on our website using the following format: "SEND ME BONUS, MY USERNAME IS..." — post it in our forum thread! 3. Get $1 for your first SMM Panel trial — just open a ticket titled "Get Trial Bonus" on our website (Support). 4. Weekly Telegram Stars giveaways in our Telegram channel and in our Stars purchasing bot! News: ➡ Telegram Channel: https://t.me/accsforyou_shop ➡ WhatsApp Channel: https://chat.whatsapp.com/K8rBy500nA73z27PxgaJUw?mode=ems_copy_t ➡ Discord Server: https://discord.gg/y9AStFFsrh Contacts and Support: ➡ Telegram: https://t.me/socnet_support ➡ WhatsApp: https://wa.me/79051904467 ➡ Discord: socnet_support ➡ ✉ Email: solomonbog@socnet.store
    • Dear friends! We are constantly growing and developing, and we are finally ready to offer you the opportunity to integrate advertising across all SOCNET projects! Our service provides the opportunity to place ads on the website socnet.store, in our SMM panel socnet.pro, in Telegram bots socnet.shop and socnet.cc (celebrity bot), as well as in another new (currently secret) project. Each platform provides detailed analytics and information about available ad banners. The document below contains all detailed information in two languages — Russian and English. Here you will find answers to frequently asked questions about exact ad placement locations, integration costs, purchasing process, restrictions, and many other details. The document also contains a table with the current advertising placement queue in our projects. Document with detailed information: https://docs.google.com/document/d/1u4ro3fLkjfyvcp1Eu64rkgQy2Xl5lj87_1W25cVsqPM/edit?usp=sharing Thank you for your attention and support! Sincerely, the SOCNET team. Active project links: Digital Goods Store (Website): Go Store Telegram Bot: Go – convenient access to the store through Telegram messenger. Telegram Bot for purchasing Telegram Stars: Go – fast and profitable purchase of stars in Telegram. SMM Panel: Go – promotion of your social media accounts. We would like to present to you the current list of promotions and special offers for purchasing goods and services from our platform: 1. Promo code OCTOBER2025 (8% discount) for purchases in our store (Website, Bot) during October! You can also use the promo code for your first purchase: SOCNET (15% discount) 2. Get $1 credited to your store balance or a 10–20% discount — simply post your username after registration on our website using the following format: "SEND ME BONUS, MY USERNAME IS..." — post it in our forum thread! 3. Get $1 for your first SMM Panel trial — just open a ticket titled "Get Trial Bonus" on our website (Support). 4. Weekly Telegram Stars giveaways in our Telegram channel and in our Stars purchasing bot! News: ➡ Telegram Channel: https://t.me/accsforyou_shop ➡ WhatsApp Channel: https://chat.whatsapp.com/K8rBy500nA73z27PxgaJUw?mode=ems_copy_t ➡ Discord Server: https://discord.gg/y9AStFFsrh Contacts and Support: ➡ Telegram: https://t.me/socnet_support ➡ WhatsApp: https://wa.me/79051904467 ➡ Discord: socnet_support ➡ ✉ Email: solomonbog@socnet.store
  • Topics

×
×
  • 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