Alright guys been working on this about a hour now seems to be working nicely , I hope someone has a use for it!
PHP:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
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
-------------------------User varibles:
local broadcastcost = 100000 --Cost to broadcast a message
npcHandler:addModule(FocusModule:new())
function creatureSayCallback(cid, type, msg)
if msg ~= "broadcast" and trigger=="1" and lastpayer==getCreatureName(cid) then --Has the user asked to broadcast yet? If so broadcast there message
trigger = "0" --Set trigger to 0 to prevent constant re-looping
doCreatureSay(cid, msg, TALKTYPE_BROADCAST) --Broadcast the message
end
if msg == "broadcast" then --User is asking to broadcast (if1)
if doPlayerRemoveMoney(cid, broadcastcost) == 1 then --Check if money was taken from user (if2)
lastpayer=getCreatureName(cid) --Remember who paid last , so if the npc looses focus and someone else comes alone they wont get a free broadcast!
selfSay("Ok . Please tell me the message to broadcast",cid)
trigger="1" --User has paid and the next message they enter is the message to broadcast
else --User did not pay (if2 failed) so lets tell them there too poor...
selfSay("Come back when you have enough gold!",cid)
end --End if1
end --Enf if2
end --End function
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)