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

Solved Problem with party shared exp it cause lag or even "freeze"

ItsMeMagic

Old Tibia Player.
Joined
Sep 11, 2008
Messages
318
Reaction score
25
Location
exiva "Magic~
Code:
Lua Script Error: [Event Interface]
data/events/scripts/party.lua:Party@onShareExperience
data/events/scripts/party.lua:35: attempt to perform arithmetic on a table value
stack traceback:
[C]: in function '__add'
data/events/scripts/party.lua:35: in function

this is my party.lua

Code:
Lua Script Error: [Event Interface]
data/events/scripts/party.lua:Party@onShareExperience
data/events/scripts/party.lua:35: attempt to perform arithmetic on a table value
stack traceback:
[C]: in function '__add'
data/events/scripts/party.lua:35: in function

Not sure what's happen...
maybe an error in the script...
someone can help me thanks !

Any1 know what happen?
 
Last edited by a moderator:
Code:
function Party:onJoin(player)
    return true
end

function Party:onLeave(player)
    return true
end

function Party:onDisband()
    return true
end

function Party:onShareExperience(exp)
    local sharedExperienceMultiplier = 1.20 --20%
   
    local vocationsIds = {}
   
    local vocationId = self:getLeader():getVocation():getId()
    if vocationId ~= VOCATION_NONE then
        table.insert(vocationsIds, self:getLeader():getVocation():getId())
    end
   
    for _, member in ipairs(self:getMembers()) do
        vocationId = member:getVocation():getId()
        if not isInArray(vocationsIds, vocationId) and vocationId ~= VOCATION_NONE then
            table.insert(vocationsIds, vocationId)
        end
    end
   
    local size = #vocationsIds
    if size > 1 then
        sharedExperienceMultiplier = 1.0 + ((size * (10 + (size - 1) * 5)) / 100)
    end
   
    exp = (exp * sharedExperienceMultiplier) / (self:getMembers() + 1)
    return exp
end

Sorry for the mistake.. hope you can help me
Thanks btw!
 
At line 35 there is self:getMembers(), this is a table with the partymembers. So atm it tries to do table + 1, which is why you get that error. To get the amount of values in a table (so amount of partymembers) use # infront of it.
Code:
#self:getMembers()
 
At line 35 there is self:getMembers(), this is a table with the partymembers. So atm it tries to do table + 1, which is why you get that error. To get the amount of values in a table (so amount of partymembers) use # infront of it.
Code:
#self:getMembers()
Limos I am unsure of how to get ahold of you but my cousin and I are trying to open up a server and having some issues that we don't quite understand. We have made servers in the past and have knowledge on the usual scenarios but are currently stumped. If you could please message me we would greatly appreciate some help.
 
Back
Top