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

Request/Questions: Vocation NPC that gives outfits

RIPSoft

∞ ∞ ∞ ∞ ∞ ∞ ∞ ∞∞
Joined
Jun 27, 2016
Messages
185
Reaction score
63
Hiho


I want my vocation NPC to give outfits when picking vocation/fraction, ..

There are 4 vocations/fractions and each should give 3 different Outfits, so in total there will be 12/4 outfits



this is the guy atm:

Lua:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

local vocation = {}
local town = {}
local config = {
    towns = {
        ["1"] = 2,
        ["2"] = 2,
        ["3"] = 2,
        ["4"] = 2,
        ["5"] = 2,
        ["6"] = 2,
        ["7"] = 2,
        ["8"] = 2,
        ["9"] = 2,
    },

    vocations = {
        ["green"] = {
            text = "A Tibian! ARE YOU SURE? THIS DECISION IS IRREVERSIBLE!",
            vocationId = 1,
            --equipment castle shield
            {{2535, 1}},
            --container rope, shovel, mana potion,
            {{2120, 1}, {2554, 1}, {7620, 1}}
        },

        ["blue"] = {
            text = "An Arghardian! ARE YOU SURE? THIS DECISION IS IRREVERSIBLE!",
            vocationId = 21,
            --equipment castle shield,spellbook, studded arm, studded legs, boots, bronze amulet, studded helmet
            {{2534, 1}},
            --container rope, shovel, mana potion, adventurer's stone
            {{2120, 1}, {2554, 1}, {7620, 1}}
        },

        ["yellow"] = {
            text = "A Daramanian! ARE YOU SURE? THIS DECISION IS IRREVERSIBLE!",
            vocationId = 32,
            --equipment castle shield, studded arm, studded legs, boots, bronze amulet, studded helmet
            {{2532, 1}},
            --container rope, health potion, bow, 25 arrow, adventurer's stone
            {{2120, 1}, {7618, 1}, {2456, 1}, {2544, 25}}
        },

        ["red"] = {
            text = "A Draconian! ARE YOU SURE? THIS DECISION IS IRREVERSIBLE!",
            vocationId = 43,
            --equipment castle shield,mace, studded arm, studded legs, boots, bronze amulet, studded helmet
            {{2533, 1}},
            --container   rope, shovel, health potion, adventurer's stone
            {{2120, 1}, {2554, 1}, {7618, 1}}
        }
    }
}

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

local function greetCallback(cid)
    local player = Player(cid)
    local level = player:getLevel()
    if level < 1 then
        npcHandler:say("CHILD! COME BACK WHEN YOU HAVE GROWN UP!", cid)
        npcHandler:resetNpc(cid)
        return false
    elseif level > 10 then
        npcHandler:say(player:getName() ..", I CAN'T LET YOU LEAVE - YOU ARE TOO STRONG ALREADY! YOU CAN ONLY LEAVE WITH LEVEL 9 OR LOWER.", cid)
        npcHandler:resetNpc(cid)
        return false
    elseif player:getVocation():getId() > 0 then
        npcHandler:say("YOU ALREADY HAVE A VOCATION!", cid)
        npcHandler:resetNpc(cid)
        return false
    else
        npcHandler:setMessage(MESSAGE_GREET, player:getName() ..", Do you want to play a game?")
    end
    return true
end

local function creatureSayCallback(cid, type, msg)
    if not npcHandler:isFocused(cid) then
        return false
    end

    local player = Player(cid)
    if npcHandler.topic[cid] == 0 then
        if msgcontains(msg, "yes") then
            npcHandler:say("Pick a number, ..: {1}, {2}, {3},{4},{5},{6},{7},{8},{9} ?", cid)
            npcHandler.topic[cid] = 1
        end
    elseif npcHandler.topic[cid] == 1 then
        local cityTable = config.towns[msg:lower()]
        if cityTable then
            town[cid] = cityTable
            npcHandler:say("Nr ".. string.upper(msg) .."! Pick a color: {Green}, {Blue}, {Yellow}, OR {Red}?", cid)
            npcHandler.topic[cid] = 2
        else
            npcHandler:say("I can offer you a fresh start in Rookyard, ..?: {rookyard} ?", cid)
        end
    elseif npcHandler.topic[cid] == 2 then
        local vocationTable = config.vocations[msg:lower()]
        if vocationTable then
            npcHandler:say(vocationTable.text, cid)
            npcHandler.topic[cid] = 3
            vocation[cid] = vocationTable.vocationId
        else
            npcHandler:say("..... ... {Tibian}, {Argardhian}, {Daramanian}, OR {Draconian}?", cid)
        end
    elseif npcHandler.topic[cid] == 3 then
        if msgcontains(msg, "yes") then
            npcHandler:say("SO BE IT!", cid)
            player:setVocation(Vocation(vocation[cid]))
            player:setTown(Town(town[cid]))
            player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
            player:teleportTo(Town(town[cid]):getTemplePosition())
            player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have received a backpack with starting items for reaching the mainlands.")
            local targetVocation = config.vocations[Vocation(vocation[cid]):getName():lower()]
            for i = 1, #targetVocation[1] do
                player:addItem(targetVocation[1][i][1], targetVocation[1][i][2])
            end
            local backpack = player:addItem(1988)
            for i = 1, #targetVocation[2] do
                backpack:addItem(targetVocation[2][i][1], targetVocation[2][i][2])
            end
        else
            npcHandler:say("THEN WHAT? {Tibian}, {Argardhian}, {Daramanian}, OR {Draconian}?", cid)
            npcHandler.topic[cid] = 2
        end
    end
    return true
end

local function onAddFocus(cid)
    town[cid] = 0
    vocation[cid] = 0
end

local function onReleaseFocus(cid)
    town[cid] = nil
    vocation[cid] = nil
end

npcHandler:setCallback(CALLBACK_ONADDFOCUS, onAddFocus)
npcHandler:setCallback(CALLBACK_ONRELEASEFOCUS, onReleaseFocus)
npcHandler:setCallback(CALLBACK_GREET, greetCallback)
npcHandler:setMessage(MESSAGE_FAREWELL, "COME BACK WHEN YOU ARE PREPARED TO FACE YOUR DESTINY!")
npcHandler:setMessage(MESSAGE_WALKAWAY, "COME BACK WHEN YOU ARE PREPARED TO FACE YOUR DESTINY!")
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Hiho


I want my vocation NPC to give outfits when picking vocation/fraction, ..

There are 4 vocations/fractions and each should give 3 different Outfits, so in total there will be 12/4 outfits



this is the guy atm:

Lua:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

local vocation = {}
local town = {}
local config = {
    towns = {
        ["1"] = 2,
        ["2"] = 2,
        ["3"] = 2,
        ["4"] = 2,
        ["5"] = 2,
        ["6"] = 2,
        ["7"] = 2,
        ["8"] = 2,
        ["9"] = 2,
    },

    vocations = {
        ["green"] = {
            text = "A Tibian! ARE YOU SURE? THIS DECISION IS IRREVERSIBLE!",
            vocationId = 1,
            --equipment castle shield
            {{2535, 1}},
            --container rope, shovel, mana potion,
            {{2120, 1}, {2554, 1}, {7620, 1}}
        },

        ["blue"] = {
            text = "An Arghardian! ARE YOU SURE? THIS DECISION IS IRREVERSIBLE!",
            vocationId = 21,
            --equipment castle shield,spellbook, studded arm, studded legs, boots, bronze amulet, studded helmet
            {{2534, 1}},
            --container rope, shovel, mana potion, adventurer's stone
            {{2120, 1}, {2554, 1}, {7620, 1}}
        },

        ["yellow"] = {
            text = "A Daramanian! ARE YOU SURE? THIS DECISION IS IRREVERSIBLE!",
            vocationId = 32,
            --equipment castle shield, studded arm, studded legs, boots, bronze amulet, studded helmet
            {{2532, 1}},
            --container rope, health potion, bow, 25 arrow, adventurer's stone
            {{2120, 1}, {7618, 1}, {2456, 1}, {2544, 25}}
        },

        ["red"] = {
            text = "A Draconian! ARE YOU SURE? THIS DECISION IS IRREVERSIBLE!",
            vocationId = 43,
            --equipment castle shield,mace, studded arm, studded legs, boots, bronze amulet, studded helmet
            {{2533, 1}},
            --container   rope, shovel, health potion, adventurer's stone
            {{2120, 1}, {2554, 1}, {7618, 1}}
        }
    }
}

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

local function greetCallback(cid)
    local player = Player(cid)
    local level = player:getLevel()
    if level < 1 then
        npcHandler:say("CHILD! COME BACK WHEN YOU HAVE GROWN UP!", cid)
        npcHandler:resetNpc(cid)
        return false
    elseif level > 10 then
        npcHandler:say(player:getName() ..", I CAN'T LET YOU LEAVE - YOU ARE TOO STRONG ALREADY! YOU CAN ONLY LEAVE WITH LEVEL 9 OR LOWER.", cid)
        npcHandler:resetNpc(cid)
        return false
    elseif player:getVocation():getId() > 0 then
        npcHandler:say("YOU ALREADY HAVE A VOCATION!", cid)
        npcHandler:resetNpc(cid)
        return false
    else
        npcHandler:setMessage(MESSAGE_GREET, player:getName() ..", Do you want to play a game?")
    end
    return true
end

local function creatureSayCallback(cid, type, msg)
    if not npcHandler:isFocused(cid) then
        return false
    end

    local player = Player(cid)
    if npcHandler.topic[cid] == 0 then
        if msgcontains(msg, "yes") then
            npcHandler:say("Pick a number, ..: {1}, {2}, {3},{4},{5},{6},{7},{8},{9} ?", cid)
            npcHandler.topic[cid] = 1
        end
    elseif npcHandler.topic[cid] == 1 then
        local cityTable = config.towns[msg:lower()]
        if cityTable then
            town[cid] = cityTable
            npcHandler:say("Nr ".. string.upper(msg) .."! Pick a color: {Green}, {Blue}, {Yellow}, OR {Red}?", cid)
            npcHandler.topic[cid] = 2
        else
            npcHandler:say("I can offer you a fresh start in Rookyard, ..?: {rookyard} ?", cid)
        end
    elseif npcHandler.topic[cid] == 2 then
        local vocationTable = config.vocations[msg:lower()]
        if vocationTable then
            npcHandler:say(vocationTable.text, cid)
            npcHandler.topic[cid] = 3
            vocation[cid] = vocationTable.vocationId
        else
            npcHandler:say("..... ... {Tibian}, {Argardhian}, {Daramanian}, OR {Draconian}?", cid)
        end
    elseif npcHandler.topic[cid] == 3 then
        if msgcontains(msg, "yes") then
            npcHandler:say("SO BE IT!", cid)
            player:setVocation(Vocation(vocation[cid]))
            player:setTown(Town(town[cid]))
            player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
            player:teleportTo(Town(town[cid]):getTemplePosition())
            player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have received a backpack with starting items for reaching the mainlands.")
            local targetVocation = config.vocations[Vocation(vocation[cid]):getName():lower()]
            for i = 1, #targetVocation[1] do
                player:addItem(targetVocation[1][i][1], targetVocation[1][i][2])
            end
            local backpack = player:addItem(1988)
            for i = 1, #targetVocation[2] do
                backpack:addItem(targetVocation[2][i][1], targetVocation[2][i][2])
            end
        else
            npcHandler:say("THEN WHAT? {Tibian}, {Argardhian}, {Daramanian}, OR {Draconian}?", cid)
            npcHandler.topic[cid] = 2
        end
    end
    return true
end

local function onAddFocus(cid)
    town[cid] = 0
    vocation[cid] = 0
end

local function onReleaseFocus(cid)
    town[cid] = nil
    vocation[cid] = nil
end

npcHandler:setCallback(CALLBACK_ONADDFOCUS, onAddFocus)
npcHandler:setCallback(CALLBACK_ONRELEASEFOCUS, onReleaseFocus)
npcHandler:setCallback(CALLBACK_GREET, greetCallback)
npcHandler:setMessage(MESSAGE_FAREWELL, "COME BACK WHEN YOU ARE PREPARED TO FACE YOUR DESTINY!")
npcHandler:setMessage(MESSAGE_WALKAWAY, "COME BACK WHEN YOU ARE PREPARED TO FACE YOUR DESTINY!")
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())


I propose to search in the support / request section
 
Back
Top