2013年6月8日 星期六

【Java教學】全體送禮物

如果模擬器內有 L1GameRestart.java 的話 

開頭加入 (抱歉之前忘記註明)

import l1j.server.server.GetNowTime; 
import l1j.server.server.serverpackets.S_SkillSound;

然後在 SetRemnant(i); 下面加入 

// 新年倒數 idea by missu0524 
int NextYear = GetNowTime.GetNowYear() + 1; 
int countdown = 10; 
if (GetNowTime.GetNowMonth() == 12 
&& GetNowTime.GetNowDay() == 31 
&& GetNowTime.GetNowHour() == 23 
&& GetNowTime.GetNowMinute() == 50 
&& GetNowTime.GetNowSecond() == 0) { 
while (countdown >= 0) { 
for (int i2 = 60; i2 >= 0; i2--) { // 執行61次 
if (countdown != 0 && i2 % 60 == 0 && i2 != 0) { 
BroadCastToAll("\\fU迎向 "+NextYear+" 新年倒數前 "+countdown+" 分鐘。"); 
System.out.println("迎向 "+NextYear+" 新年倒數前 "+countdown+" 分鐘。"); 
countdown--; 
} else if (countdown == 0 && i2 <= 59 && i2 != 0) { 
BroadCastToAll("\\fU迎向 "+NextYear+" 新年倒數前 "+i2+" 秒。"); 
System.out.println("迎向 "+NextYear+" 新年倒數前 "+i2+" 秒。"); 
} else if (countdown == 0 && i2 == 0) { 
BroadCastToAll("\\fW***** "+NextYear+" 新 年 快 樂 *****"); 
System.out.println("***** "+NextYear+" 新 年 快 樂 *****"); 
countdown--; 
for (L1PcInstance pc : L1World.getInstance().getAllPlayers()) { 
pc.sendPackets(new S_SkillSound(pc.getId(), 2047)); 
pc.broadcastPacket(new S_SkillSound(pc.getId(), 2047)); 
pc.getInventory().storeItem(60268, 1); 
pc.sendPackets(new S_SystemMessage("祝伺服器全體人員【"+NextYear+ 
"年】新年快樂,贈送禮物一份。")); 


try { 
Thread.sleep(1000); 
} catch (Exception e) { 
_log.log(Level.SEVERE, e.getLocalizedMessage(), e); 




// 新年倒數 優化 by terry0412 


這只具參考價值 

請重視別人心血別任意轉帖 by 
 terry0412

沒有留言:

張貼留言