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

TalkAction [1.X] simple working broadcast script for player

Levi999x

AoT
Joined
Dec 14, 2017
Messages
1,756
Solutions
34
Reaction score
978
Location
Germany
How it looks like

1629570468913.png

data/scripts/otland.lua

Lua:
local broadcast = TalkAction("!broadcastplayer")

local config = {
    level = 50,
    cost = 100,
    exhaust = 5,
    storage = 3929
}

function broadcast.onSay(player, words, param)
   
    if player:getStorageValue(config.storage) >= os.time() then
        player:sendCancelMessage("You cant use it now")
        return false
    end

    if player:getLevel() < config.level then
        player:sendTextMessage(MESSAGE_INFO_DESCR, 'You must be at least level ".. config.level .." to broadcast')
        return false
    end
   
    if (param == '') then
        player:sendTextMessage(MESSAGE_INFO_DESCR, 'Enter a text.')
        return false
    end
    if player:removeMoney(config.cost) then
        for _, allPlayer in ipairs(Game.getPlayers()) do
            allPlayer:sendTextMessage(MESSAGE_INFO_DESCR, ''..player:getName()..' ['..player:getLevel()..'] '..param..'')
            player:setStorageValue(config.storage, os.time() + config.exhaust)
        end
    else
        player:sendTextMessage(MESSAGE_INFO_DESCR, 'You dont have enough money to broadcast.')
    end
    return false
end

broadcast:separator(" ")
broadcast:register()

usage:

!broadcastplayer TEXT
 
Top