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

RevScripts Exp Scroll

Solution
Lua:
Lua Script Error: [Scripts Interface]
/home/forgottenserver/data/scripts/actions/exp_scroll.lua:callback
data/lib/core/player.lua:332: attempt to call global 'getExperienceForLevel' (a nil value)
stack traceback:
        [C]: in function 'getExperienceForLevel'
        data/lib/core/player.lua:332: in function 'addLevel'
        /home/forgottenserver/data/scripts/actions/exp_scroll.lua:4: in function </home/forgottenserver/data/scripts/actions/exp_scroll.lua:3>

Add this

to data/global.lua
Lua:
local expScroll = Action()

function expScroll.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    player:addLevel(2)
    player:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE)
    item:remove(1)
    return true
end

expScroll:id(1234)
expScroll:register()
 
player:addLevel() ?, this function does not exist in the default data pack, you cannot send something you only have on your server to other people they use default things and you have to assume they only have default things

In any case, the player:addExperience() function with a small simple formula you can add levels to the player
player:addExperience(getExpForLevel(player:getLevel() + 2) - player:getExperience(), false)
 
player:addLevel() ?, this function does not exist in the default data pack, you cannot send something you only have on your server to other people they use default things and you have to assume they only have default things

In any case, the player:addExperience() function with a small simple formula you can add levels to the player
player:addExperience(getExpForLevel(player:getLevel() + 2) - player:getExperience(), false)
 
Lua:
local expScroll = Action()

function expScroll.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    player:addLevel(2)
    player:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE)
    item:remove(1)
    return true
end

expScroll:id(1234)
expScroll:register()
no work bro :s
 
Lua:
Lua Script Error: [Scripts Interface]
/home/forgottenserver/data/scripts/actions/exp_scroll.lua:callback
/home/forgottenserver/data/scripts/actions/exp_scroll.lua:4: attempt to call method 'addLevel' (a nil value)
stack traceback:
        [C]: in function 'addLevel'
        /home/forgottenserver/data/scripts/actions/exp_scroll.lua:4: in function </home/forgottenserver/data/scripts/actions/exp_scroll.lua:3>
 
Lua:
Lua Script Error: [Scripts Interface]
/home/forgottenserver/data/scripts/actions/exp_scroll.lua:callback
/home/forgottenserver/data/scripts/actions/exp_scroll.lua:4: attempt to call method 'addLevel' (a nil value)
stack traceback:
        [C]: in function 'addLevel'
        /home/forgottenserver/data/scripts/actions/exp_scroll.lua:4: in function </home/forgottenserver/data/scripts/actions/exp_scroll.lua:3>
TFS version?
 
Add this

to your data/lib/core/player.lua file
Lua:
Lua Script Error: [Scripts Interface]
/home/forgottenserver/data/scripts/actions/exp_scroll.lua:callback
data/lib/core/player.lua:332: attempt to call global 'getExperienceForLevel' (a nil value)
stack traceback:
        [C]: in function 'getExperienceForLevel'
        data/lib/core/player.lua:332: in function 'addLevel'
        /home/forgottenserver/data/scripts/actions/exp_scroll.lua:4: in function </home/forgottenserver/data/scripts/actions/exp_scroll.lua:3>
 
Lua:
Lua Script Error: [Scripts Interface]
/home/forgottenserver/data/scripts/actions/exp_scroll.lua:callback
data/lib/core/player.lua:332: attempt to call global 'getExperienceForLevel' (a nil value)
stack traceback:
        [C]: in function 'getExperienceForLevel'
        data/lib/core/player.lua:332: in function 'addLevel'
        /home/forgottenserver/data/scripts/actions/exp_scroll.lua:4: in function </home/forgottenserver/data/scripts/actions/exp_scroll.lua:3>

Add this

to data/global.lua
 
Solution
thanks, it worked
Add this

to data/global.lua
Post automatically merged:

Add this

to data/global.lua
now it gives me this error in the console when using the scroll exp

Lua:
Lua Script Error: [Scripts Interface]
/home/forgottenserver/data/scripts/creaturescripts/others/familiars.lua:callback
...server/data/scripts/creaturescripts/others/familiars.lua:85: attempt to index local 'vocation' (a nil value)
stack traceback:
        [C]: in function '__index'
        ...server/data/scripts/creaturescripts/others/familiars.lua:85: in function <...server/data/scripts/creaturescripts/others/familiars.lua:81>
        [C]: in function 'addLevel'
        /home/forgottenserver/data/scripts/actions/exp_scroll.lua:4: in function </home/forgottenserver/data/scripts/actions/exp_scroll.lua:3>
 
thanks, it worked

Post automatically merged:


now it gives me this error in the console when using the scroll exp

Lua:
Lua Script Error: [Scripts Interface]
/home/forgottenserver/data/scripts/creaturescripts/others/familiars.lua:callback
...server/data/scripts/creaturescripts/others/familiars.lua:85: attempt to index local 'vocation' (a nil value)
stack traceback:
        [C]: in function '__index'
        ...server/data/scripts/creaturescripts/others/familiars.lua:85: in function <...server/data/scripts/creaturescripts/others/familiars.lua:81>
        [C]: in function 'addLevel'
        /home/forgottenserver/data/scripts/actions/exp_scroll.lua:4: in function </home/forgottenserver/data/scripts/actions/exp_scroll.lua:3>
what's on familiars.lua Line 85 ? post it
 
what's on familiars.lua Line 85 ? post it
Lua:
local familiar = {
    [VOCATION.CLIENT_ID.SORCERER] = {id = 994, name = "Sorcerer familiar"},
    [VOCATION.CLIENT_ID.DRUID] = {id = 993, name = "Druid familiar"},
    [VOCATION.CLIENT_ID.PALADIN] = {id = 992, name = "Paladin familiar"},
    [VOCATION.CLIENT_ID.KNIGHT] = {id = 991, name = "Knight familiar"}
}

local timer = {
    [1] = {storage=Storage.PetSummonEvent10, countdown=10, message = "10 seconds"},
    [2] = {storage=Storage.PetSummonEvent60, countdown=60, message = "one minute"}
}

local function sendMessageFunction(pid, message)
    if Player(pid) then
        Player(pid):sendTextMessage(MESSAGE_LOOT, "Your summon will disappear in less than " .. message)
    end
end

local function removePet(creatureId, playerId)
    local creature = Creature(creatureId)
    local player = Player(playerId)
    if not creature or not player then
        return true
    end
    creature:remove()
    for sendMessage = 1, #timer do
        player:setStorageValue(timer[sendMessage].storage, -1)
    end
end

local familiarStorage = Storage.PetSummon

local familiarLogin = CreatureEvent("FamiliarLogin")

function familiarLogin.onLogin(player)
    local vocation = familiar[player:getVocation():getClientId()]
    local familiarName
    local petTimeLeft = player:getStorageValue(familiarStorage) - player:getLastLogout()

    if vocation then
        if (not isPremium(player) and player:hasFamiliar(vocation.id)) or player:getLevel() < 200 then
                player:removeFamiliar(vocation.id)
        elseif isPremium(player) and player:getLevel() >= 200 then
            if petTimeLeft > 0 then
                familiarName = vocation.name
            end
            if player:getFamiliarLooktype() == 0 then
                player:setFamiliarLooktype(vocation.id)
            end
            if not player:hasFamiliar(vocation.id) then
                player:addFamiliar(vocation.id)
            end
        end
    end

    if familiarName then
        position = player:getPosition()
        local familiarMonster = Game.createMonster(familiarName, position, true, false)
        player:addSummon(familiarMonster)
        familiarMonster:setOutfit({lookType = player:getFamiliarLooktype()})
        --familiarMonster:reload()
        local deltaSpeed = math.max(player:getSpeed() - familiarMonster:getSpeed(), 0)
        familiarMonster:changeSpeed(deltaSpeed)
        player:setStorageValue(familiarStorage, os.time() + petTimeLeft)
        familiarMonster:registerEvent("FamiliarDeath")
        position:sendMagicEffect(CONST_ME_MAGIC_BLUE)
        addEvent(removePet, petTimeLeft*1000, familiarMonster:getId(), player:getId())
        for sendMessage = 1, #timer do
            if player:getStorageValue(timer[sendMessage].storage) == -1 and petTimeLeft >= timer[sendMessage].countdown then
                player:setStorageValue(timer[sendMessage].storage, addEvent(sendMessageFunction, (petTimeLeft-timer[sendMessage].countdown)*1000, player:getId(), timer[sendMessage].message))
            end
        end
    end
    return true
end

familiarLogin:register()

local advanceFamiliar = CreatureEvent("AdvanceFamiliar")

function advanceFamiliar.onAdvance(player, skill, oldLevel, newLevel)
    local vocation = familiar[player:getVocation():getClientId()]
    if newLevel >= 200 and isPremium(player) then
        if player:getFamiliarLooktype() == 0 then
                player:setFamiliarLooktype(vocation.id)
        end
        if not player:hasFamiliar(vocation.id) then
            player:addFamiliar(vocation.id)
        end
    end
    return true
end

advanceFamiliar:register()

local familiarDeath = CreatureEvent("FamiliarDeath")

function familiarDeath.onDeath(creature, corpse, lasthitkiller, mostdamagekiller, lasthitunjustified,
                                                                                                mostdamageunjustified)
    local player = creature:getMaster()
    if not player then
        return false
    end
    local vocation = familiar[player:getVocation():getClientId()]

    if table.contains(vocation, creature:getName()) then
        player:setStorageValue(familiarStorage, os.time())
        for sendMessage = 1, #timer do
            stopEvent(player:getStorageValue(timer[sendMessage].storage))
            player:setStorageValue(timer[sendMessage].storage, -1)
        end
    end
    return true
end

familiarDeath:register()
 
Lua:
function advanceFamiliar.onAdvance(player, skill, oldLevel, newLevel)
    local vocation = familiar[player:getVocation():getClientId()]
    if not vocation then
        print("[Warning - advanceFamiliar onAdvance] Vocation ClientID not found (" .. player:getVocation() .. ")")
        return true
    end
    if newLevel >= 200 and isPremium(player) then
        if player:getFamiliarLooktype() == 0 then
                player:setFamiliarLooktype(vocation.id)
        end
        if not player:hasFamiliar(vocation.id) then
            player:addFamiliar(vocation.id)
        end
    end
    return true
end
 
Lua:
function advanceFamiliar.onAdvance(player, skill, oldLevel, newLevel)
    local vocation = familiar[player:getVocation():getClientId()]
    if not vocation then
        print("[Warning - advanceFamiliar onAdvance] Vocation ClientID not found (" .. player:getVocation() .. ")")
        return true
    end
    if newLevel >= 200 and isPremium(player) then
        if player:getFamiliarLooktype() == 0 then
                player:setFamiliarLooktype(vocation.id)
        end
        if not player:hasFamiliar(vocation.id) then
            player:addFamiliar(vocation.id)
        end
    end
    return true
end
Lua:
Lua Script Error: [Scripts Interface]
/home/forgottenserver/data/scripts/creaturescripts/others/familiars.lua:callback
...server/data/scripts/creaturescripts/others/familiars.lua:84: attempt to concatenate a userdata value
stack traceback:
        [C]: in function '__concat'
        ...server/data/scripts/creaturescripts/others/familiars.lua:84: in function <...server/data/scripts/creaturescripts/others/familiars.lua:81>
        [C]: in function 'addLevel'
        /home/forgottenserver/data/scripts/actions/exp_scroll.lua:4: in function </home/forgottenserver/data/scripts/actions/exp_scroll.lua:3>
 
Lua:
Lua Script Error: [Scripts Interface]
/home/forgottenserver/data/scripts/creaturescripts/others/familiars.lua:callback
...server/data/scripts/creaturescripts/others/familiars.lua:84: attempt to concatenate a userdata value
stack traceback:
        [C]: in function '__concat'
        ...server/data/scripts/creaturescripts/others/familiars.lua:84: in function <...server/data/scripts/creaturescripts/others/familiars.lua:81>
        [C]: in function 'addLevel'
        /home/forgottenserver/data/scripts/actions/exp_scroll.lua:4: in function </home/forgottenserver/data/scripts/actions/exp_scroll.lua:3>
Try:
Lua:
print("[Warning - advanceFamiliar onAdvance] Vocation ClientID not found (" .. player:getVocation():getId() .. ")")
But you can remove the print if you want.
 
Back
Top