• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

TalkAction Automated Broadcasting [TFS 0.3.4]

Status
Not open for further replies.

JDB

OtLand Veteran
Joined
Jun 1, 2009
Messages
4,145
Solutions
2
Reaction score
115
This is another script I had found and updated.
I do not remember where it came from, but here it is!
Tested and Works 100%


Talkactions:
PHP:
<talkaction log="yes" access="5" words="/broadcast" event="script" value="auto_broadcast.lua"/>

Script:
Lua:
local messages = 
{
	"Type [!blessings] to see all the blessings you need or have!",
	"Write [!buyitems] to see a list of items for sale!",
	"Use [!info] for some extra server information."
}

local interval = 2 -- 2 minutes between messages.
local requiredGroupId = 3
local isActive = TRUE

function onSay(cid, words, param)
	if param == "deactivate" then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Broadcasting has been deactivated.")
		isActive = FALSE
	else
		if getPlayerGroupId(cid) >= requiredGroupId then
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Broadcasting has started.")
			broadcast(1)
		else
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You need higher access to do this.")
		end
	end
	return TRUE
end

function broadcast(pos)
	if isActive == TRUE then
		local message = messages[pos]
		if message then
			doBroadcastMessage(message, 21)
			addEvent(broadcast, interval * 60 * 1000, pos + 1)
		else
			isActive = FALSE
		end
	end
end

I guess this is Colandus's script, so credits to him.
But I did fix it -- I don't want rep for this.
 
Last edited:
@Up,

Why use globalevents?
 
PHP:
	<globalevent name="messages" interval="2000" event="script" value="messages.lua"/>

Lua:
local messages = {
    "Type [!blessings] to see all the blessings you need or have!", 
    "Write [!buyitems] to see a list of items for sale!"
}
function onThink(interval, lastExecution)
    for _, name in ipairs(getOnlinePlayers()) do
	 doPlayerSendTextMessage(getPlayerByName(name), TALKTYPE_BROADCAST, messages[math.random(1,#messages)])
    end
    return TRUE
end
 
@Jose,

That isn't the same...
but thanks for sizing it down.

@Richux,

:cool: no pls.
 
Sorry but is actually stupid use add event if we have globalevents

Lua:
local info = 
 {
  [1] = "Vote for our server ...",
  [2] = "Read the news of our server every day ...",
  [3] = "Blah Blah"
 }
function onThink(interval, lastExecution)
 doBroadcastMessage(info[math.random(1, #info)], 19)
 return TRUE
end
 
The hole Point of the script was to make it so you can turn it on and turn it off. Via why its made in talkactions not in globalevents
 
@up

still useless

using globalstorage you can do this way

Lua:
local info = 
{
 [1] = "text 1",
 [2] = "text 2",
 [3] = "text 3"
}
function onThink(interval, lastExecution)
 if (getGlobalStorageValue(5850) == 1) then
  doBroadcastMessage(info[math.random(1, #info)], 19)
 end
 return TRUE
end

Lua:
function onSay(cid, words, param, channel)
 setGlobalStorageValue(5850, param == "on" and 1 or 0)
 return TRUE
end
 
@Up,

Tell Colandus that this script is useless, I am sure hell be happy to hear.
 
yes he will happy, im sure that he used it in a very old server (when globalevents didnt exist yet) and for your knowing in old times when we (me and he) werent inactive, we shared and compared our script via msn, and he done it (auto bc) same way as i posted ;) kisses
 
@Up,

Okay...:cool:
(Don't get all offensive on me, I just updated it)
 
Status
Not open for further replies.
Back
Top