Newbie Spellweaver
- Joined
- Jun 9, 2014
- Messages
- 16
- Reaction score
- 0
Not sure what was wrong with my last post but hopefully i covered it in this new one.. The original .lua file that controls tw had major problem such as " indefinite repeat of tw announcement that it had started it wouldn't end or release the alliance holding land at the time it started ive worked it down to the announcement donst repeat now tw ends on time but the additional problems are as follows tw ends but dosnt stay ended also it dosnt released that territory owner when tw starts... Here is a copy of the lua file maybe someone could give it a look over an give me some insight into the problem..
a28.lua:
local starttime={ }
local battletime={ }
local timer={ }
local protect_time=0
function checktimer(index)
battletime=os.time()-starttime[index]
if battletime>=timer[index] then
return true
else
return false
end
end
function starttimer(index,lastfor)
starttime[index]=os.time()
timer[index]=lastfor
end
function restarttimer(index)
starttime[index]=os.time()
end
--211鍗犻搴?212棰嗗湡璧勯噾,213甯紬濂栧姳绉疮鍊?214棰嗗湡鎴樻枟涓庡惁,750x2涓績鐭?751x2涓績鐭垮叧闂€?752鎺у埗鎬嚜韬?
--21106鍒锋柊鎺у埗鎬?21107涓績鐭垮彫鍞ゆ€?21108涓績鐭垮叧闂€?
function Main(ai)
local id=ai:TemplateID()
local server=ai:ServerID()
if id==21106 then
if server==8 then
if ai:GetGlobalData(211)>1000 then ai:SetGlobalData(211,1000) end
if ai:GetGlobalData(211)<0 then ai:SetGlobalData(211,0) end
ai:SetGlobalData(214,0)
while 1 do
local domain = ai:GetGlobalData(211)
local domainmoney = ai:GetGlobalData(212)
local domainbattle = ai:GetGlobalData(214)
local time=os.date("%H:%M")
if domain<=0 and domainbattle==0 and protect_time<=0 then
ai:ActiveSpawner(750,true)
ai:Say("$AThe Territory of Gallio Kingdom is open for a Territory War!")
ai:SetGlobalData(214,1)
domainbattle=1
ai:SetPKRegion(744,true)
elseif domain >= 100000000 and protect_time<=0 then
protect_time=4*3600-600 --4灏忔椂淇濇姢
end
ai:Sleep(15)
--淇濇姢鏃堕棿鐩稿叧鎿嶄綔
if protect_time>30 then protect_time=protect_time-30 end --淇濇姢鏃堕棿澶т簬30,鍒欎繚鎶ゆ椂闂村噺灏?0绉?
if protect_time==30 then ai:Sleep(30);protect_time=0;ai:SetGlobalData(211,1000);ai:Say("$AThe Territory of Gallio Kingdom is no longer under system protection!") end --淇濇姢鏃堕棿绛変簬300,鍒?0绉掑悗灏嗗崰鏈夊害璁剧疆涓烘甯稿€?浠?000寮€濮嬮檷,骞朵笖淇濇姢鏃堕棿璁剧疆涓?
--18:00寮哄埗寮€鍚?20:00寮哄埗鍏抽棴
if time=="18:00" and domainbattle==0 and (os.date("%w")=="2" or os.date("%w")=="4" or os.date("%w")=="6" or os.date("%w")=="0")then --18:00鏈浜庢垬鏂楃姸鎬佸己鍒跺紑鍚?
protect_time=0
ai:ActiveSpawner(750,true)
ai:Say("$AThe Gallio Global Agent has set the Territory open for a Territory War!")
ai:SetGlobalData(214,1)
domainbattle=1
ai:SetPKRegion(744,true)
elseif time=="20:00" and domainbattle==1 and (os.date("%w")=="2" or os.date("%w")=="4" or os.date("%w")=="6" or os.date("%w")=="0") then --20:00澶勪簬寮€鍚姸鎬佹椂寮哄埗缁撴潫
ai:ActiveSpawner(750,false)
ai:SetPKRegion(744,false)
ai:SetGlobalData(211,0)
ai:SetGlobalData(214,0)
domainbattle=0
ai:Say("$AThe Territory War of Gallio Kingdom has been closed by the Local Agent!")
ai:TerritoryBattleEnd(2)
end
--鏃犲崰棰嗗府娲剧珛鍒诲紑鍚鍦熶簤澶?
if ai:GetOccupyFaction(2)==0 and domainbattle==0 then
protect_time=1
ai:SetGlobalData(211,100000000)
ai:ActiveSpawner(750,true)
ai:Say("$AThe Gallio Global Agent has set the Territory open for a Territory War!")
ai:SetGlobalData(214,1)
domainbattle=1
ai:SetPKRegion(744,true)
end
--瀹氭椂娓呯┖缁忛獙绉疮濂栧姳
if time=="08:01" or time=="12:01" or time=="16:01" or time=="20:01" or time=="00:01" then
ai:SetGlobalData(213,0)
end
--灏?13鎶樼畻鎴?15,鏈€澶у€间负4,姣?000涓€妗?
local temp1=ai:GetGlobalData(213)
local temp2=math.floor(temp1/10000)
if temp1>=40000 then
ai:SetGlobalData(215,4)
else
ai:SetGlobalData(215,temp2)
end
ai:Sleep(15)
end
else
ai:ActiveSpawner(752,false)
end
elseif id==21107 then
ai:ActiveSpawner(751,false)
ai:Sleep(5)
ai:CastSkill(ai:GetSelf(),489,1)
elseif id==21108 then
ai:Sleep(590)
ai:ActiveSpawner(750,false)
end
end
function OnDeath(ai,idAttacker)
local id=ai:TemplateID()
local server=ai:ServerID()
if id==21107 then
ai:SetGlobalData(212,0)
ai:SetGlobalData(213,0)
ai:ActiveSpawner(751,true)
elseif id==21108 then
ai:SetPKRegion(744,false)
ai:ActiveSpawner(750,false)
ai:SetGlobalData(211,2000000000)
ai:SetGlobalData(214,0)
ai:TerritoryBattleEnd(2)
end
end
function Battle(ai)
end
function OnReborn(ai)
end
function OnStartCombat(ai)
end
function OnEndCombat(ai)
end
function OnPathEnd(ai,pathid)
end
function OnGreeting(ai,who,faction)
end
function OnSkillAttacked(ai,who,master,skill_id)
end
function OnScriptEvent(aiObj, who, param1, pararm2)
end
P.S. Thanks for any help ahead of time
a28.lua:
local starttime={ }
local battletime={ }
local timer={ }
local protect_time=0
function checktimer(index)
battletime=os.time()-starttime[index]
if battletime>=timer[index] then
return true
else
return false
end
end
function starttimer(index,lastfor)
starttime[index]=os.time()
timer[index]=lastfor
end
function restarttimer(index)
starttime[index]=os.time()
end
--211鍗犻搴?212棰嗗湡璧勯噾,213甯紬濂栧姳绉疮鍊?214棰嗗湡鎴樻枟涓庡惁,750x2涓績鐭?751x2涓績鐭垮叧闂€?752鎺у埗鎬嚜韬?
--21106鍒锋柊鎺у埗鎬?21107涓績鐭垮彫鍞ゆ€?21108涓績鐭垮叧闂€?
function Main(ai)
local id=ai:TemplateID()
local server=ai:ServerID()
if id==21106 then
if server==8 then
if ai:GetGlobalData(211)>1000 then ai:SetGlobalData(211,1000) end
if ai:GetGlobalData(211)<0 then ai:SetGlobalData(211,0) end
ai:SetGlobalData(214,0)
while 1 do
local domain = ai:GetGlobalData(211)
local domainmoney = ai:GetGlobalData(212)
local domainbattle = ai:GetGlobalData(214)
local time=os.date("%H:%M")
if domain<=0 and domainbattle==0 and protect_time<=0 then
ai:ActiveSpawner(750,true)
ai:Say("$AThe Territory of Gallio Kingdom is open for a Territory War!")
ai:SetGlobalData(214,1)
domainbattle=1
ai:SetPKRegion(744,true)
elseif domain >= 100000000 and protect_time<=0 then
protect_time=4*3600-600 --4灏忔椂淇濇姢
end
ai:Sleep(15)
--淇濇姢鏃堕棿鐩稿叧鎿嶄綔
if protect_time>30 then protect_time=protect_time-30 end --淇濇姢鏃堕棿澶т簬30,鍒欎繚鎶ゆ椂闂村噺灏?0绉?
if protect_time==30 then ai:Sleep(30);protect_time=0;ai:SetGlobalData(211,1000);ai:Say("$AThe Territory of Gallio Kingdom is no longer under system protection!") end --淇濇姢鏃堕棿绛変簬300,鍒?0绉掑悗灏嗗崰鏈夊害璁剧疆涓烘甯稿€?浠?000寮€濮嬮檷,骞朵笖淇濇姢鏃堕棿璁剧疆涓?
--18:00寮哄埗寮€鍚?20:00寮哄埗鍏抽棴
if time=="18:00" and domainbattle==0 and (os.date("%w")=="2" or os.date("%w")=="4" or os.date("%w")=="6" or os.date("%w")=="0")then --18:00鏈浜庢垬鏂楃姸鎬佸己鍒跺紑鍚?
protect_time=0
ai:ActiveSpawner(750,true)
ai:Say("$AThe Gallio Global Agent has set the Territory open for a Territory War!")
ai:SetGlobalData(214,1)
domainbattle=1
ai:SetPKRegion(744,true)
elseif time=="20:00" and domainbattle==1 and (os.date("%w")=="2" or os.date("%w")=="4" or os.date("%w")=="6" or os.date("%w")=="0") then --20:00澶勪簬寮€鍚姸鎬佹椂寮哄埗缁撴潫
ai:ActiveSpawner(750,false)
ai:SetPKRegion(744,false)
ai:SetGlobalData(211,0)
ai:SetGlobalData(214,0)
domainbattle=0
ai:Say("$AThe Territory War of Gallio Kingdom has been closed by the Local Agent!")
ai:TerritoryBattleEnd(2)
end
--鏃犲崰棰嗗府娲剧珛鍒诲紑鍚鍦熶簤澶?
if ai:GetOccupyFaction(2)==0 and domainbattle==0 then
protect_time=1
ai:SetGlobalData(211,100000000)
ai:ActiveSpawner(750,true)
ai:Say("$AThe Gallio Global Agent has set the Territory open for a Territory War!")
ai:SetGlobalData(214,1)
domainbattle=1
ai:SetPKRegion(744,true)
end
--瀹氭椂娓呯┖缁忛獙绉疮濂栧姳
if time=="08:01" or time=="12:01" or time=="16:01" or time=="20:01" or time=="00:01" then
ai:SetGlobalData(213,0)
end
--灏?13鎶樼畻鎴?15,鏈€澶у€间负4,姣?000涓€妗?
local temp1=ai:GetGlobalData(213)
local temp2=math.floor(temp1/10000)
if temp1>=40000 then
ai:SetGlobalData(215,4)
else
ai:SetGlobalData(215,temp2)
end
ai:Sleep(15)
end
else
ai:ActiveSpawner(752,false)
end
elseif id==21107 then
ai:ActiveSpawner(751,false)
ai:Sleep(5)
ai:CastSkill(ai:GetSelf(),489,1)
elseif id==21108 then
ai:Sleep(590)
ai:ActiveSpawner(750,false)
end
end
function OnDeath(ai,idAttacker)
local id=ai:TemplateID()
local server=ai:ServerID()
if id==21107 then
ai:SetGlobalData(212,0)
ai:SetGlobalData(213,0)
ai:ActiveSpawner(751,true)
elseif id==21108 then
ai:SetPKRegion(744,false)
ai:ActiveSpawner(750,false)
ai:SetGlobalData(211,2000000000)
ai:SetGlobalData(214,0)
ai:TerritoryBattleEnd(2)
end
end
function Battle(ai)
end
function OnReborn(ai)
end
function OnStartCombat(ai)
end
function OnEndCombat(ai)
end
function OnPathEnd(ai,pathid)
end
function OnGreeting(ai,who,faction)
end
function OnSkillAttacked(ai,who,master,skill_id)
end
function OnScriptEvent(aiObj, who, param1, pararm2)
end
P.S. Thanks for any help ahead of time