• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Broadcasting NPC.

Snow

New Member
Joined
Jan 16, 2008
Messages
381
Reaction score
0
Well, I want a broadcasting npc, not too complicated that asks 1k for each broadcast like for example.

Player:broadcast
NPC:What would you like to broadcast
Player:POI Service 250k
NPC says that in Red and takes 1k.


I'll give rep++
 
in NPC its hard |:

if Player says: pits of inferno
npc will broad cast: NPC: PLAYERNAME's now starting a POI Service! Message to him.

LUA:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}

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 money = 1000
	
    if msgcontains(msg, 'pits of inferno') then 
        if doPlayerRemoveMoney(cid, money) == TRUE then  	
            doBroadcastMessage("NPC: ".. getPlayerName(cid) .."'s now starting a POI Service! Message to him.", MESSAGE_STATUS_WARNING)
        else
            doPlayerSendCancel(cid, "You need ".. money .." gold coins.")
        end	
    elseif msgcontains(msg, 'inquisition') then
        if doPlayerRemoveMoney(cid, money) == TRUE then    
            doBroadcastMessage("NPC: ".. getPlayerName(cid) .."'s now starting a Inquisition Quest Service! Message to him.", MESSAGE_STATUS_WARNING)
        else
            doPlayerSendCancel(cid, "You need ".. money .." gold coins.")
        end	
    end
    return TRUE
end

local shopModule = ShopModule:new()
npcHandler:addModule(shopModule)

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())



---


but in talkactions, it's easy!

say: /service Inquisition Quest, 1000

broadcast: 21:06 QuestService: josejunior23's now starting a PoiQuest! Price: 5000k.

LUA:
local config = {
    priceForEachMessage = 10000, 
    levelToUseQuestService = 50
}

function onSay(cid, words, param, channel)
    if(param == "") then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "[ERROR] Command requires param.")
    return TRUE
    end
	
    local t = string.explode(param, ",")
    if(not t[2]) then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "[ERROR] /service servicename, price(gold coins)")
        return TRUE
    end	
	
    if(isNumber(t[2]) == FALSE) then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "[ERROR] Price can be only numbers.")
        return TRUE
    end		
	
    if(getPlayerLevel(cid) <= config.levelToUseQuestService) then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "[ERROR] Only Players Level " .. config.levelToUseQuestService .. " or more may use this command.")	
        return TRUE 
    end

    if(doPlayerRemoveMoney(cid, config.priceForEachMessage) == TRUE) then
        doBroadcastMessage("QuestService: " .. getPlayerName(cid) .. "'s now starting a " .. t[1] .. "! Price: " .. t[2] .. "k.", MESSAGE_STATUS_WARNING)
    else
        doPlayerSendCancel(cid, "[ERROR] You need " .. config.priceForEachMessage .. " gold coins to send a message.")
    end
    return TRUE 
end
 
Last edited:
Back
Top