• 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 script rupercht

Nefs

Nefs Staff
Joined
Jul 15, 2009
Messages
521
Reaction score
7
Location
Barcelona (Spain)
hello anywhere, i am working on my winter event, and i got problems with my present bag exchanger :S

He only say Hello i am the santa's helper, but when any1 say present bag, christmas token or something he dont say nothing :S

what's worng?

Npc.xml script
Code:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Ruprecht" script="data/npc/scripts/winterevent.lua" walkinterval="2000" floorchange="0">
	<health now="150" max="150"/>
	<look type="153" head="97" body="116" legs="116" feet="21" addons="3"/>
	<parameters>
		<parameter key="message_greet" value="Hello |PLAYERNAME|, I am the Santa's Helper."/>
	</parameters>
</npc>

his scripts
Code:
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 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(npcHandler.focus ~= cid) then
        return false
    end

    -- use the real conversation? (true/false)
    real = true
    
    if real == true then
        tradeMsg = 'I accept presents that were stolen from Santa by those little pest Grynch Goblins in exchange for christmas tokens.'
        presentMsg = 'Do you want trade a present bag for a christmas token?'
        gingerMsg = 'Do you want trade a christmas token for a gingerbread man?'
        recipeMsg = 'Do you want trade 10 christmas tokens for a gingerbread man recipe?'
        jewelMsg = 'Do you want trade 25 christmas tokens for a jewel case?'
        hatMsg = 'Do you want trade 50 christmas tokens for a santa hat?'
        dollMsg = 'Do you want trade 100 christmas tokens for a santa doll?'
        hasNoMsg = 'I only want present bags.'
        askMsg = 'I will trade a gingerbread man for 1 token, the gingerbread recipe for 10, a jewel case for 25, a santa hat for 50 and a santa doll for 100 tokens.'
        noMsg = 'I\'ll be here when you\'re ready.'
    else
        tradeMsg = 'I accept presents that were stolen from Santa by those little pest Grynch Goblins in exchange for christmas tokens.'
        presentMsg = 'Do you want trade a present bag for a christmas token?'
        gingerMsg = 'Do you want trade a christmas token for a gingerbread man?'
        recipeMsg = 'Do you want trade 10 christmas tokens for a gingerbread man recipe?'
        jewelMsg = 'Do you want trade 25 christmas tokens for a jewel case?'
        hatMsg = 'Do you want trade 50 christmas tokens for a santa hat?'
        dollMsg = 'Do you want trade 100 christmas tokens for a santa doll?'
        hasNoMsg = 'I only want present bags.'
        askMsg = 'I will trade a gingerbread man for 1 token, the gingerbread recipe for 10, a jewel case for 25, a santa hat for 50 and a santa doll for 100 tokens.'
        noMsg = 'I\'ll be here when you\'re ready.'
    end
        if msgcontains(msg, 'items') or msgcontains(msg, 'item') or msgcontains(msg, 'offers') or msgcontains(msg, 'offer') then
            selfSay(tradeMsg)
        elseif msgcontains(msg, 'christmas token') or msgcontains(msg, 'token') or msgcontains(msg, 'xmas token') then
            selfSay(askMsg)
        elseif msgcontains(msg, 'present bag') or msgcontains(msg, 'present') or msgcontains(msg, 'bag') then
            selfSay(presentMsg)
            talk_state = 1
        elseif msgcontains(msg, 'gingerbread man') or msgcontains(msg, 'gingerbread cookie') or msgcontains(msg, 'ginger cookie') then
            selfSay(gingerMsg)
            talk_state = 2
        elseif msgcontains(msg, 'gingerbread recipe') or msgcontains(msg, 'recipe') or msgcontains(msg, 'cookie recipe') then
            selfSay(recipeMsg)
            talk_state = 3
        elseif msgcontains(msg, 'jewel case') or msgcontains(msg, 'case') or msgcontains(msg, 'jewel') or msgcontains(msg, 'jewels') or msgcontains(msg, 'locket') or msgcontains(msg, 'jewel box') then
            selfSay(jewelMsg)
            talk_state = 4
        elseif msgcontains(msg, 'santa hat') or msgcontains(msg, 'santas hat') or msgcontains(msg, 'hat') or msgcontains(msg, 'santa\'s hat') then
            selfSay(hatMsg)
            talk_state = 5
        elseif msgcontains(msg, 'santa doll') or msgcontains(msg, 'santas doll') or msgcontains(msg, 'doll') or msgcontains(msg, 'santa\'s doll') then
            selfSay(dollMsg)
            talk_state = 6
------------------------------------------------ confirm yes ------------------------------------------------
        elseif msgcontains(msg, 'yes') and talk_state == 1 then
            if getPlayerItemCount(cid,6497) >= 1 then
                if doPlayerTakeItem(cid,6497,1) == 0 then
                    selfSay('Here you are.')
                    doPlayerAddItem(cid,6527,1)
                end
            else
                selfSay(hasNoMsg)
            end
            talk_state = 0
        elseif msgcontains(msg, 'yes') and talk_state == 2 then
            if getPlayerItemCount(cid,6527) >= 1 then
                if doPlayerTakeItem(cid,6527,1) == 0 then
                    selfSay('Here you are.')
                    doPlayerAddItem(cid,6501,1)
                end
            else
                selfSay(hasNoMsg)
            end
            talk_state = 0
        elseif msgcontains(msg, 'yes') and talk_state == 3 then
            if getPlayerItemCount(cid,6527) >= 10 then
                if doPlayerTakeItem(cid,6527,10) == 0 then
                    selfSay('Here you are.')
                    doPlayerAddItem(cid,6523,1)
                end
            else
                selfSay(hasNoMsg)
            end
            talk_state = 0
        elseif msgcontains(msg, 'yes') and talk_state == 4 then
            if getPlayerItemCount(cid,6527) >= 25 then
                if doPlayerTakeItem(cid,6527,25) == 0 then
                    selfSay('Here you are.')
                    doPlayerAddItem(cid,6104,1)
                end
            else
                selfSay(hasNoMsg)
            end
            talk_state = 0
        elseif msgcontains(msg, 'yes') and talk_state == 5 then
            if getPlayerItemCount(cid,6527) >= 50 then
                if doPlayerTakeItem(cid,6527,50) == 0 then
                    selfSay('Here you are.')
                    doPlayerAddItem(cid,6531,1)
                end
            else
                selfSay(hasNoMsg)
            end
            talk_state = 0
        elseif msgcontains(msg, 'yes') and talk_state == 6 then
            if getPlayerItemCount(cid,6527) >= 100 then
                if doPlayerTakeItem(cid,6527,100) == 0 then
                    selfSay('Here you are.')
                    doPlayerAddItem(cid,6512,1)
                end
            else
                selfSay(hasNoMsg)
            end
            talk_state = 0
------------------------------------------------ confirm no ------------------------------------------------
        elseif msgcontains(msg, 'no') and (talk_state >= 1 and talk_state <= 5) then
            selfSay(noMsg)
            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 am using 0.3.5
 
Quick fix:
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

local Topic = {}

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
	elseif msgcontains(msg, "item") or msgcontains(msg, "offer") then
		npcHandler:say("I accept presents that were stolen from Santa by those little pest Grynch Goblins in exchange for christmas tokens.", cid)
	elseif msgcontains(msg, "token") then
		npcHandler:say("I will trade a gingerbread man for 1 token, the gingerbread recipe for 10, a jewel case for 25, a santa hat for 50 and a santa doll for 100 tokens.", cid)
	elseif msgcontains(msg, "present") or msgcontains(msg, "bag") then
		npcHandler:say("Do you want trade some present bags for christmas tokens?", cid)
		Topic[cid] = 1
	elseif (msgcontains(msg, "gingerbread") and msgcontains(msg, "man")) or msgcontains(msg, "gingerbreadman") then
		npcHandler:say("Do you want trade a christmas token for a gingerbread man?", cid)
		Topic[cid] = 2
	elseif msgcontains(msg, "recipe") then
		npcHandler:say("Do you want trade 10 christmas tokens for a gingerbread man recipe?", cid)
		Topic[cid] = 3
	elseif msgcontains(msg, "jewel") or msgcontains(msg, "case") then
		npcHandler:say("Do you want trade 25 christmas tokens for a jewel case?", cid)
		Topic[cid] = 4
	elseif msgcontains(msg, "hat") then
		npcHandler:say("Do you want trade 50 christmas tokens for a santa hat?", cid)
		Topic[cid] = 5
	elseif msgcontains(msg, "doll") then
		npcHandler:say("Do you want trade 100 christmas tokens for a santa doll?", cid)
		Topic[cid] = 6
	elseif msgcontains(msg, "yes") and Topic[cid] == 1 then
		local tmp = getPlayerItemCount(cid, 6497)
		if 0 < tmp and doPlayerRemoveItem(cid,6497,tmp) == TRUE then
			npcHandler:say("Here you are.", cid)
			doPlayerAddItem(cid,6527,tmp)
		else
			npcHandler:say("I only want present bags.", cid)
		end
		Topic[cid] = 0
	elseif msgcontains(msg, "yes") and Topic[cid] == 2 then
		if doPlayerRemoveItem(cid,6527,1) == TRUE then
			npcHandler:say("Here you are.", cid)
			doPlayerAddItem(cid,6501,1)
		else
			npcHandler:say("I only want present bags.", cid)
		end
		Topic[cid] = 0
	elseif msgcontains(msg, "yes") and Topic[cid] == 3 then
		if doPlayerRemoveItem(cid,6527,10) == TRUE then
			npcHandler:say("Here you are.", cid)
			doPlayerAddItem(cid,6523,1)
		else
			npcHandler:say("I only want present bags.", cid)
		end
		Topic[cid] = 0
	elseif msgcontains(msg, "yes") and Topic[cid] == 4 then
		if doPlayerRemoveItem(cid,6527,25) == TRUE then
			npcHandler:say("Here you are.", cid)
			doPlayerAddItem(cid,6104,1)
		else
			npcHandler:say("I only want present bags.", cid)
		end
		Topic[cid] = 0
	elseif msgcontains(msg, "yes") and Topic[cid] == 5 then
		if doPlayerRemoveItem(cid,6527,50) == TRUE then
			npcHandler:say("Here you are.", cid)
			doPlayerAddItem(cid,6531,1)
		else
			npcHandler:say("I only want present bags.", cid)
		end
		Topic[cid] = 0
	elseif msgcontains(msg, "yes") and Topic[cid] == 6 then
		if doPlayerRemoveItem(cid,6527,100) == TRUE then
			npcHandler:say("Here you are.", cid)
			doPlayerAddItem(cid,6512,1)
		else
			npcHandler:say("I only want present bags.", cid)
		end
		Topic[cid] = 0
	elseif Topic[cid] > 0 then
		npcHandler:say("I'll be here when you're ready.", cid)
		Topic[cid] = 0
	end
	return TRUE
end

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

local Topic = {}

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
	elseif msgcontains(msg, "item") or msgcontains(msg, "offer") then
		npcHandler:say("I accept presents that were stolen from Santa by those little pest Grynch Goblins in exchange for christmas tokens.", cid)
	elseif msgcontains(msg, "token") then
		npcHandler:say("I will trade a gingerbread man for 1 token, the gingerbread recipe for 10, a jewel case for 25, a santa hat for 50 and a santa doll for 100 tokens.", cid)
	elseif msgcontains(msg, "present") or msgcontains(msg, "bag") then
		npcHandler:say("Do you want trade some present bags for christmas tokens?", cid)
		Topic[cid] = 1
	elseif (msgcontains(msg, "gingerbread") and msgcontains(msg, "man")) or msgcontains(msg, "gingerbreadman") then
		npcHandler:say("Do you want trade a christmas token for a gingerbread man?", cid)
		Topic[cid] = 2
	elseif msgcontains(msg, "recipe") then
		npcHandler:say("Do you want trade 10 christmas tokens for a gingerbread man recipe?", cid)
		Topic[cid] = 3
	elseif msgcontains(msg, "jewel") or msgcontains(msg, "case") then
		npcHandler:say("Do you want trade 25 christmas tokens for a jewel case?", cid)
		Topic[cid] = 4
	elseif msgcontains(msg, "hat") then
		npcHandler:say("Do you want trade 50 christmas tokens for a santa hat?", cid)
		Topic[cid] = 5
	elseif msgcontains(msg, "doll") then
		npcHandler:say("Do you want trade 100 christmas tokens for a santa doll?", cid)
		Topic[cid] = 6
	elseif msgcontains(msg, "yes") and Topic[cid] == 1 then
		local tmp = getPlayerItemCount(cid, 6497)
		if 0 < tmp and doPlayerRemoveItem(cid,6497,tmp) == TRUE then
			npcHandler:say("Here you are.", cid)
			doPlayerAddItem(cid,6527,tmp)
		else
			npcHandler:say("I only want present bags.", cid)
		end
		Topic[cid] = 0
	elseif msgcontains(msg, "yes") and Topic[cid] == 2 then
		if doPlayerRemoveItem(cid,6527,1) == TRUE then
			npcHandler:say("Here you are.", cid)
			doPlayerAddItem(cid,6501,1)
		else
			npcHandler:say("I only want present bags.", cid)
		end
		Topic[cid] = 0
	elseif msgcontains(msg, "yes") and Topic[cid] == 3 then
		if doPlayerRemoveItem(cid,6527,10) == TRUE then
			npcHandler:say("Here you are.", cid)
			doPlayerAddItem(cid,6523,1)
		else
			npcHandler:say("I only want present bags.", cid)
		end
		Topic[cid] = 0
	elseif msgcontains(msg, "yes") and Topic[cid] == 4 then
		if doPlayerRemoveItem(cid,6527,25) == TRUE then
			npcHandler:say("Here you are.", cid)
			doPlayerAddItem(cid,6104,1)
		else
			npcHandler:say("I only want present bags.", cid)
		end
		Topic[cid] = 0
	elseif msgcontains(msg, "yes") and Topic[cid] == 5 then
		if doPlayerRemoveItem(cid,6527,50) == TRUE then
			npcHandler:say("Here you are.", cid)
			doPlayerAddItem(cid,6531,1)
		else
			npcHandler:say("I only want present bags.", cid)
		end
		Topic[cid] = 0
	elseif msgcontains(msg, "yes") and Topic[cid] == 6 then
		if doPlayerRemoveItem(cid,6527,100) == TRUE then
			npcHandler:say("Here you are.", cid)
			doPlayerAddItem(cid,6512,1)
		else
			npcHandler:say("I only want present bags.", cid)
		end
		Topic[cid] = 0
	elseif Topic[cid] > 0 then
		npcHandler:say("I'll be here when you're ready.", cid)
		Topic[cid] = 0
	end
	return TRUE
end

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


I've found a problem, NPC is not givin' gingerbread.
Is possible to make it 100% real?

Gingerbreadman for 1 Christmas Token
Gingerbread Recipe for 10 Christmas Tokens
Jewel Case for 25 Christmas Tokens
Santa Hat for 50 Christmas Tokens
Santa Backpack for 75 Christmas Tokens
Santa Doll for 100 Christmas Tokens
Snowman Doll for 150 Christmas Tokens
Santa Teddy for 500 Christmas Tokens
 
Back
Top