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

Problem with events/player.lua EXP Bonus

Grillo1995

New Member
Joined
Feb 8, 2018
Messages
21
Solutions
1
Reaction score
1
Location
Brazil
Hello everyone. :p

I have a small problem with my EXP BONUS script.

When the player has a guild, the system works 100% without errors and problems.

However, when he has no guild, the error in the log and the exp stages does not work.

events/player.lua

Code:
local guild = self:getGuild()
    if guild ~= nil then -- If player is in a guild
        if guild:getId() == guildOwner() then -- set exp bonus
            exp = exp * 1.05
        end
    else -- If player dont have guild set exp normal
        return exp
    end

Error log:

Code:
Lua Script Error: [Event Interface]
data/events/scripts/player.lua:Player@onGainExperience
data/events/scripts/player.lua:263: attempt to index global 'player' (a nil value)
stack traceback:
        [C]: in function '__index'
        data/events/scripts/player.lua:263: in function <data/events/scripts/player.lua:261>

I see that a null value is returning, I do not understand why it is not working since my IF treats this null value .. Thanks and I look forward to it!

Remembering that when the player has a guild, the script works as it should.
 
Hello everyone. :p

I have a small problem with my EXP BONUS script.

When the player has a guild, the system works 100% without errors and problems.

However, when he has no guild, the error in the log and the exp stages does not work.

events/player.lua

Code:
local guild = self:getGuild()
    if guild ~= nil then -- If player is in a guild
        if guild:getId() == guildOwner() then -- set exp bonus
            exp = exp * 1.05
        end
    else -- If player dont have guild set exp normal
        return exp
    end

Error log:
Code:
Lua Script Error: [Event Interface]
data/events/scripts/player.lua:Player@onGainExperience
data/events/scripts/player.lua:263: attempt to index global 'player' (a nil value)
stack traceback:
        [C]: in function '__index'
        data/events/scripts/player.lua:263: in function <data/events/scripts/player.lua:261>

I see that a null value is returning, I do not understand why it is not working since my IF treats this null value .. Thanks and I look forward to it!

Remembering that when the player has a guild, the script works as it should.
Hi,
You show a code with 8 lines. Your error log is telling that the error is in line 263, i know we have excellent programers here, but i think even they can't help...
What is guildOnwer()?
Too much mysterys to discover here... 🤔
 
Looks like you are probably referencing 'player' instead of 'self' somewhere, but it is hard to say for sure without seeing the whole script and knowing what line 263 looks like.
 
It has already been solved, this was not the problem, nor do I know what change I made ... but it worked!
Post automatically merged:

Hi,
You show a code with 8 lines. Your error log is telling that the error is in line 263, i know we have excellent programers here, but i think even they can't help...
What is guildOnwer()?
Too much mysterys to discover here... 🤔

It is a function that verifies who is dominating the castle, made by me.

But the problem has already been solved.
 
Back
Top