• 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 Script help

TriamerA

The Mystic One.
Joined
Nov 16, 2008
Messages
1,257
Reaction score
18
Location
Poland
So that's the error which is making troubles for me
Code:
[Warning - NpcScript::NpcScript] Can not load script: data/npc/scripts/john.lua
data/npc/scripts/john.lua:21: 'then' expected near '='

and that's the script
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

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

	local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid

	if(msgcontains(msg, 'hi') or msgcontains(msg, 'hello')) then 
		selfSay('Hello, what do you need??', cid)
		talkState[talkUser] = 1
	if msgcontains(msg, 'Kate') and talkState[talkUser] = 1 and getPlayerStorageValue(cid, 171711) = 1 then 
		selfSay('ahh she told me about you... do you want to help me??!!', cid)
		if msgcontains(msg, 'yes')
		selfSay('go there and make something.',cid)
		end
		else selfSay('Bye then.',cid)
		end
		
		

	end

	return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
I can't fix that by myself, maybe someone can.
 
LUA:
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

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

	local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid

	if(msgcontains(msg, 'hi') or msgcontains(msg, 'hello')) then 
		selfSay('Hello, what do you need??', cid)
		talkState[talkUser] = 1
	if msgcontains(msg, 'Kate') and talkState[talkUser] == 1 and getPlayerStorageValue(cid, 171711) == 1 then 
		selfSay('ahh she told me about you... do you want to help me??!!', cid)
		if msgcontains(msg, 'yes')
		selfSay('go there and make something.',cid)
		end
		else selfSay('Bye then.',cid)
		end
	end

	return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
When you are GETTING values, you should use ==, but when you are SETTING values, =.
 
Back
Top