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

Whats wrong with this? :P

furstwin

Member
Joined
Aug 9, 2007
Messages
511
Reaction score
15
Location
Sweden
As the title :P

The npc will repond but not to 'ticket' :(

LUA:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

-- OTServ event handling functions start
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
-- OTServ event handling functions end

function creatureSayCallback(cid, type, msg)
	-- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.
        if(not npcHandler:isFocused(cid)) then
                return false
        end  
        local config = {
                ["normalpot"] = 7636,
                ["strongpot"] = 7634,
                ["greatpot"] = 7635
                }

		
		if msgcontains(msg, 'job') then
			npcHandler:say('I can give you a "lotery ticket" for 100 empty vials.')
		elseif msgcontains(msg, 'lottery ticket') then
			npcHandler:say('To get a lottery ticket you need 100 vials of different kinds. Say {Ticket} to try your luck')
		elseif msgcontains(msg, 'lottery') then
			npcHandler:say('To get a lottery ticket you need 100 vials of different kinds. Say {Ticket} to try your luck')
------------------------------------------------ addon ------------------------------------------------
		if msgcontains(msg, 'ticket') then
		--normal pot
		if getPlayerItemCount(cid, config.normalpot) >= 100 then
		npcHandler:say('Do you wish to exchange 100 vials for a lottery ticket?')
		talk_state = 100
		--strong pot
		elseif getPlayerItemCount(cid, config.strongpot) >= 100 then
		npcHandler:say('Do you wish to exchange 100 vials for a lottery ticket?')
		talk_state = 200
		--great pot
		elseif getPlayerItemCount(cid, config.greatpot) >= 100 then
		npcHandler:say('Do you wish to exchange 100 vials for a lottery ticket?')
		talk_state = 300
			end	
			else npcHandler:say('You dont have these items!')
			end
------------------------------------------------ confirm yes normal pot------------------------------------------------
		elseif msgcontains(msg, 'yes') and talk_state == 100 then
			talk_state = 0
			if getPlayerItemCount(cid,config.normalpot) >= 100 then
					if doPlayerTakeItem(cid,config.normalpot) == 100 then
						npcHandler:say('Here you are. I wish you the best luck!')
                    			doPlayerAddItem(cid,5957,1)
					end
				else
				npcHandler:say('Sorry, you don\'t have these items.')
			end
			------------------------------------------------ confirm yes strong pot------------------------------------------------
		elseif msgcontains(msg, 'yes') and talk_state == 200 then
			talk_state = 0
			if getPlayerItemCount(cid,config.strongpot) >= 100 then
					if doPlayerTakeItem(cid,config.strongpot) == 100 then
						npcHandler:say('Here you are. I wish you the best luck!')
                    			doPlayerAddItem(cid,5957,1)
					end
				else
				npcHandler:say('Sorry, you don\'t have these items.')
			end
			------------------------------------------------ confirm yes great pot------------------------------------------------
		elseif msgcontains(msg, 'yes') and talk_state == 300 then
			talk_state = 0
			if getPlayerItemCount(cid,cinfig.greatpot) >= 100 then
					if doPlayerTakeItem(cid,config.greatpot) == 100 then
						npcHandler:say('Here you are. I wish you the best luck!')
                    			doPlayerAddItem(cid,5957,1)
					end
				else
				npcHandler:say('Sorry, you don\'t have these items.')
			end
------------------------------------------------ confirm no ------------------------------------------------
		elseif msgcontains(msg, 'no') and (talk_state >= 100 and talk_state <= 300) then
			npcHandler:say('Ok than.')
			talk_state = 0
		end
		
	-- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.
	return true
end

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

I guess I've done alot wrong as im a LUA beginner.



Sincerely,
Furstwin.
 
Last edited:
Change
LUA:
        local config = {
                ["normalpot"] = 7636
                ["strongpot"] = 7634
                ["greatpot"] = 7635
                }

To
LUA:
        local config = {
                normalpot = 7636,
                strongpot = 7634,
                greatpot = 7635
                }
 
AH! Thanks ima test! :)
EDIT: I could summon the npc but she didnt respond to "ticket" and I got no error in console.. :(
 
Last edited:
Using 8.2 or higher?

If so, change
PHP:
        if(npcHandler.focus ~= cid) then
                return false
        end
to
PHP:
        if(not npcHandler:isFocused(cid)) then
                return false
        end

I'll try, im using the latest :p 0.3.4 pl2~

EDIT: He will still not respond :( Also edited main post with the configured lua file
 
Last edited:
Back
Top