跳转到帖子
Facebook Instagram Twitter Youtube

[L2J] 新手奖励npc脚本[搜集于互联网]


杀气丶

已推荐帖子

  • VIP
package seidhe.NewbieManager;



import ru.catssoftware.gameserver.model.quest.Quest;
import ru.catssoftware.gameserver.model.quest.QuestState;
import ru.catssoftware.L2DatabaseFactory;
import ru.catssoftware.gameserver.model.actor.instance.L2PcInstance;
import ru.catssoftware.gameserver.model.actor.instance.L2NpcInstance;


import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;


/**
* @ author : Seidhe
* @ date 05.09.2015 
* NewbieManager for lucera. 
*/
public class NewbieManager extends Quest 
{
        private static String qn = "NewbieManager";

        private static int NEWBIE_Wings = 4037; // ID Крыльев
        private static int NEWBIE_Helm = 57; // ID Шлема
        private static int NEWBIE_Tattoo = 4037; // ID Тату
        private static int NPC_ID = 50030; // ID NPC

        
        public NewbieManager() 
        {
                super(-1,qn,"custom");                
        }
        
        @Override
        public String onAdvEvent(String event, L2NpcInstance npc, L2PcInstance player) 
        {
                String []args = event.split(" ");

                if(args[0].startsWith("add_bonus")) {
                
                Connection con = null;
                ResultSet rset = null;
                try
                {
                        con = L2DatabaseFactory.getInstance().getConnection(con);
                        PreparedStatement statement = con.prepareStatement("SELECT isNewbie FROM `_newbie` WHERE charId=?");
                        statement.setInt(1,player.getObjectId());
                        rset = statement.executeQuery();
                        int isN=0;
                        while(rset.next())
                        {
                                isN= rset.getInt("isNewbie");
                        }
                        
                        if(isN==1){
                        statement = con.prepareStatement("REPLACE INTO _newbie VALUES(?,?)");
                        statement.setInt(1, player.getObjectId());
                        statement.setInt(2, 0);


                        player.getInventory().addItem("Newbie_Bonus", NEWBIE_Wings, 1, player, player);
                        player.getInventory().addItem("Newbie_Bonus", NEWBIE_Helm, 1, player, player);
                        player.getInventory().addItem("Newbie_Bonus", NEWBIE_Tattoo, 1, player, player);
                        
                        statement.executeQuery();
                        player.sendMessage("Желаю удачи, новичёк!");
                        statement.close();

                
                        }


                        
                        else if (isN==0) {
                                player.sendMessage("Вы уже получили награду");
                                return "hello.htm";
                        }


                        
                }
                catch (Exception e)
                {
                        e.printStackTrace();
                }

        }

                return "hello.htm";
        }
        
        @Override 
        public String onFirstTalk(L2NpcInstance npc, L2PcInstance player) 
        {
                return onTalk(npc, player);
        }
        
        @Override
        public String onTalk(L2NpcInstance npc, L2PcInstance player) 
        {
                QuestState qs = player.getQuestState(qn);
                if(qs==null)
                        qs = newQuestState(player);
                return "hello.htm";
        }
        
        public static void main(String[] args) 
        {
                NewbieManager ps = new NewbieManager();
                ps.addFirstTalkId(NPC_ID); 
                ps.addStartNpc(NPC_ID); 
                ps.addTalkId(NPC_ID); 
                _log.info("========================================");
                _log.info("=== Newbie Manager by Seidhe LOADING ===");
                _log.info("========================================");
        }

}

 

意见的链接
分享到其他站点

参与讨论

你可以现在发布并稍后注册。 如果你有帐户,现在就登录发布帖子。

游客
回帖…

×   粘贴为富文本.   粘贴为纯文本来代替

  只允许使用75个表情符号.

×   你的链接已自动嵌入.   显示为链接来代替

×   你之前的帖子已恢复.   清除编辑器

×   你无法直接粘贴图像。要从网址上传或插入图像。

天堂2中文开源社区L2FATER.CN

专注于玩家游戏体验的交流社区.

血玫瑰社区bbs.l2fater.cn

关于血玫瑰社区

Important Links

×
×
  • 创建新的...