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.
Lineage II Classic Einhovant new project is looking for a skilled Java Developer to join our team!
If you're passionate about game development and eager to contribute to this project, we'd love to hear from you.
For more details, feel free to send us a message. Let’s create something amazing together!
DISCORD :
https://discord.com/users/325653525793210378
utchiha_market
telegram :
https://t.me/utchiha_market
SELLIX STORE :
https://utchihamkt.mysellix.io/
Join our server for more products :
https://discord.gg/uthciha-services
https://campsite.bio/utchihaamkt
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.