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

Lua Consult experience left to level up using a Talkaction

demon088

#088 in the Horde
Joined
Jun 17, 2009
Messages
249
Solutions
3
Reaction score
30
Location
Hell
Hello OtLand!
I have a simple request this time... Is there any script to consult experience using a talkaction? Like... Saying !tolvl and then a message appears showing 'You need X experience points to level PlayerLv+1.'

I have been searching through the forum, but couldn't find something like that and I know this already exists, because I have seen such talkaction in some servs. I couldn't figure out how to make such script myself, so I hope someone could help me with this.
Thanks for all your help and time!
 
TFS version?
I was looking into this for tfs 1.3

I don't think we have the Lua functions available to actually figure it out?

0.4 there is functions to find out the experience or skillTries available for a specific level.. then you just take away the current skillTries / experience, and you'd have the answer.

So it'd be like..
Lua:
experienceToNextLevel = getExperienceForLevel(currentLevel + 1) - currentExperience

--
Unless I'm blind.. I don't see any way to do it for 1.3
 
I was looking into this for tfs 1.3

I don't think we have the Lua functions available to actually figure it out?

0.4 there is functions to find out the experience or skillTries available for a specific level.. then you just take away the current skillTries / experience, and you'd have the answer.

So it'd be like..
Lua:
experienceToNextLevel = getExperienceForLevel(currentLevel + 1) - currentExperience

--
Unless I'm blind.. I don't see any way to do it for 1.3
It is the same in TFS 1.3.
For 1.3 it would be something like this.
Lua:
local talk = TalkAction("!tolvl")

function talk.onSay(player, words, param)
    local nextLevel = player:getLevel() + 1
    local experience = getExperienceForLevel(nextLevel) - player:getExperience()
    player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, ("You need %s exp to level %s."):format(experience, nextLevel))
    return false
end

talk:register()
 
It is the same in TFS 1.3.
For 1.3 it would be something like this.
Lua:
local talk = TalkAction("!tolvl")

function talk.onSay(player, words, param)
    local nextLevel = player:getLevel() + 1
    local experience = getExperienceForLevel(nextLevel) - player:getExperience()
    player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, ("You need %s exp to level %s."):format(experience, nextLevel))
    return false
end

talk:register()
Can we talk about the math in that function? lmfao

Lua:
(50 * level * level * level - 150 * level * level + 400 * level) / 3
 
Last edited:
Can we talk about the math in that function? lmfao

Lua:
(50 * level * level * level - 150 * level * level + 400 * level) / 3
 
Back
Top