caovanthanh22
09-11-16, 07:20 PM
Để cho cái script lua này chạy dc theo thời gian, ngoài khai bào ở script dat... ^^.. mình không biết làm thế nào cho nó hoạt động... mong các bác vô tình hay hữu tình đi qua đây giúp đỡ ạ ^^...
-- Vô Lßþng S½n
x002170_g_scriptId = 002170
x002170_g_AllBoss = {6}
x002170_g_BossSysMsgByGroupID={}
x002170_g_BossSysMsgByGroupID[1]={Msg="#cFF0000 Vô Lßþng S½n: #YTuyªn ð߶ng qua lÕi #cff6633ÐÕi Lý #Yvà #cff6633Kính H°cüa thß½ng nhân bang hµi #c0000FFTàTh¥n#Y. Chính là n½i ðây, ngay tÕi vùng ð¤t #cff6633Vô Lßþng S½n #Y này!!! Mµt miªng m°i ngon không th¬ bö qua... h·i các chiªn hæu! Chúng ta ði cß¾p tiêu thôi",isSended=0}
x002170_g_AllBoss[6]=
{
{ ID=45001, GroupId=1, Title="#-08#c00A8EBTàTh¥n Bang Chü", Name="Popi", PosX=45, PosY=170, BaseAI=1, Patrol=0, ExtAIScript=295, ScriptID=2107 },
{ ID=45012, GroupId=1, Title="#-07#c00A8EBTàTh¥n Nµi Vø SÑ", Name="XiTin", PosX=43, PosY=167, BaseAI=1, Patrol=1, ExtAIScript=300, ScriptID=2107 },
{ ID=45007, GroupId=1, Title="#-07#c00A8EBTàTh¥n Công Vø SÑ", Name="LéKim", PosX=45, PosY=173, BaseAI=1, Patrol=2, ExtAIScript=304, ScriptID=2107 },
{ ID=45013, GroupId=1, Title="#-06#c00A8EBTàTh¥n Thß½ng Nhân", Name="cTiêu", PosX=41, PosY=173, BaseAI=1, Patrol=3, ExtAIScript=301, ScriptID=2107 },
{ ID=45004, GroupId=1, Title="#-06#c00A8EBTàTh¥n Thß½ng Nhân", Name="DuyKute", PosX=37, PosY=174, BaseAI=1, Patrol=4, ExtAIScript=296, ScriptID=2107 },
}
--**********************************
function x002170_OnCharacterTimer( sceneId, objId, dataId, uTime )
local nHour = GetHour()
local nMinute = GetMinute()
if sceneId==6 then
if (nHour==19 and nMinute==30) or (nHour==19 and nMinute==40) or (nHour==19 and nMinute==50) or (nHour==20 and nMinute==00) or (nHour==20 and nMinute==10) or (nHour==20 and nMinute==20) or (nHour==20 and nMinute==30) then
x002170_CreateMonster( sceneId )
end
end
end
--**********************************
function x002170_CreateMonster( sceneId )
for j,msgData in x002170_g_BossSysMsgByGroupID do
msgData.isSended=0
end
for i,data in x002170_g_AllBoss[sceneId] do
local isExist = 0
local nMonsterNum = GetMonsterCount(sceneId)
for i=0, nMonsterNum-1 do
local MonsterId = GetMonsterObjID(sceneId,i)
local MosDataID = GetMonsterDataID( sceneId, MonsterId )
if MosDataID == data.ID then
isExist = 1
break
end
end
if isExist==0 then
local MstId = LuaFnCreateMonster(sceneId, data.ID, data.PosX, data.PosY, data.BaseAI, data.ExtAIScript, data.ScriptID )
SetCharacterTitle(sceneId, MstId, data.Title)
SetCharacterName(sceneId,MstId, data.Name)
SetPatrolId(sceneId, nNPC, data.Patrol)
x002170_SysMsg( sceneId, data.GroupId )
end
end
end
--**********************************
function x002170_SysMsg( sceneId, groupId )
if x002170_g_BossSysMsgByGroupID[groupId].isSended==0 then
AddGlobalCountNews( sceneId, x002170_g_BossSysMsgByGroupID[groupId].Msg )
x002170_g_BossSysMsgByGroupID[groupId].isSended=1
end
end
--**********************************
function x002170_MsgBox( sceneId, selfId, msg )
BeginEvent( sceneId )
AddText( sceneId, msg )
EndEvent( sceneId )
DispatchEventList( sceneId, selfId, -1 )
end
--**********************************
function x002170_NotifyTip( sceneId, selfId, Msg )
BeginEvent( sceneId )
AddText( sceneId, Msg )
EndEvent( sceneId )
DispatchMissionTips( sceneId, selfId )
end
--**********************************
function x002170_CloseMe(sceneId, selfId)
BeginUICommand(sceneId)
EndUICommand(sceneId)
DispatchUICommand(sceneId,selfId, 1000)
end
-- Vô Lßþng S½n
x002170_g_scriptId = 002170
x002170_g_AllBoss = {6}
x002170_g_BossSysMsgByGroupID={}
x002170_g_BossSysMsgByGroupID[1]={Msg="#cFF0000 Vô Lßþng S½n: #YTuyªn ð߶ng qua lÕi #cff6633ÐÕi Lý #Yvà #cff6633Kính H°cüa thß½ng nhân bang hµi #c0000FFTàTh¥n#Y. Chính là n½i ðây, ngay tÕi vùng ð¤t #cff6633Vô Lßþng S½n #Y này!!! Mµt miªng m°i ngon không th¬ bö qua... h·i các chiªn hæu! Chúng ta ði cß¾p tiêu thôi",isSended=0}
x002170_g_AllBoss[6]=
{
{ ID=45001, GroupId=1, Title="#-08#c00A8EBTàTh¥n Bang Chü", Name="Popi", PosX=45, PosY=170, BaseAI=1, Patrol=0, ExtAIScript=295, ScriptID=2107 },
{ ID=45012, GroupId=1, Title="#-07#c00A8EBTàTh¥n Nµi Vø SÑ", Name="XiTin", PosX=43, PosY=167, BaseAI=1, Patrol=1, ExtAIScript=300, ScriptID=2107 },
{ ID=45007, GroupId=1, Title="#-07#c00A8EBTàTh¥n Công Vø SÑ", Name="LéKim", PosX=45, PosY=173, BaseAI=1, Patrol=2, ExtAIScript=304, ScriptID=2107 },
{ ID=45013, GroupId=1, Title="#-06#c00A8EBTàTh¥n Thß½ng Nhân", Name="cTiêu", PosX=41, PosY=173, BaseAI=1, Patrol=3, ExtAIScript=301, ScriptID=2107 },
{ ID=45004, GroupId=1, Title="#-06#c00A8EBTàTh¥n Thß½ng Nhân", Name="DuyKute", PosX=37, PosY=174, BaseAI=1, Patrol=4, ExtAIScript=296, ScriptID=2107 },
}
--**********************************
function x002170_OnCharacterTimer( sceneId, objId, dataId, uTime )
local nHour = GetHour()
local nMinute = GetMinute()
if sceneId==6 then
if (nHour==19 and nMinute==30) or (nHour==19 and nMinute==40) or (nHour==19 and nMinute==50) or (nHour==20 and nMinute==00) or (nHour==20 and nMinute==10) or (nHour==20 and nMinute==20) or (nHour==20 and nMinute==30) then
x002170_CreateMonster( sceneId )
end
end
end
--**********************************
function x002170_CreateMonster( sceneId )
for j,msgData in x002170_g_BossSysMsgByGroupID do
msgData.isSended=0
end
for i,data in x002170_g_AllBoss[sceneId] do
local isExist = 0
local nMonsterNum = GetMonsterCount(sceneId)
for i=0, nMonsterNum-1 do
local MonsterId = GetMonsterObjID(sceneId,i)
local MosDataID = GetMonsterDataID( sceneId, MonsterId )
if MosDataID == data.ID then
isExist = 1
break
end
end
if isExist==0 then
local MstId = LuaFnCreateMonster(sceneId, data.ID, data.PosX, data.PosY, data.BaseAI, data.ExtAIScript, data.ScriptID )
SetCharacterTitle(sceneId, MstId, data.Title)
SetCharacterName(sceneId,MstId, data.Name)
SetPatrolId(sceneId, nNPC, data.Patrol)
x002170_SysMsg( sceneId, data.GroupId )
end
end
end
--**********************************
function x002170_SysMsg( sceneId, groupId )
if x002170_g_BossSysMsgByGroupID[groupId].isSended==0 then
AddGlobalCountNews( sceneId, x002170_g_BossSysMsgByGroupID[groupId].Msg )
x002170_g_BossSysMsgByGroupID[groupId].isSended=1
end
end
--**********************************
function x002170_MsgBox( sceneId, selfId, msg )
BeginEvent( sceneId )
AddText( sceneId, msg )
EndEvent( sceneId )
DispatchEventList( sceneId, selfId, -1 )
end
--**********************************
function x002170_NotifyTip( sceneId, selfId, Msg )
BeginEvent( sceneId )
AddText( sceneId, Msg )
EndEvent( sceneId )
DispatchMissionTips( sceneId, selfId )
end
--**********************************
function x002170_CloseMe(sceneId, selfId)
BeginUICommand(sceneId)
EndUICommand(sceneId)
DispatchUICommand(sceneId,selfId, 1000)
end