• 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 Player Broadcast

Status
Not open for further replies.

JDB

OtLand Veteran
Joined
Jun 1, 2009
Messages
4,145
Solutions
2
Reaction score
115
This broadcast script was released a long time ago by Colandus.
I have re-coded it, added new features, updated it and it works.


Credits:
JDB -- Updated/New Features
Colandus -- Original Idea


data/lib/data.lua: -- Add to bottom of data.lua
Lua:
dofile(getDataDir() .. "lib/exhaustion.lua")

data/talkactions/talkactions.xml:
PHP:
<talkaction words="!broadcast" event="script" value="player_broadcast.lua"/>

data/talkactions/scripts/player_broadcast.lua
Lua:
--- Config ---
local levelReq = 100 -- Level needed to use the command.
local minChars = 3 -- How many characters may you write as minumum?
local basePrice = 50 -- Base price, will be multiplied by the players level.
local group_id = 2 -- Group to not use the script.

--- Exhaust Settings ---
local useExhaust = TRUE -- FALSE = Broadcast as fast as they want.
local storageValue = 1235 -- Storage for Exhaust to work.
local exhaustTime = 1 -- Minutes.
--- End config ---

function onSay(cid, words, param)
local letterPrice = basePrice + getPlayerLevel(cid) * 2
local broadcastPrice = letterPrice * string.len(param)
    if getPlayerLevel(cid) < levelReq then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "Sorry, you need to be atleast level " .. levelReq .. " to use this command.")
    return TRUE
    end
    if (useExhaust == TRUE) and getPlayerStorageValue(cid, storageValue) == 1 then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Sorry, you need to wait before broadcasting another message.")
    return TRUE
    end
    if string.len(param) < minChars then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Sorry, you need to enter atleast " .. minChars .. " characters. Each character will cost you " .. letterPrice .. " gold coins.")
    return TRUE
    end
    if getPlayerGroupId(cid) > group_id then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Sorry, staff members do not need to broadcast messages with this command.")
    return TRUE
    end
    if doPlayerRemoveMoney(cid, broadcastPrice) == FALSE then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Sorry, you have not enough money. This message would have costed you " .. broadcastPrice .. " gold coins.")
    else
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Broadcast successfully sent. Your message contained " .. string.len(param) .. " characters and cost you " .. broadcastPrice .. " gold coins.")
        broadcastMessage(getPlayerName(cid) .. " [" .. getPlayerLevel(cid) .. "]: " .. param, MESSAGE_STATUS_WARNING)
        setPlayerStorageValue(cid, storageValue, 1)
        addEvent(endExhaust, exhaustTime * 60000, cid)
    end
end

function endExhaust(cid)
    if (useExhaust == TRUE) then
        setPlayerStorageValue(cid, storageValue, -1)
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "You may now broadcast another message.")
    end
end

I hope everyone likes this script,
it took me a while to figure this whole script out.
Hopefully it will be usefull to many people, I tried to explain it well.


How it works:
Prices: Each letter has a certain price; [local basePrice].
---
Levels: The player level decides the price basically.
The higher of level you are, the more the message will cost.
---
Length: Of course the length of the message will determine the price also.
 
Last edited:
Hope you like it :cool:
Took me a while to get the exhaust thing...
trying to use "exhaustion.set(cid, storage, exhaustTime)"

Didn't work, so I just added an event.
 
Thanks mate. Been looking for a script for this and using it right now. Thanks again! ;)
 
Glad you liked it, not many people like to post on my threads. :huh:
 
Works fine for me, thanks for releasing!
 
what if player log out $:?

d:

Logged off and on.
Code:
13:14 Sorry, you need to wait before broadcasting another message.

It just doesn't send the last message if your logging off and on.
But the storage will still work.
 
Last edited:
The exhaust is so he can't spam broadcasts...

Logs Off - Logs On
Lua:
local storage = xxxx
function onLogin(cid)
    if getPlayerStorageValue(cid, storage) ~= 1 then
	doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You may broadcast a message if you wish.")
    else
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You still have time left, and you cannot broadcast any messages.")
    end
    return TRUE
end
 
Last edited:
The exhaust is so he can't spam broadcasts...

Logs Off - Logs On
Lua:
local storage = xxxx
function onLogin(cid)
    if getPlayerStorageValue(cid, storage) ~= 1 then
	doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You may broadcast a message if you wish.")
    else
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You still have time left, and you cannot broadcast any messages.")
    end
    return TRUE
end

No, thats not what I asked. Does it just exhaust the player sending it, or the talkaction from being used in general? Like one broadcast per minute, not one player sending one every minute
 
It exhausts him, so he can't use broadcasts right after eachother...
So noobs don't spam server.
 
Thanks, oh no Nahruto is here...
Gonna make it smaller?

joke :cool:
 
for me this doesnt works (i'm using tfs 0.3.1 - tibia client 8.4)
 
Status
Not open for further replies.
Back
Top