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

Broadcast NPC

Imfreezing

Krossa Kapitalismen
Joined
Jun 7, 2012
Messages
1,009
Solutions
1
Reaction score
88
Location
Edron
hello guys,do you guys have BROADCAST npc? that would be amazing if u had,Rep+ if helping (short ^^)
Kind regard Us from Forthefun :P
 
You can also use this one if you don't need the extra stuff.
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(msgcontains(msg, 'o') or msgcontains(msg, 'a') or msgcontains(msg, 'i') or msgcontains(msg, 'e') and talkState[talkUser] == 0) then
		selfSay("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 getPlayerMoney(cid) >= 100 then
		doBroadcastMessage(getCreatureName(cid) ..": ".. messages[cid])
                doPlayerRemoveMoney(cid, 100)
		else
			selfSay("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())
 
Back
Top