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

TFS 1.X+ Reset level when login/logout + teleport to temple

ivvanek

New Member
Joined
Mar 24, 2009
Messages
113
Reaction score
3
Hi, someone has the scripts for TFS 1.4 When you login you has 150 lvl + teleport to position?
Searched forum but i have found some for TFS 0.4 and it not working for me.

Best Regards
 
Solution
Here is a script for the level; resetlevel.lua: (I'm afraid I can't help you with the teleport)
Code:
local function getExp(level) return ((50 * level * level * level) - (150 * level * level) + (400 * level)) / 3 end

function getExpForLevel(level, offsetLevel)
    level       = level - 1
    offsetLevel = offsetLevel and offsetLevel - 1 or nil
    local total = getExp(level)
    local offset = offsetLevel and offsetLevel < level and getExp(offsetLevel) or 0
    return total - offset
end
function Player:addLevel(amount, round, ...)
  local exp    = 0
  local level  = self:getLevel()
  exp = math.abs(getExpForLevel(level + amount) - (round and self:getExperience() or getExpForLevel(level)))
  return amount >= 0 and...
Here is a script for the level; resetlevel.lua: (I'm afraid I can't help you with the teleport)
Code:
local function getExp(level) return ((50 * level * level * level) - (150 * level * level) + (400 * level)) / 3 end

function getExpForLevel(level, offsetLevel)
    level       = level - 1
    offsetLevel = offsetLevel and offsetLevel - 1 or nil
    local total = getExp(level)
    local offset = offsetLevel and offsetLevel < level and getExp(offsetLevel) or 0
    return total - offset
end
function Player:addLevel(amount, round, ...)
  local exp    = 0
  local level  = self:getLevel()
  exp = math.abs(getExpForLevel(level + amount) - (round and self:getExperience() or getExpForLevel(level)))
  return amount >= 0 and self:addExperience(exp, ...) or self:removeExperience(exp, ...)
end
function Player:setLevel(level, round, ...)
  return self:addLevel(level - self:getLevel(), round == nil or round, ...)
end
function onLogin(player)
  -- How to use on login
  if player:getLevel() < 150 then
    local level = 150
    local round = true
    local sendText = false
    player:setLevel(level, round, sendText)
  end
  return true
end
Code:
<event type="login" name="ResetLevel" script="resetlevel.lua" />

If you want everything to stay as is onDeath, then put "save = 0" in the database.
Otherwise keep up the search and I'm sure you'll find a teleport script you can merge into that one. Just be sure to merge it under "function onLogin(player)" when you do.
 
Solution
Thank you Lovely, script on Login works perfect, i just need the same on Logout, trying modify it yourself by change
Code:
function onLogout(player)
  -- How to use on login
  if player:getLevel() > 150 then
    local level = 150
    local round = true
    local sendText = false
    player:setLevel(level, round, sendText)
  end
  return true
end
but didnt work
 
Thank you Lovely, script on Login works perfect, i just need the same on Logout, trying modify it yourself by change
Code:
function onLogout(player)
  -- How to use on login
  if player:getLevel() > 150 then
    local level = 150
    local round = true
    local sendText = false
    player:setLevel(level, round, sendText)
  end
  return true
end
but didnt work
Why do you need to put that onLogout? o_O
That function can never work in such a way, because it is trying to use code that can only be executed while a player is online. (at least to my knowledge)
If you want it to execute when a player is offline I guess you can use Database Queries?
I'm not at the least familiar with database functions so someone else has to help you with that.

Anyway, glad it worked for you partly, good luck with your project!
Ask me if you have any other questions, I might be able to help you with those.
 
Last edited:
Back
Top