Reklama
Pokazuje wyniki od 1 do 4 z 4

Temat: [8.54][NPC-lua] Nie trybi kiedy pisze yes kiedy pisze no trybi

  1. #1
    cyrek

    Domyślny [8.54][NPC-lua] Nie trybi kiedy pisze yes kiedy pisze no trybi

    Kod :
    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 oracle(cid, message, keywords, parameters, node)
    	if(not npcHandler:isFocused(cid)) then
    		return false
    	end
    
    	local vocNode = node:getParent()
    	local vocation = vocNode:getParameters().vocation
    
    	if(vocation ~= nil) then
    		if (vocation == 1) then
    			doPlayerAddOutfit(cid,138,0)
    			doPlayerAddOutfit(cid,130,0)
    			doPlayerAddItem(cid, 2461, 1)
    			doPlayerAddItem(cid, 2512, 1)
    			doPlayerAddItem(cid, 2190, 1)
    			doPlayerAddItem(cid, 2467, 1)
    			doPlayerAddItem(cid, 2649, 1)
    		elseif (vocation == 2) then
    			doPlayerAddOutfit(cid,148,0)
    			doPlayerAddOutfit(cid,144,0)
    			doPlayerAddItem(cid, 2461, 1)
    			doPlayerAddItem(cid, 2512, 1)
    			doPlayerAddItem(cid, 2182, 1)
    			doPlayerAddItem(cid, 2467, 1)
    			doPlayerAddItem(cid, 2649, 1)
    		elseif (vocation == 3) then
    			doPlayerAddOutfit(cid,137,0)
    			doPlayerAddOutfit(cid,129,0)
    			doPlayerAddItem(cid, 2482, 1)
    			doPlayerAddItem(cid, 2526, 1)
    			doPlayerAddItem(cid, 2389, 1)
    			doPlayerAddItem(cid, 2484, 1)
    			doPlayerAddItem(cid, 2468, 1)
    		elseif (vocation == 4) then
    			doPlayerAddOutfit(cid,139,0)
    			doPlayerAddOutfit(cid,131,0)
    			doPlayerAddItem(cid, 2458, 1)
    			doPlayerAddItem(cid, 2413, 1)
    			doPlayerAddItem(cid, 2378, 1)
    			doPlayerAddItem(cid, 2394, 1)
    			doPlayerAddItem(cid, 2464, 1)
    			doPlayerAddItem(cid, 2648, 1)
    		end
    		doPlayerSetVocation(cid, vocation)
    		doPlayerSetTown(cid, 1)	
    		local tmp = getCreaturePosition(cid)
    		doSendMagicEffect(tmp, CONST_ME_POFF)
    		doTeleportThing(cid, {x=1036, y=1050, z=6})
    		doSendMagicEffect({x=1036, y=1050, z=6}, CONST_ME_TELEPORT) 
    		npcHandler:resetNpc()
    	end
    	return true
    end
    
    function greetCallback(cid)
    	if(getPlayerVocation(cid) > 0) then
    		npcHandler:say('Good Lock')
    		return false
    	else
    		return true
    	end
    end
    npcHandler:setCallback(CALLBACK_GREET, greetCallback)
    npcHandler:setMessage(MESSAGE_GREET, 'Welcome |PLAYERNAME| in our land. Are you ready to start an adventure?')
    
    local yesNode = KeywordNode:new({'yes'}, oracle, {level = 1})
    local noNode1 = KeywordNode:new({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, moveup = 1, text = 'Then what vocation do you want to become?'})
    local noNode2 = KeywordNode:new({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, moveup = 1, text = '{Axe}, {club} or {sword}'})
    
    local node1 = keywordHandler:addKeyword({'yes'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'So what vocation do you wish to become? {Sorcerer}, {druid}, {paladin} or {knight}?'})
    	local node2 = node1:addChildKeyword({'sorcerer'}, StdModule.say, {npcHandler = npcHandler, vocation = 1, onlyFocus = true, text = 'c'})
    		node2:addChildKeywordNode(yesNode)
    		node2:addChildKeywordNode(noNode1)
    	node2 = node1:addChildKeyword({'druid'}, StdModule.say, {npcHandler = npcHandler, vocation = 2, onlyFocus = true, text = 'c'})
    		node2:addChildKeywordNode(yesNode)
    		node2:addChildKeywordNode(noNode1)
    	node2 = node1:addChildKeyword({'paladin'}, StdModule.say, {npcHandler = npcHandler, vocation = 3, onlyFocus = true, text = 'c'})
    		node2:addChildKeywordNode(yesNode)
    		node2:addChildKeywordNode(noNode1)
    	node2 = node1:addChildKeyword({'knight'}, StdModule.say, {npcHandler = npcHandler, vocation = 4, onlyFocus = true, text = 'lol?'})
    		node2:addChildKeywordNode(noNode1)
    			local node3 = node2:addChildKeyword({'yes'},  StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = '{Axe}, {club} or {sword}?'})
    				local node4 = node3:addChildKeyword({'axe'},  StdModule.say, {npcHandler = npcHandler, weapon = 1, onlyFocus = true, text = 'axe'})
    						node4:addChildKeywordNode(yesNode)
    						node4:addChildKeywordNode(noNode2)
    					node4 = node3:addChildKeyword({'club'},  StdModule.say, {npcHandler = npcHandler, weapon = 2, onlyFocus = true, text = 'club'})
    						node4:addChildKeywordNode(yesNode)
    						node4:addChildKeywordNode(noNode2)
    					node4 = node3:addChildKeyword({'sword'},  StdModule.say, {npcHandler = npcHandler, weapon = 3, onlyFocus = true, text = 'sword'})
    						node4:addChildKeywordNode(yesNode)
    						node4:addChildKeywordNode(noNode2)		
    keywordHandler:addKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Then logout.'})
    npcHandler:addModule(FocusModule:new())
    Chodzi o moment po wpisaniu sword/axe/club kiedy napisze yes nie teleportuje, nie daje voc. ani nic się nie dzieje. Kiedy napisze yes po wybraniu druida wszystko idzie normalnie

  2. #2
    Avatar moth
    Data rejestracji
    2007
    Położenie
    Gdańsk
    Wiek
    40
    Posty
    16,996
    Siła reputacji
    30

    Domyślny

    Kod :
    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
    
    -- =========================
    -- ORACLE
    -- =========================
    function oracle(cid, message, keywords, parameters, node)
        if not npcHandler:isFocused(cid) then
            return false
        end
    
        local parent = node:getParent()
        if not parent then
            return false
        end
    
        local params = parent:getParameters()
        local vocation = params.vocation
        local weapon = params.weapon
    
        if not vocation then
            return false
        end
    
        -- ===== OUTFITS + ITEMS =====
        if vocation == 1 then -- SORCERER
            doPlayerAddOutfit(cid, 138, 0)
            doPlayerAddOutfit(cid, 130, 0)
            doPlayerAddItem(cid, 2461, 1)
            doPlayerAddItem(cid, 2512, 1)
            doPlayerAddItem(cid, 2190, 1)
            doPlayerAddItem(cid, 2467, 1)
            doPlayerAddItem(cid, 2649, 1)
    
        elseif vocation == 2 then -- DRUID
            doPlayerAddOutfit(cid, 148, 0)
            doPlayerAddOutfit(cid, 144, 0)
            doPlayerAddItem(cid, 2461, 1)
            doPlayerAddItem(cid, 2512, 1)
            doPlayerAddItem(cid, 2182, 1)
            doPlayerAddItem(cid, 2467, 1)
            doPlayerAddItem(cid, 2649, 1)
    
        elseif vocation == 3 then -- PALADIN
            doPlayerAddOutfit(cid, 137, 0)
            doPlayerAddOutfit(cid, 129, 0)
            doPlayerAddItem(cid, 2482, 1)
            doPlayerAddItem(cid, 2526, 1)
            doPlayerAddItem(cid, 2389, 1)
            doPlayerAddItem(cid, 2484, 1)
            doPlayerAddItem(cid, 2468, 1)
    
        elseif vocation == 4 then -- KNIGHT
            doPlayerAddOutfit(cid, 139, 0)
            doPlayerAddOutfit(cid, 131, 0)
            doPlayerAddItem(cid, 2458, 1)
            doPlayerAddItem(cid, 2394, 1)
            doPlayerAddItem(cid, 2464, 1)
            doPlayerAddItem(cid, 2648, 1)
    
            -- BROŃ WYBRANA
            if weapon == 1 then
                doPlayerAddItem(cid, 2389, 1) -- axe
            elseif weapon == 2 then
                doPlayerAddItem(cid, 2423, 1) -- club
            elseif weapon == 3 then
                doPlayerAddItem(cid, 2413, 1) -- sword
            end
        end
    
        -- ===== FINAL =====
        doPlayerSetVocation(cid, vocation)
        doPlayerSetTown(cid, 1)
    
        local pos = getCreaturePosition(cid)
        doSendMagicEffect(pos, CONST_ME_POFF)
        doTeleportThing(cid, {x = 1036, y = 1050, z = 6})
        doSendMagicEffect({x = 1036, y = 1050, z = 6}, CONST_ME_TELEPORT)
    
        npcHandler:resetNpc()
        return true
    end
    
    -- =========================
    -- GREET
    -- =========================
    function greetCallback(cid)
        if getPlayerVocation(cid) > 0 then
            npcHandler:say('Good luck.')
            return false
        end
        return true
    end
    
    npcHandler:setCallback(CALLBACK_GREET, greetCallback)
    npcHandler:setMessage(MESSAGE_GREET,
        'Welcome |PLAYERNAME| in our land. Are you ready to start an adventure?'
    )
    
    -- =========================
    -- DIALOG TREE
    -- =========================
    local yesNode = KeywordNode:new({'yes'}, oracle, {})
    
    local noNode1 = KeywordNode:new({'no'}, StdModule.say, {
        npcHandler = npcHandler,
        onlyFocus = true,
        moveup = 1,
        text = 'Then what vocation do you want to become?'
    })
    
    local noNode2 = KeywordNode:new({'no'}, StdModule.say, {
        npcHandler = npcHandler,
        onlyFocus = true,
        moveup = 1,
        text = '{Axe}, {club} or {sword}?'
    })
    
    local node1 = keywordHandler:addKeyword({'yes'}, StdModule.say, {
        npcHandler = npcHandler,
        onlyFocus = true,
        text = 'So what vocation do you wish to become? {Sorcerer}, {druid}, {paladin} or {knight}?'
    })
    
    -- SORCERER
    local node2 = node1:addChildKeyword({'sorcerer'}, StdModule.say, {
        npcHandler = npcHandler,
        vocation = 1,
        onlyFocus = true,
        text = 'Are you sure?'
    })
    node2:addChildKeywordNode(yesNode)
    node2:addChildKeywordNode(noNode1)
    
    -- DRUID
    node2 = node1:addChildKeyword({'druid'}, StdModule.say, {
        npcHandler = npcHandler,
        vocation = 2,
        onlyFocus = true,
        text = 'Are you sure?'
    })
    node2:addChildKeywordNode(yesNode)
    node2:addChildKeywordNode(noNode1)
    
    -- PALADIN
    node2 = node1:addChildKeyword({'paladin'}, StdModule.say, {
        npcHandler = npcHandler,
        vocation = 3,
        onlyFocus = true,
        text = 'Are you sure?'
    })
    node2:addChildKeywordNode(yesNode)
    node2:addChildKeywordNode(noNode1)
    
    -- KNIGHT
    node2 = node1:addChildKeyword({'knight'}, StdModule.say, {
        npcHandler = npcHandler,
        vocation = 4,
        onlyFocus = true,
        text = 'Are you sure?'
    })
    node2:addChildKeywordNode(noNode1)
    
    local node3 = node2:addChildKeyword({'yes'}, StdModule.say, {
        npcHandler = npcHandler,
        onlyFocus = true,
        text = '{Axe}, {club} or {sword}?'
    })
    
    -- AXE
    local node4 = node3:addChildKeyword({'axe'}, StdModule.say, {
        npcHandler = npcHandler,
        vocation = 4,
        weapon = 1,
        onlyFocus = true,
        text = 'Are you sure?'
    })
    node4:addChildKeywordNode(yesNode)
    node4:addChildKeywordNode(noNode2)
    
    -- CLUB
    node4 = node3:addChildKeyword({'club'}, StdModule.say, {
        npcHandler = npcHandler,
        vocation = 4,
        weapon = 2,
        onlyFocus = true,
        text = 'Are you sure?'
    })
    node4:addChildKeywordNode(yesNode)
    node4:addChildKeywordNode(noNode2)
    
    -- SWORD
    node4 = node3:addChildKeyword({'sword'}, StdModule.say, {
        npcHandler = npcHandler,
        vocation = 4,
        weapon = 3,
        onlyFocus = true,
        text = 'Are you sure?'
    })
    node4:addChildKeywordNode(yesNode)
    node4:addChildKeywordNode(noNode2)
    
    keywordHandler:addKeyword({'no'}, StdModule.say, {
        npcHandler = npcHandler,
        onlyFocus = true,
        text = 'Then logout.'
    })
    
    npcHandler:addModule(FocusModule:new())
    trzymaj kolego

  3. #3

    ⬛★ Użytkownik TORG VIP ★⬛ rosen jest teraz offline
    Avatar rosen
    Data rejestracji
    2014
    Wiek
    57
    Posty
    3,076
    Siła reputacji
    14

    Domyślny


  4. Reklama
  5. #4
    Avatar Taca
    Data rejestracji
    2012
    Położenie
    Kraków
    Posty
    10,693
    Siła reputacji
    21

    Domyślny

    Cytuj Lord Xivan napisał Pokaż post
    Cytat został ukryty, ponieważ ignorujesz tego użytkownika. Pokaż cytat.
    jak riot games zakrecony niekumaty sam nie wie

Reklama

Informacje o temacie

Użytkownicy przeglądający temat

Aktualnie 1 użytkowników przegląda ten temat. (0 użytkowników i 1 gości)

Podobne tematy

  1. [LUA] Krótsze odpowiedniki w lua - autorstwa Grimkka
    Przez Grimekk w dziale Artykuły developerskie
    Odpowiedzi: 2
    Ostatni post: 13-01-2014, 18:36
  2. [c++] Polimorfizm nie trybi
    Przez Celestian hunter w dziale Programowanie
    Odpowiedzi: 5
    Ostatni post: 04-09-2013, 15:45
  3. [Lua] Od zera do skryptera, czyli LUA: Pętle i tablice*
    Przez Grim90 w dziale Artykuły developerskie
    Odpowiedzi: 9
    Ostatni post: 21-08-2010, 02:47
  4. [7.6][Lua & XML][YurOts] Problem ze zrobieniem npc.
    Przez Elor Tulot w dziale Strefa developerska
    Odpowiedzi: 3
    Ostatni post: 07-06-2010, 17:04
  5. [Lua] Od zera do skryptera, czyli LUA: PODSTAWY i Actions*
    Przez Grim90 w dziale Artykuły developerskie
    Odpowiedzi: 7
    Ostatni post: 02-08-2009, 01:05

Zakładki

Zakładki

Zasady postowania

  • Nie możesz pisać nowych tematów
  • Nie możesz pisać postów
  • Nie możesz używać załączników
  • Nie możesz edytować swoich postów
  •