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

Premium Travel NPC.

Varev

New Member
Joined
Mar 23, 2015
Messages
29
Reaction score
0
Hello guys!
I need premium travel NPC. We must got premium account to travel with our NPC. I don't like rl boat npc script. Help me please!!
 
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

local talkState, xmsg = {}, {}

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 locations = {
     ["Thais"] = {pos = {x = 94, y = 115, z = 7}, gold = 100},
     ["Carlin"] = {pos = {x = 94, y = 116, z = 7}, gold = 120},
     ["Venore"] = {pos = {x = 94, y = 117, z = 7}, gold = 90}
}

local function Cptl(f, r)
     return f:upper()..r:lower()
end

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

     local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid

     local x = locations[msg:gsub("(%a)([%w_']*)", Cptl)]
     if msgcontains(msg, 'travel') then
         if getPlayerPremiumDays(cid) >= 1 then
             selfSay('Where do you want to go? I can bring you to Thais, Carlin or Venore.', cid)
             talkState[talkUser] = 1
         else
             selfSay('Travel is only for premium.', cid)
         end
     elseif x and talkState[talkUser] == 1 then
         selfSay('Do you want to travel to '..msg..' for '..x.gold..' gold?', cid)
         xmsg[cid] = msg
         talkState[talkUser] = 2
     elseif msgcontains(msg, 'yes') and talkState[talkUser] == 2 then
         x = locations[xmsg[cid]:gsub("(%a)([%w_']*)", Cptl)]
         if doPlayerRemoveMoney(cid, x.gold) then
             selfSay('Here you go, have a fun trip to '..xmsg[cid]..'.', cid)
             doTeleportThing(cid, x.pos)
             talkState[talkUser] = 0
         else
             selfSay('You don\'t have enough money.', cid)
             talkState[talkUser] = 0
         end
     else
         selfSay('What? I don\'t understand what you mean with '..msg..'.', cid)
     end
     return true
end

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

Next time post your server version.
 
Back
Top