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

[8.11]NPC Prosze naprawcie skrypt :/

Hekan

New Member
Joined
Jun 14, 2008
Messages
94
Reaction score
0
Code:
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

-- Makes sure the npc reacts when you say hi, bye etc.
npcHandler:addModule(FocusModule:new())

-- Don't forget npcHandler = npcHandler in the parameters. It is required for all StdModule functions!
keywordHandler:addKeyword({'offers'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Eu compro/vendo Pearls, Gems e vendo jewelry.'})
keywordHandler:addKeyword({'pearls'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Eu compro/vendo Black Pearl (280gp/560gp) e White Pearl (160gp/320gp).'})
keywordHandler:addKeyword({'gems'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Eu compro/vendo Small Diamond (300gp/600gp), Small Sapphire (250gp/500gp), Small Ruby (250gp/500gp), Small Emerald (250gp/500gp) e Small Amethyst (200gp/400gp).'})
keywordHandler:addKeyword({'jewelry'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Eu vendo Wedding Ring (990gp), Golden Amulet (6600gp) e Ruby Necklace (3560gp).'})

function creatureSayCallback(cid, type, msg)

part = getPlayerStorageValue(cid, 7512)
addon = getPlayerStorageValue(cid, 7513)
sex = getPlayerSex(cid)
pos = getPlayerPosition(cid)

if msgcontains(msg, 'frostheart shard') then
    if getPlayerStorageValue(cid, 10000) < 1 then
        selfSay("Do you bring frostheart shards for our spell?")
        talkState = 1
end
elseif msgcontains(msg, 'frostheart shard') then
    if getPlayerStorageValue(cid, 10000) == 2 then
        selfSay("Do you bring frostheart shards for our spell?")
        talkState = 2
end

elseif msgcontains(msg, 'yes') and talkState == 1 then
     selfSay('Excellent, you collected 5 of them. If you have collected 5 or more, talk to me about your reward.')
     talk_state = 3
elseif msgcontains(msg, 'yes') and talkState == 2 then
     selfSay('Excellent, you collected 10 of them. If you have collected 10 or more, talk to me about your reward.')
     talk_state = 4

elseif talk_state == 3 then
if msgcontains(msg, 'reward') then
			IO = getPlayerItemCount(cid,7290)
			if IO >= 5 then
				selfSay('Take this. It might suit your Nordic outfit fine.')
				doPlayerRemoveItem(cid,7290,5)
                                setPlayerStorageValue(cid, 10000, 2)
				doSendMagicEffect(getPlayerPosition(cid), 14)
				doPlayerAddOutfit(cid, 252, 1)
				doPlayerAddOutfit(cid, 251, 1)
				talk_state = 0
			else
				selfSay('you don\'t have all the request items,')
			end
end
elseif talk_state == 4 then
if msgcontains(msg, 'reward') then
			IO = getPlayerItemCount(cid,7290)
			if IO >= 10 then
				selfSay('Take this. It might suit your Nordic outfit fine.')
				doPlayerRemoveItem(cid,7290,10)
                                setPlayerStorageValue(cid, 10000, 3)
				doSendMagicEffect(getPlayerPosition(cid), 14)
				doPlayerAddOutfit(cid, 252, 2)
				doPlayerAddOutfit(cid, 251, 2)
				talk_state = 0
			else
				selfSay('you don\'t have all the request items,')
			end
end

            talk_state = 0
			
  
        elseif msgcontains(msg, 'no') and (talk_state >= 1 and talk_state <= 5) then
            selfSay('Ok.')
            talk_state = 0
        end

    return 1
end

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

Moglibyscie powiedziec co tu jest zle i ewentualnie poprawic?
 
Code:
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

-- Makes sure the npc reacts when you say hi, bye etc.
npcHandler:addModule(FocusModule:new())

-- Don't forget npcHandler = npcHandler in the parameters. It is required for all StdModule functions!
keywordHandler:addKeyword({'offers'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Eu compro/vendo Pearls, Gems e vendo jewelry.'})
keywordHandler:addKeyword({'pearls'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Eu compro/vendo Black Pearl (280gp/560gp) e White Pearl (160gp/320gp).'})
keywordHandler:addKeyword({'gems'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Eu compro/vendo Small Diamond (300gp/600gp), Small Sapphire (250gp/500gp), Small Ruby (250gp/500gp), Small Emerald (250gp/500gp) e Small Amethyst (200gp/400gp).'})
keywordHandler:addKeyword({'jewelry'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Eu vendo Wedding Ring (990gp), Golden Amulet (6600gp) e Ruby Necklace (3560gp).'})

function creatureSayCallback(cid, type, msg)

part = getPlayerStorageValue(cid, 7512)
addon = getPlayerStorageValue(cid, 7513)
sex = getPlayerSex(cid)
pos = getCreaturePosition(cid)

if msgcontains(msg, 'frostheart shard') then
    if getPlayerStorageValue(cid, 10000) < 1 then
        selfSay("Do you bring frostheart shards for our spell?")
        talkState = 1
    elseif getPlayerStorageValue(cid, 10000) == 2 then
        selfSay("Do you bring frostheart shards for our spell?")
        talkState = 2
    end
elseif msgcontains(msg, 'yes') then
	if talkState == 1 then
		selfSay('Excellent, you collected 5 of them. If you have collected 5 or more, talk to me about your reward.')
	    talkState = 3
	elseif talkState == 2 then
		selfSay('Excellent, you collected 10 of them. If you have collected 10 or more, talk to me about your reward.')
	    talkState = 4
	end
elseif msgcontains(msg, 'reward') then
	if talkState == 3 then
		IO = getPlayerItemCount(cid,7290)
		if IO >= 5 then
			if doPlayerRemoveItem(cid,7290,5) == TRUE then
				selfSay('Take this. It might suit your Nordic outfit fine.')
		        setPlayerStorageValue(cid, 10000, 2)
				doSendMagicEffect(getCreaturePosition(cid), 14)
				doPlayerAddOutfit(cid, 252, 1)
				doPlayerAddOutfit(cid, 251, 1)
				talkState = 0
			else
				selfSay('You don\'t have all the request items.')
				talkState = 0
			end
		else
			selfSay('You don\'t have all the request items.')
			talkState = 0
		end
	elseif talkState == 4 then
		IO = getPlayerItemCount(cid,7290)
		if IO >= 10 then
			if doPlayerRemoveItem(cid,7290,10) == TRUE then
				selfSay('Take this. It might suit your Nordic outfit fine.')
                setPlayerStorageValue(cid, 10000, 3)
				doSendMagicEffect(getCreaturePosition(cid), 14)
				doPlayerAddOutfit(cid, 252, 2)
				doPlayerAddOutfit(cid, 251, 2)
				talkState = 0
			else
				selfSay('You don\'t have all the request items.')
				talkState = 0
			end
		end
	end		
elseif msgcontains(msg, 'no') and (talkState >= 1 and talkState <= 5) then
    selfSay('Ok.')
    talkState = 0
end
    return TRUE
end

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

:mad:
 
Back
Top