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

Doggynub

LUA / C++
Joined
Sep 28, 2008
Messages
2,541
Reaction score
186
in npc is there a way to say like this
local plaace = {["temple"]={pos = {x=y=z=}}

can i say like
place = plaace[msgcontain(msg)]

i dont know if this can be done?
 
Code:
local [COLOR="Blue"][B]place[/B][/COLOR] = { -- This is 'local'
   ["temple"]={pos = {x=y=z=}
}

[COLOR="Red"]place[/COLOR] = [COLOR="Blue"][I]place[/I][/COLOR][msgcontain(msg)] -- This is 'global', the 'Red' is not the Bold 'Blue' it's like a different statement, but after this 'place = place[msgcontain(msg)]' 'Red' is Bold 'Blue' plus what you have stated in []
if place then
	doTeleportThing(cid, place[msgcontain(msg)].pos, false)
end
I think that's how it would work, I'm not to good on NPC since I just started to work with them.
 
Last edited:
i just wantd to know if the msgcontain will work as a command to get values from thetable or not (i understand the rest ofcourse) :D
 
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

local places = {
	['temple'] = {x=100, y=100, z=7},
}

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
	
	for keyword, pos in pairs(places) do
		if msgcontains(msg, keyword) then
			return doTeleportThing(cid, pos)
		end
	end

	return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

local places = {
	['temple'] = {x=100, y=100, z=7}[B][COLOR="Red"],[/COLOR][/B]
}

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
	
	for keyword, pos in pairs(places) do
		if msgcontains(msg, keyword) then
			return doTeleportThing(cid, pos)
		end
	end

	return true
end

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




i think i shouldnt put that comma :)
Thx by the way :P
 
Back
Top