Jump to content
  • 0

[Help] Script for Event


Question

Posted

Hi guys , i have find this event (Last man standing):

 

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 import Quest
from net.sf.l2j.gameserver.datatables import DoorTable
from net.sf.l2j.gameserver.datatables import SkillTable
from net.sf.l2j.gameserver.model.quest.jython import QuestJython as JQuest
from net.sf.l2j.gameserver import Announcements
from net.sf.l2j import L2DatabaseFactory
from net.sf.l2j.gameserver.ai import CtrlIntention
from net.sf.l2j.util import Rnd
from java.lang import System
from net.sf.l2j.gameserver.model import L2World
from net.sf.l2j.gameserver.model.actor.instance import L2DoorInstance
from net.sf.l2j.gameserver.datatables import DoorTable;

qn = "777_LastHero"

# =======================================#
#              Config Event              #
# =======================================#
# The Name Of Event
#Default : LastHero
Event_name = "LastManStanding" 

# Registration Event 
#Default : Giran
StartLocation = "Giran" 

# ID Npc 
Reg_Npc = 77777

# Coordinat npc registration
StartNpcCoordinat = [82698,148638,-3468] 

# Price for partecipation.
# Partecipation item [itemId1,itemId2,....]
Price = [5575,57]

# Ñêîëüêî çàäàííûõ âåùåé íåîáõîäèìûõ äëÿ ó÷àñòèÿ â Ýâåíòå. Åñëè õîòèòå ÷òîáû ó÷àñòèå áûëî áåñïëàòíûì - ïîñòàâòå 0.
# Ôîðìàò çàïèñè [itemId1_count,itemId2_count,....]
Price_count = [0,5]

# Min Level for partecipation.
Min_level = 40 

# After Restart the event will start)
Time_to_start_after_restart = 120

# Time to wait begin battle
Time_to_wait_battle = 35

# Time to next start event
Time_to_next_start = 60

# Time for registration (minutes).
Time_for_regestration = 5

# Announce (in seconds) the event partecipation
Announce_reg_delay = 60

# Min partecipate for start event
Min_participate_count = 2

# Max partecipate in the event.
Max_participate_count = 40

# Reward for win battle 
# Apply this : [[itemId1,count1,chance1],[itemId2,count2,chanceN],...]
Rewards = [[4356,500,100],[6393,100,100]] 

# Teleport partecipants at this coordinate
Teleport_coordinat = [149438, 46785, -3413]

# Door of events stats
# Apply this : [Door_id1,Door_id2,...]
Doors = [24190002,24190003]


# ================Information================ #
lastPlayers = []
lastX = []
lastY = []
lastZ = []
closed = 1
Players = []
Deadplayers = []
annom = 1

class Quest (JQuest) :
def __init__(self,id,name,descr): JQuest.__init__(self,id,name,descr)

def init_LoadGlobalData(self) :
   self.startQuestTimer("open_reg", Time_to_start_after_restart *1000, None, None)
   return

def onTalk (Self,npc,player):
  global Players,closed
  st = player.getQuestState(qn)
  npcId = npc.getNpcId()
  if npcId == Reg_Npc:
   if closed<>1:
    if not player.isInOlympiadMode() :
     if player.getLevel() >= Min_level:
      if player.getName() not in Players:
       if len(Players) <= Max_participate_count :
        if Price_count[0]<>0:   
         if st.getQuestItemsCount(Price[0])>Price_count[0]:
           st.takeItems(Price[0],Price_count[0])
           Players.append(player.getName())
           return "reg.htm"
         else:
           st.exitQuest(1)
           return "noPrice.htm"
        else:
            Players.append(player.getName())
            return "reg.htm"
       else:		 
         return "max.htm"
      else:
       return "yje.htm"
     else:
      return "lvl.htm"
    else:
     return "You register in olympiad games now"
   else:
    return "noreg.htm"
  return

def onAdvEvent (self,event,npc,player):
   global Deadplayers,Players,annom,closed,Doors,lastPlayers,lastX,lastY,lastZ
   if event == "open_reg" :
    closed = 0
    annom = 1
    lastPlayers = []
    Players = []
    Deadplayers = []
    lastX = []
    lastY = []
    lastZ = []
    npc = self.addSpawn(Reg_Npc,StartNpcCoordinat[0],StartNpcCoordinat[1],StartNpcCoordinat[2],30000,False,0)
    self.startQuestTimer("wait_battle", Time_for_regestration*60000, npc, None)
    self.startQuestTimer("announce", Announce_reg_delay*1000, None, None)
    Announcements.getInstance().announceToAll("Opened registration "+str(Event_name)+" event! Register in "+str(StartLocation)+".")
   if event == "start_event":
    if len(Players)< Min_participate_count :
      closed=1
      Announcements.getInstance().announceToAll("Event "+str(Event_name)+" was canceled due lack of participation.")
      self.startQuestTimer("set_winner", 1000, None, None)
      self.startQuestTimer("open_reg", Time_to_next_start*60000, None, None)
    else:
      closed=1
      Announcements.getInstance().announceToAll("Event "+str(Event_name)+" started!")
      for nm in Players :
       i=L2World.getInstance().getPlayer(nm)
       if i<>None:
        if i.isOnline() :
	 i.getAppearance().setVisible()
	 i.broadcastStatusUpdate()
	 i.broadcastUserInfo()
      while len(Players)>1 :
       for nm in Players :
        i=L2World.getInstance().getPlayer(nm)
        if i<>None:
     if i.isDead():
	  i.reviveAnswer(0)
	  Deadplayers.append(i.getName())
	  Players.remove(i.getName())
      self.startQuestTimer("set_winner", 1000, None, None)
   if event == "announce" and closed==0 and (Time_for_regestration*60 - Announce_reg_delay * annom)>0: 
     Announcements.getInstance().announceToAll(str(Time_for_regestration*60 - Announce_reg_delay * annom ) + " seconds until event "+str(Event_name)+" will start! You can register in "+str(StartLocation)+".")
     annom=annom+1
     self.startQuestTimer("announce", Announce_reg_delay*1000, None, None)
   if event == "set_winner" :
     if len(Players) > 0 and len(Players + Deadplayers) >= Min_participate_count:
         winner=L2World.getInstance().getPlayer(Players[0])
         Deadplayers.append(Players[0])
         if winner.isDead():
             Announcements.getInstance().announceToAll("Event "+str(Event_name)+" has ended. All players is dead. Nobody Win")
         else :
             Announcements.getInstance().announceToAll("Event "+str(Event_name)+" has ended.")
             Announcements.getInstance().announceToAll("Event: "+str(Players[0])+" win, Gf!")
         for nm in Deadplayers :
             i=L2World.getInstance().getPlayer(nm)
             if i<>None and i.isOnline():
                 if i.isDead():
                     i.doRevive()
                 i.setCurrentCp(i.getMaxCp())
                 i.setCurrentHp(i.getMaxHp())
                 i.setCurrentMp(i.getMaxMp())
                 i.stopAllEffects()
                 i.broadcastStatusUpdate()
                 i.broadcastUserInfo()
         if len(Deadplayers)>0:
             n = 0
             for nm in lastPlayers :
                 i=L2World.getInstance().getPlayer(nm)
                 i.teleToLocation(lastX[n],lastY[n],lastZ[n])
                 n = n + 1
         if winner<>None:
           if winner.isOnline() :
             for id, count, chance in Rewards :
               winner.getQuestState(qn).giveItems(id,count)
     Announcements.getInstance().announceToAll("Next time registration opend at "+str(Time_to_next_start)+" minute(s)")
     for d in Doors:
         door = DoorTable.getInstance().getDoor(d)
         door.openMe()
     lastPlayers = []
     Players = []
     Deadplayers = []
     lastX = []
     lastY = []
     lastZ = []
     self.startQuestTimer("open_reg", Time_to_next_start*60000, None, None)
   if event == "exit" :
     if player.getName() in Players:
       Players.remove(player.getName())
       return "exit.htm"
     else:
       return "default.htm"
   if event == "wait_battle":
    npc.deleteMe()
    if len(Players) >= Min_participate_count:
      for nm in Players:
        i=L2World.getInstance().getPlayer(nm)
        if i<>None:
          if not i.isOnline() or i.isInOlympiadMode() or i.isInJail():
            Players.remove(nm)
        else:
            Players.remove(nm)
      for nm in Players:
        i=L2World.getInstance().getPlayer(nm)
        if i<>None:
          if i.isOnline() :
            if i.isDead():
              i.doRevive()
            i.setCurrentCp(i.getMaxCp())
            i.setCurrentHp(i.getMaxHp())
            i.setCurrentMp(i.getMaxMp())
            i.stopAllEffects()
            i.getAppearance().setInvisible();
            i.broadcastStatusUpdate()
            i.broadcastUserInfo()
            lastPlayers.append(nm)
            lastX.append(i.getX())
            lastY.append(i.getY())
            lastZ.append(i.getZ())
            i.teleToLocation(Teleport_coordinat[0],Teleport_coordinat[1],Teleport_coordinat[2])
      for d in Doors:
        door = DoorTable.getInstance().getDoor(d)
        door.closeMe()
      Announcements.getInstance().announceToAll("Event "+str(Event_name)+": Registration close. You have "+str(Time_to_wait_battle)+" seconds for buffs before battle start")
      self.startQuestTimer("start_event", Time_to_wait_battle*1000, None, None)
    else :
        self.startQuestTimer("start_event", 1000, None, None)

QUEST = Quest(777, qn, "Custom")

QUEST.addStartNpc(int(Reg_Npc))
QUEST.addTalkId(int(Reg_Npc))

 

In this event , char can use potions and other items , what i can make for change? (char can't use cp pots ,mp pots , hp and scrolls)

Thanks

6 answers to this question

Recommended Posts

  • 0
Posted

well I think is something here. I selected with red

 

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 import Quest

from net.sf.l2j.gameserver.datatables import DoorTable

from net.sf.l2j.gameserver.datatables import SkillTable

from net.sf.l2j.gameserver.model.quest.jython import QuestJython as JQuest

from net.sf.l2j.gameserver import Announcements

from net.sf.l2j import L2DatabaseFactory

from net.sf.l2j.gameserver.ai import CtrlIntention

from net.sf.l2j.util import Rnd

from java.lang import System

from net.sf.l2j.gameserver.model import L2World

from net.sf.l2j.gameserver.model.actor.instance import L2DoorInstance

from net.sf.l2j.gameserver.datatables import DoorTable;

 

qn = "777_LastHero"

 

# =======================================#

#              Config Event              #

# =======================================#

# The Name Of Event

#Default : LastHero

Event_name = "LastManStanding"

 

# Registration Event

#Default : Giran

StartLocation = "Giran"

 

# ID Npc

Reg_Npc = 77777

 

# Coordinat npc registration

StartNpcCoordinat = [82698,148638,-3468]

 

# Price for partecipation.

# Partecipation item [itemId1,itemId2,....]

Price = [5575,57]

 

# Ñêîëüêî çàäàííûõ âåùåé íåîáõîäèìûõ äëÿ ó÷àñòèÿ â Ýâåíòå. Åñëè õîòèòå ÷òîáû ó÷àñòèå áûëî áåñïëàòíûì - ïîñòàâòå 0.

# Ôîðìàò çàïèñè [itemId1_count,itemId2_count,....]

Price_count = [0,5]

 

# Min Level for partecipation.

Min_level = 40

 

# After Restart the event will start)

Time_to_start_after_restart = 120

 

# Time to wait begin battle

Time_to_wait_battle = 35

 

# Time to next start event

Time_to_next_start = 60

 

# Time for registration (minutes).

Time_for_regestration = 5

 

# Announce (in seconds) the event partecipation

Announce_reg_delay = 60

 

# Min partecipate for start event

Min_participate_count = 2

 

# Max partecipate in the event.

Max_participate_count = 40

 

# Reward for win battle

# Apply this : [[itemId1,count1,chance1],[itemId2,count2,chanceN],...]

Rewards = [[4356,500,100],[6393,100,100]]

 

# Teleport partecipants at this coordinate

Teleport_coordinat = [149438, 46785, -3413]

 

# Door of events stats

# Apply this : [Door_id1,Door_id2,...]

Doors = [24190002,24190003]

 

 

# ================Information================ #

lastPlayers = []

lastX = []

lastY = []

lastZ = []

closed = 1

Players = []

Deadplayers = []

annom = 1

 

class Quest (JQuest) :

def __init__(self,id,name,descr): JQuest.__init__(self,id,name,descr)

 

def init_LoadGlobalData(self) :

  self.startQuestTimer("open_reg", Time_to_start_after_restart *1000, None, None)

  return

 

def onTalk (Self,npc,player):

  global Players,closed

  st = player.getQuestState(qn)

  npcId = npc.getNpcId()

  if npcId == Reg_Npc:

  if closed<>1:

    if not player.isInOlympiadMode() :

    if player.getLevel() >= Min_level:

      if player.getName() not in Players:

      if len(Players) <= Max_participate_count :

        if Price_count[0]<>0: 

        if st.getQuestItemsCount(Price[0])>Price_count[0]:

          st.takeItems(Price[0],Price_count[0])

          Players.append(player.getName())

          return "reg.htm"

        else:

          st.exitQuest(1)

          return "noPrice.htm"

        else:

            Players.append(player.getName())

            return "reg.htm"

      else:

        return "max.htm"

      else:

      return "yje.htm"

    else:

      return "lvl.htm"

    else:

    return "You register in olympiad games now"

  else:

    return "noreg.htm"

  return

 

def onAdvEvent (self,event,npc,player):

  global Deadplayers,Players,annom,closed,Doors,lastPlayers,lastX,lastY,lastZ

  if event == "open_reg" :

    closed = 0

    annom = 1

    lastPlayers = []

    Players = []

    Deadplayers = []

    lastX = []

    lastY = []

    lastZ = []

    npc = self.addSpawn(Reg_Npc,StartNpcCoordinat[0],StartNpcCoordinat[1],StartNpcCoordinat[2],30000,False,0)

    self.startQuestTimer("wait_battle", Time_for_regestration*60000, npc, None)

    self.startQuestTimer("announce", Announce_reg_delay*1000, None, None)

    Announcements.getInstance().announceToAll("Opened registration "+str(Event_name)+" event! Register in "+str(StartLocation)+".")

  if event == "start_event":

    if len(Players)< Min_participate_count :

      closed=1

      Announcements.getInstance().announceToAll("Event "+str(Event_name)+" was canceled due lack of participation.")

      self.startQuestTimer("set_winner", 1000, None, None)

      self.startQuestTimer("open_reg", Time_to_next_start*60000, None, None)

    else:

      closed=1

      Announcements.getInstance().announceToAll("Event "+str(Event_name)+" started!")

      for nm in Players :

      i=L2World.getInstance().getPlayer(nm)

      if i<>None:

        if i.isOnline() :

i.getAppearance().setVisible()

i.broadcastStatusUpdate()

i.broadcastUserInfo()

      while len(Players)>1 :

      for nm in Players :

        i=L2World.getInstance().getPlayer(nm)

        if i<>None:

    if i.isDead():

  i.reviveAnswer(0)

  Deadplayers.append(i.getName())

  Players.remove(i.getName())

      self.startQuestTimer("set_winner", 1000, None, None)

  if event == "announce" and closed==0 and (Time_for_regestration*60 - Announce_reg_delay * annom)>0:

    Announcements.getInstance().announceToAll(str(Time_for_regestration*60 - Announce_reg_delay * annom ) + " seconds until event "+str(Event_name)+" will start! You can register in "+str(StartLocation)+".")

    annom=annom+1

    self.startQuestTimer("announce", Announce_reg_delay*1000, None, None)

  if event == "set_winner" :

    if len(Players) > 0 and len(Players + Deadplayers) >= Min_participate_count:

        winner=L2World.getInstance().getPlayer(Players[0])

        Deadplayers.append(Players[0])

        if winner.isDead():

            Announcements.getInstance().announceToAll("Event "+str(Event_name)+" has ended. All players is dead. Nobody Win")

        else :

            Announcements.getInstance().announceToAll("Event "+str(Event_name)+" has ended.")

            Announcements.getInstance().announceToAll("Event: "+str(Players[0])+" win, Gf!")

        for nm in Deadplayers :

            i=L2World.getInstance().getPlayer(nm)

            if i<>None and i.isOnline():

                if i.isDead():

                    i.doRevive()

                i.setCurrentCp(i.getMaxCp())

                i.setCurrentHp(i.getMaxHp())

                i.setCurrentMp(i.getMaxMp())

                i.stopAllEffects()

                i.broadcastStatusUpdate()

                i.broadcastUserInfo()

        if len(Deadplayers)>0:

            n = 0

            for nm in lastPlayers :

                i=L2World.getInstance().getPlayer(nm)

                i.teleToLocation(lastX[n],lastY[n],lastZ[n])

                n = n + 1

        if winner<>None:

          if winner.isOnline() :

            for id, count, chance in Rewards :

              winner.getQuestState(qn).giveItems(id,count)

    Announcements.getInstance().announceToAll("Next time registration opend at "+str(Time_to_next_start)+" minute(s)")

    for d in Doors:

        door = DoorTable.getInstance().getDoor(d)

        door.openMe()

    lastPlayers = []

    Players = []

    Deadplayers = []

    lastX = []

    lastY = []

    lastZ = []

    self.startQuestTimer("open_reg", Time_to_next_start*60000, None, None)

  if event == "exit" :

    if player.getName() in Players:

      Players.remove(player.getName())

      return "exit.htm"

    else:

      return "default.htm"

  if event == "wait_battle":

    npc.deleteMe()

    if len(Players) >= Min_participate_count:

      for nm in Players:

        i=L2World.getInstance().getPlayer(nm)

        if i<>None:

          if not i.isOnline() or i.isInOlympiadMode() or i.isInJail():

            Players.remove(nm)

        else:

            Players.remove(nm)

      for nm in Players:

        i=L2World.getInstance().getPlayer(nm)

        if i<>None:

          if i.isOnline() :

            if i.isDead():

              i.doRevive()

            i.setCurrentCp(i.getMaxCp())

            i.setCurrentHp(i.getMaxHp())

            i.setCurrentMp(i.getMaxMp())

            i.stopAllEffects()

            i.getAppearance().setInvisible();

            i.broadcastStatusUpdate()

            i.broadcastUserInfo()

            lastPlayers.append(nm)

            lastX.append(i.getX())

            lastY.append(i.getY())

            lastZ.append(i.getZ())

            i.teleToLocation(Teleport_coordinat[0],Teleport_coordinat[1],Teleport_coordinat[2])

      for d in Doors:

        door = DoorTable.getInstance().getDoor(d)

        door.closeMe()

      Announcements.getInstance().announceToAll("Event "+str(Event_name)+": Registration close. You have "+str(Time_to_wait_battle)+" seconds for buffs before battle start")

      self.startQuestTimer("start_event", Time_to_wait_battle*1000, None, None)

    else :

        self.startQuestTimer("start_event", 1000, None, None)

 

QUEST = Quest(777, qn, "Custom")

 

QUEST.addStartNpc(int(Reg_Npc))

QUEST.addTalkId(int(Reg_Npc))

  • 0
Posted

Create your own .properties files info gameserver/config folder, like Event and the rest of stuff do... "fun_engines.properties"

 

Then create a var AllowPotionUseonEvent or something like that...  Store his content (True/False), Load his content on Java files LMS and make a restriction (function)...

 

Check how restriction on TvT are used with potions and copy/learning them...

 

Good luck...

  • 0
Posted

For example, you can create new boolean with seter/geter for L2PcInstance like

 

private boolean _isAtLMSEvent = false;

public boolean isAtLMS()
{
     return _isAtLMSEvent;
}

public void setAtLMS(boolean b)
{
     _isAtLMSEvent = b
}

 

Now edit code of your LMS event, and when player is participated to the LMS and event is started:

 

player.setAtLMS(true)

 

And now edit item handler or what ever is this for Potion and check, if

 

if (player.isAtLMS())

{

    //GTFO you will not use potions...

    return;

 

}

 

Its simple sample, or simply take a look how does TvT potion restriction works.

 

Btw, python suck...

 

  • 0
Posted

For example, you can create new boolean with seter/geter for L2PcInstance like

 

private boolean _isAtLMSEvent = false;

public boolean isAtLMS()
{
     return _isAtLMSEvent;
}

public void setAtLMS(boolean b)
{
     _isAtLMSEvent = b
}

 

Now edit code of your LMS event, and when player is participated to the LMS and event is started:

 

And now edit item handler or what ever is this for Potion and check, if

 

Its simple sample, or simply take a look how does TvT potion restriction works.

 

Btw, python suck...

 

 

Sure python suck xD but i haven't find last man standing in java :P

ps. Thx now i try

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

    • L2GOLD - Gold x45 C4 Project   C4 - Scions of Destiny: Protocol 656   Fully L2Gold Features - Daily Quest - Daily Mining Quest - Ancient Weapons -Refine System  -Rebirth System -Fully configurable everything you want -Gold stats/Gold skills/Gold items working 100% -Zones 100% alike  -Unique donations system (npc or voicedcommand .donate) - On Enchant success announcement ( if +16 for weapon, 8 for armor , 7 for jewel) - Announce of Castle Lord - Announce of Hero  - Olympiad Max A grade - Olympiad Buffs on matches changed to Gold Alike -Buff shop system on selling buffs with command .buffshop Shift+click dropinfo on mobs. and many more ingame addons.   Server is running a Test Server: Online to anyone can test it.   Game Client: https://www.mediafire.com/file/d0000rmt8ym0323/Lineage_2_C4_Client.rar/file   Game Patch: https://www.mediafire.com/file/39sojdex2mgj55k/L2Gold+Patch+C4.rar/file   GM Accounts: ID: root1 pass root1 [ accounts go from  root1 until root20 ]   Regular Accounts Registrations: http://84.247.164.27/?page=register   Some Screenshots: https://imgur.com/a/KSE4kdq   Contact me here via PM (only serious buyers).    Price of the product: Fully Server Pack + Source ( 200 Euros )
    • Https://lineage2dex.com Discord link : https://discord.com/channels/786506979493281794/814778540893536307/1424434670690504874 ## Dexters! **Our x25 server is celebrating its first week!** 🔥 Online stays strong at peak levels!  New players are joining every day, with 200+ new master accounts registered daily — amazing results! ✨ Tomorrow we launch a new episode along with the first event. Full details will be shared in the morning(October 6). 🎁 And for this little celebration, here’s a bonus code with a small gift for you! ## O05-IIW **Contains: ** * x3 - Training Potion 200% (20 min) * x200 - Mana Potions Loyatly (no weight) *The code will remain active until October 6, 7 AM(server time). And be sure, you have at less 20 slots free on inv before using a code.* **👉 How to redeem:** 1. Log in to your Master Account on site. 2. Click the Redeem Bonus Code button at the top of the panel, type code click redeem. 3. Select the account and character you want to receive the gift.  **Codes work only 1 time for 1 Master Account!** ### Enjoy your adventure, Dexters!
    • Complete Server Pack + Source Files:     C4 Scions Of Destiny: P656 Retail X1 L2OFF Server Pack + Source: Price: 70 EUR   C4 Scions Of Destiny: P656 ESL2 Athena x45 L2OFF Server Pack + Source: Price: 90 EUR Screenshots: https://imgur.com/a/eternal-sin-l2-athena-x45-c4-WYCpbjl   C6 Interlude: P746 ESL2 Athena x45 L2OFF Server Pack + Source: Price: 100EUR The same as C4 but in C6 Client so the Screenshots is the same: https://imgur.com/a/eternal-sin-l2-athena-x45-c4-WYCpbjl     C6 Interlude: P746 L2Gold L2OFF Server Pack + Source: Price: 50EUR Screenshots: https://imgur.com/a/9kB3oA9   C6 - Classic Interlude: P110 ESL2 Athena x45 L2OFF Server Pack + Source: Price: 100EUR Screenshots: https://imgur.com/a/Z2kZxuv   Contact me here via PM (only serious buyers). 
    • Where should I modify the IP to be able to put it online for testing?
    • I had issues with Smart Guard to, there is not even support in many cases.
  • 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