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

Solved Broadcast message debug

Hugofasima

Website: thenosegang.servegame.com
Joined
Jun 24, 2015
Messages
206
Reaction score
23
The following script is for TFS 1.0, and my TFS is 1.1. I can't see what is wrong with the script, heeelp :/


Problems:


-Distro error
- I can't send broadcast msgs with GOD account (debug error)

This error show up:
Code:
Lua Script Error: [Chat Interface]
data/chatchannels/scripts/events.lua:onJoin
LuaScriptInterface::luaAddEvent(). Argument #3 is unsafe
stack traceback:
        [C]: in function 'addEvent'
        data/chatchannels/scripts/events.lua:10: in function <data/chatchannels/
scripts/events.lua:9>

events.lua
Code:
local muted = createConditionObject(CONDITION_CHANNELMUTEDTICKS)
setConditionParam(muted, CONDITION_PARAM_SUBID, 32)
setConditionParam(muted, CONDITION_PARAM_TICKS, 1000)

function send_d_motd(cid)
   return Creature(cid):sendChannelMessage("", "[Channel]: Welcome to the event channel. Here you may talk about in-game events and receive news about their status.", TALKTYPE_CHANNEL_O, 32)
end

function onJoin(cid)
   addEvent(send_d_motd, 100, cid)
   return true
end

function onSpeak(cid, type, message)
   if getCreatureCondition(cid, CONDITION_CHANNELMUTEDTICKS, 32) then
     Creature(cid):sendChannelMessage("", "Please do not spam.", TALKTYPE_CHANNEL_O, 32)
     return false
   end
   doAddCondition(cid, muted)
   if getPlayerAccountType(cid) > 2 then
     if getPlayerGroupId(cid) > 2 then
       local groupnames = {[2] = "Mod", [3] = "Admin"}
       sendChannelMessage(32, TALKTYPE_CHANNEL_R1, getCreatureName(cid) .. " [" .. (groupnames[getPlayerGroupId(cid)] or "GM") .. "]: ".. message)
       return false
     end
   end
   return TALKTYPE_CHANNEL_Y
end

Untitled.jpg

Thanks OT Land!
 
Last edited:
from config.lua change

warnUnsafeScripts = true
to
warnUnsafeScripts = false

The error spam is solved! Thanks!!

Still debugin with broadcast send!


@EDIT --------------------------

SOLVED!!

The problem to debug was located on Talkactions

I've removed
Code:
local player = Player(cid)

So the script like
Code:
function onSay(cid, words, param)
    if not getPlayerFlagValue(cid, PlayerFlag_CanBroadcast) then
        return true
    end

    local player = Player(cid)
    print("> " .. player:getName() .. " broadcasted: \"" .. param .. "\".")
    for _, tmpPlayer in ipairs(Game.getPlayers()) do
        tmpPlayer:channelSay(player, TALKTYPE_BROADCAST, param, 0)
    end
    return false
end

Was changed to this:
Code:
function onSay(player, words, param)
    if not getPlayerFlagValue(player, PlayerFlag_CanBroadcast) then
        return true
    end

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