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@@@Overridepublicvoid onAction(Player player){+if(!TvTEvent.getInstance().canTarget(this, player))+{+ player.sendPacket(ActionFailed.STATIC_PACKET);+return;+}+// Set the target of the playerif(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..70c66e4100644--- 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)+returnfalse;++if(player.getTeam()==TeamType.RED && target.getTeam()==TeamType.RED)+returnfalse;++returntrue;+}++@Overridepublicvoid 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;
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.
I present to your attention two options for the Hellbound location map
details in the archive
if you have larger effect files, you do not need to replace them
download
updates can be made behind the scenes, so if you catch a crit, post on the forum or download the archive, it may have already been fixed
additionally you can download
all la2 music from the latest version of the game 2025 download
the entire La2 ambisound from the latest version of the game 2025 download
Question
Williams
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.
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
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.