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

izaak

New Member
Joined
Feb 1, 2009
Messages
161
Reaction score
3
Hi i have a problem with all my npc's
im 50% new to adding npc's on servers
im running tfs 3 -> forgotten server
i have this same error with each one of my npc's

data/npc/lib/npcsystem/modules.lua:764: attempt to call global 'getItemNameById' (a nil value)
[Warning - NpcScript::NpcScript] Can not load script: data/npc/scripts/parcel.lua

how can i fix this? cause idk what madules are and how to edit them im 100% new to the new npc system
 
Hi i have a problem with all my npc's
im 50% new to adding npc's on servers

i have this same error with each one of my npc's

data/npc/lib/npcsystem/modules.lua:764: attempt to call global 'getItemNameById' (a nil value)
[Warning - NpcScript::NpcScript] Can not load script: data/npc/scripts/parcel.lua

how can i fix this? cause idk what madules are and how to edit them im 100% new to the new npc system

data/npc/scripts/Parcel.lua <- copy all text in there and post here as "Code", Like this under here..

Code:
Post the npc in this "Code" :D
 
oke

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

local shopModule = ShopModule:new()
npcHandler:addModule(shopModule)

--NPC sell to Player--
shopModule:addBuyableItem({'parcel', 'parcel'}, 2595, 14, 'parcel')
shopModule:addBuyableItem({'letter', 'letter'}, 2597, 10, 'letter')
shopModule:addBuyableItem({'label', 'label'}, 2599, 1, 'label')

npcHandler:addModule(FocusModule:new())

okecan u post the selution here as a "code"like this :D:D
 
Last edited:
ive done what u said Cykotitan but now it gives this error

data/npc/scripts/parcel.lua:1: attempt to index global 'KeywordHandler' (a nil value)
[Warning - NpcScript::NpcScript] Can not load script: data/npc/scripts/parcel.lua
 
ive done what u said Cykotitan but now it gives this error

Have you replaced all 5 files:
PHP:
keywordhandler.lua
modules.lua
npchandler.lua
npcsystem.lua
queue.lua
with the ones at the repository? I think it shouldn't give you an error then.
 
k ie replaced all files but now i got this error

data/npc/lib/npcsystem/modules.lua:740: attempt to call global 'getItemName' (a nil value)
[Warning - NpcScript::NpcScript] Can not load script: data/npc/scripts/parcel.lua

sry for all the trouble but i rly need my npc's to work xD
 
k ie replaced all files but now i got this error



sry for all the trouble but i rly need my npc's to work xD

Download this one, and open it, put the folder in your server folder and accept all "Replace"..

this one wont remove anything of you server, it will just update your npc system..
data.zip

add me some Rep++ if it worked :D
 
Oops, I didn't notice you're using TFS 0.3
Maybe you've messed up the sources, as getItemNameById should work in TFS 0.3
 
wow im replacing a error with a diffrent error lol
i got another error :/ it might be the script or somthing idk

data/npc/lib/npcsystem/modules.lua:748: attempt to call global 'getItemNameById' (a nil value)
[Warning - NpcScript::NpcScript] Can not load script: data/npc/scripts/parcel.lua
 
Use this for buy npc's,

Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}

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

local shopModule = ShopModule:new()
npcHandler:addModule(shopModule)



shopModule:addBuyableItem({'ITEM NAME'}, ID NUMBER, PRICE IN GOLD, 'ITEM NAME')


function creatureSayCallback(cid, type, msg)
	if(not npcHandler:isFocused(cid)) then
		return false
	end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

This script are working with the update file you got from me,

you add more items by do this
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}

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

local shopModule = ShopModule:new()
npcHandler:addModule(shopModule)



shopModule:addBuyableItem({'ITEM NAME'}, ID NUMBER, PRICE IN GOLD, 'ITEM NAME')

[COLOR="Red"]
shopModule:addBuyableItem({'ITEM NAME'}, ID NUMBER, PRICE IN GOLD, 'ITEM NAME')[/COLOR]

function creatureSayCallback(cid, type, msg)
	if(not npcHandler:isFocused(cid)) then
		return false
	end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
oke i inported the script like this

function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end
function onThink() npcHandler:onThink() end

local shopModule = ShopModule:new()
npcHandler:addModule(shopModule)



shopModule:addBuyableItem({'parcel'}, 2595, 14, 'parcel')


shopModule:addBuyableItem({'label'}, 2599, 1, 'label')

function creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

but now i get this error

data/npc/scripts/parcel.lua:21: 'end' expected (to close 'function' at line 14) near '<eof>'
 
Code:
function creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false
end

Missing end, boobs.

Code:
function creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false
end
end
 
ok that fixed the error i got but gave me a new 1

data/npc/scripts/runes.lua:5: attempt to index global 'npcHandler' (a nil value)
[Warning - NpcScript::NpcScript] Can not load script: data/npc/scripts/runes.lua
 

Similar threads

Back
Top