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

Playerstorageid

freak15

Professional Hoster
Joined
Dec 31, 2008
Messages
356
Reaction score
2
Location
Sweden
Hello can some1 do this script for me please ;)
i use tfs 0.3.5pl
;) should be very happy if some1 helped me (the npcs dosnt even open trade chat or answer in any way just walking around :S

Code:
-- based on a sweaty cyclops.lua (no credits since he didn't leave any names)
-- edited by krille09

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

    -- use the real conversation? (true/false)
    real = false
    
    if real == true then
        tradeMsg = 'I can fix all the four pieces of the broken amulet into one!'
        fourpobaMsg = 'Do you want me to fix all the four pieces of that broken amulet?'
        hasNoMsg = 'You need all four piece of the broken amulet to get all, or I can't fix it!'
        noMsg = 'I have no time, I\'m a busy man, LEAVE!'
    else
        tradeMsg = 'I can fix all the four pieces of the broken amulet into one!'
        fourpobaMsg = 'Do you want me to fix all the four pieces of that broken amulet?'
        hasNoMsg = 'You need all four piece of the broken amulet to get all, or I can\'t fix it!'
        noMsg = 'I have no time, I\'m a busy man, LEAVE!'
    end
        if msgcontains(msg, 'trade') or msgcontains(msg, 'fix') then
            selfSay(tradeMsg)
        elseif msgcontains(msg, 'change') or msgcontains(msg, 'piece') or msgcontains(msg, 'four') then
            selfSay(fourpobaMsg)
            talk_state = 1
------------------------------------------------ confirm yes ------------------------------------------------
        elseif msgcontains(msg, 'yes') and talk_state == 1 then
            if getPlayerItemCount(cid,8262) >= 1 then
            if getPlayerItemCount(cid,8263) >= 1 then
            if getPlayerItemCount(cid,8264) >= 1 then
            if getPlayerItemCount(cid,8265) >= 1 then
                if doPlayerTakeItem(cid,8262,1) == 0 then
                if doPlayerTakeItem(cid,8263,1) == 0 then
                if doPlayerTakeItem(cid,8264,1) == 0 then
                if doPlayerTakeItem(cid,8265,1) == 0 then
                    selfSay('Here you are.')
                    doPlayerAddItem(cid,8266,1)
                end
            else
                selfSay(hasNoMsg)
            end
            talk_state = 0

------------------------------------------------ confirm no ------------------------------------------------
        elseif msgcontains(msg, 'no') and (talk_state == 1) 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())

Code:
<?xml version="1.0"?>
<npc name="Blue Legs Quest NPC" script="data/npc/scripts/blue_legs_quest_npc.lua" access="5" lookdir="2" walkinterval="3">
<health now="137" max="1337" />
<look type="133" head="67" body="61" legs="61" feet="67" />
<parameters>
<parameter key="module_shop" value="1" />
 <parameter key="message_greet" value="Greetings, |PLAYERNAME|. I can change your four items into one amulet!" />
</parameters>
</npc>

i add rep++
 
Last edited:
Lua:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

local Topic = {}
local items = {8262, 8263, 8264, 8265}

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 greetCallback(cid)
	local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
	Topic[talkUser] = 0
	return true
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, "trade") or msgcontains(msg, "fix") then
		npcHandler:say("I can fix all the four pieces of the broken amulet into one!", cid)
		Topic[talkUser] = 0
	elseif msgcontains(msg, "change") or msgcontains(msg, "piece") or msgcontains(msg, "four") then
		npcHandler:say("Do you want me to fix all the four pieces of that broken amulet?", cid)
		Topic[talkUser] = 1
	elseif Topic[talkUser] == 1 then
		if msgcontains(msg, "yes") then
			if getPlayerItemCount(cid,8262) > 0 and getPlayerItemCount(cid,8263) > 0 and getPlayerItemCount(cid,8264) > 0 and getPlayerItemCount(cid,8265) > 0 then
				for i = 1, 4 do
					doPlayerRemoveItem(cid, items[i], 1)
				end
				npcHandler:say("Here you are.", cid)
				doPlayerAddItem(cid,8266,1)
			else
				npcHandler:say("You need all four piece of the broken amulet to get all, or I can"t fix it!", cid)
			end
		else
			npcHandler:say("I have no time, I'm a busy man, LEAVE!", cid)
		end
		Topic[talkUser] = 0
	end
    return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:setCallback(CALLBACK_GREET, greetCallback)
npcHandler:addModule(FocusModule:new())
PHP:
<?xml version="1.0"?>
<npc name="Blue Legs Quest NPC" script="blue_legs_quest_npc.lua" walkinterval="2000">
<health now="100" max="100" />
<look type="133" head="67" body="61" legs="61" feet="67" />
	<parameters>
		<parameter key="message_greet" value="Greetings, |PLAYERNAME|. I can change your four items into one amulet!" />
	</parameters>
</npc>
 
Back
Top Bottom