zbizu
Legendary OT User
This simple script allows you to configure all server events in one script and let people know what events will be running soon.
Do not post that script on other forums without my permission
Firstly: This isn't made for newbies. If you can't configure server events yourself, this script may only make it even harder.
Secondly: I don't have time to improve this script so it's up to you.
Globalevents.xml:
event_calendar.lua:
chatchannels.xml:
events.lua:
Do not post that script on other forums without my permission
Firstly: This isn't made for newbies. If you can't configure server events yourself, this script may only make it even harder.
Secondly: I don't have time to improve this script so it's up to you.
Globalevents.xml:
Code:
<globalevent name="event calendar" interval="60000" script="event_calendar.lua"/>
event_calendar.lua:
Code:
events_calendar = {
channel_id = 32, -- channel to post event news. Use broadcastMessage function if you want this stuff to be posted on local chat or server log
[1] = { -- mon
},
[2] = { -- tue
[7] = {{8, true}}, -- 7 am
[14] = {{1, arg}, {3, arg}} -- 2 pm -- [hour] = {{event1, function arguments(to do)}}
},
[3] = { -- wed
},
[4] = { -- thu
},
[5] = { -- fri
},
[6] = { -- sat
},
[0] = { -- sun
}
}
events_calendar_list = {
[1] = "extra exp",
[2] = "extra loot",
[3] = "random gift",
[4] = "sheep",
[5] = "raining fire",
[6] = "hardcore dungeon",
[7] = "zombie survival",
[8] = "pvp-party",
[9] = "castle war(region 1)",
[10] = "castle war(region 2)",
[11] = "castle war(region 3)"
}
function doExecuteScheduledEvent(day, hour, id)
if id == 8 then
sendChannelMessage(events_calendar.channel_id, TALKTYPE_CHANNEL_O, "[Notice]: Pvp party arena is open!")
-- open arena or whatever
return true
end
end
function onThink(interval)
if events_calendar[tonumber(os.date("%w"))] ~= nil then
if tonumber(os.date("%M")) == 59 then
if tonumber(os.date("%S")) >= 30 then
if events_calendar[tonumber(os.date("%w"))][tonumber(os.date("%H")) + 1] ~= nil then
for i = 1, #events_calendar[tonumber(os.date("%w"))][tonumber(os.date("%H")) + 1] do
doExecuteScheduledEvent(events_calendar[tonumber(os.date("%w"))], tonumber(os.date("%H")) + 1, i)
end
end
end
return true
elseif tonumber(os.date("%M")) == 0 then
if tonumber(os.date("%S")) < 30 then
if events_calendar[tonumber(os.date("%w"))][tonumber(os.date("%H"))] ~= nil then
for i = 1, #events_calendar[tonumber(os.date("%w"))][tonumber(os.date("%H"))] do
doExecuteScheduledEvent(events_calendar[tonumber(os.date("%w"))], tonumber(os.date("%H")), i)
end
end
end
return true
else
-- if tonumber(os.date("%S")) == 30 then -- message only 30 minutes before event
if events_calendar[tonumber(os.date("%w"))][tonumber(os.date("%H")) + 1] ~= nil then
if #events_calendar[tonumber(os.date("%w"))][tonumber(os.date("%H")) + 1] > 0 then
s_events_list = {}
for i = 1, #events_calendar[tonumber(os.date("%w"))][tonumber(os.date("%H")) + 1] do
table.insert(s_events_list, events_calendar_list[events_calendar[tonumber(os.date("%w"))][tonumber(os.date("%H")) + 1][i][1]])
end
local m = 60 - tonumber(os.date("%M"))
sendChannelMessage(events_calendar.channel_id, TALKTYPE_CHANNEL_O, "[Notice]: Upcoming events: " .. table.concat(s_events_list, ", ") .. " (" .. m .. " minute" .. (m > 1 and "s" or "") .. " left).")
end
end
-- end
return true
end
end
end
chatchannels.xml:
Code:
<channel id="32" name="Events" public="1" script="events.lua" />
events.lua:
Code:
local muted = createConditionObject(CONDITION_CHANNELMUTEDTICKS)
setConditionParam(muted, CONDITION_PARAM_SUBID, 32)
setConditionParam(muted, CONDITION_PARAM_TICKS, 1000)
function send_d_motd(cid)
return Creature(cid):sendChannelMessage("", "[Channel]: Welcome to the event channel. Here you may talk about in-game events and receive news about their status.", TALKTYPE_CHANNEL_O, 32)
end
function onJoin(cid)
addEvent(send_d_motd, 100, cid)
return true
end
function onSpeak(cid, type, message)
if getCreatureCondition(cid, CONDITION_CHANNELMUTEDTICKS, 32) then
Creature(cid):sendChannelMessage("", "Please do not spam.", TALKTYPE_CHANNEL_O, 32)
return false
end
doAddCondition(cid, muted)
if getPlayerAccountType(cid) > 2 then
if getPlayerGroupId(cid) > 2 then
local groupnames = {[2] = "Mod", [3] = "Admin"}
sendChannelMessage(32, TALKTYPE_CHANNEL_R1, getCreatureName(cid) .. " [" .. (groupnames[getPlayerGroupId(cid)] or "GM") .. "]: ".. message)
return false
end
end
return TALKTYPE_CHANNEL_Y
end
Last edited: