fuction searchs jail pe0ple problem
Forum rules
READ NOW: L2j Forums Rules of Conduct
READ NOW: L2j Forums Rules of Conduct
-
- Posts: 42
- Joined: Mon Oct 26, 2009 9:22 pm
fuction searchs jail pe0ple problem
public boolean isLeaderInJail(int playerId)
{
boolean jailed = false;
for (L2PcInstance player : L2World.getAllPlayers())
{
if (player != null && player.getObjectId() == playerId)
{
jailed = player.isInJail();
}
}
return jailed;
}
Dear Member of l2j community,
this should check if a player is in jail. i am using it in siege.java like if (isLeaderInJail(getCastle().getOwnerId())) ... .but it doesn't work. all time fuctions send 0.
any ideas or suggestion for an other coding way or fix the current one?
Regards
{
boolean jailed = false;
for (L2PcInstance player : L2World.getAllPlayers())
{
if (player != null && player.getObjectId() == playerId)
{
jailed = player.isInJail();
}
}
return jailed;
}
Dear Member of l2j community,
this should check if a player is in jail. i am using it in siege.java like if (isLeaderInJail(getCastle().getOwnerId())) ... .but it doesn't work. all time fuctions send 0.
any ideas or suggestion for an other coding way or fix the current one?
Regards
-
- Posts: 915
- Joined: Thu Sep 03, 2009 6:36 pm
- Location: Israel
- Contact:
Re: fuction searchs jail pe0ple problem
castle.getOwnerId() returns the id of the owning clan, not its leader.
try using:
try using:
Code: Select all
L2Clan owningClan = ClanTable.getInstance().getClan(castle.getOwnerId());int leaderId = owningClan.getLeader().getObjectId();if (isLeaderInJail(leaderId)).....
- janiii
- L2j Veteran
- Posts: 4269
- Joined: Wed May 28, 2008 3:15 pm
- Location: Slovakia
Re: fuction searchs jail pe0ple problem
if he has already the leader player instance, he doesnt need to get its object id and then loop all players in game again to search for the player instance. when having the ownerclan.getLeader() just check isInJail() on it.
Code: Select all
L2Clan owningClan = ClanTable.getInstance().getClan(castle.getOwnerId());boolean leaderIsInJail = false;if (owningClan != null && owningClan.getLeader() != null) leaderIsInJail = owningClan.getLeader().isInJail();.....
DO NOT EVEN TRY TO MESS WITH ME!
forum flOOder dancing dEVILoper ♀
I don't give private support - PM will be ignored!
forum flOOder dancing dEVILoper ♀
I don't give private support - PM will be ignored!
-
- Posts: 915
- Joined: Thu Sep 03, 2009 6:36 pm
- Location: Israel
- Contact:
Re: fuction searchs jail pe0ple problem
didn't want to make him feel like he worked for nothing 

-
- Posts: 42
- Joined: Mon Oct 26, 2009 9:22 pm
Re: fuction searchs jail pe0ple problem
i have problem with that with compiler :
L2Clan owningClan = ClanTable.getInstance().getClan(castle.getOwnerId());
i have it like that :
public void registerAttacker(L2PcInstance player, boolean force)
{
if (player.getClan() == null)
return;
int allyId = 0;
L2Clan owningClan = ClanTable.getInstance().getClan(castle.getOwnerId());
int leaderId = owningClan.getLeader().getObjectId();
if (getCastle().getOwnerId() != 0)
allyId = ClanTable.getInstance().getClan(getCastle().getOwnerId()).getAllyId();
if (isLeaderInJail(leaderId)
.............................
.............................
....................
}
L2Clan owningClan = ClanTable.getInstance().getClan(castle.getOwnerId());
i have it like that :
public void registerAttacker(L2PcInstance player, boolean force)
{
if (player.getClan() == null)
return;
int allyId = 0;
L2Clan owningClan = ClanTable.getInstance().getClan(castle.getOwnerId());
int leaderId = owningClan.getLeader().getObjectId();
if (getCastle().getOwnerId() != 0)
allyId = ClanTable.getInstance().getClan(getCastle().getOwnerId()).getAllyId();
if (isLeaderInJail(leaderId)
.............................
.............................
....................
}
-
- Posts: 915
- Joined: Thu Sep 03, 2009 6:36 pm
- Location: Israel
- Contact:
Re: fuction searchs jail pe0ple problem
did you import
net.sf.l2j.gameserver.DataTables.ClanTable;
its best if you drop the method you made and do what janiii suggested.
net.sf.l2j.gameserver.DataTables.ClanTable;
its best if you drop the method you made and do what janiii suggested.
Code: Select all
public void registerAttacker(L2PcInstance player, boolean force){ if (player.getClan() == null) return; L2Clan owningClan = ClanTable.getInstance().getClan(getCastle().getOwnerId()); int leaderId = owningClan.getLeader().getObjectId(); if (getCastle().getOwnerId() != 0) // not sure why you need this? allyId = ClanTable.getInstance().getClan(getCastle().getOwnerId()).getAllyId(); if (owningClan.getLeader().getPlayerInstance().isInJail()) ....
-
- Posts: 42
- Joined: Mon Oct 26, 2009 9:22 pm
Re: fuction searchs jail pe0ple problem
i found it it needs getCastle 
btw your way is sending the castles owner id right?

btw your way is sending the castles owner id right?
-
- Posts: 915
- Joined: Thu Sep 03, 2009 6:36 pm
- Location: Israel
- Contact:
Re: fuction searchs jail pe0ple problem
oh yea you're right 
player.getClan().getOwner().getPlayerInstance().isInJail()
for the player's clan leader

player.getClan().getOwner().getPlayerInstance().isInJail()
for the player's clan leader
-
- Posts: 42
- Joined: Mon Oct 26, 2009 9:22 pm
Re: fuction searchs jail pe0ple problem
again fuction didn't work.
L2Clan owningClan = ClanTable.getInstance().getClan(castle.getOwnerId());
int leaderId = owningClan.getLeader().getObjectId();
if (isLeaderInJail(leaderId))
but the fuction again returned 0...
i want to check if the owner castle leader is in jail. shall i change something else
L2Clan owningClan = ClanTable.getInstance().getClan(castle.getOwnerId());
int leaderId = owningClan.getLeader().getObjectId();
if (isLeaderInJail(leaderId))
but the fuction again returned 0...
i want to check if the owner castle leader is in jail. shall i change something else
- janiii
- L2j Veteran
- Posts: 4269
- Joined: Wed May 28, 2008 3:15 pm
- Location: Slovakia
Re: fuction searchs jail pe0ple problem
you have to give us info. where are you running the code from? which class? how does your isLeaderInJail method looks like? but still you didnt understand that you dont need your method and you can make it more easily with Probe's code. check it what he and me wrote.
Code: Select all
if (owningClan.getLeader().getPlayerInstance().isInJail())
DO NOT EVEN TRY TO MESS WITH ME!
forum flOOder dancing dEVILoper ♀
I don't give private support - PM will be ignored!
forum flOOder dancing dEVILoper ♀
I don't give private support - PM will be ignored!
-
- Posts: 42
- Joined: Mon Oct 26, 2009 9:22 pm
Re: fuction searchs jail pe0ple problem
i have it like this and it didn't work. i can not register but the leader is not in jail. if you have time check it too
in siege java
Code: Select all
]public void registerAttacker(L2PcInstance player, boolean force) { if (player.getClan() == null) return; int allyId = 0; if (getCastle().getOwnerId() != 0) allyId = ClanTable.getInstance().getClan(getCastle().getOwnerId()).getAllyId(); L2Clan owningClan = ClanTable.getInstance().getClan(getCastle().getOwnerId()); if(Config.IS_IN_JAIL) { if (owningClan.getLeader().getPlayerInstance().isInJail()) { player.sendMessage("You can not register as an attacker because castle owner is in jail."); return; } } if (allyId != 0) { if (player.getClan().getAllyId() == allyId && !force) { player.sendMessage("You can not register as an attacker because your alliance owns the castle."); return; } } if (force || checkIfCanRegister(player, ATTACKER)) saveSiegeClan(player.getClan(), ATTACKER, false); // Save to database }
-
- Posts: 915
- Joined: Thu Sep 03, 2009 6:36 pm
- Location: Israel
- Contact:
Re: fuction searchs jail pe0ple problem
instead of
do
Code: Select all
if (getCastle().getOwnerId() != 0) allyId = ClanTable.getInstance().getClan(getCastle().getOwnerId()).getAllyId();
Code: Select all
allyId = owningClan.getAllyId();
-
- Posts: 42
- Joined: Mon Oct 26, 2009 9:22 pm
Re: fuction searchs jail pe0ple problem
this do not touch the code inside the if(config.is_in_jail). why to change it?
none can register again
none can register again