Lua script

ninolouco

New Member
Joined
Mar 11, 2019
Messages
24
Reaction score
1
Hi, otland, im using the forgotten server 1.2

How add this code

Lua:
player:getVocation():getId() ~= 0 and player:getVocation():getId() < 5 and player:getStorageValue(30018) == 1 then
            player:setVocation(player:getVocation():getId() + 4)
inside this code? is it possible? someone can help me ?

Lua:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    player:addPremiumDays(30)
    player:sendTextMessage(MESSAGE_INFO_DESCR, "premium account.")
    player:getPosition():sendMagicEffect(CONST_ME_MAGIC_GREEN)
    item:remove(1)
    return true
end
thanks
 

Apollos

Dude who does stuff
Joined
Apr 22, 2009
Messages
722
Reaction score
442
Location
United States
Hi, otland, im using the forgotten server 1.2

How add this code

Lua:
player:getVocation():getId() ~= 0 and player:getVocation():getId() < 5 and player:getStorageValue(30018) == 1 then
            player:setVocation(player:getVocation():getId() + 4)
inside this code? is it possible? someone can help me ?

Lua:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    player:addPremiumDays(30)
    player:sendTextMessage(MESSAGE_INFO_DESCR, "premium account.")
    player:getPosition():sendMagicEffect(CONST_ME_MAGIC_GREEN)
    item:remove(1)
    return true
end
thanks
If you want the vocation to determine if ALL these functions should work then do this:
Lua:
local storage = 30018

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local voc_id = player:getVocation():getId()
    if voc_id ~= 0 and voc_id < 5 and player:getStorageValue(storage) == 1 then
        player:setVocation(voc_id + 4)
        player:addPremiumDays(30)
        player:sendTextMessage(MESSAGE_INFO_DESCR, "premium account.")
        player:getPosition():sendMagicEffect(CONST_ME_MAGIC_GREEN)
        item:remove(1)
    end
    return true
end
If you want vocation to only determine the vocation change and let the rest continue no matter what then do this:
Lua:
local storage = 30018

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local voc_id = player:getVocation():getId()
    if voc_id ~= 0 and voc_id < 5 and player:getStorageValue(storage) == 1 then
        player:setVocation(voc_id + 4)
    end
    player:addPremiumDays(30)
    player:sendTextMessage(MESSAGE_INFO_DESCR, "premium account.")
    player:getPosition():sendMagicEffect(CONST_ME_MAGIC_GREEN)
    item:remove(1)
    return true
end
 
Top