• 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!
  • If you're using Gesior 2012 or MyAAC, please review this thread for information about a serious security vulnerability and a fix.

Lua Npc Revscriptsys

adrenyslopez

Member
Joined
Dec 22, 2015
Messages
198
Reaction score
14
Hello, I need to pass this npc to revscript, is it possible?
i use canary tfs 1.3

Lua:
 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

local playerTopic = {}
local function greetCallback(cid)
    local player = Player(cid)
    if player then
        if player:getStorageValue(Storage.GraveDanger.CobraBastion.Grave) < 1 then
            npcHandler:setMessage(MESSAGE_GREET, "Welcome, |PLAYERNAME|! There is much we have to {discuss}, if you want to get the {outfit} you must kill King Zelos you can add addons with {Final Judgement} and {Shadow Cowl}..")
            playerTopic[cid] = 1
        else
            npcHandler:setMessage(MESSAGE_GREET, "Welcome, |PLAYERNAME|! if you want to get the {outfit} you must kill King Zelos you can add addons with {Final Judgement} and {Shadow Cowl}")
            playerTopic[cid] = 0
        end
    end
    npcHandler:addFocus(cid)
    return true
end

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

    npcHandler.topic[cid] = playerTopic[cid]
    local player = Player(cid)
    local playerName = player:getName()

    -- start quest
    if msgcontains(msg, "discuss") and npcHandler.topic[cid] == 1 then
        npcHandler:say({"While you travel and fight the threat where is arises, we will put all our resources into reasearching the ultimate plans of the legion. Perhaps I can tell you more when you report back..."}, cid)
        npcHandler.topic[cid] = 2
        playerTopic[cid] = 2
        player:setStorageValue(Storage.GraveDanger.Questline, 1)
        player:setStorageValue(Storage.GraveDanger.CobraBastion.Grave, 1)
    elseif msgcontains(msg, "yes") and npcHandler.topic[cid] == 4 then
         player:setStorageValue(Storage.GraveDanger.CobraBastion.Grave, 1)
        npcHandler.topic[cid] = 0
        playerTopic[cid] = 0
        elseif player:getStorageValue(Storage.GraveDanger.CobraBastion.Kingzelos) > 1 then
            npcHandler:say({
                "You defeated the great King Zelosl!. ...",
                "You are worthy to wear this outfit."
            }, cid)
            doPlayerAddOutfit(cid, 1243, 0)
            doPlayerAddOutfit(cid, 1244,0)
            player:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE)
            npcHandler.topic[cid] = 0
    end
    
        if msgcontains(msg, "Final Judgement") then
                if player:getStorageValue(Storage.GraveDanger.CobraBastion.Kingzelos) < 1 then
            npcHandler:say("You did not defeat the King Zelos!", cid)
            npcHandler.topic[cid] = 1
            
            elseif player:removeItem(36573, 1) then
                npcHandler:say({
                    "take it."
                }, cid)
                 doPlayerAddOutfit(cid, 1243, 1)
                 doPlayerAddOutfit(cid, 1244, 1)
            player:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE)
            else
                npcHandler:say("You need 1 Final Judgement.", cid)
            end
            npcHandler.topic[cid] = 0
      
 
        
        elseif msgcontains(msg, "Shadow Cowl") then
                if player:getStorageValue(Storage.GraveDanger.CobraBastion.Kingzelos) < 1 then
            npcHandler:say("You did not defeat the King Zelos!", cid)
            npcHandler.topic[cid] = 1
            
            elseif player:removeItem(36572, 1) then
                npcHandler:say({
                    "take it."
                }, cid)
            doPlayerAddOutfit(cid, 1243, 2)
            doPlayerAddOutfit(cid, 1244, 2)
            player:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE)
            else
                npcHandler:say("You need 1 Shadow Cowl.", cid)
            end
            npcHandler.topic[cid] = 0
                  
 
        
        elseif msgcontains(msg, "Outfit") then
                if player:getStorageValue(Storage.GraveDanger.CobraBastion.Kingzelos) < 1 then
            npcHandler:say("You did not defeat the King Zelos!", cid)
            npcHandler.topic[cid] = 1
            
            elseif player:removeItem(0, 0) then
                npcHandler:say({
                    "take it."
                }, cid)
            doPlayerAddOutfit(cid, 1243, 0)
            doPlayerAddOutfit(cid, 1244, 0)
            player:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE)
            else
                npcHandler:say("You need kill King Zelos.", cid)
            end
            npcHandler.topic[cid] = 0
 end

    return true
end



npcHandler:setMessage(MESSAGE_WALKAWAY, 'Well, bye then.')

npcHandler:setCallback(CALLBACK_ONADDFOCUS, onAddFocus)
npcHandler:setCallback(CALLBACK_ONRELEASEFOCUS, onReleaseFocus)

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

Xikini

I whore myself out for likes
Support Team
Joined
Nov 17, 2010
Messages
6,107
Solutions
506
Reaction score
4,274
As far as I know, npc's cannot currently be made using revscripts.

Actions,
CreatureEvents,
GlobalEvents,
MonsterTypes,
MoveEvents,
Spells,
TalkActions,
Weapons

can all be made using revscripts tho
 

Xikini

I whore myself out for likes
Support Team
Joined
Nov 17, 2010
Messages
6,107
Solutions
506
Reaction score
4,274
Top