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

NPC Walker - walks, ignore players and spam configured msges

PhoOwned

^_^
Joined
Nov 11, 2010
Messages
375
Reaction score
66
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
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())
../data/npc/Walker.xml
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>
 
thanks for this. it reminded me of an NPC i had on a 7.5 server just updated it now for my current server using this as a base.
 
It's possible make the npc talk with you, if you have a certain storage value?
If you dont have the storage, the npc simply ignore you...
 
TheMaX said:
It's possible make the npc talk with you, if you have a certain storage value?
If you dont have the storage, the npc simply ignore you...

Lua:
function greeter(cid, type, msg)
	if(getCreatureStorage(cid, 12345) == 1) then -- check player storage
		selfSay('Welcome ' .. getCreatureName(cid) .. '! You have good storage.') -- say on default window (game window)
		selfSay('Welcome ' .. getCreatureName(cid) .. '! You have good storage.', cid) -- say on NPCs chat
		return true -- npc will add player to his focuses list - talk with him
	end
	return false -- npc will ignore player
end
 
npcHandler:setCallback(CALLBACK_GREET, greeter)
Add it at end of any NPC .lua file and it should work :thumbup:
 
instead of storage, you could've used a variable. yes i know they get deleted on reload
 
Hi! I have error :( I talk with "walker" and all my NPC say this: selfSay('I am busy. I am spamming!',cid)
can you fix?
 
RL OTservers these days in a nutshell:
Lua:
local random_texts = {'Send SMSes!', 'Make donations!', 'Send PayPal transfers!', 'There is no game without donation items!'}


tmo.png

Works perfectly, thread is little old, but have my three rep points for that awesome script anyway!

@up
in any npc find and replace:
Lua:
function onThink()                    npcHandler:onThink()                    end
for:
Lua:
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

and add this below other locals:
Lua:
local random_texts = {'Welcome to our humble temple.', 'If you are hurt ask me, I\'ll heal you.', 'Feeling lost? Ask me for help.', 'Praise our God. He has power to revive andventurers whose adventure is not over yet!'}
local random_texts_chance = 40 -- percent
local random_texts_interval = 5 -- seconds

if it doesn't work download tfs 0.3.7 pre1 from public svn and replace your npc system
 
NPC Walker - walks, ignore players and spam configured messages.

[video=youtube;5GtTNKy38WM]

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:eek:nCreatureAppear(cid) end
function onCreatureDisappear(cid)             npcHandler:eek:nCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg)     npcHandler:eek:nCreatureSay(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:eek:nThink()
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())
../data/npc/Walker.xml
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>
it keeps showing faces...FIX IT PLEASE!!!
 
Back
Top