• 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+ Exp Score

abdala ragab

Veteran OT User
Joined
Aug 18, 2018
Messages
446
Solutions
11
Reaction score
330
Location
gamelaot.sytes.net
Lua:
-- OTcentrum.pl - Polskie Centrum OpenTibii
local config = {
funnyEffect = "YES", -- effects firework's & Animated Text  (YES/NO)
minimumLevel = 20,
maximumLevel = 160, -- for infinite type math.huge
}
local addExp = {
[{config.minimumLevel, 40}] = 100,
[{40, 60}] = 7000000,
[{60, 80}] = 7000000,
[{80, 100}] = 7000000,
[{100, 120}] = 7000000,
[{120, 1400}] = 7000000,
[{140, config.maximumLevel}] = 5000
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
local level = getPlayerLevel(cid)
    local effect = math.random(CONST_ME_FIREWORK_YELLOW,CONST_ME_FIREWORK_BLUE)

    if level < config.minimumLevel then
        doPlayerSendCancel(cid, "You need to be at least "..config.minimumLevel.." to use a scroll.")
        return FALSE
    end
    
    if level >= config.maximumLevel then
        doPlayerSendCancel(cid, "Your level is too high for using a scroll.")
        return FALSE
    end

    for k, v in pairs(addExp) do
        if level >= k[1] and level < k[2] then
            doPlayerAddExp(cid, v)
            doRemoveItem(item.uid, 1)
            break
        end
    end 

        if config.funnyEffect == "YES" then
        local pos = getPlayerPosition(cid)
        local positions = {
                {x=pos.x+1,y=pos.y-1,z=pos.z},
                {x=pos.x-1,y=pos.y-1,z=pos.z},
                {x=pos.x+1,y=pos.y+1,z=pos.z},
                {x=pos.x-1,y=pos.y+1,z=pos.z},
                {x=pos.x+1,y=pos.y,z=pos.z},
                {x=pos.x-1,y=pos.y,z=pos.z},
                {x=pos.x,y=pos.y+1,z=pos.z},
                {x=pos.x,y=pos.y-1,z=pos.z}
        }

        for i = 1, table.getn(positions) do
            doSendAnimatedText(getThingPos(cid), "Yeah! Exp!", TEXTCOLOR_RED)
            doSendMagicEffect(positions[i],effect)
        end
    end
    return TRUE
end
Help me convert this text from xml to tfs 1.2
 
Solution
Lua:
local config = {
    itemId = 6543,
    minLevel = 1,
    maxLevel = 2000,
    effect = 1,
    rates = {
        {range = {0, 9}, experience = 2000000},
        {range = {10, 24}, experience = 3000000},
        {range = {25, 34}, experience = 4000000},
        {range = {35, 49}, experience = 5000000},
        {range = {50, 64}, experience = 6500000},
        {range = {65, 74}, experience = 8000000},
        {range = {75, 99}, experience = 9500000},
        {range = {100, 124}, experience = 11000000},
        {range = {125, 149}, experience = 12500000},
    }
}

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
  
    local level = player:getLevel()
    if level < config.minLevel then...
Lua:
local config = {
    itemId = 6543,
    minLevel = 1,
    maxLevel = 2000,
    effect = 1,
    rates = {
        {range = {0, 9}, experience = 2000000},
        {range = {10, 24}, experience = 3000000},
        {range = {25, 34}, experience = 4000000},
        {range = {35, 49}, experience = 5000000},
        {range = {50, 64}, experience = 6500000},
        {range = {65, 74}, experience = 8000000},
        {range = {75, 99}, experience = 9500000},
        {range = {100, 124}, experience = 11000000},
        {range = {125, 149}, experience = 12500000},
    }
}

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
  
    local level = player:getLevel()
    if level < config.minLevel then
        player:sendTextMessage(MESSAGE_INFO_DESCR, 'Sorry but you must be atleast '..config.minLevel..' to use this scroll.')
        return true
    end
  
    if level > config.maxLevel then
        player:sendTextMessage(MESSAGE_INFO_DESCR, 'Sorry but you are above the max level of '..config.maxLevel..' to use this scroll.')
        return true
    end
  
    for _, tableLevel in pairs(config.rates) do
        if level >= tableLevel.range[1] and level <= tableLevel.range[2] then
            player:addExperience(tableLevel.experience, true)
            break
        end
    end
    player:getPosition():sendMagicEffect(config.effect)
    player:say(player:getName()..' has used a experience scroll and reached level '..player:getLevel()..'.', TALKTYPE_MONSTER_SAY)
    item:remove(1)
    return true
end
 
Last edited by a moderator:
Solution
I fixed it
Code:
 player:addExperience(tableLevel.rate, true)
To
Code:
player:addExperience(tableLevel.experience, true)

Lua:
local config = {
    itemId = 6119,
    minLevel = 1,
    maxLevel = 600,
    effect = 1,
    rates = {
        {range = {1, 9}, experience = 2000000},
        {range = {10, 24}, experience = 3000000},
        {range = {25, 34}, experience = 4000000},
        {range = {35, 49}, experience = 5000000},
        {range = {50, 64}, experience = 6500000},
        {range = {65, 74}, experience = 8000000},
        {range = {75, 99}, experience = 9500000},
        {range = {100, 124}, experience = 11000000},
        {range = {125, 149}, experience = 12500000},
    }
}

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
  
    local level = player:getLevel()
    if level < config.minLevel then
        player:sendTextMessage(MESSAGE_INFO_DESCR, 'Sorry but you must be atleast '..config.minLevel..' to use this scroll.')
        return true
    end
  
    if level > config.maxLevel then
        player:sendTextMessage(MESSAGE_INFO_DESCR, 'Sorry but you are above the max level of '..config.maxLevel..' to use this scroll.')
        return true
    end
  
    for _, tableLevel in pairs(config.rates) do
        if level >= tableLevel.range[1] and level <= tableLevel.range[2] then
            player:addExperience(tableLevel.experience, true)
            break
        end
    end
    player:getPosition():sendMagicEffect(config.effect)
    player:say(player:getName()..' has used a experience scroll and reached level '..player:getLevel()..'.', TALKTYPE_MONSTER_SAY)
    item:remove(1)
    return true
end
 
Why didnt you marked levi's answer as solution? It was a typo bug which you never mentioned
looks to me like the same script with just a different word, and the item id, the guy gave the solution and didn't get the credits, but someone who mysteriously came up with the same script
 
I've went ahead and changed the solution to the initial answer in this thread.

While in most cases it's best to leave it up to the op's decision, I think an intervention was required here.
 
Back
Top