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

TFS 1.X+ broadcast talkaction possible to tutor without changing flags

Thorn

Spriting since 2013
Joined
Sep 24, 2012
Messages
2,203
Solutions
1
Reaction score
922
Location
Chile
Hello guys!! is it possible to change this broadcast script to work with access?? account access? i want onluy gms and tutor be allowed to broadcast, but without changing the flag values?

tfs 1.3
LUA:
local color = {
    ['green'] = MESSAGE_INFO_DESCR,
    ['blue'] = MESSAGE_STATUS_CONSOLE_BLUE,
    ['orange'] = MESSAGE_STATUS_CONSOLE_ORANGE,
    ['white'] = MESSAGE_EVENT_ADVANCE,
}
function onSay(player, words, param)
    if not player:hasFlag(PlayerFlag_CanBroadcast) then
        return true
    end
    local split = param:split(",")
    if color[split[1]] == nil then
        player:sendCancelMessage("Wrong color")
        return false
    end
    broadcastMessage(split[2], color[split[1]])
    return false
end
 
LUA:
if player:getGroup():getId() < 2 then
  return true
end
(assuming tutor is group 2)
instead of
LUA:
    if not player:hasFlag(PlayerFlag_CanBroadcast) then
        return true
    end


//btw. this one's basic. you could learn to do something like this at least.
 
LUA:
if player:getGroup():getId() < 2 then
  return true
end
(assuming tutor is group 2)
instead of
LUA:
    if not player:hasFlag(PlayerFlag_CanBroadcast) then
        return true
    end


//btw. this one's basic. you could learn to do something like this at least.
oh actually i tried that before and didnt work :S
if player:getGroup():getId() <= 2 then

added the = because he has type account 2, but that didnt work either :S
 
oh actually i tried that before and didnt work :S
if player:getGroup():getId() <= 2 then

added the = because he has type account 2, but that didnt work either :S
Because <= is 'lower or equal', so if player has group id 2 then it wont work. (because it equals 2)
 
Because <= is 'lower or equal', so if player has group id 2 then it wont work. (because it equals 2)
Code:
function onSay(player, words, param)
    if player:getAccountType() < ACCOUNT_TYPE_TUTOR then
        return false
    end

    print("> " .. player:getName() .. " broadcasted: \"" .. param .. "\".")
    for _, targetPlayer in ipairs(Game.getPlayers()) do
        targetPlayer:sendPrivateMessage(player, param, TALKTYPE_BROADCAST)
    end
    return false
end

Fixed it!! now it works as expected :)
 
Back
Top