• 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 Upgrade script to 1.X please

Athenuz

Owlz!
Joined
Oct 1, 2015
Messages
234
Reaction score
27
Location
México
Hello,

Can someone help me please to upgrade this script to 1.x tfs?

Code:
local config = {
funnyEffect = TRUE, -- effects fireworks & Animated Text (TRUE/FALSE)
minimumLevel = 20,
maximumLevel = 160, -- for infinite type math.huge
timesPerCharacter = 2, -- how many times one character can use this stupid useless exp scroll
storageUsed = 45800 -- storage used for timesPerCharacter
}
local addExp = {
[{config.minimumLevel, 40}] = 100,
[{40, 60}] = 500,
[{60, 80}] = 1000,
[{80, 100}] = 2000,
[{100, 120}] = 3000,
[{120, 140}] = 4000,
[{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(getPlayerStorageValue(cid, config.storageUsed) < config.timesPerCharacter) then
setPlayerStorageValue(cid, config.storageUsed, getPlayerStorageValue(cid, config.storageUsed)+1)
else
doPlayerSendCancel(cid, "You can use this scroll only twice per character.")
return FALSE
end

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 == TRUE) 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
 
@Athenuz, follow:

Code:
local config = {
    funnyEffect = true, -- effects fireworks & Animated Text (TRUE/FALSE)
    minimumLevel = 20,
    maximumLevel = 160, -- for infinite type math.huge
    timesPerCharacter = 2, -- how many times one character can use this stupid useless exp scroll
    storageUsed = 45800 -- storage used for timesPerCharacter
}

local addExp = {
    [{config.minimumLevel, 40}] = 100,
    [{40, 60}] = 500,
    [{60, 80}] = 1000,
    [{80, 100}] = 2000,
    [{100, 120}] = 3000,
    [{120, 140}] = 4000,
    [{140, config.maximumLevel}] = 5000
}

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local level = player:getLevel()
    local effect = math.random(CONST_ME_FIREWORK_YELLOW, CONST_ME_FIREWORK_BLUE)

    if player:getStorageValue(config.storageUsed) < config.timesPerCharacter then
        player:setStorageValue(config.storageUsed, player:getStorageValue(config.storageUsed) + 1)
    else
        player:sendTextMessage(MESSAGE_STATUS_SMALL, "You can use this scroll only twice per character.")
        return false
    end

    if level < config.minimumLevel then
        player:sendTextMessage(MESSAGE_STATUS_SMALL, "You need to be at least " .. config.minimumLevel .. " to use a scroll.")
        return false
    end

    if level >= config.maximumLevel then
        player:sendTextMessage(MESSAGE_STATUS_SMALL, "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
            player:addExperience(v, true)
            item:remove(1)
            break
        end
    end

    if config.funnyEffect then
        local pos = player:getPosition()
        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, #positions do
            local effectPos = Position(positions[i])
            effectPos:sendMagicEffect(effect)
        end
        player:say("Yeah! Exp!", TALKTYPE_MONSTER_SAY)
    end
    return true
end
 
Last edited:
@Athenuz, follow:

Code:
local config = {
    funnyEffect = true, -- effects fireworks & Animated Text (true/false)
    minimumLevel = 20,
    maximumLevel = 160, -- for infinite type math.huge
    timesPerCharacter = 2, -- how many times one character can use this stupid useless exp scroll
    storageUsed = 45800 -- storage used for timesPerCharacter
}

local addExp = {
    [{config.minimumLevel, 40}] = 100,
    [{40, 60}] = 500,
    [{60, 80}] = 1000,
    [{80, 100}] = 2000,
    [{100, 120}] = 3000,
    [{120, 140}] = 4000,
    [{140, config.maximumLevel}] = 5000
}

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local level = player:getLevel()
    local effect = math.random(CONST_ME_FIREWORK_YELLOW, CONST_ME_FIREWORK_BLUE)

    if player:getStorageValue(config.storageUsed) < config.timesPerCharacter then
        player:setStorageValue(config.storageUsed, player:getStorageValue(config.storageUsed) + 1)
    else
        player:sendTextMessage(MESSAGE_STATUS_SMALL, "You can use this scroll only twice per character.")
        return false
    end

    if level < config.minimumLevel then
        player:sendTextMessage(MESSAGE_STATUS_SMALL, "You need to be at least " .. config.minimumLevel .. " to use a scroll.")
        return false
    end

    if level >= config.maximumLevel then
        player:sendTextMessage(MESSAGE_STATUS_SMALL, "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
            player:addExperience(v, true)
            item:remove(1)
            break
        end
    end

    if config.funnyEffect then
        local pos = player:getPosition()
        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
            local effectPos = Position(positions[i])
            player:say("Yeah! Exp!", TALKTYPE_MONSTER_SAY)
            effectPos:sendMagicEffect(effect)
        end
    end
    return true
end

Thanks! Testing right now~
 
Back
Top