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

Convert Script TFS 1.2 to 0.4

Dohko

Active Member
Joined
Mar 7, 2017
Messages
100
Reaction score
29
Hello OtLand, I have 2 script's for a function for a Tibia Otserv.
The only problem is that it was written to be used in TFS 0.4 and I have TFS 1.2.
Can you guys help me out converting this script? If its not possible, thats fine, just let me know!!
Thanks in advance yall.

Script 1

Lua:
local function filtrateString(str)
    if type(str) ~= "string" then
        return false
    end
    local first, last = 0, 0
    local second, final = 0, #str
    for i = 1, #str do
        if string.byte(str:sub(i,i)) == string.byte('a') then
            first = i + 2
            for t = first, #str do
                if string.byte(str:sub(t,t)) == string.byte(' ') then
                    last = t - 1
                    break
                end
            end
        end
        if string.byte(str:sub(i,i)) == string.byte('b') then
            second = i + 2
        end
    end
    return {str:sub(first, last), str:sub(second, final)}
end


function onUse(cid, item, fromPosition, itemEx, toPosition)
    if getPlayerLevel(cid) > 700 then
    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Voce e maior que level 700, porem nao pode usar a cave exclusiva.")
    return false
    end
        if tonumber(filtrateString(getGlobalStorageValue(822081))[2]) < os.time() then
        doRemoveItem(item.uid)
        setGlobalStorageValue(822081, "a "..getPlayerAccountId(cid).." b ".. os.time() + (3600 * 4))
        doPlayerSendTextMessage(cid, 25, "Agora você é o dono da cave 1 e pode upar lá por 4 horas.")
    elseif tonumber(filtrateString(getGlobalStorageValue(822082))[2]) < os.time() then
        doRemoveItem(item.uid)
        setGlobalStorageValue(822082, "a "..getPlayerAccountId(cid).." b ".. os.time() + (3600 * 4))
        doPlayerSendTextMessage(cid, 25, "Agora você é o dono da cave 2 e pode upar lá por 4 horas.")
    elseif tonumber(filtrateString(getGlobalStorageValue(822083))[2]) < os.time() then
        doRemoveItem(item.uid)
        setGlobalStorageValue(822083, "a "..getPlayerAccountId(cid).." b ".. os.time() + (3600 * 4))
        doPlayerSendTextMessage(cid, 25, "Agora você é o dono da cave 3 e pode upar lá por 4 horas.")
    elseif tonumber(filtrateString(getGlobalStorageValue(822084))[2]) < os.time() then
        doRemoveItem(item.uid)
        setGlobalStorageValue(822084, "a "..getPlayerAccountId(cid).." b ".. os.time() + (3600 * 4))
        doPlayerSendTextMessage(cid, 25, "Agora você é o dono da cave 4 e pode upar lá por 4 horas.")
    elseif tonumber(filtrateString(getGlobalStorageValue(822085))[2]) < os.time() then
        doRemoveItem(item.uid)
        setGlobalStorageValue(822085, "a "..getPlayerAccountId(cid).." b ".. os.time() + (3600 * 4))
        doPlayerSendTextMessage(cid, 25, "Agora você é o dono da cave 5 e pode upar lá por 4 horas.")
    elseif tonumber(filtrateString(getGlobalStorageValue(822086))[2]) < os.time() then
        doRemoveItem(item.uid)
        setGlobalStorageValue(822086, "a "..getPlayerAccountId(cid).." b ".. os.time() + (3600 * 4))
        doPlayerSendTextMessage(cid, 25, "Agora você é o dono da cave 6 e pode upar lá por 4 horas.")
    elseif tonumber(filtrateString(getGlobalStorageValue(822087))[2]) < os.time() then
        doRemoveItem(item.uid)
        setGlobalStorageValue(822087, "a "..getPlayerAccountId(cid).." b ".. os.time() + (3600 * 4))
        doPlayerSendTextMessage(cid, 25, "Agora você é o dono da cave 7 e pode upar lá por 4 horas.")
    elseif tonumber(filtrateString(getGlobalStorageValue(822088))[2]) < os.time() then
        doRemoveItem(item.uid)
        setGlobalStorageValue(822088, "a "..getPlayerAccountId(cid).." b ".. os.time() + (3600 * 4))
        doPlayerSendTextMessage(cid, 25, "Agora você é o dono da cave 8 e pode upar lá por 4 horas.")
    elseif tonumber(filtrateString(getGlobalStorageValue(822089))[2]) < os.time() then
        doRemoveItem(item.uid)
        setGlobalStorageValue(822089, "a "..getPlayerAccountId(cid).." b ".. os.time() + (3600 * 4))
        doPlayerSendTextMessage(cid, 25, "Agora você é o dono da cave 9 e pode upar lá por 4 horas.")
    elseif tonumber(filtrateString(getGlobalStorageValue(822090))[2]) < os.time() then
        doRemoveItem(item.uid)
        setGlobalStorageValue(822090, "a "..getPlayerAccountId(cid).." b ".. os.time() + (3600 * 4))
        doPlayerSendTextMessage(cid, 25, "Agora você é o dono da cave 10 e pode upar lá por 4 horas.")
    elseif tonumber(filtrateString(getGlobalStorageValue(822091))[2]) < os.time() then
        doRemoveItem(item.uid)
        setGlobalStorageValue(822091, "a "..getPlayerAccountId(cid).." b ".. os.time() + (3600 * 4))
        doPlayerSendTextMessage(cid, 25, "Agora você é o dono da cave 11 e pode upar lá por 4 horas.")
    elseif tonumber(filtrateString(getGlobalStorageValue(822092))[2]) < os.time() then
        doRemoveItem(item.uid)
        setGlobalStorageValue(822092, "a "..getPlayerAccountId(cid).." b ".. os.time() + (3600 * 4))
        doPlayerSendTextMessage(cid, 25, "Agora você é o dono da cave 12 e pode upar lá por 4 horas.")
    elseif tonumber(filtrateString(getGlobalStorageValue(822093))[2]) < os.time() then
        doRemoveItem(item.uid)
        setGlobalStorageValue(822093, "a "..getPlayerAccountId(cid).." b ".. os.time() + (3600 * 4))
        doPlayerSendTextMessage(cid, 25, "Agora você é o dono da cave 13 e pode upar lá por 4 horas.")
    elseif tonumber(filtrateString(getGlobalStorageValue(822094))[2]) < os.time() then
        doRemoveItem(item.uid)
        setGlobalStorageValue(822094, "a "..getPlayerAccountId(cid).." b ".. os.time() + (3600 * 4))
        doPlayerSendTextMessage(cid, 25, "Agora você é o dono da cave 14 e pode upar lá por 4 horas.")
    elseif tonumber(filtrateString(getGlobalStorageValue(822095))[2]) < os.time() then
        doRemoveItem(item.uid)
        setGlobalStorageValue(822095, "a "..getPlayerAccountId(cid).." b ".. os.time() + (3600 * 4))
        doPlayerSendTextMessage(cid, 25, "Agora você é o dono da cave 15 e pode upar lá por 4 horas.")
    elseif tonumber(filtrateString(getGlobalStorageValue(822096))[2]) < os.time() then
        doRemoveItem(item.uid)
        setGlobalStorageValue(822096, "a "..getPlayerAccountId(cid).." b ".. os.time() + (3600 * 4))
        doPlayerSendTextMessage(cid, 25, "Agora você é o dono da cave 16 e pode upar lá por 4 horas.")
    elseif tonumber(filtrateString(getGlobalStorageValue(822097))[2]) < os.time() then
        doRemoveItem(item.uid)
        setGlobalStorageValue(822097, "a "..getPlayerAccountId(cid).." b ".. os.time() + (3600 * 4))
        doPlayerSendTextMessage(cid, 25, "Agora você é o dono da cave 17 e pode upar lá por 4 horas.")
    elseif tonumber(filtrateString(getGlobalStorageValue(822098))[2]) < os.time() then
        doRemoveItem(item.uid)
        setGlobalStorageValue(822098, "a "..getPlayerAccountId(cid).." b ".. os.time() + (3600 * 4))
        doPlayerSendTextMessage(cid, 25, "Agora você é o dono da cave 18 e pode upar lá por 4 horas.")
  
    else
        doPlayerSendCancel(cid, "Todas as caves já estão com dono no momento. Tente mais tarde.")
    end
    return true
end

Script 2
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    local game
    if item.actionid == 4619 then
        game = MiniGame:new({cid = cid, playerPos = {x = 391, y = 165, z = 7}, birdPos = {x = 386, y = 165, z = 7}, fromPos = {x = 385, y = 160, z = 7}, toPos = {x = 391, y = 169, z = 7}})
        game:Start(1)
    elseif item.actionid == 4620 then
        game = MiniGame:new({cid = cid, playerPos = {x = 391, y = 175, z = 7}, birdPos = {x = 386, y = 175, z = 7}, fromPos = {x = 385, y = 170, z = 7}, toPos = {x = 391, y = 179, z = 7}})
        game:Start(2)
    elseif item.actionid == 4621 then
        game = MiniGame:new({cid = cid, playerPos = {x = 391, y = 185, z = 7}, birdPos = {x = 386, y = 185, z = 7}, fromPos = {x = 385, y = 180, z = 7}, toPos = {x = 391, y = 189, z = 7}})
        game:Start(3)
    elseif item.actionid == 4622 then
        game = MiniGame:new({cid = cid, playerPos = {x = 403, y = 165, z = 7}, birdPos = {x = 398, y = 165, z = 7}, fromPos = {x = 397, y = 160, z = 7}, toPos = {x = 403, y = 169, z = 7}})
        game:Start(4)
    elseif item.actionid == 4623 then
        game = MiniGame:new({cid = cid, playerPos = {x = 403, y = 175, z = 7}, birdPos = {x = 398, y = 175, z = 7}, fromPos = {x = 397, y = 170, z = 7}, toPos = {x = 403, y = 179, z = 7}})
        game:Start(5)
    elseif item.actionid == 4624 then
        game = MiniGame:new({cid = cid, playerPos = {x = 403, y = 185, z = 7}, birdPos = {x = 398, y = 185, z = 7}, fromPos = {x = 397, y = 180, z = 7}, toPos = {x = 403, y = 189, z = 7}})
        game:Start(6)
    end
    return true
end
 
Back
Top