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

Lua Problem with lua

Tibiamakers

yourolist.com
Joined
May 24, 2010
Messages
1,377
Reaction score
97
Location
España
PHP:
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, 'cave')) and (getPlayerStorageValue(cid,13500,1)) then
SelfSay('Please Find {Kalima}, I need to know if it\'s alive!... tell her that I love her...',cid)
else
selfSay('Oh, Never told about it to nobody...do you want to know about that {cave}..?', cid)
talkState[talkUser] = 1
end

if(msgcontains(msg, 'no')) and talkState[talkUser] == 1 then
selfSay('I think, she will be... fine.', cid)
elseif (msgcontains(msg, 'yes')) or (msgcontains(msg, 'cave')) and talkState[talkUser] == 1 then
SelfSay(' Well i\'m a bit nervious... In that cave are the most horror can you think, nasty and horrible creatures live there, everybody who enter don\'t come again... But you.. You are the last hope to.. Well if you see {Kalima} tell her that I love her...',cid)
setPlayerStorageValue(cid,13500,1)
end

if(msgcontains(msg, 'Kalima')) and talkState[talkUser] == 1 then
SelfSay(' Kalima...she entered the cave...',cid)
else
SelfSay('How do you know that Name?! You know something about she?!',cid)
end
return true
end

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





I'm learning LUA, and I can't see the error here, someone can correct it or tell me what I have done wrong?

thanks:)
 
SelfSay doesn't exist it seems to me

try replacing SelfSay with
LUA:
npcHandler:say

try this
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, 'cave')) and (getPlayerStorageValue(cid,13500,1)) then 
npcHandler:say('Please Find {Kalima}, I need to know if it\'s alive!... tell her that I love her...',cid) 
else 
npcHandler:say('Oh, Never told about it to nobody...do you want to know about that {cave}..?', cid) 
talkState[talkUser] = 1 
end 

if(msgcontains(msg, 'no')) and talkState[talkUser] == 1 then 
npcHandler:say('I think, she will be... fine.', cid) 
elseif (msgcontains(msg, 'yes')) or (msgcontains(msg, 'cave')) and talkState[talkUser] == 1 then 
npcHandler:say(' Well i\'m a bit nervious... In that cave are the most horror can you think, nasty and horrible creatures live there, everybody who enter don\'t come again... But you.. You are the last hope to.. Well if you see {Kalima} tell her that I love her...',cid) 
setPlayerStorageValue(cid,13500,1) 
end 

if(msgcontains(msg, 'Kalima')) and talkState[talkUser] == 1 then 
npcHandler:say(' Kalima...she entered the cave...',cid) 
else 
npcHandler:say('How do you know that Name?! You know something about she?!',cid) 
end 
return true 
end 

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) 
npcHandler:addModule(FocusModule:new())
 
it exists, but my error was, use capital letter , it has to be selfSay('XXX', cid)

I think that npcHandler:say is the same as selfSay

but know I got another problem, I don't know if "setPlayerStorageValue(cid, 13500, 1)" is well written in the script because when I talk to him and say cave in console appears:

thanks for help :)
 
You should use KeywordHandler, not callack event.
LUA:
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
function onPlayerEndTrade(cid)				npcHandler:onPlayerEndTrade(cid)			end
function onPlayerCloseChannel(cid)			npcHandler:onPlayerCloseChannel(cid)		end

local node1 = keywordHandler:addKeyword({'promot'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I can promote you for 20000 gold coins. Do you want me to promote you?'})
	node1:addChildKeyword({'yes'}, StdModule.promotePlayer, {npcHandler = npcHandler, cost = 20000, level = 20, promotion = 1, text = 'Congratulations! You are now promoted.'})
	node1:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Alright then, come back when you are ready.', reset = true})
--[[
local node2 = keywordHandler:addKeyword({'epic'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I can epicize you for 200000 gold coins. Do you want me to epicize you?'})
	node2:addChildKeyword({'yes'}, StdModule.promotePlayer, {npcHandler = npcHandler, cost = 200000, level = 120, promotion = 2, text = 'Congratulations! You are now epicized.'})
	node2:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Alright then, come back when you are ready.', reset = true})
]]--

npcHandler:addModule(FocusModule:new())
 
Back
Top