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

How to add broadcast type for npc

SixNine

Active Member
Joined
Dec 12, 2018
Messages
452
Reaction score
41
Hi,
so i made this ugly code but i cant figure out how to change broadcast type to one that send in the middle of screen since now its sends in default chat only i was looking into /b talkaction so i though maybe it just not possible i dont know. This is my code TFS 1.2
Lua:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
local messages = {}

function onCreatureAppear(cid)            npcHandler:onCreatureAppear(cid)            end
function onCreatureDisappear(cid)            npcHandler:onCreatureDisappear(cid)            end
function onCreatureSay(cid, type, msg)        npcHandler:onCreatureSay(cid, type, msg)        end
function onThink()                    npcHandler:onThink()                    end

function creatureSayCallback(cid, type, msg)
    if(not npcHandler:isFocused(cid)) then
        return false
    end

    local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
    if not isPremium(cid) then
    npcHandler:say("You dont have premium!", cid)

    elseif(msgcontains(msg, 'broadcast') or msgcontains(msg, 'b') or msgcontains(msg, 'cast') or msgcontains(msg, 'broadcastt') and talkState[talkUser] == 0) then
        npcHandler:say("Do you want to broadcast '".. msg .."' for 100 gold?", cid)
        messages[cid] = msg
        talkState[talkUser] = 1
    elseif (msg == "yes" and talkState[talkUser] == 1) then
        if getPlayerItemCount(cid, 2160) >= 100 then
        broadcastMessage(getCreatureName(cid) ..": ".. messages[cid])
        doPlayerRemoveItem(cid, 2160, 100)
        else
            npcHandler:say("You don't have enough money.", cid)
        end
        messages[cid] = nil
        talkState[talkUser] = 0
    end
    return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())/code]
 
Thanks buddy, what if i want in to be in default chat either so i should use two broadcastmessages?
These are all the message types that show up in default chat:
Code:
MESSAGE_STATUS_CONSOLE_BLUE
MESSAGE_STATUS_CONSOLE_ORANGE
MESSAGE_STATUS_CONSOLE_RED
 
These are all the message types that show up in default chat:
Code:
MESSAGE_STATUS_CONSOLE_BLUE
MESSAGE_STATUS_CONSOLE_ORANGE
MESSAGE_STATUS_CONSOLE_RED
It didnt answer the question if it have to be two broadcastmessages like this if i want in the mid and default chat
Game.broadcastMessage(getCreatureName(cid) ..": ".. messages[cid], MESSAGE_INFO_DESCR)
Game.broadcastMessage(getCreatureName(cid) ..": ".. messages[cid], MESSAGE_STATUS_CONSOLE_BLUE)
but i will take it as a yes
 
It didnt answer the question if it have to be two broadcastmessages like this if i want in the mid and default chat
Game.broadcastMessage(getCreatureName(cid) ..": ".. messages[cid], MESSAGE_INFO_DESCR)
Game.broadcastMessage(getCreatureName(cid) ..": ".. messages[cid], MESSAGE_STATUS_CONSOLE_BLUE)
but i will take it as a yes
Yes, you need to use 2 separate broadcasts.
 
Back
Top