NPC Walker - walks, ignore players and spam configured messages.
[video=youtube;5GtTNKy38WM]http://www.youtube.com/watch?v=5GtTNKy38WM[/video]
Requested by Alegres ( http://otland.net/f83/request-two-npcs-128131/ ).
../data/npc/scripts/walker.lua
../data/npc/Walker.xml
[video=youtube;5GtTNKy38WM]http://www.youtube.com/watch?v=5GtTNKy38WM[/video]
Requested by Alegres ( http://otland.net/f83/request-two-npcs-128131/ ).
../data/npc/scripts/walker.lua
Lua:
local random_texts = {'Send SMSes!', 'Make donations!', 'Send PayPal transfers!', 'There is no game without donation items!'}
local random_texts_chance = 50 -- percent
local random_texts_interval = 2 -- seconds
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()
if(getCreatureStorage(getNpcId(), 1) < os.time()) then
doCreatureSetStorage(getNpcId(), 1, os.time() + random_texts_interval)
if(math.random(1, 100) < random_texts_chance) then
selfSay(random_texts[math.random(1, #random_texts)])
end
end
npcHandler:onThink()
end
function bajbajer(cid, type, msg)
selfSay('I am busy. I am spamming!',cid)
return false
end
npcHandler:setCallback(CALLBACK_GREET, bajbajer)
npcHandler:addModule(FocusModule:new())
XML:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Walker" script="walker.lua" walkinterval="600">
<health now="100" max="100"/>
<look type="131" head="58" body="43" legs="38" feet="76" addons="0"/>
<parameters>
</parameters>
</npc>