• 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 NPC Teleport (OTX)

ADM24horas

New Member
Joined
Oct 4, 2015
Messages
70
Reaction score
0
I would like this teleport NPC vip vip is only those who type for storage since my server has two types of vip



Code:
local cities = {
    ['treiners'] = {
        pos = {x = 1988, y = 1595, z = 7};
        level = 250;
    };
    ['teleports'] = {
        pos = {x = 1912, y = 1594, z = 7};
        level = 250;
    };
    ['templo'] = {
        pos = {x = 160, y=53, z = 7};
        level = 250;
    };
    ['vip city'] = {
        pos = {x = 2962, y = 1316, z = 7};
        level = 250;
    };
}

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:lower())   end
function onThink()                  npcHandler:onThink()                  end

local talkState = {}
local cityChoosed = {}
function creatureSayCallback(cid, type, msg)
       if(not npcHandler:isFocused(cid)) then
          return false
       end
       local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
     for cityName, param in pairs(cities) do
         if msgcontains(msg, cityName) then
             selfSay("You want to travel to " .. cityName .. "?", cid)
             talkState[talkUser] = 1
             cityChoosed[talkUser] = cityName
             return true
         end
     end

     if msgcontains(msg, "yes") and talkState[talkUser] == 1 then
         local city = cityChoosed[talkUser]
         if city and cities[city] then
             local cityParam = cities[city]
             if vip.hasVip(cid) == TRUE and getPlayerLevel(cid) >= cityParam.level then
                 selfSay("Here we go, hold on tight!", cid)
                 doSendMagicEffect(getThingPos(cid), 10)
                 npcHandler:releaseFocus(cid)
                 doTeleportThing(cid, cityParam.pos)
                 doSendMagicEffect(cityParam.pos, 10)
              else
                 selfSay("Sorry, only VIP players and Level 250 can travel there.", cid)
              end
          end
          talkState[talkUser] = 0
          cityChoosed[talkUser] = nil
       end
       return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Back
Top