• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Lua Help con converting npc vocation 1 to tfs 1.2

wafuboe

Active Member
Joined
Dec 24, 2010
Messages
884
Solutions
2
Reaction score
26
Well im exhausted i dont find some npc of island of destiny working on tfs 1.2

i got this, can anyone turn it to tfs 1.2?

thanks

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
 
item = 'You do not have the required Level or You Already have a Vocation!.'
done = 'Congratulations now you are sorcerer, Go to the dungeon and take your items and hunt.'
 
function creatureSayCallback(cid, type, msg)
    if(not npcHandler:isFocused(cid)) then
        return false
    end
 
    if msgcontains(msg, 'ok') then
        selfSay('Do you Want to become a sorcerer?', cid)
    elseif msgcontains(msg, 'yes') then
                        if(getPlayerLevel(cid) > 1) then                   
            selfSay('Say it Proudly: Yes, I Want to Become a sorcerer!', cid)
            talk_state = 1
        else
            selfSay('You do not have the required Level or You Already have a Vocation!.', cid)
            talk_state = 0
        end
    elseif msgcontains(msg, 'sorcerer') and talk_state == 1 then
        talk_state = 0
                if getCreatureStorage(cid, 43211) == 1 == FALSE then
            selfSay(done, cid)
            doPlayerSetVocation(cid, 1)
                        setPlayerStorageValue(cid, 43211,1)
                        doSendMagicEffect(getCreaturePosition(cid), 14)
        else
            selfSay(item, cid)
        end
    elseif msgcontains(msg, 'no') and (talk_state >= 1 and talk_state <= 5) then
        selfSay('Ok than.')
        talk_state = 0
    end
    return true
end
 
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
try this
might not work cause i'm bad at npcs
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

item = 'You do not have the required Level or You Already have a Vocation!.'
done = 'Congratulations now you are sorcerer, Go to the dungeon and take your items and hunt.'

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

    local player = Player(cid)

    if msgcontains(msg, 'ok') then
        npcHandler:say('Do you Want to become a sorcerer?', cid)
    elseif msgcontains(msg, 'yes') then
        if (player:getLevel() > 1) then                  
            npcHandler:say('Say it Proudly: Yes, I Want to Become a sorcerer!', cid)
            npcHandler.topic[cid] = 1
        else
            npcHandler:say('You do not have the required Level or You Already have a Vocation!.', cid)
            npcHandler.topic[cid] = 0
        end
    elseif msgcontains(msg, 'sorcerer') and npcHandler.topic[cid] == 1 then
        npcHandler.topic[cid] = 0
        if player:getStorageValue(43211) ~= 1 then
            npcHandler:say(done, cid)
            player:setVocation(1)
            player:setStorageValue(43211, 1)
            player:getPosition():sendMagicEffect(CONST_ME_MAGIC_GREEN)
        else
            npcHandler:say(item, cid)
        end
    elseif msgcontains(msg, 'no') and (npcHandler.topic[cid] >= 1 and npcHandler.topic[cid] <= 5) then
        npcHandler:say('Ok than.', cid)
        npcHandler.topic[cid] = 0
    end
    return true
end

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