Jump to content

Level Zones Areas With Commands.


Recommended Posts

Don't you think, what better way would be like this:

write .lvlzone and you will be teleported to level zone by your level?

I mean if you are 20lvl you will be teleported to x1,y1,z1 coords if you will be 40lvl you will be teleported to x2,y2,z2 and so on... :)

Link to comment
Share on other sites

Don't you think, what better way would be like this:

write .lvlzone and you will be teleported to level zone by your level?

I mean if you are 20lvl you will be teleported to x1,y1,z1 coords if you will be 40lvl you will be teleported to x2,y2,z2 and so on... :)

sure,and it's more advanced ^^
Link to comment
Share on other sites

Okay so here I reworked those commands.

Changes:

1. Optimized ifs.

2. Changed the commands from .lvl20, .lvl40 and so on, to .lvl.

Here is the code:

=====
Index: net.sf.l2j.gameserver.handler.voicedcommandhandlers.LevelZones.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 net.sf.l2j.gameserver.handler.voicedcommandhandlers;

import net.sf.l2j.Config;
import net.sf.l2j.gameserver.handler.IVoicedCommandHandler;
import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
import net.sf.l2j.gameserver.serverpackets.SetupGauge;
import net.sf.l2j.gameserver.ThreadPoolManager;

@SuppressWarnings("unused")
public class LevelZones implements net.sf.l2j.gameserver.handler.IVoicedCommandHandler
{
private static final String[] VOICED_COMMANDS =
{
		"lvl"
};

@Override
public boolean useVoicedCommand(String command, L2PcInstance activeChar, String target)
{
	if (command.equalsIgnoreCase("lvl")) {
		if(activeChar.isInJail())
		{
			activeChar.sendMessage("Sorry,you are in Jail!");
			return false;
		}
		else if(activeChar.isInOlympiadMode())
		{
			activeChar.sendMessage("Sorry,you are in the Olympiad now.");
			return false;
		}
		else if(activeChar.isInDuel())
		{
			activeChar.sendMessage("Sorry,you are in a duel!");
			return false;
		}
		else if(activeChar.inObserverMode())
		{
			activeChar.sendMessage("Sorry,you are in the observation mode.");
			return false;
		}
		else if(activeChar.isFestivalParticipant())
		{
			activeChar.sendMessage("Sorry,you are in a festival.");
			return false;
		}
		else if(!Config.ALT_GAME_KARMA_PLAYER_CAN_USE_GK && activeChar.getKarma() > 0)
		{
			activeChar.sendMessage("Sorry,PK player can't use this.");
			return false;
		}
		else if(activeChar.isDead())
		{
			activeChar.sendMessage("Sorry,Dead player can't teleport.");			
						return false;
		}
		else if(activeChar.isFakeDeath())
		{
			activeChar.sendMessage("Sorry,on fake death mode can't use this.");
			return false;
		}
		else if(activeChar.atEvent)
		{
			activeChar.sendMessage("Sorry,you are on event now.");
			return false;
		}

		int placex;
		int placey;
		int placez;
		String message;
		if (activeChar.getLevel() >= 75 && Config.LVL75_COMMAND_ALLOW) {
			placex = Config.LVL75_X;
			placey = Config.LVL75_Y;
			placez = Config.LVL75_Z;
			message = Config.LVL75_MESSAGE;
		}
		else if (activeChar.getLevel() >= 60 && Config.LVL60_COMMAND_ALLOW) {
			placex = Config.LVL60_X;
			placey = Config.LVL60_Y;
			placez = Config.LVL60_Z;
			message = Config.LVL60_MESSAGE;
		}
		else if (activeChar.getLevel() >= 40 && Config.LVL40_COMMAND_ALLOW) {
			placex = Config.LVL40_X;
			placey = Config.LVL40_Y;
			placez = Config.LVL40_Z;
			message = Config.LVL40_MESSAGE;
		}
		else if(activeChar.getLevel() >= 20 && Config.LVL20_COMMAND_ALLOW)
		{
			placex = Config.LVL20_X;
			placey = Config.LVL20_Y;
			placez = Config.LVL20_Z;
			message = Config.LVL20_MESSAGE;
		}
		else {
			activeChar.sendMessage("You don't have anywhere to go. Your level is too high or too low.");
			return false;
		}
		SetupGauge sg = new SetupGauge(SetupGauge.BLUE, 15000);
		activeChar.sendPacket(sg);
		sg = null;
		activeChar.setIsImobilised(true);

		ThreadPoolManager.getInstance().scheduleGeneral(new teleportTask(activeChar, placex, placey, placez, message), 15000);
	}
	return true;
}

@Override
public String[] getVoicedCommandList()
{
	return VOICED_COMMANDS;
}

class teleportTask implements Runnable
{
	private final L2PcInstance _activeChar;
	private final int _x;
	private final int _y;
	private final int _z;
	private final String _message;

	teleportTask(L2PcInstance activeChar, int x, int y, int z, String message)
	{
		_activeChar = activeChar;
		_x = x;
		_y = y;
		_z = z;
		_message = message;
	}

	@Override
	public void run()
	{
		if(_activeChar == null)
			return;

		_activeChar.teleToLocation(_x, _y, _z);
		_activeChar.sendMessage(_message);
		_activeChar.setIsImobilised(false);
	}
}
}

Link to comment
Share on other sites

No, you see. This is 1 big if block, becouse all ifs don't sepperate (I think good word ;D), I mean not if (lvl >= 75){} if (lvl >= 20) {} and so on, but if, elseif, elseif and so on. You see I started from 75Lvl, becouse if I start from 20lvl, then I need more checks, if (lvl >= 20 && lvl < 40) {} elseif (lvl >= 40 && lvl < 60) {} and so on, so if I get level bigger than 75, I will be using first if statement and do the other code, no more work with ifs :)

Link to comment
Share on other sites

Look what I want to say.

If my code would be like this:

int yourLevel = 78;

if (yourLevel >= 75) goHere1;

if (yourLevel >= 60) goHere2;

if (yourLevel >= 40) goHere3;

if (yourLevel >= 20) goHere4;

You will get goHere4, becouse ifs are seperated. So you will check all 4 ifs.

But in my code is:

if (yourLevel >= 75) goHere1;

else if (yourLevel >= 60) goHere2;

else if (yourLevel >= 40) goHere3;

else if (yourLevel >= 20) goHere4;

So if my level will be higher than 78, I will check only first if, becouse others are with else (same with thing, if - else).

Link to comment
Share on other sites

put it whenever you want,just be sure you'll make the proper changes in config.java

 

Sorry i am still kinda confused on what to do with the config part, Do i add it into eclipse or after i compile my server i just make this a config file like Custom Level Zones.config and stick it in the config folder of my server, i am still learning :D

 

Edit: I think i found where i put it, workspace\L2J_Server\dist\game\config\

 

Is that right ? IF so what do i name it, can i name it anything ?

Link to comment
Share on other sites

  • 6 months later...
  • 2 weeks later...

Yes there is, but the problem? not stopping nor with esc.

When player is on this mode, can't stop the teleport.

 

And Thank you dude.

 

You can to fix this error with EscapeFinalizer.

 

For more info, see my topic on L2jFrozen forum: http://www.l2jfrozen.com/forum/index.php?topic=3923.msg13432#msg13432

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.




  • Posts

    • Welcome to my store :  https://topestore.mysellix.io/fr/ 2015-2022 Aged Discord Account 2015 Discord Account : 50.99 $ 2016 Discord Account : 10$ 2017 Discord Account :3.99 $ 2018 Discord Account : 3.50$ 2019 Discord Account : 2.70 $ 2020 Discord Account :1.50$ 2021 Discord Account :0.99$ 2022 Discord Account :0.70$ Warranty :Lifetime Payment Methods : Crypto/ PayPal Contact Me On Discord Or Telegram Discord : @ultrasstore11 Telegram : https://t.me/ultrastore1 Welcome to my store :  https://topestore.mysellix.io/fr/ 2015-2022 Aged Discord Account 2015 Discord Account : 50.99 $ 2016 Discord Account : 10$ 2017 Discord Account :3.99 $ 2018 Discord Account : 3.50$ 2019 Discord Account : 2.70 $ 2020 Discord Account :1.50$ 2021 Discord Account :0.99$ 2022 Discord Account :0.70$ Warranty :Lifetime Payment Methods : Crypto/ PayPal Contact Me On Discord Or Telegram Discord : @ultrasstore11
    • L2 ArenaWar: Low Rate PvP Server with Free Buffs & Autofarm [PVP]⚔️ [Free]🆓 Classic Interlude with  3x XP rates! Free starter pack(no grade) to kickstart your adventure! Autofarm for convenient grinding! Free buffs to keep you fighting fit! (2 job buffs) No experience loss on death! (Except with Karma) Clear Karma system to keep things fair! ⚖️ Active community of 800-1k players! Join our Discord to learn more! >> Discord <<     Server website: https://l2arenawar.com/en/    
    • This is dedication! 2 years working on a problem. Congratulations!
    • You indeed have to save player position over Enterworld to properly clean it up later (if you don't, even trying to delete packet content would eventually keep it up), that's what we do with debug packet (which is a reusable Map of ExServerPrimitive packets) on aCis.   It doesn't solve the FPS stuttering - more you draw/delete lines, more your client becomes laggy. It's like if client wasn't deleting drawn points/lines properly, but instead simply hide them and redrawn content above.   If you got a solution, I would happy to integrate it.   You should check aCis#Player _debug packet integration, it allows very big amount of lines/points to be drawn, it is also reusable.   https://gitlab.com/Tryskell/acis_public/-/blob/master/aCis_gameserver/java/net/sf/l2j/gameserver/model/actor/Player.java?ref_type=heads https://gitlab.com/Tryskell/acis_public/-/blob/master/aCis_gameserver/java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java?ref_type=heads  
    • we sell website templates, make websites to order. Great selection at very good prices. My contacts discord : advert1231 telegram : https://t.me/ggwpins  
  • Topics

×
×
  • Create New...