Hey
Im kinda new in lua and would like to know how it would be "better" to make this script
The script is working as it should but is it fine like this? or is there a better way?
The part I dislike is == 5 or 6 or 7 or 8
is there a way to make it better or easier?
Im kinda new in lua and would like to know how it would be "better" to make this script
The script is working as it should but is it fine like this? or is there a better way?
Lua:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
if player:getLevel() >= 10000 then
player:sendTextMessage(MESSAGE_INFO_DESCR, "You must be atleast level 10000 to use this item!")
return true
end
if player:getVocation() == 1 or 2 or 3 or 4 then
player:sendTextMessage(MESSAGE_INFO_DESCR, "You must buy first promotion to use this item!")
return true
end
if player:getVocation() == 9 or 10 or 11 or 12 then
player:sendTextMessage(MESSAGE_INFO_DESCR, "You alredy have been promoted to a epic vocation!")
return true
end
if player:getVocation() == 5 or 6 or 7 or 8 then
local voc = player:getVocation():getId()
-- item:remove(1)
player:setVocation(voc + 4)
player:sendTextMessage(MESSAGE_INFO_DESCR, "You have been promoted to a " .. player:getVocation():getName() .. "!")
player:getPosition():sendMagicEffect(27)
end
return true
end
The part I dislike is == 5 or 6 or 7 or 8
is there a way to make it better or easier?