• 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 02 Vocations using same door

Bruce Leal

New Member
Joined
Nov 9, 2017
Messages
77
Reaction score
3
This script was made so that only one vocation goes through the door, however I would like 3 or more Vocations to pass.

Code:
function onUse(cid, item, frompos, item2, topos)

local VOCNAME = Knight -- NOME DA VOCAçÃO
local Vocid = 4 -- Id da vocacao

if item.uid == 7070 then
status1 = getPlayerVocation(cid)
if status1 == Vocid then

pos = getPlayerPosition(cid)

if pos.x == topos.x then
if pos.y < topos.y then
pos.y = topos.y + 1
else
pos.y = topos.y - 1
end
elseif pos.y == topos.y then
if pos.x < topos.x then
pos.x = topos.x + 1
else
pos.x = topos.x - 1
end
else
doPlayerSendCancel(cid,'Esteja em frente a porta.')
return 1
end

doTeleportThing(cid,pos)
doSendMagicEffect(topos,12)
else
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Voce nao pode passar, pois nao pertence a linhagem dos Knights.")
end
return 1
else
return 0
end
end
 
Solution
Lua:
local Vocid = {1,2,3,4} --for all vocations without promotion.

if isInArray(Vocid, getPlayerVocation(cid)) == true then --this will check if the player's vocation match one of the vocations listed on the array Vocid.
Lua:
local Vocid = {1,2,3,4} --for all vocations without promotion.

if isInArray(Vocid, getPlayerVocation(cid)) == true then --this will check if the player's vocation match one of the vocations listed on the array Vocid.
 
Solution
Not working.

Code:
function onUse(cid, item, frompos, item2, topos)

local VOCNAME = Knight -- NOME DA VOC
local Vocid = {4,8,10,11,12,13,14,15,16} -- Id da vocacao

if isInArray(Vocid, getPlayerVocation(cid)) == true then --this will check if the player's vocation match one of the vocations listed on the array Vocid.
end

if item.uid == 7070 then
status1 = getPlayerVocation(cid)
if status1 == Vocid then

pos = getPlayerPosition(cid)

if pos.x == topos.x then
if pos.y < topos.y then
pos.y = topos.y + 1
else
pos.y = topos.y - 1
end
elseif pos.y == topos.y then
if pos.x < topos.x then
pos.x = topos.x + 1
else
pos.x = topos.x - 1
end
else
doPlayerSendCancel(cid,'Esteja em frente a porta.')
return 1
end

doTeleportThing(cid,pos)
doSendMagicEffect(topos,12)
else
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Voce nao pode passar, pois nao pertence a linhagem dos Knights.")
end
return 1
else
return 0
end
end
 
It's clear that it wont work this way, you are doing the "if" check and ending it without any purpose, I gave you what you need to make it work, it's up to you now to check your script and understand what it is doing then apply the case I gave to you! :)
 
Back
Top