Jump to content

Recommended Posts

Posted

Hello. With this share (as the subject says) your players can teleport to other players for an item. Use the .goto <playername> command. You can set the item ID in teleportItem, the cost in teleportCost and the teleport time in the teleportTimer variables. You can allow/disallow players to teleport to you with the .blockgoto command. When you teleport to the player he/she got a system message about it.

 

Tested on L2JFree 1.2.10. Credits to me. (but Intrepid helped a bit too:P)

com.l2jfree.gameserver.handler.voicedcommandhandlers.GoToPlayer.java


/*
* 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 3 of the License, 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, see <http://www.gnu.org/licenses/>.
*/
package com.l2jfree.gameserver.handler.voicedcommandhandlers;

import com.l2jfree.Config;
import java.util.StringTokenizer;
import com.l2jfree.gameserver.network.serverpackets.InventoryUpdate;
import com.l2jfree.gameserver.GameTimeController;
import com.l2jfree.gameserver.SevenSigns;
import com.l2jfree.gameserver.ThreadPoolManager;
import com.l2jfree.gameserver.ai.CtrlIntention;
import com.l2jfree.gameserver.datatables.SkillTable;
import com.l2jfree.gameserver.handler.IVoicedCommandHandler;
import com.l2jfree.gameserver.instancemanager.CoupleManager;
import com.l2jfree.gameserver.instancemanager.DimensionalRiftManager;
import com.l2jfree.gameserver.instancemanager.SiegeManager;
import com.l2jfree.gameserver.model.L2Character;
import com.l2jfree.gameserver.model.L2FriendList;
import com.l2jfree.gameserver.model.L2Skill;
import com.l2jfree.gameserver.model.L2World;
import com.l2jfree.gameserver.model.actor.instance.L2PcInstance;
import com.l2jfree.gameserver.model.entity.Siege;
import com.l2jfree.gameserver.model.zone.L2Zone;
import com.l2jfree.gameserver.model.restriction.AvailableRestriction;
import com.l2jfree.gameserver.model.restriction.ObjectRestrictions;
import com.l2jfree.gameserver.network.SystemMessageId;
import com.l2jfree.gameserver.network.serverpackets.ConfirmDlg;
import com.l2jfree.gameserver.network.serverpackets.MagicSkillUse;
import com.l2jfree.gameserver.network.serverpackets.SetupGauge;
import com.l2jfree.gameserver.network.serverpackets.SystemMessage;
import com.l2jfree.gameserver.util.Broadcast;

/** 
* @author Rizel
* 
*/
public class GoToPlayer implements IVoicedCommandHandler
{
private static final String[]	VOICED_COMMANDS	=
												{ "goto", "blockgoto" };

/* (non-Javadoc)
 * @see com.l2jfree.gameserver.handler.IVoicedCommandHandler#useVoicedCommand(String, com.l2jfree.gameserver.model.L2PcInstance), String)
 */
public boolean useVoicedCommand(String command, L2PcInstance activeChar, String name)
{
	if (command.startsWith("goto"))
	{
		return playerTeleport(activeChar, name);
	}
	if (command.startsWith("blockgoto"))
	{
		if ( activeChar._blockgoto == true )
		{
			activeChar._blockgoto = false;
			activeChar.sendMessage("Players are now allowed to teleport to you!");

		}
		if ( activeChar._blockgoto == false )
		{
			activeChar._blockgoto = true;
			activeChar.sendMessage("Players are now not allowed to teleport to you!");

		}
		return true;
	}
	return false;
}



public boolean playerTeleport(L2PcInstance activeChar, String name)
{
int teleportItem = 57;
int teleportCost = 1000;





	if (activeChar.isCastingNow() || activeChar.isMovementDisabled() || activeChar.isMuted() || activeChar.isAlikeDead())
		return false;

	Siege siege = SiegeManager.getInstance().getSiege(activeChar);

	// Check to see if the player is in olympiad.
	if (activeChar.isInOlympiadMode())
	{
		activeChar.sendMessage("You are in Olympiad!");
		return false;
	}
	// Check to see if the player is in observer mode
	else if (activeChar.inObserverMode())
	{
		activeChar.sendMessage("You are in observer mode.");
		return false;
	}
	// Check to see if the player is in an event
	else if (activeChar.isInFunEvent())
	{
		activeChar.sendMessage("You are in event now.");
		return false;
	}
	// Check to see if the player is in a festival.
	else if (activeChar.isFestivalParticipant())
	{
		activeChar.sendMessage("You can't escape from a festival.");
		return false;
	}
	// Check to see if the player is in dimensional rift.
	else if (activeChar.isInParty() && activeChar.getParty().isInDimensionalRift())
	{
		activeChar.sendMessage("You are in the dimensional rift.");
		return false;
	}
	// Check to see if player is in jail
	else if (activeChar.isInJail() || activeChar.isInsideZone(L2Zone.FLAG_JAIL))
	{
		activeChar.sendMessage("You can't escape from jail.");
		return false;
	}
	// Check if player is in Siege
	else if (siege != null && siege.getIsInProgress())
	{
		activeChar.sendMessage("You are in siege, you can't go to your partner.");
		return false;
	}
	// Check if player is in Duel
	else if (activeChar.isInDuel())
	{
		activeChar.sendMessage("You are in a duel!");
		return false;
	}
	// Check if player is a Cursed Weapon owner
	else if (activeChar.isCursedWeaponEquipped())
	{
		activeChar.sendMessage("You are currently holding a cursed weapon.");
		return false;
	}
	// Check if player is in a Monster Derby Track
	else if (activeChar.isInsideZone(L2Zone.FLAG_NOESCAPE))
	{
		activeChar.sendMessage("You cannot escape from here.");
		return false;
	}


	L2PcInstance targetplayer = L2World.getInstance().getPlayer(name);
	if (targetplayer._blockgoto == true)
	{
		activeChar.sendMessage("Your target blocked the teleport to him/her.");
		return false;
	}
                if (targetplayer.isGM())
	{
		activeChar.sendMessage("You can't teleport to GM.");
		return false;
	}
	if (targetplayer != null)
	{
		siege = SiegeManager.getInstance().getSiege(targetplayer);
	}
	else
	{
		activeChar.sendMessage("Your target is not online.");
		return false;
	}

	// Check to see if the player is in a instance.
	if (activeChar.getInstanceId() != targetplayer.getInstanceId())
	{
		activeChar.sendMessage("Your target is in another World!");
		return false;
	}
	else if (targetplayer.isInJail() || targetplayer.isInsideZone(L2Zone.FLAG_JAIL))
	{
		activeChar.sendMessage("Your target is in jail.");
		return false;
	}
	else if (targetplayer.isInOlympiadMode())
	{
		activeChar.sendMessage("Your target is in Olympiad now.");
		return false;
	}
	else if (targetplayer.inObserverMode())
	{
		activeChar.sendMessage("Your target is in observer mode.");
		return false;
	}
	else if (targetplayer.isInDuel())
	{
		activeChar.sendMessage("Your target is in a duel.");
		return false;
	}
	else if (targetplayer.isInFunEvent())
	{
		activeChar.sendMessage("Your target is in an event.");
		return false;
	}
	else if (DimensionalRiftManager.getInstance().checkIfInRiftZone(targetplayer.getX(), targetplayer.getY(), targetplayer.getZ(), false))
	{
		activeChar.sendMessage("Your target is in dimensional rift.");
		return false;
	}
	else if (targetplayer.isFestivalParticipant())
	{
		activeChar.sendMessage("Your target is in a festival.");
		return false;
	}
	else if (siege != null && siege.getIsInProgress())
	{
		if (targetplayer.getAppearance().getSex())
			activeChar.sendMessage("Your target is in siege, you can't go to her.");
		else
			activeChar.sendMessage("Your target is in siege, you can't go to him.");
		return false;
	}
	else if (targetplayer.isCursedWeaponEquipped())
	{
		activeChar.sendMessage("Your target is currently holding a cursed weapon.");
		return false;
	}
	else if (targetplayer.isInsideZone(L2Zone.FLAG_NOESCAPE))
	{
		activeChar.sendMessage("Your target is in a unsuitable area for teleporting.");
		return false;
	}
	else if (targetplayer.isIn7sDungeon() && !activeChar.isIn7sDungeon())
	{
		int playerCabal = SevenSigns.getInstance().getPlayerCabal(activeChar);
		boolean isSealValidationPeriod = SevenSigns.getInstance().isSealValidationPeriod();
		int compWinner = SevenSigns.getInstance().getCabalHighestScore();

		if (isSealValidationPeriod)
		{
			if (playerCabal != compWinner)
			{
				activeChar.sendMessage("Your target is in a Seven Signs Dungeon and you are not in the winner Cabal!");
				return false;
			}
		}
		else
		{
			if (playerCabal == SevenSigns.CABAL_NULL)
			{
				activeChar.sendMessage("Your target is in a Seven Signs Dungeon and you are not registered!");
				return false;
			}
		}
	}

	int teleportTimer = 10 * 1000;
	if (!activeChar.destroyItemByItemId("", teleportItem, teleportCost, activeChar, true))
	{
		activeChar.sendMessage("You don't have enough item to teleport.");
		return false;
	}
	activeChar.sendMessage("After " + teleportTimer / 1000 + " sec. you will be teleported to " + name +".");
	targetplayer.sendMessage("Player " + activeChar + "teleporting to you.");
	activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
	// SoE Animation section
	activeChar.setTarget(activeChar);
	activeChar.disableAllSkills();



	MagicSkillUse msk = new MagicSkillUse(activeChar, 1050, 1, teleportTimer, 0);
	Broadcast.toSelfAndKnownPlayersInRadius(activeChar, msk, 810000/*900*/);
	SetupGauge sg = new SetupGauge(0, teleportTimer);
	activeChar.sendPacket(sg);
	// End SoE Animation section

	EscapeFinalizer ef = new EscapeFinalizer(activeChar, targetplayer.getX(), targetplayer.getY(), targetplayer.getZ(), targetplayer.isIn7sDungeon());
	// Continue execution later
	activeChar.setSkillCast(ThreadPoolManager.getInstance().scheduleGeneral(ef, teleportTimer));
	activeChar.forceIsCasting(GameTimeController.getGameTicks() + teleportTimer / GameTimeController.MILLIS_IN_TICK);

	return true;
}


private static class EscapeFinalizer implements Runnable
{
private L2PcInstance	_activeChar;
private int				_partnerx;
private int				_partnery;
private int				_partnerz;
private boolean			_to7sDungeon;

EscapeFinalizer(L2PcInstance activeChar, int x, int y, int z, boolean to7sDungeon)
{
	_activeChar = activeChar;
	_partnerx = x;
	_partnery = y;
	_partnerz = z;
	_to7sDungeon = to7sDungeon;
}

public void run()
{
	if (_activeChar.isDead())
		return;
	_activeChar.setIsIn7sDungeon(_to7sDungeon);
	_activeChar.enableAllSkills();
	_activeChar.setIsCastingNow(false);

	try
	{
		_activeChar.teleToLocation(_partnerx, _partnery, _partnerz);
	}
	catch (Exception e)
	{
		_log.error(e.getMessage(), e);
	}
}
}


/* (non-Javadoc)
 * @see com.l2jfree.gameserver.handler.IVoicedCommandHandler#getVoicedCommandList()
 */
public String[] getVoicedCommandList()
{
	return VOICED_COMMANDS;
}
}

 

com.l2jfree.gameserver.model.actor.instance.L2PcInstance.java


public boolean							_inEventTvT				= false;
public boolean							_voteEvent				= false;
+	public boolean							_blockgoto				= false;

 

com.l2jfree.gameserver.handler.VoicedCommandHandler.java


	registerVoicedCommandHandler(new Banking());
+		registerVoicedCommandHandler(new GoToPlayer());

Posted

omfg. i was doing this but i stoped coding for it due to other projects:D anw cool! gj man:) keep it up! as i can see you edited the Wedding.java file and the gotolove part right?

 

also _inEventTvt is already defined in L2PcInstance no need to add it again

Posted

omfg. i was doing this but i stoped coding for it due to other projects:D anw cool! gj man:) keep it up! as i can see you edited the Wedding.java file and the gotolove part right?

 

No he dont tuch them those are just show how you can do it

Posted

well, that was an easiest way to do it coz it was already ready in Wedding.java:) good job and good luck with your java contribs:)

 

 

EDIT:

 

what about adding the teleport item and the cost into altsettings.properties?

 

in Config.java under line 1316 put:

 

	public static int		ALT_TELEPORT_ITEM;
public static int		ALT_TELEPORT_ITEM_COST;	

 

then under line 1512 put:

 

ALT_TELEPORT_ITEM = Integer.parseInt(altSettings.getProperty("AltGotoplayeritem", "57"));
ALT_TELEPORT_ITEM_COST = Integer.parseInt(altSettings.getProperty("AltGotoplayeritemcost", "10000"));	

 

and in altsettings.properties put

 

### Item ID needed to use .gotoplayer command ###
AltGotoplayeritem=57
### Item Amount ###
AltGotoplayeritemcost=10000

 

then do some changes in the GoToPlayer.java like changing

 

if (!activeChar.destroyItemByItemId("", teleportItem, teleportCost, activeChar, true))

 

to

 

if (!activeChar.destroyItemByItemId("", config.ALT_TELEPORT_ITEM, config.ALT_TELEPORT_ITEM_COST, activeChar, true))

 

Posted

well, that was an easiest way to do it coz it was already ready in Wedding.java:) good job and good luck with your java contribs:)

 

yes but you know best things come in small packages:D

and now i start to w8 for his next share he started an automated speed quiz event:D

Posted

int z = player1.getZ

int y = player1.getY

int x = player1.getX

 

If (player1.allowGoTo() && player2.getInventory.getItemByItemId(57) != null)

{

if (player2.getItemByItemId(57).getCount() >= 20000000)

{

player2.teleToCoords(x,y,z);

}

}

 

 

Much less code...Thats for teleport....you must make one more command and a new method in l2pcinstance. The allowgoto command will enable allowgoto in l2pcinstance so .goto can be used...

 

Your code is WAY too big and I still cant get why you created a new private in the voice handler and you didnt use the teleport private in l2pcinstance...Oo

Posted

my code is long becouse the event,jail,siege etc. checks ,the SoE effect and the blockgoto function. this script is a modified .gotolove but here you not teleport to your partner but teleport to any player

Posted

i didnt tell that code is bad or something like this man. i just mentioned that you could have edited wedding.java but as Vago said it could be donee in l2pcinstance.

Posted

aye...Well I didnt read it I just saw its huge :) Good job :)

 

Edit: xMaylox it eats less resources the way he did it than writing it in L2PcInstance...That code is being read every time a character uses the command, L2PcInstance is read almost every sec, event more, on a big server

Posted

 

if (player2.getItemByItemId(57).getCount() >= 20000000)

 

 

Why >= ... if some1 have 2kk the teleport make him the 2kk .. again if character have 2kkk this will make the 2kkk ...

 

>= mean for example 20000000 and up , why not == 20000000 ...??

 

 

@Rizel: Good job  you do great Modify :) Keep Up m8!

  • 2 weeks later...
Posted

ok so i just change the command from .goto to .getto

np in compiling.

 

but when i try it IG[i tried both .goto and .getto,same error],it gives this error  [L2jfree 1.2.10]

SEVERE Client: [Character: test - Account: admin - IP: 127.0.0.1] - Failed runni
ng: [C] 38 Say2 - L2J Server Version: 1.2.10
java.lang.NullPointerException
        at com.l2jfree.gameserver.handler.voicedcommandhandlers.GetToPlayer.play
erTeleport(GetToPlayer.java:161)
        at com.l2jfree.gameserver.handler.voicedcommandhandlers.GetToPlayer.useV
oicedCommand(GetToPlayer.java:61)
        at com.l2jfree.gameserver.network.clientpackets.Say2.runImpl(Say2.java:1
56)
        at com.l2jfree.gameserver.network.clientpackets.L2GameClientPacket.run(L
2GameClientPacket.java:78)
        at com.l2jfree.gameserver.threadmanager.ExecuteWrapper.run(ExecuteWrappe
r.java:40)
        at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
        at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
        at java.util.concurrent.FutureTask.run(Unknown Source)
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.
access$301(Unknown Source)
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.
run(Unknown Source)
        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source
)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
        at java.lang.Thread.run(Unknown Source)

 

any reason for this?

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

    • L2 Kings    Stage 1 – The Awakening Dynasty and Moirai Level Cap: 83 Gear: Dynasty -Moirai & Weapons (Shop for Adena + Drop from mobs/instances ) Masterwork System: Available (Neolithics S required with neolithics u can do armor parts foundation aswell) Class Cloaks: Level 1 - Masterwork sets such us moirai/dynasty stats are boosted also vesper(stage 2) Olf T-Shirt: +6 (fails don’t reset) safe is +2 Dolls: Level 1 Belts: Low & Medium Enchant: Safe +3 / Max +8 / Attribution Easy in Moirai-Dynasty . Main Zones: Varka Outpost: Easy farm, Adena, EXP for new players = > 80- 100kk hour Dragon Valley: Main farm zone — , 100–120kk/hour Weapon Weakness System active (all classes can farm efficiently) Archers get vampiric auto-hits vs mobs Dragon Valley Center: Main Party Zone — boosted drops (Blessed enchants, Neolithics chance) => farm like 150-200kk per hour. Dragon Valley North: Spoil Zone (Asofe + crafting materials for MW) Primeval Isle: Safe autofarm zone (low adena for casual players) ==> 50kk per hour Forge of the Gods & Imperial Tomb: Available from Stage 1 (lower Adena reward in compare with Dragon Valley) Hellbound also avaliable from stage 1 In few words all zones opened but MAIN farm zone with boosted adena and drops is Dragon valley also has more mobs Instances: Zaken (24h Reuse) → Instead of Vespers drop Moirai , 100% chance to drop 1 of 9 dolls lvl 1, Zaken 7-Day Jewelry Raid Bosses (7 RBs): Drop Moirai Parts + Neolithic S grade instead of Vespers parts that has 7 Rb Quest give Icarus Weapons Special Feature 7rb bosses level up soul crystals aswell. Closed Areas : Monaster of SIlence, LOA, ( It wont have mobs) / Mahum Quest/Lizardmen off) Grand Epics: Unlocked on Day 4 of Stage 1 → Antharas, Valakas, Baium, AQ, etc ================================================================================= Stage 2 – Rise of Vespers Level Cap: 85 Gear: Moirai Armors (Adena GM SHOP / Craft/ Drop) Weapons: Icarus Cloaks: Level 2 Olf: +8 Dolls: Level 2 Belts: High & Top Enchant: Safe +3 / Max +8 Masterwork can be with Neolithics S84 aswell but higher so craft will be usefull aswell. 7 Raid Boss Quest Updated: Now works retail give vesper weapons 7rb Bosses Drops : Vespers Instances: Zaken : Drops to retail vespers + the dolls and the extra items that we added on stage 1 New Freya Instance: Added — drops vespers and instead of mid s84 weapons will drop vespers . Extra drops Blessed Bottle of Freya - drops 100% chance 1 of 9 dolls. Farm Areas Dragon Valley remains main farm New Zone : Lair of Antharas (mobs nerfed and added drop Noble stone so solo players can farm too) New Party Zone : LOA Circle   ============================================================================   Stage 3 – The Vorpal ERA Gear: Vorpal Unclock Cloaks: Level 3 Olf: +10 (max cap) Dolls: Level 3 Enchant: Safe +3 / Max +12 Farm Zones : Dragon Valley Center Scorpions becomes a normal solo zone (no longer party zone) Drops:   LOA & Knorik → Mid Weapons avaliable in drop New Party Zone Kariks Instances: Easy Freya Drops Mid Weapons Frintezza Release =================================================================================     Stage 4 – Elegia Era (Final Stage) Elegia Unlock Gear: Elegia Weapons: Elegia TOP s84 ( farmed via H-Freya/ Drops ) Cloaks: Level 5 Dolls: Level 3 (final bonuses) Enchant: Safe +6 / Max +16 Instances: Hard Freya → Drops Elegia Weapons + => The Instance will drop 2-3 parts for sure and also will be able to Join with 7 people . Party Zone will have also drop chances for elegia armor parts and weapons but small   Events (Hourly): Win: 50 Event Medals + 3 GCM + morewards Lose: 25 Medals + 1 GCM + more rewards Tie: 30 Medals + 2 GCM + more rewards   ================================================================================ Epic Fragments Currency Participating in Daily Bosses mass rewarding all players Participating in Instances (zaken freya frintezza etc) all players get reward ================================================================================ Adena - Main server currency (all items in gm shop require adena ) Event Medals (Festival Adena) - Event shop currency Donation coins you can buy with them dressme,cosmetics and premium account Epic Fragments you can buy with them fake epic jewels Olympiad Tokens you can buy many items from olympiad shop (Hero Coin even items that are on next stages) Olympiad Win = 1000 Tokens / Lose = 500 Tokens ================================================================================= Offline Autofarm Allows limited Offline farming requires offline autofarm ticket that you get by voting etc ================================================================================= Grand Epics have Specific Custom NPC that can spawn Epics EU/LATIN TIME ZONE ================================================================================= First Olympiad Day 19 December First Heroes 22 December ( 21 December Last day of 1st Period) After that olympiad will be weekly. ================================================================================= Item price and economy Since adena is main coin of server and NOT donation coins we will always add new items in gm shop with adena in order to burn the adena of server and not be inflation . =================================================================================        
    • Hello, I'd like to change a title color for custom npc.  I created custom NPC, cloned existing. I put unique id for it in npcname-e, npcgrp and database. I have "0" to serverSideName in db, so that it would use npcname-e, but instead it has "NoNameNPC"and no title color change.
    • Trusted Guy 100% ,  I asked him for some work and he did it right away.
  • 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