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

Lua Transfer town at temple NPC

ralke

(҂ ͠❛ ෴ ͡❛)ᕤ
Joined
Dec 17, 2011
Messages
1,470
Solutions
27
Reaction score
844
Location
Santiago - Chile
GitHub
ralke23
Twitch
ralke23
Hi! I have this temple NPC and I would like to request a feature, basically I need that the player says:
hi, transfer, yes And then the player will be teleported and residenced to town 2.

Also need that player has premium to request this transfer.

Lua:
local marks = {
    [1]={{x=1019,y=975,z=7},"Father Zuke",MAPMARK_TEMPLE},
    [2]={{x=1025,y=981,z=7},"Jassu",MAPMARK_STAR},
    [3]={{x=0979,y=0962,z=5},"Rin",MAPMARK_STAR},
    [4]={{x=989,y=964,z=5},"O'aka",MAPMARK_STAR},
    [5]={{x=989,y=971,z=5},"Keyakku",MAPMARK_STAR},
    [6]={{x=989,y=979,z=5},"Jassu",MAPMARK_STAR},
    [7]={{x=976,y=978,z=5},"Clasko",MAPMARK_STAR},
    [8]={{x=976,y=970,z=5},"Lucil",MAPMARK_STAR},
    [9]={{x=977,y=962,z=4},"Tromell",MAPMARK_STAR},
    [10]={{x=988,y=963,z=4},"Seymour",MAPMARK_STAR},
    [11]={{x=975,y=978,z=4},"Henricus",MAPMARK_QUESTION},
    [12]={{x=1022,y=977,z=8},"Amanda",MAPMARK_STAR},
    [13]={{x=986,y=1003,z=7},"Tim, The Guard",MAPMARK_QUESTION},
    [14]={{x=1048,y=999,z=7},"Walter, The Guard",MAPMARK_QUESTION},
    [15]={{x=1061,y=950,z=5},"Kulag, The Guard",MAPMARK_QUESTION},
    [16]={{x=1025,y=928,z=7},"Grof, The Guard",MAPMARK_QUESTION},
    [17]={{x=961,y=950,z=6},"Miles, The Guard",MAPMARK_QUESTION},
    [18]={{x=982,y=995,z=5},"Zaon",MAPMARK_STAR},
    [19]={{x=991,y=982,z=7},"Padreia",MAPMARK_QUESTION},
    [20]={{x=1168,y=1015,z=7},"Maroda",MAPMARK_QUESTION},
}

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

local function creatureSayCallback(cid, type, msg)
    if not npcHandler:isFocused(cid) then
        return false
    end
    if table.contains({"fuck", "idiot", "asshole", "ass", "fag", "stupid", "tyrant", "shit", "lunatic"}, msg) then
        npcHandler:say("Take this!", cid)
        local player = Player(cid)
        player:getPosition():sendMagicEffect(CONST_ME_EXPLOSIONAREA)
        player:addCondition(condition)
        npcHandler:releaseFocus(cid)
        npcHandler:resetNpc(cid)
    end


    local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
     local player = Player(cid)
     if msg == "marks" then
      for i = 1, #marks do
      player:addMapMark(marks[i][1],marks[i][3],marks[i][2],marks[i][4],marks[i][5],marks[i][6],marks[i][7],marks[i][8],marks[i][9],marks[i][10],marks[i][11],marks[i][12],marks[i][13],marks[i][14],marks[i][15],marks[i][16],marks[i][17],marks[i][18],marks[i][19],marks[i][20])
      end
      selfSay('Your world map has been marked with non-playable characters location.', cid)
      player:getPosition():sendMagicEffect(CONST_ME_STEPSVERTICAL)
      talkState[talkUser] = 0
      elseif msg == "home" then
      player:setTown(Town(1))
      selfSay('From now on you have become a citizen of Kilika.', cid)
      player:getPosition():sendMagicEffect(CONST_ME_YALAHARIGHOST)
      talkState[talkUser] = 0
      elseif msg == "mark" then
      for i = 1, #marks do
      -------------
      player:addMapMark(marks[i][1],marks[i][3],marks[i][2],marks[i][4],marks[i][5],marks[i][6],marks[i][7],marks[i][8],marks[i][9],marks[i][10],marks[i][11],marks[i][12],marks[i][13],marks[i][14],marks[i][15],marks[i][16],marks[i][17],marks[i][18],marks[i][19],marks[i][20])
      end
      selfSay('Your world map has been marked with non-playable characters location.', cid)
      player:getPosition():sendMagicEffect(CONST_ME_STEPSVERTICAL)
      talkState[talkUser] = 0
      elseif msg == "hometown" then
      player:setTown(Town(1))
      selfSay('From now on you have become a citizen of Kilika.', cid)
      player:getPosition():sendMagicEffect(CONST_ME_YALAHARIGHOST)
      talkState[talkUser] = 0
     else
    selfSay('I can only {mark} your world map, change your {hometown} or give you a {promotion}.', cid)
    talkState[talkUser] = 0
   end
   return true
end

local node1 = keywordHandler:addKeyword({'promot'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I can promote you for 20000 gold coins. Do you want me to promote you?'})
    node1:addChildKeyword({'yes'}, StdModule.promotePlayer, {npcHandler = npcHandler, cost = 20000, level = 20, text = 'Congratulations! You are now promoted.'})
    node1:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Alright then, come back when you are ready.', reset = true})



npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Last edited:
Solution
Lua:
if msg == "transfer" then
    selfSay("transfer?", cid)
    talkState[talkUser] = 1
elseif msg == "yes" and talkState[talkUser] == 1 then
    if not player:isPremium() then
        selfSay("need premium", cid)
    else
        selfSay("done", cid)
        player:setTown(Town(2))
        player:teleportTo(player:getTown():getTemplePosition())
    end
    talkState[talkUser] = 0
end
Lua:
if msg == "transfer" then
    selfSay("transfer?", cid)
    talkState[talkUser] = 1
elseif msg == "yes" and talkState[talkUser] == 1 then
    if not player:isPremium() then
        selfSay("need premium", cid)
    else
        selfSay("done", cid)
        player:setTown(Town(2))
        player:teleportTo(player:getTown():getTemplePosition())
    end
    talkState[talkUser] = 0
end
 
Solution
Lua:
if msg == "transfer" then
    selfSay("transfer?", cid)
    talkState[talkUser] = 1
elseif msg == "yes" and talkState[talkUser] == 1 then
    if not player:isPremium() then
        selfSay("need premium", cid)
    else
        selfSay("done", cid)
        player:setTown(Town(2))
        player:teleportTo(player:getTown():getTemplePosition())
    end
    talkState[talkUser] = 0
end

Thanks again @Xikini :)
So happy to have your help as always!
 
Back
Top