a0905265000 發表於 2019-7-31 00:55

[教學] 在線一段時間後給予道具

L1SkillId

加入

/** 在線一段時間後給予一個狀態(自訂) */
public static final int LOGIN_TIME_GET_ITEM = 9000;


L1SkillTimer



料理?係

在上面加入

else if (skillId == LOGIN_TIME_GET_ITEM) { // 在線一段時間後給予道具
if (Config.OnLine_Accumulate_Time) {
if (cha instanceof L1PcInstance) {
L1PcInstance pc = (L1PcInstance) cha;
L1ItemInstance item = ItemTable.getInstance().createItem(
Config.O_L_A_T_Item);
item.setCount(1);
if (item != null) {
if (pc.getInventory().checkAddItem(item, 1) == L1Inventory.OK) {
pc.getInventory().storeItem(item);
} else { // 持???場合?地面?落?? 處理??????????(不正防止)
L1World.getInstance()
.getInventory(pc.getX(), pc.getY(),
pc.getMapId()).storeItem(item);
}
pc.sendPackets(new S_ServerMessage(403, item
.getLogName())); // %0?手?入
}
}
cha.setSkillEffect(L1SkillId.LOGIN_TIME_GET_ITEM,
Config.O_L_A_T_Time * 1000); // N分鐘
}
}

C_LoginToServer
宣告

import static l1j.server.server.model.skill.L1SkillId.LOGIN_TIME_GET_ITEM; // 在線一段時間後給予一個狀態



public static void items(L1PcInstance pc) {

在上面加入

// 在線一段時間後給予道具 by 丫傑
if (Config.OnLine_Accumulate_Time) {
if (!pc.hasSkillEffect(LOGIN_TIME_GET_ITEM)) {
pc.setSkillEffect(LOGIN_TIME_GET_ITEM,
Config.O_L_A_T_Time * 1000); // N分鐘
}
}
// end



Config
位置我放在(//othersettings.properties)

加入1

public static boolean OnLine_Accumulate_Time; // 設定在線一段時間後是否給予道具
public static short O_L_A_T_Time; // 累積時間
public static int O_L_A_T_Item; // 發送道具編號

加入2

OnLine_Accumulate_Time = Boolean.parseBoolean(otherSettings
.getProperty("OnLineAccumulateTime", "false")); // 設定在線一段時間後是否給予道具
O_L_A_T_Time = Short.parseShort(otherSettings.getProperty(
"OLATTime", "3600")); // 累積時間
O_L_A_T_Item = Integer.parseInt(otherSettings.getProperty(
"OLATItem", "60000")); // 發送道具編號

加入3

} else if (pName.equalsIgnoreCase("OnLineAccumulateTime")) {
OnLine_Accumulate_Time = Boolean.valueOf(pValue); // 設定在線一段時間後是否給予道具
} else if (pName.equalsIgnoreCase("OLATTime")) {
O_L_A_T_Time = Short.valueOf(pValue); // 累積時間
} else if (pName.equalsIgnoreCase("OLATItem")) {
O_L_A_T_Item = Short.valueOf(pValue); // 發送道具編號

最後

模擬器開啟

config資料夾



othersettings.properties檔

加入

#a-設定在線一段時間後是否給予道具? True=是, False=否
OnLineAccumulateTime = True
#b-累積時間 (單位:秒)
OLATTime = 900
#c-發送道具編號 (item_id)
OLATItem = 40733


完成!!!

鬼子傳說 發表於 2019-8-6 08:54

感謝無私分享
L1SkillId

加入

/** 在線一段時間後給予一個狀態(自訂) */
public static final int LOGIN_TIME_GET_ITEM = 9000;


L1SkillTimer



料理?係

在上面加入

else if (skillId == LOGIN_TIME_GET_ITEM) { // 在線一段時間後給予道具
if (Config.OnLine_Accumulate_Time) {
if (cha instanceof L1PcInstance) {
L1PcInstance pc = (L1PcInstance) cha;
L1ItemInstance item = ItemTable.getInstance().createItem(
Config.O_L_A_T_Item);
item.setCount(1);
if (item != null) {
if (pc.getInventory().checkAddItem(item, 1) == L1Inventory.OK) {
pc.getInventory().storeItem(item);
} else { // 持???場合?地面?落?? 處理??????????(不正防止)
L1World.getInstance()
.getInventory(pc.getX(), pc.getY(),
pc.getMapId()).storeItem(item);
}
pc.sendPackets(new S_ServerMessage(403, item
.getLogName())); // %0?手?入
}
}
cha.setSkillEffect(L1SkillId.LOGIN_TIME_GET_ITEM,
Config.O_L_A_T_Time * 1000); // N分鐘
}
}

C_LoginToServer
宣告

import static l1j.server.server.model.skill.L1SkillId.LOGIN_TIME_GET_ITEM; // 在線一段時間後給予一個狀態



public static void items(L1PcInstance pc) {

在上面加入

// 在線一段時間後給予道具 by 丫傑
if (Config.OnLine_Accumulate_Time) {
if (!pc.hasSkillEffect(LOGIN_TIME_GET_ITEM)) {
pc.setSkillEffect(LOGIN_TIME_GET_ITEM,
Config.O_L_A_T_Time * 1000); // N分鐘
}
}
// end



Config
位置我放在(//othersettings.properties)

加入1

public static boolean OnLine_Accumulate_Time; // 設定在線一段時間後是否給予道具
public static short O_L_A_T_Time; // 累積時間
public static int O_L_A_T_Item; // 發送道具編號

加入2

OnLine_Accumulate_Time = Boolean.parseBoolean(otherSettings
.getProperty("OnLineAccumulateTime", "false")); // 設定在線一段時間後是否給予道具
O_L_A_T_Time = Short.parseShort(otherSettings.getProperty(
"OLATTime", "3600")); // 累積時間
O_L_A_T_Item = Integer.parseInt(otherSettings.getProperty(
"OLATItem", "60000")); // 發送道具編號

加入3

} else if (pName.equalsIgnoreCase("OnLineAccumulateTime")) {
OnLine_Accumulate_Time = Boolean.valueOf(pValue); // 設定在線一段時間後是否給予道具
} else if (pName.equalsIgnoreCase("OLATTime")) {
O_L_A_T_Time = Short.valueOf(pValue); // 累積時間
} else if (pName.equalsIgnoreCase("OLATItem")) {
O_L_A_T_Item = Short.valueOf(pValue); // 發送道具編號

最後

模擬器開啟

config資料夾



othersettings.properties檔

加入

#a-設定在線一段時間後是否給予道具? True=是, False=否
OnLineAccumulateTime = True
#b-累積時間 (單位:秒)
OLATTime = 900
#c-發送道具編號 (item_id)
OLATItem = 40733

瑪奇 發表於 2019-8-6 10:43

謝謝分享

洛特希爾 發表於 2019-8-11 20:10

筆記一下,謝謝

SZX3310 發表於 2019-8-11 20:39

謝謝分享

19870922 發表於 2019-8-11 22:11

感謝分享

bennyst 發表於 2021-7-16 16:17

ga782200 發表於 2023-4-20 21:37

感謝大大分享

lesa1234 發表於 2023-7-4 23:24

謝謝分享

a12538967 發表於 2023-10-27 13:15

感謝分享

755263 發表於 2023-10-27 13:41

好複雜阿

zzzzzz 發表於 2023-11-28 12:21

多謝你的分享 讓我好想下載玩玩看
頁: [1]
查看完整版本: [教學] 在線一段時間後給予道具