/* * Patch for filter_var() */ if(!function_exists('filter_var')){ define('FILTER_VALIDATE_IP', 'ip'); define('FILTER_FLAG_IPV4', 'ipv4'); define('FILTER_FLAG_IPV6', 'ipv6'); define('FILTER_VALIDATE_EMAIL', 'email'); define('FILTER_FLAG_EMAIL_UNICODE', 'unicode'); function filter_var($variable, $filter, $option = false){ if($filter == 'ip'){ if($option == 'ipv4'){ if(preg_match("/(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/", $variable, $matches)){ $variable = $matches[1]; return $variable; } } if($option == 'ipv6'){ if(preg_match("/\s*(([:.]{0,7}[0-9a-fA-F]{0,4}){1,8})\s*/", $variable, $matches)){ $variable = $matches[1]; return $variable; } } } if($filter == 'email'){ if($option == 'unicode' || $option == false){ if(preg_match("/\s*(\S*@\S*\.\S*)\s*/", $variable, $matches)){ $variable = $matches[1]; return $variable; } } } } }
<instance id="134" name="Moja instancja" />
/*
* 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 instances.WlasnaInstancja;
import com.l2jserver.gameserver.model.quest.Quest;
/**
* @author InsOmnia
*/
public class WlasnaInstancja extends Quest
{
public WlasnaInstancja(int questId, String name, String descr)
{
super(questId, name, descr);
}
public static void main(String[] args)
{
new WlasnaInstancja(196, "WlasnaInstancja", "custom");
}
}
<?xml version="1.0" encoding="UTF-8"?>
<instance name="Moja instancja">
<activityTime val="60" />
<emptyDestroyTime val="3000" />
<allowSummon val="false" />
<spawnPoint spawnX="-80666" spawnY="151321" spawnZ="-3040" />
</instance>
<?xml version="1.0" encoding="UTF-8"?>
<instance name="Moja instancja">
<activityTime val="60" />
<emptyDestroyTime val="3000" />
<allowSummon val="false" />
<spawnPoint spawnX="-80666" spawnY="151321" spawnZ="-3040" />
</instance>
public class WlasnaInstancja extends Quest
private static final int[] enterCords = { 1, 2, 3 };
private static final void teleportPlayer(L2PcInstance player, int[] coords, int instanceId)
{
player.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
player.setInstanceId(instanceId);
player.teleToLocation(coords[0], coords[1], coords[2], false);
}
private static final int INSTANCE_ID = 134;
private synchronized void enterInstance(L2PcInstance player)
{
InstanceWorld world = InstanceManager.getInstance().getPlayerWorld(player);
if (world != null)
{
if (world.templateId != INSTANCE_ID)
{
player.sendPacket(new SystemMessage(SystemMessageId.ALREADY_ENTERED_ANOTHER_INSTANCE_CANT_ENTER));
return;
}
Instance inst = InstanceManager.getInstance().getInstance(world.instanceId);
if (inst != null)
teleportPlayer(player, enterCords, world.instanceId);
return;
}
else
{
final int instanceId = InstanceManager.getInstance().createDynamicInstance("WlasnaInstancja.xml");
world = InstanceManager.getInstance().new InstanceWorld();
world.instanceId = instanceId;
world.templateId = INSTANCE_ID;
InstanceManager.getInstance().addWorld(world);
_log.info("WlasnaInstancja: started instance: " +instanceId + " created by player: " + player.getName());
world.allowed.add(player.getObjectId());
teleportPlayer(player, enterCords, instanceId);
}
}
/*
* 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 instances.WlasnaInstancja;
import com.l2jserver.gameserver.instancemanager.InstanceManager;
import com.l2jserver.gameserver.instancemanager.InstanceManager.InstanceWorld;
import com.l2jserver.gameserver.model.entity.Instance;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
import com.l2jserver.gameserver.ai.CtrlIntention;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.quest.Quest;
/**
* @author InsOmnia
*/
public class WlasnaInstancja extends Quest
{
private static final int[] enterCords = { 1, 2, 3 };
private static final int INSTANCE_ID = 134;
public WlasnaInstancja(int questId, String name, String descr)
{
super(questId, name, descr);
}
private synchronized void enterInstance(L2PcInstance player)
{
//sprawdzamy czy gracz jest już w jakiejś instancji
InstanceWorld world = InstanceManager.getInstance().getPlayerWorld(player);
if (world != null)
{
if (world.templateId != INSTANCE_ID)
{
player.sendPacket(new SystemMessage(SystemMessageId.ALREADY_ENTERED_ANOTHER_INSTANCE_CANT_ENTER));
return;
}
Instance inst = InstanceManager.getInstance().getInstance(world.instanceId);
if (inst != null)
teleportPlayer(player, enterCords, world.instanceId);
return;
}
//New instance
else
{
final int instanceId = InstanceManager.getInstance().createDynamicInstance("SealOfTheEmperor.xml");
world = InstanceManager.getInstance().new InstanceWorld();
world.instanceId = instanceId;
world.templateId = INSTANCE_ID;
InstanceManager.getInstance().addWorld(world);
_log.info("SealOfTheEmperor: started instance: " +instanceId + " created by player: " + player.getName());
world.allowed.add(player.getObjectId());
teleportPlayer(player, enterCords, instanceId);
}
}
private static final void teleportPlayer(L2PcInstance player, int[] coords, int instanceId)
{
player.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
player.setInstanceId(instanceId);
player.teleToLocation(coords[0], coords[1], coords[2], false);
}
public static void main(String[] args)
{
new WlasnaInstancja(196, "WlasnaInstancja", "custom");
}
}
Jutro dodam kolejny podpunkt poradnika, mianowicie, jak stworzyć npc który nas będzie teleportować do środka, jakie są sposoby dodawania npc wewnątrz instancji, jak bezpiecznie teleportować gracza wewnątrz instancji (metoda teleportPlayer nie wystarcza)
Kod: [Zaznacz]Jutro dodam kolejny podpunkt poradnika, mianowicie, jak stworzyć npc który nas będzie teleportować do środka, jakie są sposoby dodawania npc wewnątrz instancji, jak bezpiecznie teleportować gracza wewnątrz instancji (metoda teleportPlayer nie wystarcza)
Mistrzu :D
Gdzie to jest bo szukam i lipa xD