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

Lua What does this mean?

Sherice

Sky&Wind
Joined
Jan 20, 2012
Messages
183
Reaction score
7
Location
Sweden
Hi guys, as the title said, what does this error mean?:

Code:
Description:
data/npc/lib/npc.lua:73: attempt to index local 'message' <a nil value>
[Warning - NpcEvents::NpcEvents] Cannot load script,
blablabla

Anyone that can tell me what the problem is?


Thx, Sherice.
 
Well there is a problem in line 73 and that the local 'message' has a nil value (learning lua atm so can't tell u that much xd)
 
Ok, thanks =)


[EDIT]: It says:

Code:
	local a, b = message:lower(), keyword:lower()

in npc.lua, so what's this?
 
Last edited:
Ok:

Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
 
local Topic = {}
local storage = 20000
 
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 creatureSayCallback(cid, type, msg)
	local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
	if msgcontains(msg, "hi") or msgcontains(msg, "hello") then
		if getPlayerStorageValue(cid, storage) == 1 then
			npcHandler:say("Have you brought the loot?", cid)
			Topic[talkUser] = 1
		end
		npcHandler:addFocus(cid)
		return true
	end
	if(not npcHandler:isFocused(cid)) then
		return false
	end
end
	if msgcontains(msg, "mission") or msgcontains(msg, "guard") and getPlayerStorageValue(cid, storage) > 0 then
		if getPlayerStorageValue(cid, storage) < 1 then
			npcHandler:say("You wish to become a guard? Are you sure you want to become a guard?", cid)
			Topic[talkUser] = 1
			doSetPlayerStorageValue(cid, storage, 3)
		elseif getPlayerStorageValue(cid, storage) == 1 then
			npcHandler:say("Have you brought the loot yet?", cid)
			Topic[talkUser] = 1
		elseif getPlayerStorageValue(cid, storage) == 2 then
			npcHandler:say("WIP.", cid)
			Topic[talkUser] = 0
		end
			end
			if msgcontains(msg, "yes") then
				if getPlayerStorageValue(cid, storage) == 3 then
			npcHandler:say("Alright, first, to become a guard, you have to prove your strength. Listen, lately, there have been some bandits lurking around the city, stealing stuff. I want you to take back the loot from them. Do you understand?", cid)
			Topic[talkUser] = 1
			doSetPlayerStorageValue(cid, storage, 4)
			end
			if msgcontains(msg, "yes") then
				if getPlayerStorageValue(cid, storage) == 4 then
			npcHandler:say("Good, go west from this hall, and you'll reach the west gate. Walk out of the city, and follow the sign warning of bandits. Good luck!", cid)
			doSetPlayerStorageValue(cid, storage, 1)
			npcHandler:releaseFocus(cid)
			Topic[talkUser] = 0
		end
	elseif Topic[talkUser] == 1 then
		if msgcontains(msg, "yes") then
			if getPlayerItemCount(cid, 13537) >= 1 then
				doPlayerRemoveItem(cid, 13537, 1)
				npcHandler:say("You acutally did it! You've now become a guard, congratulations!", cid)
				doPlayerAddExperience(cid, 5000)
				doPlayerSetVocation(cid, 4)
				setPlayerStorageValue(cid, storage, 2)
			else
				npcHandler:say("You dont have the items? Well, go and get them!", cid)
		end
		else
			npcHandler:say("Hey, go and get them already!", cid)
		end
		Topic[talkUser] = 0
	end
	return TRUE
end
 
npcHandler:setMessage(MESSAGE_WALKAWAY, "Good bye.")
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)

It's an NPC quest script, yea I know, it's fucked up, I just modified it, didn't make it all by myself. Couldn't change it back to original so, I suck at lua scripting :P
 

Similar threads

Back
Top