slaw
Software Developer
Announcement's for your server.
Example:
/announ "HEJ HO,3,consolered
Will broadcast every 3 seconds message "HEJ HO" in type "consolered".
OK LETS GO!
data/talkactions/talkactions.xml
data/talkactions/scripts/announcement.lua
global.lua, add in end of file:
There is also needed this function to work:
http://otland.net/showthread.php?t=10727 (paste in functions.lua or global.lua)
You can also use in short way this talkaction. Like:
/announ "HEEJ
Then COLOR and FREQUENCY will be taked from default script.
You can stop announcement and start another one again by writing:
/announ "stop
Example:
/announ "HEJ HO,3,consolered
Will broadcast every 3 seconds message "HEJ HO" in type "consolered".
OK LETS GO!
data/talkactions/talkactions.xml
PHP:
<talkaction access="3" words="/announ" script="announcement.lua" />
data/talkactions/scripts/announcement.lua
PHP:
-- CONFIG
local SERVER_VERSION = 0 -- 0=TAGS/0.2, 1=TRUNK
local MSG_FREQUENCY = 2000 -- in ms
local MSG_COLOR = MESSAGE_INFO_DESCR
function doAnnouncement(string, delay, color)
if SERVER_VERSION == 0 then
broadcastMessage(string, color)
else
doBroadcastMessage(string, color)
end
annEvent = addEvent(doAnnouncement, delay, string, delay, color)
end
function onSay(cid, words, param)
if param ~= "" then
parameters = explode(",", param)
if param == "stop" then
if annEvent ~= nil then
stopEvent(annEvent)
annEvent = nil
doPlayerSendCancel(cid, "Announcement has been stopped.")
else
doPlayerSendCancel(cid, "No announcement running.")
end
elseif annEvent ~= nil then
doPlayerSendCancel(cid, "Announcement is already running... Stop it by writing: '/announ stop'")
else
if parameters[2] ~= nil then
MSG_FREQUENCY = parameters[2] * 1000
end
if parameters[3] ~= nil then
if MESSAGES[parameters[3]] ~= nil then
MSG_COLOR = MESSAGES[parameters[3]]
end
end
if SERVER_VERSION == 0 then
broadcastMessage(parameters[1], MSG_COLOR)
else
doBroadcastMessage(parameters[1], MSG_COLOR)
end
annEvent = addEvent(doAnnouncement, MSG_FREQUENCY, parameters[1], MSG_FREQUENCY, MSG_COLOR)
end
else
doPlayerSendCancel(cid, "You need to give announcement message as param!")
end
end
global.lua, add in end of file:
PHP:
MESSAGES =
{
consolered = MESSAGE_STATUS_CONSOLE_RED,
consoleorange = MESSAGE_STATUS_CONSOLE_ORANGE,
red = MESSAGE_STATUS_WARNING,
white = MESSAGE_EVENT_ADVANCE,
default = MESSAGE_EVENT_DEFAULT,
green = MESSAGE_INFO_DESCR,
statussmall = MESSAGE_STATUS_SMALL,
consoleblue = MESSAGE_STATUS_CONSOLE_BLUE
}
There is also needed this function to work:
http://otland.net/showthread.php?t=10727 (paste in functions.lua or global.lua)
You can also use in short way this talkaction. Like:
/announ "HEEJ
Then COLOR and FREQUENCY will be taked from default script.
You can stop announcement and start another one again by writing:
/announ "stop
Last edited: