- 0
-
Posts
-
package custom.events.RandomZoneEvent; import java.io.File; import java.util.ArrayList; import java.util.List; import java.util.Random; import java.util.concurrent.ScheduledFuture; import org.w3c.dom.Document; import org.w3c.dom.Node; import org.l2jmobius.commons.threads.ThreadPool; import org.l2jmobius.commons.time.SchedulingPattern; import org.l2jmobius.commons.time.TimeUtil; import org.l2jmobius.commons.util.IXmlReader; import org.l2jmobius.gameserver.managers.ZoneManager; import org.l2jmobius.gameserver.model.StatSet; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.actor.Npc; import org.l2jmobius.gameserver.model.actor.Player; import org.l2jmobius.gameserver.model.quest.Event; import org.l2jmobius.gameserver.model.zone.ZoneId; import org.l2jmobius.gameserver.model.zone.ZoneType; import org.l2jmobius.gameserver.model.zone.type.RandomZone; import org.l2jmobius.gameserver.util.Broadcast; /** * Random Zone Event - Activates one random PvP zone temporarily. No modifica la clase de la zona: usa flags PvP en runtime. * @author Juan */ public class RandomZoneEvent extends Event { private static final String CONFIG_FILE = "data/scripts/custom/events/RandomZoneEvent/config.xml"; private static int EVENT_DURATION_MINUTES = 15; private static boolean _isActive = false; private ScheduledFuture<?> _eventTask = null; private final List<ZoneType> _availableZones = new ArrayList<>(); private ZoneType _activeZone = null; public RandomZoneEvent() { loadConfig(); loadZones(); registerZoneListeners(); } /** * Registra listeners a TODAS LAS ZONAS random */ private void registerZoneListeners() { for (ZoneType zone : _availableZones) { addEnterZoneId(zone.getId()); addExitZoneId(zone.getId()); LOGGER.info("[RandomZoneEvent] Registered listener for zone: " + zone.getName()); } } private void loadConfig() { new IXmlReader() { @Override public void load() { parseDatapackFile(CONFIG_FILE); } @Override public void parseDocument(Document doc, File file) { forEach(doc, "event", eventNode -> { final StatSet att = new StatSet(parseAttributes(eventNode)); final String name = att.getString("name"); for (Node node = eventNode.getFirstChild(); node != null; node = node.getNextSibling()) { if ("schedule".equals(node.getNodeName())) { final StatSet attributes = new StatSet(parseAttributes(node)); final String pattern = attributes.getString("pattern"); final SchedulingPattern schedulingPattern = new SchedulingPattern(pattern); final StatSet params = new StatSet(); params.set("Name", name); params.set("SchedulingPattern", pattern); final long delay = schedulingPattern.getDelayToNextFromNow(); getTimers().addTimer("Schedule_" + name, params, delay + 5000, null, null); LOGGER.info("[RandomZoneEvent] Event " + name + " scheduled at " + TimeUtil.getDateTimeString(System.currentTimeMillis() + delay)); } } }); } }.load(); } private void loadZones() { for (ZoneType zone : ZoneManager.getInstance().getAllZones(RandomZone.class)) { if ((zone.getName() != null) && zone.getName().toLowerCase().startsWith("random_zone")) { _availableZones.add(zone); LOGGER.info("[RandomZoneEvent] Loaded zone: " + zone.getName() + " (id=" + zone.getId() + ")"); } } LOGGER.info("[RandomZoneEvent] Total random zones loaded: " + _availableZones.size()); } @Override public void onTimerEvent(String event, StatSet params, Npc npc, Player player) { if (event.startsWith("Schedule_")) { eventStart(null); final SchedulingPattern schedulingPattern = new SchedulingPattern(params.getString("SchedulingPattern")); final long delay = schedulingPattern.getDelayToNextFromNow(); getTimers().addTimer(event, params, delay + 5000, null, null); LOGGER.info("[RandomZoneEvent] Rescheduled for " + TimeUtil.getDateTimeString(System.currentTimeMillis() + delay)); } } @Override public boolean eventStart(Player eventMaker) { if (_isActive) { if (eventMaker != null) { eventMaker.sendMessage("RandomZoneEvent already active."); } return false; } if (_availableZones.isEmpty()) { Broadcast.toAllOnlinePlayers("[RandomZoneEvent] No zones configured."); return false; } _isActive = true; Broadcast.toAllOnlinePlayers("⚔️ Random Zone Event has started!"); _eventTask = ThreadPool.schedule(this::activateRandomZone, 5_000); return true; } private void activateRandomZone() { _activeZone = _availableZones.get(new Random().nextInt(_availableZones.size())); _activeZone.setEnabled(true); Broadcast.toAllOnlinePlayers("🔥 Random Zone Event: " + _activeZone.getName() + " is now PvP for " + EVENT_DURATION_MINUTES + " minutes!"); _eventTask = ThreadPool.schedule(this::eventStop, EVENT_DURATION_MINUTES * 60 * 1000L); } @Override public boolean eventStop() { if (!_isActive) { return false; } _isActive = false; if (_eventTask != null) { _eventTask.cancel(true); _eventTask = null; } if (_activeZone != null) { _activeZone.setEnabled(false); Broadcast.toAllOnlinePlayers("🏁 Random Zone Event ended. " + _activeZone.getName() + " is back to normal."); _activeZone = null; } else { Broadcast.toAllOnlinePlayers("🏁 Random Zone Event ended."); } return true; } @Override public void onEnterZone(Creature creature, ZoneType zone) { if (!_isActive || (_activeZone == null)) { return; } if ((zone == _activeZone) && creature.isPlayable()) { creature.setInsideZone(ZoneId.PVP, true); if (creature.isPlayer()) { creature.sendMessage("Esta zona está en modo PvP temporalmente."); } } } @Override public void onExitZone(Creature creature, ZoneType zone) { if (!_isActive || (_activeZone == null)) { return; } if ((zone == _activeZone) && creature.isPlayable()) { creature.setInsideZone(ZoneId.PVP, false); if (creature.isPlayer()) { creature.sendMessage("Abandonaste la zona PvP temporal."); } } } @Override public boolean eventBypass(Player player, String bypass) { return true; } @Override public String onEvent(String event, Npc npc, Player player) { return super.onEvent(event, npc, player); } @Override public String onFirstTalk(Npc npc, Player player) { return null; } public static void main(String[] args) { new RandomZoneEvent(); } } i have this but its not working
-
Topics

Question
gspzoumhs
guys i have problem with Noblesse at "Possessor of a Precious Soul 4"
when i press the final button to get noblesse i get this error at gameserver..
Traceback (innermost last):
File "C:\Server\gameserver\data\jscript\quests\247_PossessorOfPreciousSoul4\__
init__.py", line 61, in onTalk
NameError: true
at org.python.core.Py.NameError(Py.java:148)
at org.python.core.PyFrame.getglobal(PyFrame.java:202)
at data.jscript.quests.247_PossessorOfPreciousSoul4$py.onTalk$4(C:\Serve
r\gameserver\data\jscript\quests\247_PossessorOfPreciousSoul4\__init__.py:61)
at data.jscript.quests.247_PossessorOfPreciousSoul4$py.call_function(C:\
Server\gameserver\data\jscript\quests\247_PossessorOfPreciousSoul4\__init__.py)
at org.python.core.PyTableCode.call(PyTableCode.java:213)
at org.python.core.PyTableCode.call(PyTableCode.java:426)
at org.python.core.PyTableCode.call(PyTableCode.java:322)
at org.python.core.PyFunction.__call__(PyFunction.java:193)
at org.python.core.PyMethod.__call__(PyMethod.java:93)
at org.python.core.PyObject.__call__(PyObject.java:570)
at org.python.core.PyObject._jcallexc(PyObject.java:2573)
at org.python.core.PyObject._jcall(PyObject.java:2605)
at org.python.proxies.data.jscript.quests.247_PossessorOfPreciousSoul4$Q
uest$83.onTalk(Unknown Source)
at net.sf.l2j.gameserver.model.quest.Quest.notifyTalk(Quest.java:185)
at net.sf.l2j.gameserver.model.actor.instance.L2NpcInstance.showQuestWin
dow(L2NpcInstance.java:1520)
at net.sf.l2j.gameserver.model.actor.instance.L2NpcInstance.showQuestWin
dow(L2NpcInstance.java:1626)
at net.sf.l2j.gameserver.model.actor.instance.L2NpcInstance.onBypassFeed
back(L2NpcInstance.java:988)
at net.sf.l2j.gameserver.clientpackets.RequestBypassToServer.runImpl(Req
uestBypassToServer.java:109)
at net.sf.l2j.gameserver.clientpackets.ClientBasePacket.run(ClientBasePa
cket.java:59)
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)
can you someone help me to fix it?
==== This is the file.. if someone can fix the error.. thanks..===
print "importing quests: 247: Possessor of a Precious Soul 4"
import sys
from net.sf.l2j.gameserver.model.quest import State
from net.sf.l2j.gameserver.model.quest import QuestState
from net.sf.l2j.gameserver.model.quest.jython import QuestJython as JQuest
CARADINE_LETTER2_ID = 7679
NOBLESSE_ID = 7694
class Quest (JQuest) :
def __init__(self,id,name,descr): JQuest.__init__(self,id,name,descr)
def onEvent (self,event,st) :
htmltext = event
if event=="1" :
htmltext = "start.htm"
st.set("cond","1")
st.setState(STARTED)
st.playSound("ItemSound.quest_accept")
if event=="2" :
htmltext = "start.htm"
st.player.teleToLocation(143283,44055,-3049)
st.set("cond","2")
return htmltext
def onTalk (Self,npc,st):
npcId = npc.getNpcId()
htmltext = "<html><head><body>I have nothing to say you</body></html>"
id = st.getState()
if id == CREATED :
st.setState(STARTING)
st.set("cond","0")
st.set("onlyone","0")
st.set("id","0")
if npcId==8740 and int(st.get("cond"))==0 and int(st.get("onlyone"))==0 :
if st.getQuestItemsCount(NOBLESSE_ID)==1 :
htmltext = "<html><head><body>CHEATER!!!!!!!!!!!!!!!</body></html>"
elif st.getQuestItemsCount(CARADINE_LETTER2_ID)==1 :
if st.getPlayer().getSubLevel() >= 75 :
htmltext = "8740-1.htm"
st.takeItems(CARADINE_LETTER2_ID,1)
else:
htmltext = "8740-10.htm"
st.exitQuest(1)
else:
htmltext = "8740-10.htm"
st.exitQuest(1)
elif npcId == 8740 and int(st.get("cond"))==0 and int(st.get("onlyone"))==1 :
htmltext = "<html><head><body>This quest have already been completed.</body></html>"
elif npcId==8740 and int(st.get("cond"))==1 and st.player.isSubClassActive() :
htmltext = "8740-2.htm"
elif npcId==8745 and int(st.get("cond"))==2 and st.player.isSubClassActive() :
htmltext = "8745-1.htm"
st.set("cond","0")
st.player.setNoble(true)
st.giveItems(NOBLESSE_ID,1)
st.set("onlyone","1")
st.setState(COMPLETED)
st.playSound("ItemSound.quest_finish")
return htmltext
QUEST = Quest(247,"247_PossessorOfPreciousSoul4","Possessor Of Precious Soul 4")
CREATED = State('Start', QUEST)
STARTING = State('Starting', QUEST)
STARTED = State('Started', QUEST)
COMPLETED = State('Completed', QUEST)
QUEST.setInitialState(CREATED)
QUEST.addStartNpc(8740)
STARTING.addTalkId(8740)
STARTED.addTalkId(8740)
STARTED.addTalkId(8745)
STARTED.addQuestDrop(8745,NOBLESSE_ID,1)
i am Using L2j C4.
download the file from here: http://gsp-l2.do.am/247_PossessorOfPreciousSoul4.rar
4 answers to this question
Recommended Posts