Checking spawn

Support for the latest build of L2J Server, get help here with installations, upgrades, problems.
Do not post bugs reports here, use viewforum.php?f=77 instead.
There is no support for other server builds than the official provided by l2jserver.com
Forum rules
READ NOW: L2j Forums Rules of Conduct
User avatar
DreamStage
Posts: 222
Joined: Mon Oct 11, 2010 2:38 am
Location: Portugal

Checking spawn

Post by DreamStage »

If you want to receive support we need this info to help you properly.
» Find Revision
L2J Revision 4422:
L2JDP Revision 7669:

Hello L2J Community!

Does anyone knows how can i know if npc is spawned?
For example: i added new spawn, but know i want to check if hes spawned.

Thx
Ignorance comes when you dont want to know the truth about facts.
User avatar
MELERIX
L2j Veteran
L2j Veteran
Posts: 6667
Joined: Sat Sep 23, 2006 11:31 pm
Location: Chile
Contact:

Re: Checking spawn

Post by MELERIX »

search npc in spawnlist table.
User avatar
DreamStage
Posts: 222
Joined: Mon Oct 11, 2010 2:38 am
Location: Portugal

Re: Checking spawn

Post by DreamStage »

not like that :D

i mean inside a script!
Ignorance comes when you dont want to know the truth about facts.
User avatar
tukune
Posts: 533
Joined: Sun Mar 29, 2009 2:35 pm
Location: Japan

Re: Checking spawn

Post by tukune »

:shock: login gameserver
User avatar
DreamStage
Posts: 222
Joined: Mon Oct 11, 2010 2:38 am
Location: Portugal

Re: Checking spawn

Post by DreamStage »

IN JAVA / Python CODE my dear
Ignorance comes when you dont want to know the truth about facts.
User avatar
SolidSnake
Posts: 865
Joined: Wed Jan 20, 2010 6:54 pm
Location: Italy

Re: Checking spawn

Post by SolidSnake »

MELERIX wrote:search npc in spawnlist table.
As MELERIX said, just search the npc in the spawnlist table:

Code: Select all

import com.l2jserver.gameserver.datatables.SpawnTable;import com.l2jserver.gameserver.model.L2Spawn;import com.l2jserver.gameserver.model.actor.L2Npc;     @SuppressWarnings("unused")    public boolean checkNpcSpawn()    {        L2Npc npc;        for (L2Spawn spawn : SpawnTable.getInstance().getSpawnTable())        {            if (spawn != null)            {                if (spawn.getNpcid() == YOURID)                {                    npc = spawn.getLastSpawn();                    if (npc != null)                        return true;                }            }        }        return false;    }
So if you want to do something after checking the npc spawn:

Code: Select all

if (checkNpcSpawn())your code
Last edited by SolidSnake on Sat Aug 06, 2011 1:04 pm, edited 2 times in total.
Image
User avatar
DreamStage
Posts: 222
Joined: Mon Oct 11, 2010 2:38 am
Location: Portugal

Re: Checking spawn

Post by DreamStage »

3 Errors:
for (L2Spawn spawn : SpawnTable.getInstance().getSpawnTable())

L2Spawn cannot be resolved to a type

for (L2Spawn spawn : SpawnTable.getInstance().getSpawnTable())

SpawnTable cannot be resolved to a type

if (!checkNpcSpawn)

checkNpcSpawn cannot be resolved to a variable
Ignorance comes when you dont want to know the truth about facts.
User avatar
SolidSnake
Posts: 865
Joined: Wed Jan 20, 2010 6:54 pm
Location: Italy

Re: Checking spawn

Post by SolidSnake »

Import l2spawn and spawntable. I forgot to write () on checkNpcSpawn -> "checkNpcSpawn()"
Image
User avatar
DreamStage
Posts: 222
Joined: Mon Oct 11, 2010 2:38 am
Location: Portugal

Re: Checking spawn

Post by DreamStage »

Now i only have 1 error:
for (L2Spawn spawn : SpawnTable.getInstance().getSpawnTable())

Can only iterate over an array or an of java.lang.Iterable
Dont you need to create a fast list? like at foursepulcher java file?
Ignorance comes when you dont want to know the truth about facts.
User avatar
SolidSnake
Posts: 865
Joined: Wed Jan 20, 2010 6:54 pm
Location: Italy

Re: Checking spawn

Post by SolidSnake »

Post updated with all the imports and the complete code
Image
User avatar
DreamStage
Posts: 222
Joined: Mon Oct 11, 2010 2:38 am
Location: Portugal

Re: Checking spawn

Post by DreamStage »

Code: Select all

/* * 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/>. */ /** *  changed by DreamStage (fixed sort of retail) */package hellbound.Galate;  import com.l2jserver.gameserver.instancemanager.HellboundManager;import com.l2jserver.gameserver.Announcements;import com.l2jserver.gameserver.model.actor.L2Npc;import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;import com.l2jserver.gameserver.model.quest.Quest;import com.l2jserver.gameserver.model.quest.QuestState;import com.l2jserver.gameserver.model.L2Spawn;import com.l2jserver.gameserver.datatables.SpawnTable; /** * @author theOne */public class Galate extends Quest{    private static final int Galate = 32292;    private int WARPGATEAZUL = 32314;    private int WARPGATEAZULESCURO = 32315;    private int WARPGATELILAZ = 32316;    private int WARPGATEAMARELO = 32317;    private int WARPGATEVERDECLARO = 32318;    private int WARPGATEVERDEESCURO = 32319;    private boolean checked = false;    private int points = 0;    private int nowLevel = 0;    private int nowTrust = 0;    private int showTrust = 0;    private int firstTrust = 0;    private L2Npc _warpgateazulum, _warpgateazuldois, _warpgateazultres, _warpgateazulescuroum, _warpgateazulescurodois, _warpgateazulescurotres, _warpgatelilazum, _warpgatelilazdois, _warpgatelilaztres, _warpgateamareloum, _warpgateamarelodois, _warpgateamarelotres, _warpgateverdeclaroum, _warpgateverdeclarodois, _warpgateverdeclarotres, _warpgateverdeescuroum, _warpgateverdeescurodois, _warpgateverdeescurotres;    public Galate(int id, String name, String descr)    {        super(id, name, descr);        addStartNpc(Galate);        addTalkId(Galate);        addFirstTalkId(Galate);        int hellboundLevel = HellboundManager.getInstance().getLevel();        points = HellboundManager.getInstance().getTrust();        if (hellboundLevel >= 0)        {            startQuestTimer("CheckPoints", 500, null, null, true);            startQuestTimer("pontoszero", 500, null, null, true);            startQuestTimer("pontosdois", 500, null, null, true);            startQuestTimer("pontostres", 500, null, null, true);            startQuestTimer("pontosquatro", 500, null, null, true);            startQuestTimer("pontoscinco", 500, null, null, true);        }    }                public boolean checkNpcSpawn()        {            for (L2Spawn spawn : SpawnTable.getInstance().getSpawnTable())                if (spawn != null)                    if (spawn.getNpcid() == 32319)                        return true;            return false;        }            @Override    public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)    {        String htmltext = "";        QuestState st = null;        points = HellboundManager.getInstance().getTrust();        if (player != null)        {            st = player.getQuestState(getName());             if (st == null)                st = newQuestState(player);        }         if (event.equalsIgnoreCase("cf"))        {            long CF = st.getQuestItemsCount(9693);            if ((int)CF >= 1)            {                st.takeItems(9693,1);                long trustam = (10 * 1);                points += trustam;                _log.info(getClass().getSimpleName() + ": Current points - " + points);                HellboundManager.getInstance().increaseTrust((int)(int)trustam);                showTrust = HellboundManager.getInstance().getTrust();                _log.info(getClass().getSimpleName() + ": Current Hellbound Trust - " + showTrust);                htmltext = "<html><body>Galate:<br>Thank you for Contributting, warpagate will be opened soon.<br>(You can only contribute 1 crystal each time)</body></html>";            }            else            {                htmltext = "<html><body>Galate:<br>You dont have Crystal Fragments.</body></html>";            }        }        else if (event.equalsIgnoreCase("bc"))        {            long BC = st.getQuestItemsCount(9695);            if ((int)BC >= 1)            {                st.takeItems(9695,1);                long trustam = (50 * 1);                points += trustam;                _log.info(getClass().getSimpleName() + ": Current points - " + points);                HellboundManager.getInstance().increaseTrust((int)(int)trustam);                showTrust = HellboundManager.getInstance().getTrust();                _log.info(getClass().getSimpleName() + ": Current Hellbound Trust - " + showTrust);                htmltext = "<html><body>Galate:<br>Thank you for Contributting, warpagate will be opened soon.<br>(You can only contribute 1 crystal each time)</body></html>";            }            else            {                htmltext = "<html><body>Galate:<br>You dont have Blue Crystals.</body></html>";            }        }        else if (event.equalsIgnoreCase("rc"))        {            long RC = st.getQuestItemsCount(9696);            if ((int)RC >= 1)            {                st.takeItems(9696,1);                long trustam = (100 * 1);                points += trustam;                _log.info(getClass().getSimpleName() + ": Current points - " + points);                HellboundManager.getInstance().increaseTrust((int)(int)trustam);                showTrust = HellboundManager.getInstance().getTrust();                _log.info(getClass().getSimpleName() + ": Current Hellbound Trust - " + showTrust);                htmltext = "<html><body>Galate:<br>Thank you for Contributting, warpagate will be opened soon.<br>(You can only contribute 1 crystal each time)</body></html>";            }            else            {                htmltext = "<html><body>Galate:<br>You dont have Red Crystals.</body></html>";            }        }        else if (event.equalsIgnoreCase("cc"))        {            long CC = st.getQuestItemsCount(9697);            if ((int)CC >= 1)            {                st.takeItems(9697,1);                long trustam = (200 * 1);                points += trustam;                _log.info(getClass().getSimpleName() + ": Current points - " + points);                HellboundManager.getInstance().increaseTrust((int)(int)trustam);                showTrust = HellboundManager.getInstance().getTrust();                _log.info(getClass().getSimpleName() + ": Current Hellbound Trust - " + showTrust);                htmltext = "<html><body>Galate:<br>Thank you for Contributting, warpagate will be opened soon.<br>(You can only contribute 1 crystal each time)</body></html>";            }            else            {                htmltext = "<html><body>Galate:<br>You dont have Clear Crystals.</body></html>";            }        }        else if (event.equalsIgnoreCase("pontoszero"))        {            if (!checked && points >= 0 && points < 20000)            {                cancelQuestTimers("pontoszero");                _warpgateazulum = addSpawn(WARPGATEAZUL,112080, 219568, -3664,0,false,0);                _warpgateazuldois = addSpawn(WARPGATEAZUL,-16899, 209827, -3640,0,false,0);                _warpgateazultres = addSpawn(WARPGATEAZUL, 82230, 148604, -3467,0,false,0);            }        }        else if (event.equalsIgnoreCase("pontosdois"))        {            if (!checked && points >= 20000 && points < 40000)            {                cancelQuestTimers("pontosdois");                _warpgateazulescuroum = addSpawn(WARPGATEAZULESCURO,112080, 219568, -3664,0,false,0);                _warpgateazulescurodois = addSpawn(WARPGATEAZULESCURO,-16899, 209827, -3640,0,false,0);                _warpgateazulescurotres = addSpawn(WARPGATEAZULESCURO, 82230, 148604, -3467,0,false,0);                _warpgateazulum.deleteMe();                _warpgateazuldois.deleteMe();                _warpgateazultres.deleteMe();                Announcements.getInstance().announceToAll("Warpgate is now 20% energized!");             }        }        else if (event.equalsIgnoreCase("pontostres"))        {            if (!checked && points >= 40000 && points < 60000)            {                cancelQuestTimers("pontostres");                _warpgatelilazum = addSpawn(WARPGATELILAZ,112080, 219568, -3664,0,false,0);                _warpgatelilazdois = addSpawn(WARPGATELILAZ,-16899, 209827, -3640,0,false,0);                _warpgatelilaztres = addSpawn(WARPGATELILAZ, 82230, 148604, -3467,0,false,0);                _warpgateazulescuroum.deleteMe();                _warpgateazulescurodois.deleteMe();                _warpgateazulescurotres.deleteMe();                Announcements.getInstance().announceToAll("Warpgate is now 40% energized!");            }        }        else if (event.equalsIgnoreCase("pontosquatro"))        {            if (!checked && points >= 60000 && points < 80000)            {                cancelQuestTimers("pontosquatro");                _warpgateamareloum = addSpawn(WARPGATEAMARELO,112080, 219568, -3664,0,false,0);                _warpgateamarelodois = addSpawn(WARPGATEAMARELO,-16899, 209827, -3640,0,false,0);                _warpgateamarelotres = addSpawn(WARPGATEAMARELO, 82230, 148604, -3467,0,false,0);                _warpgatelilazum.deleteMe();                _warpgatelilazdois.deleteMe();                _warpgatelilaztres.deleteMe();                Announcements.getInstance().announceToAll("Warpgate is now 60% energized!");            }        }        else if (event.equalsIgnoreCase("pontoscinco"))        {            if (!checked && points >= 80000 && points < 100000)            {                cancelQuestTimers("pontoscinco");                _warpgateverdeclaroum = addSpawn(WARPGATEVERDECLARO,112080, 219568, -3664,0,false,0);                _warpgateverdeclarodois = addSpawn(WARPGATEVERDECLARO,-16899, 209827, -3640,0,false,0);                _warpgateverdeclarotres = addSpawn(WARPGATEVERDECLARO, 82230, 148604, -3467,0,false,0);                _warpgateamareloum.deleteMe();                _warpgateamarelodois.deleteMe();                _warpgateamarelotres.deleteMe();                Announcements.getInstance().announceToAll("Warpgate is now 80% energized!");                                if (checkNpcSpawn())                                {                                    _warpgateverdeescuroum.deleteMe();                                    _warpgateverdeescurodois.deleteMe();                                    _warpgateverdeescurotres.deleteMe();                                }            }        }        else if (event.equalsIgnoreCase("CheckPoints"))        {            if (!checked && points >= 100000)            {                checked = true;                HellboundManager.getInstance().changeLevel(1);                saveGlobalQuestVar("life_points", String.valueOf(points));                _warpgateverdeescuroum = addSpawn(WARPGATEVERDEESCURO,112080, 219568, -3664,0,false,0);                _warpgateverdeescurodois = addSpawn(WARPGATEVERDEESCURO,-16899, 209827, -3640,0,false,0);                _warpgateverdeescurotres = addSpawn(WARPGATEVERDEESCURO, 82230, 148604, -3467,0,false,0);                cancelQuestTimers("CheckPoints");                _warpgateverdeclaroum.deleteMe();                _warpgateverdeclarodois.deleteMe();                _warpgateverdeclarotres.deleteMe();                Announcements.getInstance().announceToAll("Warpgate is now 100% energized!");            }        }        else if (event.equalsIgnoreCase("cwp"))        {            firstTrust = HellboundManager.getInstance().getTrust();            if (firstTrust <= 99999)            {                 htmltext = "<html><body>Galate:<br><font color=\"CC0000\">Warpgate Energy Points:</font> <font color=\"CCCC00\">" + points + "</font><br><font color=\"CC0000\">Warpgate Maximum Energy:</font> <font color=\"CCCC00\">100000</font></body></html>";            }            else                htmltext = "<html><body>Warpgate not Opened Yet.</body></html>";        }        else if (event.equalsIgnoreCase("cp"))        {            nowLevel = HellboundManager.getInstance().getLevel();            nowTrust = HellboundManager.getInstance().getTrust();            if (nowTrust >= 100000)            {                 htmltext = "<html><body>Galate:<br><font color=\"CC0000\">Hellbound Stage:</font> <font color=\"CCCC00\">" + nowLevel + "</font><br><font color=\"CC0000\">Hellbound Trust:</font> <font color=\"CCCC00\">" + nowTrust + "</font></body></html>";            }            else                htmltext = "<html><body>Warpgate not Opened Yet.</body></html>";        }         return htmltext;    }    @Override    public String onTalk(L2Npc npc, L2PcInstance player)    {        String htmltext = "";        int hellboundTrust = HellboundManager.getInstance().getTrust();        if (hellboundTrust <= 99999)            htmltext = "32292-2.htm";         return htmltext;    }     @Override    public String onFirstTalk(L2Npc npc, L2PcInstance player)    {        String htmltext = "";         int hellboundTrust = HellboundManager.getInstance().getTrust();        if (hellboundTrust <= 99999)            htmltext = "32292.htm";        else if (hellboundTrust >= 100000)            htmltext = "32292-1.htm";         return htmltext;    }     public static void main(String[] args)    {        new Galate(-1, "Galate", "hellbound");    }}
Ignorance comes when you dont want to know the truth about facts.
User avatar
SolidSnake
Posts: 865
Joined: Wed Jan 20, 2010 6:54 pm
Location: Italy

Re: Checking spawn

Post by SolidSnake »

:?:
Image
User avatar
DreamStage
Posts: 222
Joined: Mon Oct 11, 2010 2:38 am
Location: Portugal

Re: Checking spawn

Post by DreamStage »

That is the code my friend, wich i made and fixed from the Hellbound.java from L2JDP.

I just want to know how to fix the dam spawn, because i have a null spawn and i want to make a condition to check if its spawned or not!
Ignorance comes when you dont want to know the truth about facts.
User avatar
SolidSnake
Posts: 865
Joined: Wed Jan 20, 2010 6:54 pm
Location: Italy

Re: Checking spawn

Post by SolidSnake »

Can you upload it as an attachment?
Image
User avatar
DreamStage
Posts: 222
Joined: Mon Oct 11, 2010 2:38 am
Location: Portugal

Re: Checking spawn

Post by DreamStage »

Check ur private messages.

Btw check what i wrote about my other problem, at your private messages 8)
Ignorance comes when you dont want to know the truth about facts.
Post Reply