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>
data/global.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 thingsplayer:addExperience()
function with a small simple formula you can add levels to the playerplayer: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, theplayer:addExperience()
function with a small simple formula you can add levels to the player
player:addExperience(getExpForLevel(player:getLevel() + 2) - player:getExperience(), false)
Sorry, I never realized that they had implemented such a functionforgottenserver/data/lib/core/player.lua at master · otland/forgottenserver
A free and open-source MMORPG server emulator written in C++ - otland/forgottenservergithub.com
no work bro :sLua: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()
Thanks for the awesome infono work bro :s
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?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>
1.3 otbrTFS version?
Add this1.3 otbr
data/lib/core/player.lua
fileAdd this
forgottenserver/data/lib/core/player.lua at master · otland/forgottenserver
A free and open-source MMORPG server emulator written in C++ - otland/forgottenservergithub.com
to yourdata/lib/core/player.lua
file
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>
data/global.lua
Add this
forgottenserver/data/global.lua at f9d9944242bd5e455d97af2ef11d29da834ec8da · otland/forgottenserver
A free and open-source MMORPG server emulator written in C++ - otland/forgottenservergithub.com
todata/global.lua
now it gives me this error in the console when using the scroll expAdd this
forgottenserver/data/global.lua at f9d9944242bd5e455d97af2ef11d29da834ec8da · otland/forgottenserver
A free and open-source MMORPG server emulator written in C++ - otland/forgottenservergithub.com
todata/global.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 itthanks, 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
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()
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 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: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>
print("[Warning - advanceFamiliar onAdvance] Vocation ClientID not found (" .. player:getVocation():getId() .. ")")
Try:
But you can remove the print if you want.Lua:print("[Warning - advanceFamiliar onAdvance] Vocation ClientID not found (" .. player:getVocation():getId() .. ")")