What's new

[8.2][npc] Problem Z Npc pod tfs

Status
Not open for further replies.

Karolek8999

New User
Joined
May 31, 2008
Messages
9
Reaction score
0
otoz mam pewien problem na otsie mam rl system np mowisz hi>trade i pokazuje ci sie okienko dzialaja sami prawie ci npc ktorzy maja to okienko trade
a np NPC Joseph od soft bootsow mi nie dziala (blad nie pokazuje sie w silniku nie wiem na 100% czego to wina)
LUA
PHP:
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

POMOCY:o
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

        if msgcontains(msg, 'specialised') or msgcontains(msg, 'boots') then
            selfSay('I can refill your worn soft boots for 100 platinum coins.')
        elseif msgcontains(msg, 'soft boots') or msgcontains(msg, 'worn soft boots') or msgcontains(msg, 'soft boot') or msgcontains(msg, 'worn soft boot') then
            selfSay('Would you like to refill your worn soft boots for 100 platinum coins?')
            talk_state = 1
        

        elseif msgcontains(msg, 'yes') and talk_state == 1 then
            if getPlayerItemCount(cid,6530) >= 1 and getPlayerItemCount(cid,2152) >= 100 then
                if doPlayerTakeItem(cid,6530,1) and doPlayerTakeItem(cid,2152,100) == 0 then
                selfSay('Here are your refilled soft boots.')
                    doPlayerAddItem(cid,2640,1)
                end
            else
                selfSay('Sorry, you don\'t have the item.')
            end
          

        elseif msgcontains(msg, 'no') and (talk_state >= 1 and talk_state <= 5) then
            selfSay('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())
XML
PHP:
<npc name="Joseph" script="data/npc/scripts/softboots.lua" floorchange="0" access="5" level="1" maglevel="1">
	<health now="150" max="150"/>
        <look type="134" head="114" body="102" legs="95" feet="72" addons="1" corpse="2212"/>
	<parameters>
<parameter key="message_greet" value="Hello |PLAYERNAME|. My job is to refill soft boots." />

	</parameters>
</npc>
 

Shadow

Senior User
Joined
Jul 22, 2008
Messages
685
Reaction score
64
Odp: Tfs 8.2 Problem Z Npc

Odp: Tfs 8.2 Problem Z Npc

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)
	if(not npcHandler:isFocused(cid)) then
		return false
	end

	if msgcontains(msg, 'soft') or msgcontains(msg, 'boots') then
		selfSay('Do you want to repair your worn soft boots for 10000 gold coins?', cid)
		talkState = 1
	elseif msgcontains(msg, 'yes') then
		if talkState == 1 then
			if getPlayerItemCount(cid, 6530) >= 1 then
				if doPlayerRemoveMoney(cid, 10000) == TRUE then
					local item = getPlayerItemById(cid, TRUE, 6530)
					doTransformItem(item.uid, 2640)	
					selfSay('Here you are.', cid)
				else
					selfSay('Sorry, you don\'t have enough gold.', cid)
				end
			else
				selfSay('Sorry, you don\'t have the item.', cid)
			end
		end
		talkState = 0
	elseif msgcontains(msg, 'no') and isInArray({1}, talkState) == TRUE then
		talkState = 0
		selfSay('Ok then.', cid)
	end

	return TRUE
end

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

powinien dzia?a?
 

Hulala

Senior User
Joined
May 2, 2008
Messages
539
Reaction score
37
Age
32
Odp: [8.2][npc] Problem Z Npc pod tfs

Shadow A czy po 8.31 B?dzie on chodzi??
 

Shadow

Senior User
Joined
Jul 22, 2008
Messages
685
Reaction score
64
Odp: [8.2][npc] Problem Z Npc pod tfs

Ten b?dzie, na przysz?o?? nie od?wie?aj starych temat?w.
Code:
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, 'soft') or msgcontains(msg, 'boots')) then
		selfSay('Do you want to repair your worn soft boots for 10000 gold coins?', cid)
		talkState[talkUser] = 1
	elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
		if(getPlayerItemCount(cid, 6530) >= 1) then
			if(doPlayerRemoveMoney(cid, 10000) == TRUE) then
				local item = getPlayerItemById(cid, TRUE, 6530)
				doTransformItem(item.uid, 2640)
				selfSay('Here you are.', cid)
			else
				selfSay('Sorry, you don\'t have enough gold.', cid)
			end
		else
			selfSay('Sorry, you don\'t have the item.', cid)
		end
		talkState[talkUser] = 0
	elseif(msgcontains(msg, 'no') and isInArray({1}, talkState[talkUser]) == TRUE) then
		talkState[talkUser] = 0
		selfSay('Ok then.', cid)
	end
	return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

Pozdrawiam,
Shadow.
 
Status
Not open for further replies.
Top