Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local keywordHandler = KeywordHandler:new()
- local npcHandler = NpcHandler:new(keywordHandler)
- NpcSystem.parseParameters(npcHandler)
- local t, K = {
- level = 75,
- minl = 10,
- maxl = 150,
- base = 25000,
- char = 1000,
- timer = 45001
- }, {}
- 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 greetCallback(cid)
- K[cid] = nil
- return true
- end
- function creatureSayCallback(cid, type, msg)
- if not npcHandler:isFocused(cid) then
- return false
- elseif not K[cid] then
- if t.level and getPlayerLevel(cid) < t.level then
- selfSay('You need to be level ' .. t.level .. ' or higher to broadcast.', cid)
- elseif t.minl and msg:len() < t.minl then
- selfSay('Your message must contain at least ' .. t.minl .. ' characters.', cid)
- elseif t.maxl and msg:len() >= t.maxl then
- selfSay('Your message may contain no more than ' .. t.maxl .. ' characters.', cid)
- else
- selfSay('Do you want to broadcast this message for ' .. (t.base or 0) + (t.char or 0) * msg:len() .. ' gold?', cid)
- K[cid] = msg
- end
- elseif K[cid] and msgcontains(msg, 'yes') then
- if doPlayerRemoveMoney(cid, (t.base or 0) + (t.char or 0) * K[cid]:len()) then
- for _, pid in ipairs(getPlayersOnline()) do
- doCreatureSay(cid, K[cid], TALKTYPE_BROADCAST, false, pid)
- end
- selfSay('Your message has been broadcasted.', cid)
- else
- selfSay('Come back when you\'ve got enough money!', cid)
- end
- K[cid] = nil
- end
- return true
- end
- npcHandler:setCallback(CALLBACK_GREET, greetCallback)
- npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
- npcHandler:addModule(FocusModule:new())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement