• 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.

[TFS 1.1] Players Broadcast

Hokku

Member
Joined
Jul 25, 2013
Messages
95
Reaction score
18
Location
Extremadura, Spain
Hello!
Here is a player broadcast system working on TFS 1.1 by Mark Samman, min level, broadcast price, time betwen broadcasts, and how it is displayed in chat can be configured. I didnt made this script, just took and modified to work in TFS 1.1.

data/talkactions/scripts/broadcast22.lua
Code:
local config = {
storage = 19400, -- change to an non used storage if u use it
cor = "advance", -- No working on TFS 1.1, edit line 21 param
tempo = 2, -- in minutes
price = 1000, -- price of each bc
level = 100 -- lvl requiered to use bc
}


function onSay(cid, words, param, channel)
if(param == '') then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command param required.")
return true
end


if getPlayerLevel(cid) >= config.level then
if getPlayerStorageValue(cid, config.storage) - os.time() <= 0 then
if doPlayerRemoveMoney(cid, config.price) then
setPlayerStorageValue(cid, config.storage, os.time() + (config.tempo*60))
Game.broadcastMessage("[ALL] "..getCreatureName(cid)..": "..param.."", MESSAGE_STATUS_CONSOLE_ORANGE)
doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, "You have successfully sent a broadcast, now you'll have to wait " ..config.tempo.. " minute(s) until you broadcast again.")
else
doPlayerSendCancel(cid, "You don't have " ..config.price.. " gp's for broadcasting.")
return true
end
else
doPlayerSendCancel(cid, "You have to wait " ..(getPlayerStorageValue(cid, config.storage) - os.time()).. " seconds until you can broadcast again.")
return true
end
else
doPlayerSendCancel(cid, "You have to be level " ..config.level.. " or more in order to use broadcast.")
end
end

data/talkactions.xml
<talkaction words="/all" separator=" " script="broadcast22.lua"/>

Enjoy! ;)
 
Is there option to make NPC that could broadcast your message in same way.
>he is receiving money>now you say what you want to>it's broadcasted>cooldown 2h for each player?
 
#2 Thanks!

#3 Yes ofcourse, its not seems to be hard, but i dont know how to, im newbie on xml and lua atm, sorry.
 
Last edited:
Nice... but can add some functions like anti-advertising ("www", ".com") ? :D

Because someone will take some money and will broadcast his server ;S
 
doesnt work for 0.3.6? ;d

Code:
[16/02/2016 22:04:37] [Error - TalkAction Interface] 
[16/02/2016 22:04:37] data/talkactions/scripts/playerbroadcast.lua:onSay
[16/02/2016 22:04:37] Description: 
[16/02/2016 22:04:37] data/talkactions/scripts/playerbroadcast.lua:21: attempt to index global 'Game' (a nil value)
[16/02/2016 22:04:37] stack traceback:
[16/02/2016 22:04:37]     data/talkactions/scripts/playerbroadcast.lua:21: in function <data/talkactions/scripts/playerbroadcast.lua:10>
 
doesnt work for 0.3.6? ;d

Code:
[16/02/2016 22:04:37] [Error - TalkAction Interface]
[16/02/2016 22:04:37] data/talkactions/scripts/playerbroadcast.lua:onSay
[16/02/2016 22:04:37] Description:
[16/02/2016 22:04:37] data/talkactions/scripts/playerbroadcast.lua:21: attempt to index global 'Game' (a nil value)
[16/02/2016 22:04:37] stack traceback:
[16/02/2016 22:04:37]     data/talkactions/scripts/playerbroadcast.lua:21: in function <data/talkactions/scripts/playerbroadcast.lua:10>

broadcastMessage
 
do i replace 'Game' with 'broadcastMessage'?
You know how I figure out how to write code for the scripts I write for you people?
I check the sources, and you can do the same thing too.
If you are using the latest distro then just do a search on the function
https://github.com/otland/forgottenserver/search?l=lua&q=broadcastMessage&utf8=✓

You don't even need to open the scripts up, you will see a list of scripts if any and them in use along with their arguments if any.
Make a comparison with what exists and apply changes as needed, if the function doesn't exist then break up the word broadcast Message.
 
You know how I figure out how to write code for the scripts I write for you people?
I check the sources, and you can do the same thing too.
If you are using the latest distro then just do a search on the function
https://github.com/otland/forgottenserver/search?l=lua&q=broadcastMessage&utf8=✓

You don't even need to open the scripts up, you will see a list of scripts if any and them in use along with their arguments if any.
Make a comparison with what exists and apply changes as needed, if the function doesn't exist then break up the word broadcast Message.
i already fixed it but thanks ^^
 
Back
Top