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

Solved npc checking your vocation

Verrine

Member
Joined
Mar 2, 2016
Messages
117
Reaction score
7
Hi!
I want to make npc that check your vocation and depending on vocation he speaking other messages
i dont know how to check voc can anyone help me with this?
 
https://github.com/otland/forgottenserver/blob/master/data/lib/compat/compat.lua#L212
Here you can see the TFS 1.2 functions you can use for that.
With if statements you can check for different voc ids, or you can also do it with a table.
I can write an example if you post how it should work exactly and with which vocations and which messages.

Code:
if getPlayerVocation(cid):getID() == 1 or getPlayerVocation(cid):getID() == 5 and player:getStorageValue(44923) == 1 then
         npcHandler:say('Do you have free 120 oz and 5 slots in your backpack? Make sure and check 2 times!', cid)
         npcHandler.topic[cid] = 6
       elseif getPlayerVocation(cid):getID() == 2 or getPlayerVocation(cid):getID() == 6 and player:getStorageValue(44923) == 1 then
         npcHandler:say('Do you have free 120 oz and 5 slots in your backpack? Make sure and check 2 times!', cid)
         npcHandler.topic[cid] = 5
       elseif getPlayerVocation(cid):getID() == 3 or getPlayerVocation(cid):getID() == 7 and player:getStorageValue(44923) == 1 then
         npcHandler:say('Do you have free 130 oz and 4 slots in your backpack? Make sure and check 2 times!', cid)
         npcHandler.topic[cid] = 4
       elseif getPlayerVocation(cid):getID() == 4 or getPlayerVocation(cid):getID() == 8 and player:getStorageValue(44923) == 1 then
         npcHandler:say('What\'s your specialization? {axe}, {club} or {sword}?', cid)
         npcHandler.topic[cid] = 2
       elseif getPlayerVocation(cid):getID() == 12 or getPlayerVocation(cid):getID() == 13 and player:getStorageValue(44923) == 1 then
         npcHandler:say('Do you have free 200 oz and 5 slots in your backpack? Make sure and check 2 times!', cid)
         npcHandler.topic[cid] = 7
       else
         npcHandler:say('You need to be level 50+.', cid)
       end

i can handle everything else just want to work this I want to do smth like items for start after reaching lvl 50 (player gets automaticly token + storage so I think its ok now) and now i dont want players to tell npc what vocation you are. It should know it without telling 'him' that. Here is an example of that what i need verry simplified becouse I think you know what i mean
 
Last edited:
If you want something different for every voc most easy thing would be using a table, you can add anything in it that should be different for the different vocations.
Code:
local config = {
     [{1, 5}] = {text = "Do you have free 120 oz and 5 slots in your backpack? Make sure and check 2 times!", topic = 6},
     [{2, 6}] = {text = "Do you have free 120 oz and 5 slots in your backpack? Make sure and check 2 times!", topic = 5},
     [{3, 7}] = {text = "Do you have free 130 oz and 4 slots in your backpack? Make sure and check 2 times!", topic = 4},
     [{4, 8}] = {text = "What's your specialization? {axe}, {club} or {sword}?", topic = 2},
     [{12, 13}] = {text = "Do you have free 200 oz and 5 slots in your backpack? Make sure and check 2 times!", topic = 7}
}

for voc, x in pairs(config) do
     local v = player:getVocation():getId()
     if (v == voc[1] or v == voc[2]) and player:getStorageValue(44923) == 1 then
           npcHandler:say(x.test, cid)
           npcHandler.topic[cid] = x.topic
     end
end
 
Back
Top