新手奖励npc脚本[搜集于互联网]
新手奖励npc脚本[搜集于互联网]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.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("========================================");
}
}
路过顶一下!~ 載點已經失效了 710923 发表于 2022-5-20 12:44
載點已經失效了
直接复制啊
页:
[1]