- Joined
- Aug 1, 2009
- Messages
- 65
- Reaction score
- 8
This is just a quick fix for any1 who is wanting events to work on v14 and cannot find out why they dont load.
This isnt the best way for them to work, but maybe you can learn something from it, or maybe not.
Just copy and paste this, and your events shall work.
Quick instructions for people who may need them
1.Go to get this to work you go into your servers resource folder
2.Open the LuaFunc Folder
3.then open your EventFunc.lua with notepad
4.Select all then delete it
5.copy and paste whats in the code box and press save
and if you want your Event to work without reloading your Worldserver.exe just go on an admin char and type
/Lua Event
and it will reload your event, and if you relog you will see you little message that an event is runnning
This isnt the best way for them to work, but maybe you can learn something from it, or maybe not.
Just copy and paste this, and your events shall work.
Code:
tEvent = {} -- ??? ?? ???
tNotice = {} -- ?? ?? ??
bNotice = false
function SEC( n )
return n*1000
end
function MIN( n )
return n*SEC(60)
end
-----------------------------------------------------------------------------------
function Notice( strTime, nInterval, nNoticeCount )
tNotice.strTime = strTime
tNotice.nInterval = nInterval
tNotice.nNoticeCount = nNoticeCount
tNotice.tMessage = {}
end
function AddMessage( strMessage )
local nSize = table.getn( tNotice.tMessage ) + 1
tNotice.tMessage[nSize] = strMessage
end
function IsNoticeTime()
if( (bNotice == true) and (tNotice.nNoticeCount > 0) and (tNotice.strTime == os.date("%a %H:%M")) ) then
tNotice.nNoticeCount = tNotice.nNoticeCount - 1
SetNextNoticeTime()
return true
end
return false
end
function SetNextNoticeTime()
local nMin = tonumber( os.date( "%M" ) )
local nHour = tonumber( os.date( "%H" ) )
local strTemp;
tNotice.strTime = os.date( "%a " )
nMin = nMin + tNotice.nInterval;
if( nMin > 59 ) then
nMin = 60 - nMin
nHour = nHour + 1
end
-- ?
strTemp = tostring( nHour )..":"
if( nHour < 10 ) then strTemp = "0"..strTemp end
tNotice.strTime = tNotice.strTime .. strTemp
-- ?
strTemp = tostring( nMin )
if( nMin < 10 ) then strTemp = "0"..strTemp end
tNotice.strTime = tNotice.strTime .. strTemp
end
function GetNoticeMessage()
return tNotice.tMessage
end
-----------------------------------------------------------------------------------
------- C?? ??? ?? ?? ----------------------------------------------------
-----------------------------------------------------------------------------------
-- ??? ??? ??? (DBSERVER)
function GetEventState()
local tReturn = {}
local nCount = 1
for i in pairs(tEvent) do
local OldState = tEvent[i].State
for j in pairs(tEvent[i].Time) do
if( tEvent[i].Time[j].nStart <= tonumber(os.date("%Y%m%d%H%M")) ) then
if( tEvent[i].Time[j].nEnd > tonumber(os.date("%Y%m%d%H%M")) ) then
if( tEvent[i].State == 0 ) then
tEvent[i].State = 1
end
else
if( tEvent[i].State == 1 ) then
tEvent[i].State = 0
end
end
end
end
if( OldState ~= tEvent[i].State ) then
tReturn[nCount] = {}
tReturn[nCount].nId = i
tReturn[nCount].State = tEvent[i].State
nCount = nCount + 1
end
end
return tReturn
end
-- WORLDSERVER?? ??? ???? ???? ??? state? ???? ?? ??
function SetState( nId, nState )
if( tEvent[nId] == nil ) then
TRACE( string.format( "Pas d'évènement ayant l'id : %d", nId ) )
ERROR( string.format( "Pas d'évènement ayant l'id : %d", nId ) )
return false;
end
tEvent[nId].State = nState
TRACE( string.format( "ID de l'évènement : %d, Nom : %s, Etat : %d", nId, tEvent[nId].Desc, tEvent[nId].State ) )
ERROR( string.format( "ID de l'évènement : %d, Nom : %s, Etat : %d", nId, tEvent[nId].Desc, tEvent[nId].State ) )
return true;
end
-- ???? ??? ???
function GetEventList()
local tList = {}
local nCount = 1
for i in pairs(tEvent) do
if( tEvent[i].State == 1 ) then
tList[nCount] = i
nCount = nCount + 1
end
end
return tList
end
-- ??? ???? ?? ?? ???
function GetAllEventList()
local tAllList = {}
local nCount = 1
for i in pairs(tEvent) do
tAllList[nCount] = {}
tAllList[nCount].nId = i
tAllList[nCount].strTitle = tEvent[i].Desc
tAllList[nCount].nState = tEvent[i].State
nCount = nCount + 1
end
return tAllList
end
-- ??? ?? ?? ???? ??
function GetEventInfo( nId )
local tEventInfo = {}
if( tEvent[nId] == nil ) then
tEventInfo[1] = "Pas d'infos sur l'évènement ayant l'id : "..nId
return tEventInfo
end
local nCount = 3
tEventInfo[1] = "Nom = " .. tEvent[nId].Desc
tEventInfo[2] = "Etat = " .. tEvent[nId].State
for i in pairs(tEvent[nId].Time) do
local strTime = tEvent[nId].Time[i].nStart .. ", " ..tEvent[nId].Time[i].nEnd
tEventInfo[nCount] = "Time["..i.."] = " .. strTime
nCount = nCount + 1
end
for i in pairs(tEvent[nId].Item) do
local strItem = tEvent[nId].Item[i].ItemId ..", ".. tEvent[nId].Item[i].ItemMaxNum ..", ".. tEvent[nId].Item[i].ItemNum ..", ".. tEvent[nId].Item[i].nLevel
tEventInfo[nCount] = "Objet["..i.."] = " .. strItem
nCount = nCount + 1
end
if( tEvent[nId].fExpFactor ~= 5 ) then
tEventInfo[nCount] = "Expérience multiplié par : " .. tEvent[nId].fExpFactor
nCount = nCount + 1
end
if( tEvent[nId].fItemDropRate ~= 5 ) then
tEventInfo[nCount] = "Drop multiplié par : " .. tEvent[nId].fItemDropRate
nCount = nCount + 1
end
if( tEvent[nId].fPieceItemDropRate ~= 5 ) then
tEventInfo[nCount] = "Nombre d'objets multiplié par : " .. tEvent[nId].fPieceItemDropRate
nCount = nCount + 1
end
if( tEvent[nId].fGoldDropFactor ~= 5 ) then
tEventInfo[nCount] = "Penyas multiplié par : " .. tEvent[nId].fGoldDropFactor
nCount = nCount + 1
end
if( tEvent[nId].nAttackPower ~= 0 ) then
tEventInfo[nCount] = "Attaque augmentée de : " .. tEvent[nId].nAttackPower
nCount = nCount + 1
end
if( tEvent[nId].nDefensePower ~= 0 ) then
tEventInfo[nCount] = "Défense augmentée de : " .. tEvent[nId].nDefensePower
nCount = nCount + 1
end
if( tEvent[nId].nCouponEvent ~= 0 ) then
if( tEvent[nId].nCouponEvent < MIN(1) ) then
tEventInfo[nCount] = "Durée des coupons évènement : " .. tEvent[nId].nCouponEvent / SEC(1) .. "Secondes"
else
tEventInfo[nCount] = "Durée des coupons évènement : " .. tEvent[nId].nCouponEvent / MIN(1) .. "Minutes"
end
nCount = nCount + 1
end
for i in pairs(tEvent[nId].Gift) do
local strGift = tEvent[nId].Gift[i].nLevel ..", ".. tEvent[nId].Gift[i].strAccount ..", ".. tEvent[nId].Gift[i].strItemId ..", ".. tEvent[nId].Gift[i].nItemNum
tEventInfo[nCount] = "Cadeaux n°["..i.."] : " .. strGift
nCount = nCount + 1
end
if( tEvent[nId].fCheerExpFactor ~= 1 ) then
tEventInfo[nCount] = "fCheerExpFactor = " .. tEvent[nId].fCheerExpFactor
nCount = nCount + 1
end
return tEventInfo
end
-- ??? ??
function GetDesc( nId )
local strDesc = tEvent[nId].Desc
return strDesc
end
-- ??? ??? ???? ??
function GetTimeToNumber( strTime )
local strTemp = ""
local j = 0
for i in string.gfind( strTime, "%d+" ) do
j = j + 1
if( (j~=1) and (tonumber(i)<10) ) then
i = "0"..tonumber(i)
end
strTemp = strTemp..i
end
return tonumber( strTemp )
end
---------------------------------------------------------------------------
------ ??? ?? ?? ---------------------------------------------------
---------------------------------------------------------------------------
-- ??? ??? ??
function AddEvent( strDesc )
local nEventId = table.getn(tEvent) + 1
tEvent[nEventId] = {}
tEvent[nEventId].Item = {}
tEvent[nEventId].Time = {}
tEvent[nEventId].Desc = strDesc
tEvent[nEventId].fExpFactor = 1
tEvent[nEventId].fItemDropRate = 1
tEvent[nEventId].fPieceItemDropRate = 1
tEvent[nEventId].fGoldDropFactor = 1
tEvent[nEventId].State = 1
tEvent[nEventId].nAttackPower = 0
tEvent[nEventId].nDefensePower = 0
tEvent[nEventId].nCouponEvent = 0
tEvent[nEventId].Gift = {}
tEvent[nEventId].fCheerExpFactor = 1
end
-- ????, ???
function SetTime( strStart, strEnd )
local nEventId = table.getn(tEvent)
local nSize = table.getn( tEvent[nEventId].Time ) + 1
tEvent[nEventId].Time[nSize] = {}
tEvent[nEventId].Time[nSize].nStart = GetTimeToNumber( strStart )
tEvent[nEventId].Time[nSize].nEnd = GetTimeToNumber( strEnd )
end
-- ???
function SetItem( ItemId, nItemMaxNum, nItemNum, nLevel )
local nEventId = table.getn(tEvent)
local nSize = table.getn(tEvent[nEventId].Item)
tEvent[nEventId].Item[nSize+1] = {}
tEvent[nEventId].Item[nSize+1].ItemId = ItemId
tEvent[nEventId].Item[nSize+1].ItemMaxNum = nItemMaxNum
tEvent[nEventId].Item[nSize+1].ItemNum = nItemNum
tEvent[nEventId].Item[nSize+1].nLevel = nLevel
tEvent[nEventId].Item[nSize+1].TimeOut = 0
tEvent[nEventId].Item[nSize+1].Skip = 0
local tInterval = {}
local nTotal = 0
for i in pairs(tHour) do
nTotal = nTotal + tHour[i]
end
for i in pairs(tHour) do
tInterval[i] = 3600000 / ( nItemMaxNum * tHour[i] / nTotal )
tInterval[i] = math.floor(tInterval[i])
end
tEvent[nEventId].Item[nSize+1].tInterval = tInterval
end
-- ??? ??? ??
function GetItem( nTickCount, nLevel )
local nHour = tonumber(os.date("%H")) + 1
local tList = GetEventList()
local tReturn = {}
local nCount = 1
for i in pairs(tList) do
local tItem = tEvent[tList[i]].Item
for j in pairs(tItem) do
local nRandom = math.random(0, tItem[j].ItemNum)
if( (nRandom > 0) and (nTickCount >= tItem[j].TimeOut) and (tItem[j].nLevel <= nLevel) ) then
tItem[j].TimeOut = tItem[j].tInterval[nHour] + nTickCount
if( tItem[j].Skip == 0 ) then
tReturn[nCount] = {}
tReturn[nCount].ItemId = tItem[j].ItemId
tReturn[nCount].ItemNum = nRandom
tItem[j].Skip = nRandom - 1
nCount = nCount + 1
TRACE( "Event.lua : GetItem() - Drop - "..tItem[j].ItemId..", "..nRandom.."?, Skip:"..tItem[j].Skip.." ???:"..(nHour-1).." ~ "..nHour )
else
tItem[j].Skip = tItem[j].Skip - 1
TRACE( "Event.lua : GetItem() - Skip - "..tItem[j].ItemId..", ?? Skip:"..tItem[j].Skip.." ???:"..(nHour-1).." ~ "..nHour )
end
end
end
end
return tReturn
end
-- ??? ??
function SetExpFactor( fExpFactor )
local nEventId = table.getn(tEvent)
tEvent[nEventId].fExpFactor = fExpFactor
end
function GetExpFactor()
local tList = GetEventList()
local fExpFactor = 135
for i in pairs(tList) do
if( tEvent[tList[i]].fExpFactor ~= nil ) then
fExpFactor = fExpFactor * tEvent[tList[i]].fExpFactor
end
end
return fExpFactor
end
-- ??? ??? ??
function SetItemDropRate( fItemDropRate )
local nEventId = table.getn(tEvent)
tEvent[nEventId].fItemDropRate = fItemDropRate
end
function GetItemDropRate()
local tList = GetEventList()
local fItemDropRate = 85
for i in pairs(tList) do
if( tEvent[tList[i]].fItemDropRate ~= nil ) then
fItemDropRate = fItemDropRate * tEvent[tList[i]].fItemDropRate
end
end
return fItemDropRate
end
-- ?? ??? ??? ??
function SetPieceItemDropRate( fPieceItemDropRate )
local nEventId = table.getn(tEvent)
tEvent[nEventId].fPieceItemDropRate = fPieceItemDropRate
end
function GetPieceItemDropRate()
local tList = GetEventList()
local fPieceItemDropRate = 85
for i in pairs(tList) do
if( tEvent[tList[i]].fPieceItemDropRate ~= nil ) then
fPieceItemDropRate = fPieceItemDropRate * tEvent[tList[i]].fPieceItemDropRate
end
end
return fPieceItemDropRate
end
-- ?? ?? ??
function SetGoldDropFactor( fGoldDropFactor )
local nEventId = table.getn(tEvent)
tEvent[nEventId].fGoldDropFactor = fGoldDropFactor
end
function GetGoldDropFactor()
local tList = GetEventList()
local fGoldDropFactor = 2100
for i in pairs(tList) do
if( tEvent[tList[i]].fGoldDropFactor ~= nil ) then
fGoldDropFactor = fGoldDropFactor * tEvent[tList[i]].fGoldDropFactor
end
end
return fGoldDropFactor
end
-- ??? ??
function SetAttackPower( nAttackPower )
local nEventId = table.getn(tEvent)
tEvent[nEventId].nAttackPower = nAttackPower
end
function GetAttackPower()
local tList = GetEventList()
local nAttackPower = 0
for i in pairs(tList) do
if( tEvent[tList[i]].nAttackPower ~= nil ) then
nAttackPower = nAttackPower + tEvent[tList[i]].nAttackPower
end
end
return nAttackPower
end
-- ??? ??
function SetDefensePower( nDefensePower )
local nEventId = table.getn(tEvent)
tEvent[nEventId].nDefensePower = nDefensePower
end
function GetDefensePower()
local tList = GetEventList()
local nDefensePower = 0
for i in pairs(tList) do
if( tEvent[tList[i]].nDefensePower ~= nil ) then
nDefensePower = nDefensePower + tEvent[tList[i]].nDefensePower
end
end
return nDefensePower
end
-- ?? ???
function SetCouponEvent( nTime )
local nEventId = table.getn(tEvent)
tEvent[nEventId].nCouponEvent = nTime
end
function GetCouponEvent()
local tList = GetEventList()
for i in pairs(tList) do
if( tEvent[tList[i]].nCouponEvent ~= 0 ) then
return tEvent[tList[i]].nCouponEvent
end
end
return 0
end
function SetLevelUpGift( nLevel, strAccount, strItemId, nItemNum, byFlag )
local nEventId = table.getn(tEvent)
local nSize = table.getn(tEvent[nEventId].Gift)
tEvent[nEventId].Gift[nSize+1] = {}
tEvent[nEventId].Gift[nSize+1].nLevel = nLevel
tEvent[nEventId].Gift[nSize+1].strAccount = strAccount
tEvent[nEventId].Gift[nSize+1].strItemId = strItemId
tEvent[nEventId].Gift[nSize+1].nItemNum = nItemNum
tEvent[nEventId].Gift[nSize+1].byFlag = byFlag
end
function GetLevelUpGift( nLevel, strAccount )
local nCount = 1
local tGiftList = {}
local tList = GetEventList()
for i in pairs(tList) do
local tGift = tEvent[tList[i]].Gift
for j in pairs(tGift) do
local nTemp = string.find( strAccount, tGift[j].strAccount )
if( (tGift[j].strAccount == "all") or (nTemp ~= nil) ) then
if( tGift[j].nLevel == nLevel ) then
tGiftList[nCount] = {}
tGiftList[nCount].strItemId = tGift[j].strItemId
tGiftList[nCount].nItemNum = tGift[j].nItemNum
tGiftList[nCount].byFlag = tGift[j].byFlag
nCount = nCount + 1
end
end
end
end
return tGiftList
end
function SetCheerExpFactor( fCheerExpFactor )
local nEventId = table.getn(tEvent)
tEvent[nEventId].fCheerExpFactor = fCheerExpFactor
end
function GetCheerExpFactor()
local tList = GetEventList()
local fCheerExpFactor = 1
for i in pairs(tList) do
if( tEvent[tList[i]].fCheerExpFactor ~= nil ) then
fCheerExpFactor = fCheerExpFactor * tEvent[tList[i]].fCheerExpFactor
end
end
return fCheerExpFactor
end
1.Go to get this to work you go into your servers resource folder
2.Open the LuaFunc Folder
3.then open your EventFunc.lua with notepad
4.Select all then delete it
5.copy and paste whats in the code box and press save
and if you want your Event to work without reloading your Worldserver.exe just go on an admin char and type
/Lua Event
and it will reload your event, and if you relog you will see you little message that an event is runnning
Last edited:

