• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

[NPC] Worker

Synergy

New Member
Joined
Nov 24, 2011
Messages
334
Reaction score
0
Hello!

I request an npc for the latest tfs distro. 0.2.12 9.46

The name is "Worker"

An DWARF npc that will face one direction and stand still and talk to himself randomly with 4 phrases.
If you say "hi" to him he will answer: "Can't you see i'm busy?!?"


Thanks in advance, rep++

/ J


Edit:

BTW, please only post the npcs xml and lua and not any suggestions or stuff, will be given rep++ after
Thanks.
 
Last edited:
This may work for 0.2:

Credits to Phoowned.
LUA:
local random_texts = {'text1', 'text2', 'text3', 'text4'}
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() local startLookDirection = EAST if #npcHandler.focuses == 0 then selfTurn(startLookDirection) end npcHandler:onThink() end
	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="TestNPCdwarf" script="dwarf.lua" walkinterval="2000" floorchange="0">
	<health now="100" max="100"/>
	<look type="139" head="20" body="39" legs="45" feet="7" addons="0"/>
</npc>
 
Thanks, added you rep since you helped me with last one anyways.
Love you bro! XDXD

But heres the funny thing.. I cant even summon the worker and I get no errors only this:
[23/05/2012 23:21:25] [Warning - NpcScript::NpcScript] Can not load script: worker.lua
[23/05/2012 23:21:25] cannot open worker.lua: No such file or directory
 
Now i changed name to dwarf, in xml to dwarf and the lua file to dwarf, it says the same but cant find "dwarf" lool..

This is weird.. all the other npcs can be found..
 
Nop.. Isn't there anyone except WarOfTheTitans who can help me?
Is the community dead ?O_O


BTW, thank you for giving it your time wott. :)
 
I am not sure if this will work for you, but you can try. (since you're using an old distro)

Use this XML code, but save it as special dwarf.xml:

Code:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Dwarf" script="dwarf.lua" walkinterval="2000" floorchange="0">
	<health now="100" max="100"/>
	<look type="139" head="20" body="39" legs="45" feet="7" addons="0"/>
</npc>

The LUA script of this npc should be named dwarf.lua, as written in the xml code, and should be placed in the scripts folder.
Now when you want to summon this NPC, type "/n special dwarf" and he will be summoned.

Ingame NPC names are loaded from the inside of the script, while the NPC files themselves can have different names which are used to approach them. So it doesn't matter what you put as a file name of its xml, it only matters what's inside.
 
Now it found but now it has this error:


[26/05/2012 21:26:42] [Warning - NpcScript::NpcScript] Can not load script: data/npc/scripts/dwarf.lua
[26/05/2012 21:26:42] data/npc/scripts/dwarf.lua:19: '<eof>' expected near 'end'
 
PHP:
local random_texts = {'text1', 'text2', 'text3', 'text4'}
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() local startLookDirection = EAST if #npcHandler.focuses == 0 then selfTurn(startLookDirection) end npcHandler:onThink() end
	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()
 
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())

try
 
Back
Top