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

RevScripts msg guild

alcapone

Member
Joined
Jan 13, 2021
Messages
246
Reaction score
19
I'm looking for a command that the guild leader will use and it will send msg to all guild members /b style
 
Solution
Lua:
local config = {
    storage = 89500,
    seconds = 60,
    maxlength = 100,
    messagetype = MESSAGE_STATUS_WARNING
}

local talk = TalkAction("/guildbc", "!guildbc")

function talk.onSay(player, words, param)
    if player:getStorageValue(config.storage) > os.time() then
        player:sendTextMessage(MESSAGE_STATUS_SMALL, "You can broadcast message only one time per " .. config.seconds .. " seconds.")
        return false
    end

    if not player:getGuild() then
        player:sendTextMessage(MESSAGE_STATUS_SMALL, "Sorry, you\'re not in a guild.")
        return false
    end

    if player:getGuildLevel() < 3 then
        player:sendTextMessage(MESSAGE_STATUS_SMALL, "You have to be at least leader to guildcast!")...
Lua:
local config = {
    storage = 89500,
    seconds = 60,
    maxlength = 100,
    messagetype = MESSAGE_STATUS_WARNING
}

local talk = TalkAction("/guildbc", "!guildbc")

function talk.onSay(player, words, param)
    if player:getStorageValue(config.storage) > os.time() then
        player:sendTextMessage(MESSAGE_STATUS_SMALL, "You can broadcast message only one time per " .. config.seconds .. " seconds.")
        return false
    end

    if not player:getGuild() then
        player:sendTextMessage(MESSAGE_STATUS_SMALL, "Sorry, you\'re not in a guild.")
        return false
    end

    if player:getGuildLevel() < 3 then
        player:sendTextMessage(MESSAGE_STATUS_SMALL, "You have to be at least leader to guildcast!")
        return false
    end

    if param == '' then
        player:sendTextMessage(MESSAGE_STATUS_SMALL, "You need to type a message to broadcast!")
        return false
    end

    if param:len() > config.maxlength then
        player:sendTextMessage(MESSAGE_STATUS_SMALL, "Your message max lenght " .. config.maxlength .. " characters")
        return false
    end

    local members, message = 0,
    "*Guild* " .. player:getName() .. " [" .. player:getLevel() .. "]:\n" .. param

    for i, players in ipairs(Game.getPlayers()) do
        if players:getGuild() and players:getGuild():getId() == player:getGuild():getId() then
            players:sendTextMessage(config.messagetype, message)
            members = members + 1
        end
    end

    player:sendTextMessage(MESSAGE_STATUS_SMALL, "Message sent to your guild members. (Total: " .. members .. ")")
    player:setStorageValue(config.storage, os.time() + config.seconds)
    return false
end

talk:separator(" ")
talk:register()
 
Last edited:
Solution
Back
Top