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

Oracle for Each Vocation

trayron1

New Member
Joined
Jun 28, 2015
Messages
55
Reaction score
1
Hello Otland Fans, im want a npc that teleport the player according to your vocation.
My server have 8 vocations, and 8 citys, 1 city for each vocation, but until level 10, all vocations playing in same place (like rookgard, but the player already have your vocation).

Im want a oracle, when the vocation to him, the oracle teleport the player according to your vocation for your according city.
like this, Mage lvl 9 cant teleport, because is level 9, npc only teleport players level 10, when the player get level 10, come back to oracle and he gonna teleport for Mage City.
Crusader level 10, goto oracle and teleport for Crusader City.

Its possible? Ty Otland <3
 
Generally do this.. idk what tfs your using though
Code:
local vocation = {
   [1] = { position = {x = 1000, y = 1000, z = 7}, city = "City Name" },
   [2] = { position = {x = 1000, y = 1000, z = 7}, city = "City Name" },
   [3] = { position = {x = 1000, y = 1000, z = 7}, city = "City Name" },
   [4] = { position = {x = 1000, y = 1000, z = 7}, city = "City Name" },
   [5] = { position = {x = 1000, y = 1000, z = 7}, city = "City Name" },
   [6] = { position = {x = 1000, y = 1000, z = 7}, city = "City Name" },
   [7] = { position = {x = 1000, y = 1000, z = 7}, city = "City Name" },
   [8] = { position = {x = 1000, y = 1000, z = 7}, city = "City Name" }
}

if getPlayerLevel(cid) < 10 then
   selfSay("You must be level 10 or higher to leave this island.", cid)
   return true
end

elseif msgcontains(msg, "teleport") then
   local voc = vocation[getPlayerVocation(cid)]
   doTeleportThing(cid, voc.position)
   selfSay("You have been teleported to ".. voc.city ..".", cid)
end
 
One thing to note, it is currently set-up to teleport players of level 10 and above. If you only want level 10 players to teleport then change this line..
Code:
if getPlayerLevel(cid)  < 10 then
to this..
Code:
 if getPlayerLevel(cid)  ~= 10 then
 
Now, the npc dont talk with me when i say hi, what im need to say?
Npc: data/npcs/Vision.xml
Code:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Vision" script="vocTravel.lua" walkinterval="2000" floorchange="0">
    <health now="100" max="100"/>
    <look type="128" head="17" body="54" legs="114" feet="0" addons="2"/>
    <parameters>
        <parameter key="message_greet" value="Hello, |PLAYERNAME|! I can help u?"/>
    </parameters>
</npc>

Script: data/npcs/scripts/vocTravel.lua
Code:
local vocation = {
   [1] = { position = {x = 832, y = 217, z = 5}, city = "Mage Quarter" },
   [2] = { position = {x = 926, y = 131, z = 6}, city = "Forbidden Town" },
   [3] = { position = {x = 1000, y = 1000, z = 7}, city = "City Name" },
   [4] = { position = {x = 1000, y = 1000, z = 7}, city = "City Name" },
   [5] = { position = {x = 1000, y = 1000, z = 7}, city = "City Name" },
   [6] = { position = {x = 1000, y = 1000, z = 7}, city = "City Name" },
   [7] = { position = {x = 1000, y = 1000, z = 7}, city = "City Name" },
   [8] = { position = {x = 1000, y = 1000, z = 7}, city = "City Name" }
}

if getPlayerLevel(cid)  ~= 10 then
   selfSay("You must be level 10 or higher to leave this island.", cid)
   return true
end

if msgcontains(msg, "teleport") then
   local voc = vocation[getPlayerVocation(cid)]
   doTeleportThing(cid, voc.position)
   selfSay("You have been teleported to ".. voc.city ..".", cid)
end
 
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
msgcontains = doMessageCheck -- I beleive I added this at some point because of an issue I was having. If it causes you issues, just remove it.

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

function greet(cid)  talkState[cid] = 0  return true  end
function getNpcName()  return getCreatureName(getNpcId())  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
 
 
   if msgcontains(msg, "job") then
     selfSay("My job is to show the world how fashionable they can be!", cid)
     talkState[talkUser] = 0
   elseif msgcontains(msg, "name") then
     selfSay("My name is " .. getNpcName() .. ".", cid)
     talkState[talkUser] = 0
   
   -- Above and below these lines are a regular npc scripts in 0.3.7
 
 
   -- Put the script inbetween these lines.. otherwise you won't load all the correct functions. 
  end
   return true
end

npcHandler:setCallback(CALLBACK_GREET, greet)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
Now, the npc dont talk with me when i say hi, what im need to say?
Npc: data/npcs/Vision.xml
Code:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Vision" script="vocTravel.lua" walkinterval="2000" floorchange="0">
    <health now="100" max="100"/>
    <look type="128" head="17" body="54" legs="114" feet="0" addons="2"/>
    <parameters>
        <parameter key="message_greet" value="Hello, |PLAYERNAME|! I can help u?"/>
    </parameters>
</npc>

Script: data/npcs/scripts/vocTravel.lua
Code:
local vocation = {
   [1] = { position = {x = 832, y = 217, z = 5}, city = "Mage Quarter" },
   [2] = { position = {x = 926, y = 131, z = 6}, city = "Forbidden Town" },
   [3] = { position = {x = 1000, y = 1000, z = 7}, city = "City Name" },
   [4] = { position = {x = 1000, y = 1000, z = 7}, city = "City Name" },
   [5] = { position = {x = 1000, y = 1000, z = 7}, city = "City Name" },
   [6] = { position = {x = 1000, y = 1000, z = 7}, city = "City Name" },
   [7] = { position = {x = 1000, y = 1000, z = 7}, city = "City Name" },
   [8] = { position = {x = 1000, y = 1000, z = 7}, city = "City Name" }
}

if getPlayerLevel(cid)  ~= 10 then
   selfSay("You must be level 10 or higher to leave this island.", cid)
   return true
end

if msgcontains(msg, "teleport") then
   local voc = vocation[getPlayerVocation(cid)]
   doTeleportThing(cid, voc.position)
   selfSay("You have been teleported to ".. voc.city ..".", cid)
end


Use this.
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
msgcontains = doMessageCheck -- I beleive I added this at some point because of an issue I was having. If it causes you issues, just remove it.

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

function greet(cid)  talkState[cid] = 0  return true  end
function getNpcName()  return getCreatureName(getNpcId())  end

local vocation = {
     [1] = { position = {x = 832, y = 217, z = 5}, city = "Mage Quarter" },
     [2] = { position = {x = 926, y = 131, z = 6}, city = "Forbidden Town" },
     [3] = { position = {x = 1000, y = 1000, z = 7}, city = "City Name" },
     [4] = { position = {x = 1000, y = 1000, z = 7}, city = "City Name" },
     [5] = { position = {x = 1000, y = 1000, z = 7}, city = "City Name" },
     [6] = { position = {x = 1000, y = 1000, z = 7}, city = "City Name" },
     [7] = { position = {x = 1000, y = 1000, z = 7}, city = "City Name" },
     [8] = { position = {x = 1000, y = 1000, z = 7}, city = "City Name" }
   }

function creatureSayCallback(cid, type, msg)
   if(not npcHandler:isFocused(cid)) then
     return false
   end
  
   local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
  
   if getPlayerLevel(cid) < 10 then
     selfSay("You must be level 10 to leave this island. You will need to gain some levels before leaving.", cid)
     return true
   elseif getPlayerLevel(cid) > 10 then
     selfSay("You must be level 10 to leave this island. You will need to lose some levels before leaving", cid)
     return true  
   end
  
   if msgcontains(msg, "teleport") then
     local voc = vocation[getPlayerVocation(cid)]
     doTeleportThing(cid, voc.position)
     selfSay("You have been teleported to ".. voc.city ..".", cid)
   end  
  
   return true
end

npcHandler:setCallback(CALLBACK_GREET, greet)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Last edited:
Thanks for help me, npc now talk with me, but this happens.

When im level 9 or bellow, the npc say it "You must be level 10 to leave this island. You will need to gain some levels before leaving"
When im level 11 or above, the npc say it too "You must be level 10 to leave this island. You will need to gain some levels before leaving"
When im exactly level 10, this error happens in console.
Error \/
 
read line 5 in the script. :p
Thanks for help me, npc now talk with me, but this happens.

When im level 9 or bellow, the npc say it "You must be level 10 to leave this island. You will need to gain some levels before leaving"
When im level 11 or above, the npc say it too "You must be level 10 to leave this island. You will need to gain some levels before leaving"
When im exactly level 10, this error happens in console.
Error \/
 
Xikini, where im change for he say with players lvl 10 and above? because he only speak with players exactly level 10 :/
 
Code:
function creatureSayCallback(cid, type, msg)
   if(not npcHandler:isFocused(cid)) then
     return false
   end
   
   local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
   
   if msgcontains(msg, "teleport") then
     if getPlayerLevel(cid) < 10 then
       selfSay("You must be level 10 to leave this island. You will need to gain some levels before leaving.", cid)
       return true
     elseif getPlayerLevel(cid) > 10 then
       selfSay("You must be level 10 to leave this island. You will need to lose some levels before leaving", cid)
       return true  
     end
     local voc = vocation[getPlayerVocation(cid)]
     doTeleportThing(cid, voc.position)
     selfSay("You have been teleported to ".. voc.city ..".", cid)
   end  
   
   return true
end
If you want players 10 and above to be able to leave the island
change this
Code:
if getPlayerLevel(cid) < 10 then
   selfSay("You must be level 10 to leave this island. You will need to gain some levels before leaving.", cid)
   return true
elseif getPlayerLevel(cid) > 10 then
   selfSay("You must be level 10 to leave this island. You will need to lose some levels before leaving", cid)
   return true 
end
To this.
Code:
if getPlayerLevel(cid) < 10 then
   selfSay("You must be level 10 to leave this island. You will need to gain some levels before leaving.", cid)
   return true
end
 
Back
Top