• 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!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

NPC Simple Broadcast npc (tested on tfs)

rarevps

New Member
Joined
Apr 9, 2009
Messages
1
Reaction score
0
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)
 
yo man thanks for the script but for me when i try to "buy" a broadcast he just takes money from me...
i say broadcast and then he takes the money and says come back when you have enough money!
thanks for the stuff dude :)
 
Back
Top