Ir para conteúdo
  • Cadastre-se

(Resolvido)Script Teleport Por Tempo


Ir para solução Resolvido por Vodkart,

Posts Recomendados

Versão do Servidor: TFS - 0.4
Tipo de Script: Talkaction

Código:

Spoiler

local quests = {
    ["vipquest"] = {
        min_level = 500,
        enter_pos = {x = 1285, y = 191, z = 7}, 
        area = {fromPos = {x = 1263, y = 245, z = 7}, toPos = {x = 1525, y = 143, z = 7}}, 
        time_to_finish = {15, "min"}, 
        time_to_make_again = {15, "min"}
    -- },
    -- ["dragon"] = {
        -- min_level = 10,
        -- enter_pos = {x = 1, y = 1, z = 1}, 
        -- area = {fromPos = {x = 1, y = 1, z = 1}, toPos = {x = 1, y = 1, z = 1}}, 
        -- time_to_finish = {10, "min"}, 
        -- time_to_make_again = {1, "hour"}
    }
}

local time_storage = 87871 -- só modifique se necessário

function onSay(cid, words, param, channel)
    local param, p, check = param:lower(), getPlayerPosition(cid), false
    if not param or param == "" then
        local str, n = '~~ [Available Quests] ~~\n\n', 1
        for quest, info in pairs(quests) do
            str = str .. n .. " - " .. Fupper(quest) .. " (Level: "..info.min_level..")\n"
            n = n + 1
        end
        doShowTextDialog(cid, 1955, str)
        return true
    end
    local t = quests[param]
    if not t then
        return doPlayerSendCancel(cid, "Quest not found.")
    end
    if getPlayerLevel(cid) < t.min_level then
        return doPlayerSendCancel(cid, "Only players level "..t.min_level.." or higher can go the "..param.." quest.")
    end
    if isInRange(p, t.area.fromPos, t.area.toPos) then
        return doPlayerSendCancel(cid, "You are already inside the "..param.." quest area.")
    end
    for quest, info in pairs(quests) do
        if isInRange(p, info.area.fromPos, info.area.toPos) then
            check = true
        end
    end
    if check then
        return doPlayerSendCancel(cid, "You cannot go to another quest inside a quest.")
    end
    local stor = getPlayerStorageValue(cid, time_storage)
    if stor > os.time() then
        return doPlayerSendCancel(cid, "Voce so podera entrar novamente na quest "..os.date("%d %B %Y %X", stor)..".")
    end
    doSendMagicEffect(p, CONST_ME_POFF)
    local destination = t.enter_pos
    doTeleportThing(cid, destination)
    doSendMagicEffect(destination, CONST_ME_TELEPORT)
    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Good luck in "..param.." quest! You have "..getStrTime(t.time_to_finish).." to finish or you will be kicked.")
    setPlayerStorageValue(cid, time_storage, mathtime(t.time_to_make_again) + os.time())
    addEvent(function()
        if isPlayer(cid) then
            if isInRange(getPlayerPosition(cid), t.area.fromPos, t.area.toPos) then
                doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
                local temple = getTownTemplePosition(getPlayerTown(cid))
                doTeleportThing(cid, temple)
                doSendMagicEffect(temple, CONST_ME_TELEPORT)
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "Your time is over!")
            end
        end
    end, mathtime(t.time_to_finish) * 1000)
    return true
end

function mathtime(table) -- by dwarfer
local unit = {"sec", "min", "hour", "day"}
for i, v in pairs(unit) do
if v == table[2] then
return table[1]*(60^(v == unit[4] and 2 or i-1))*(v == unit[4] and 24 or 1)
end
end
return error("Bad declaration in mathtime function.")
end

function getStrTime(table) -- by dwarfer
local unit = {["sec"] = "second",["min"] = "minute",["hour"] = "hour",["day"] = "day"}
return tostring(table[1].." "..unit[table[2]]..(table[1] > 1 and "s" or ""))
end 

function Fupper(str)
    return (str:gsub("^%l", string.upper))
end  

 



Tenho este script de teleport por tempo, porem queria que só pudesse usar ele numa determinada pos (configuravel).
ex position errada: voce precisa estar dentro da quest para usar este comando.

Link para o post
Compartilhar em outros sites
1 hora atrás, underpunk disse:

ja tentou usar um if getPlayerPosition = X?

 

Bem tentei desta maneira e o script parou de funcionar olha abaixo

 

Spoiler

local quests = {
    ["vipquest"] = {
        min_level = 500,
        enter_pos = {x = 1283, y = 191, z = 7}, 
        area = {fromPos = {x = 1263, y = 245, z = 7}, toPos = {x = 1525, y = 143, z = 7}}, 
        time_to_finish = {15, "min"}, 
        time_to_make_again = {15, "min"}
    -- },
    -- ["dragon"] = {
        -- min_level = 10,
        -- enter_pos = {x = 1, y = 1, z = 1}, 
        -- area = {fromPos = {x = 1, y = 1, z = 1}, toPos = {x = 1, y = 1, z = 1}}, 
        -- time_to_finish = {10, "min"}, 
        -- time_to_make_again = {1, "hour"}
    }
	position = {x = 655, y = 423, z = 7} -- Posição que o Player precisa para usar o comando
}

local time_storage = 87871 -- só modifique se necessário

function onSay(cid, words, param, channel)
    local param, p, check = param:lower(), getPlayerPosition(cid), false
    if not param or param == "" then
        local str, n = '~~ [Available Quests] ~~\n\n', 1
        for quest, info in pairs(quests) do
            str = str .. n .. " - " .. Fupper(quest) .. " (Level: "..info.min_level..")\n"
            n = n + 1
        end
        doShowTextDialog(cid, 1955, str)
        return true
    end
    local t = quests[param]
    if not t then
        return doPlayerSendCancel(cid, "Quest not found.")
    end
    if getPlayerLevel(cid) < t.min_level then
        return doPlayerSendCancel(cid, "Only players level "..t.min_level.." or higher can go the "..param.." quest.")
    end
    if isInRange(p, t.area.fromPos, t.area.toPos) then
        return doPlayerSendCancel(cid, "You are already inside the "..param.." quest area.")
    end
    for quest, info in pairs(quests) do
        if isInRange(p, info.area.fromPos, info.area.toPos) then
            check = true
        end
    end
    if check then
        return doPlayerSendCancel(cid, "You cannot go to another quest inside a quest.")
    end
    local stor = getPlayerStorageValue(cid, time_storage)
    if stor > os.time() then
        return doPlayerSendCancel(cid, "Voce so podera entrar novamente na quest "..os.date("%d %B %Y %X", stor)..".")
    end
    if getPlayerPosition(cid).x == quests.position.x and getPlayerPosition(cid).y == quests.position.y and getPlayerPosition(cid).z == quests.position.z then

    doSendMagicEffect(p, CONST_ME_POFF)
    local destination = t.enter_pos
    doTeleportThing(cid, destination)
    doSendMagicEffect(destination, CONST_ME_TELEPORT)
    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Good luck in "..param.." quest! You have "..getStrTime(t.time_to_finish).." to finish or you will be kicked.")
    setPlayerStorageValue(cid, time_storage, mathtime(t.time_to_make_again) + os.time())
    addEvent(function()
        if isPlayer(cid) then
            if isInRange(getPlayerPosition(cid), t.area.fromPos, t.area.toPos) then
                doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
                local temple = getTownTemplePosition(getPlayerTown(cid))
                doTeleportThing(cid, temple)
                doSendMagicEffect(temple, CONST_ME_TELEPORT)
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "Your time is over!")
            end
        end
    end, mathtime(t.time_to_finish) * 1000)
    else
    doPlayerSendTextMessage(cid, 25, "wrong position")
    end
    return true
end

function mathtime(table) -- by dwarfer
local unit = {"sec", "min", "hour", "day"}
for i, v in pairs(unit) do
if v == table[2] then
return table[1]*(60^(v == unit[4] and 2 or i-1))*(v == unit[4] and 24 or 1)
end
end
return error("Bad declaration in mathtime function.")
end

function getStrTime(table) -- by dwarfer
local unit = {["sec"] = "second",["min"] = "minute",["hour"] = "hour",["day"] = "day"}
return tostring(table[1].." "..unit[table[2]]..(table[1] > 1 and "s" or ""))
end 

function Fupper(str)
    return (str:gsub("^%l", string.upper))
end  

 

 

Editado por Thony D. Serv (veja o histórico de edições)
Link para o post
Compartilhar em outros sites
20 minutos atrás, Thony D. Serv disse:

 

Bem tentei desta maneira e o script parou de funcionar olha abaixo

 

  Mostrar conteúdo oculto


local quests = {
    ["vipquest"] = {
        min_level = 500,
        enter_pos = {x = 1283, y = 191, z = 7}, 
        area = {fromPos = {x = 1263, y = 245, z = 7}, toPos = {x = 1525, y = 143, z = 7}}, 
        time_to_finish = {15, "min"}, 
        time_to_make_again = {15, "min"}
    -- },
    -- ["dragon"] = {
        -- min_level = 10,
        -- enter_pos = {x = 1, y = 1, z = 1}, 
        -- area = {fromPos = {x = 1, y = 1, z = 1}, toPos = {x = 1, y = 1, z = 1}}, 
        -- time_to_finish = {10, "min"}, 
        -- time_to_make_again = {1, "hour"}
    }
	position = {x = 655, y = 423, z = 7} -- Posição que o Player precisa para usar o comando
}

local time_storage = 87871 -- só modifique se necessário

function onSay(cid, words, param, channel)
    local param, p, check = param:lower(), getPlayerPosition(cid), false
    if not param or param == "" then
        local str, n = '~~ [Available Quests] ~~\n\n', 1
        for quest, info in pairs(quests) do
            str = str .. n .. " - " .. Fupper(quest) .. " (Level: "..info.min_level..")\n"
            n = n + 1
        end
        doShowTextDialog(cid, 1955, str)
        return true
    end
    local t = quests[param]
    if not t then
        return doPlayerSendCancel(cid, "Quest not found.")
    end
    if getPlayerLevel(cid) < t.min_level then
        return doPlayerSendCancel(cid, "Only players level "..t.min_level.." or higher can go the "..param.." quest.")
    end
    if isInRange(p, t.area.fromPos, t.area.toPos) then
        return doPlayerSendCancel(cid, "You are already inside the "..param.." quest area.")
    end
    for quest, info in pairs(quests) do
        if isInRange(p, info.area.fromPos, info.area.toPos) then
            check = true
        end
    end
    if check then
        return doPlayerSendCancel(cid, "You cannot go to another quest inside a quest.")
    end
    local stor = getPlayerStorageValue(cid, time_storage)
    if stor > os.time() then
        return doPlayerSendCancel(cid, "Voce so podera entrar novamente na quest "..os.date("%d %B %Y %X", stor)..".")
    end
    if getPlayerPosition(cid).x == quests.position.x and getPlayerPosition(cid).y == quests.position.y and getPlayerPosition(cid).z == quests.position.z then

    doSendMagicEffect(p, CONST_ME_POFF)
    local destination = t.enter_pos
    doTeleportThing(cid, destination)
    doSendMagicEffect(destination, CONST_ME_TELEPORT)
    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Good luck in "..param.." quest! You have "..getStrTime(t.time_to_finish).." to finish or you will be kicked.")
    setPlayerStorageValue(cid, time_storage, mathtime(t.time_to_make_again) + os.time())
    addEvent(function()
        if isPlayer(cid) then
            if isInRange(getPlayerPosition(cid), t.area.fromPos, t.area.toPos) then
                doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
                local temple = getTownTemplePosition(getPlayerTown(cid))
                doTeleportThing(cid, temple)
                doSendMagicEffect(temple, CONST_ME_TELEPORT)
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "Your time is over!")
            end
        end
    end, mathtime(t.time_to_finish) * 1000)
    else
    doPlayerSendTextMessage(cid, 25, "wrong position")
    end
    return true
end

function mathtime(table) -- by dwarfer
local unit = {"sec", "min", "hour", "day"}
for i, v in pairs(unit) do
if v == table[2] then
return table[1]*(60^(v == unit[4] and 2 or i-1))*(v == unit[4] and 24 or 1)
end
end
return error("Bad declaration in mathtime function.")
end

function getStrTime(table) -- by dwarfer
local unit = {["sec"] = "second",["min"] = "minute",["hour"] = "hour",["day"] = "day"}
return tostring(table[1].." "..unit[table[2]]..(table[1] > 1 and "s" or ""))
end 

function Fupper(str)
    return (str:gsub("^%l", string.upper))
end  

 

 

tentei aqui, porem nao sei os parametros corretos para usar o getplayerpositoin

Link para o post
Compartilhar em outros sites

No caso o player só poderia usar o comando em uma certa posição, aí meio q nesta posição o script iria funcionar teleportando ele para a área que ele tem tempo para terminar 

Link para o post
Compartilhar em outros sites

se for só 1 posição especifica, vc pd usar o que o danado ali em cima falou ficaria:
 

Spoiler

local quests = {
    ["vipquest"] = {
        min_level = 500,
        enter_pos = {x = 1283, y = 191, z = 7}, 
        area = {fromPos = {x = 1263, y = 245, z = 7}, toPos = {x = 1525, y = 143, z = 7}}, 
        time_to_finish = {15, "min"}, 
        time_to_make_again = {15, "min"}
    -- },
    -- ["dragon"] = {
        -- min_level = 10,
        -- enter_pos = {x = 1, y = 1, z = 1}, 
        -- area = {fromPos = {x = 1, y = 1, z = 1}, toPos = {x = 1, y = 1, z = 1}}, 
        -- time_to_finish = {10, "min"}, 
        -- time_to_make_again = {1, "hour"}
    }
	position = {x = 655, y = 423, z = 7} -- Posição que o Player precisa para usar o comando
}

local time_storage = 87871 -- só modifique se necessário

function onSay(cid, words, param, channel)
    local param, p, check = param:lower(), getPlayerPosition(cid), false
    if not param or param == "" then
        local str, n = '~~ [Available Quests] ~~\n\n', 1
        for quest, info in pairs(quests) do
            str = str .. n .. " - " .. Fupper(quest) .. " (Level: "..info.min_level..")\n"
            n = n + 1
        end
        doShowTextDialog(cid, 1955, str)
        return true
    end
    local t = quests[param]
    if not t then
        return doPlayerSendCancel(cid, "Quest not found.")
    end
    
    if (getCreaturePosition(cid) ~= quests.position) then
        return doPlayerSendCancel(cid, "Only players level "..t.min_level.." or higher can go the "..param.." quest.")
    end

    if getPlayerLevel(cid) < t.min_level then
        return doPlayerSendCancel(cid, "Only players level "..t.min_level.." or higher can go the "..param.." quest.")
    end
    if isInRange(p, t.area.fromPos, t.area.toPos) then
        return doPlayerSendCancel(cid, "You are already inside the "..param.." quest area.")
    end
    for quest, info in pairs(quests) do
        if isInRange(p, info.area.fromPos, info.area.toPos) then
            check = true
        end
    end
    if check then
        return doPlayerSendCancel(cid, "You cannot go to another quest inside a quest.")
    end
    local stor = getPlayerStorageValue(cid, time_storage)
    if stor > os.time() then
        return doPlayerSendCancel(cid, "Voce so podera entrar novamente na quest "..os.date("%d %B %Y %X", stor)..".")
    end
    if getPlayerPosition(cid).x == quests.position.x and getPlayerPosition(cid).y == quests.position.y and getPlayerPosition(cid).z == quests.position.z then

    doSendMagicEffect(p, CONST_ME_POFF)
    local destination = t.enter_pos
    doTeleportThing(cid, destination)
    doSendMagicEffect(destination, CONST_ME_TELEPORT)
    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Good luck in "..param.." quest! You have "..getStrTime(t.time_to_finish).." to finish or you will be kicked.")
    setPlayerStorageValue(cid, time_storage, mathtime(t.time_to_make_again) + os.time())
    addEvent(function()
        if isPlayer(cid) then
            if isInRange(getPlayerPosition(cid), t.area.fromPos, t.area.toPos) then
                doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
                local temple = getTownTemplePosition(getPlayerTown(cid))
                doTeleportThing(cid, temple)
                doSendMagicEffect(temple, CONST_ME_TELEPORT)
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "Your time is over!")
            end
        end
    end, mathtime(t.time_to_finish) * 1000)
    else
    doPlayerSendTextMessage(cid, 25, "wrong position")
    end
    return true
end

function mathtime(table) -- by dwarfer
local unit = {"sec", "min", "hour", "day"}
for i, v in pairs(unit) do
if v == table[2] then
return table[1]*(60^(v == unit[4] and 2 or i-1))*(v == unit[4] and 24 or 1)
end
end
return error("Bad declaration in mathtime function.")
end

function getStrTime(table) -- by dwarfer
local unit = {["sec"] = "second",["min"] = "minute",["hour"] = "hour",["day"] = "day"}
return tostring(table[1].." "..unit[table[2]]..(table[1] > 1 and "s" or ""))
end 

function Fupper(str)
    return (str:gsub("^%l", string.upper))
end  

 

 

Link para o post
Compartilhar em outros sites
7 horas atrás, So volto tarde disse:

se for só 1 posição especifica, vc pd usar o que o danado ali em cima falou ficaria:
 

  Mostrar conteúdo oculto


local quests = {
    ["vipquest"] = {
        min_level = 500,
        enter_pos = {x = 1283, y = 191, z = 7}, 
        area = {fromPos = {x = 1263, y = 245, z = 7}, toPos = {x = 1525, y = 143, z = 7}}, 
        time_to_finish = {15, "min"}, 
        time_to_make_again = {15, "min"}
    -- },
    -- ["dragon"] = {
        -- min_level = 10,
        -- enter_pos = {x = 1, y = 1, z = 1}, 
        -- area = {fromPos = {x = 1, y = 1, z = 1}, toPos = {x = 1, y = 1, z = 1}}, 
        -- time_to_finish = {10, "min"}, 
        -- time_to_make_again = {1, "hour"}
    }
	position = {x = 655, y = 423, z = 7} -- Posição que o Player precisa para usar o comando
}

local time_storage = 87871 -- só modifique se necessário

function onSay(cid, words, param, channel)
    local param, p, check = param:lower(), getPlayerPosition(cid), false
    if not param or param == "" then
        local str, n = '~~ [Available Quests] ~~\n\n', 1
        for quest, info in pairs(quests) do
            str = str .. n .. " - " .. Fupper(quest) .. " (Level: "..info.min_level..")\n"
            n = n + 1
        end
        doShowTextDialog(cid, 1955, str)
        return true
    end
    local t = quests[param]
    if not t then
        return doPlayerSendCancel(cid, "Quest not found.")
    end
    
    if (getCreaturePosition(cid) ~= quests.position) then
        return doPlayerSendCancel(cid, "Only players level "..t.min_level.." or higher can go the "..param.." quest.")
    end

    if getPlayerLevel(cid) < t.min_level then
        return doPlayerSendCancel(cid, "Only players level "..t.min_level.." or higher can go the "..param.." quest.")
    end
    if isInRange(p, t.area.fromPos, t.area.toPos) then
        return doPlayerSendCancel(cid, "You are already inside the "..param.." quest area.")
    end
    for quest, info in pairs(quests) do
        if isInRange(p, info.area.fromPos, info.area.toPos) then
            check = true
        end
    end
    if check then
        return doPlayerSendCancel(cid, "You cannot go to another quest inside a quest.")
    end
    local stor = getPlayerStorageValue(cid, time_storage)
    if stor > os.time() then
        return doPlayerSendCancel(cid, "Voce so podera entrar novamente na quest "..os.date("%d %B %Y %X", stor)..".")
    end
    if getPlayerPosition(cid).x == quests.position.x and getPlayerPosition(cid).y == quests.position.y and getPlayerPosition(cid).z == quests.position.z then

    doSendMagicEffect(p, CONST_ME_POFF)
    local destination = t.enter_pos
    doTeleportThing(cid, destination)
    doSendMagicEffect(destination, CONST_ME_TELEPORT)
    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Good luck in "..param.." quest! You have "..getStrTime(t.time_to_finish).." to finish or you will be kicked.")
    setPlayerStorageValue(cid, time_storage, mathtime(t.time_to_make_again) + os.time())
    addEvent(function()
        if isPlayer(cid) then
            if isInRange(getPlayerPosition(cid), t.area.fromPos, t.area.toPos) then
                doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
                local temple = getTownTemplePosition(getPlayerTown(cid))
                doTeleportThing(cid, temple)
                doSendMagicEffect(temple, CONST_ME_TELEPORT)
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "Your time is over!")
            end
        end
    end, mathtime(t.time_to_finish) * 1000)
    else
    doPlayerSendTextMessage(cid, 25, "wrong position")
    end
    return true
end

function mathtime(table) -- by dwarfer
local unit = {"sec", "min", "hour", "day"}
for i, v in pairs(unit) do
if v == table[2] then
return table[1]*(60^(v == unit[4] and 2 or i-1))*(v == unit[4] and 24 or 1)
end
end
return error("Bad declaration in mathtime function.")
end

function getStrTime(table) -- by dwarfer
local unit = {["sec"] = "second",["min"] = "minute",["hour"] = "hour",["day"] = "day"}
return tostring(table[1].." "..unit[table[2]]..(table[1] > 1 and "s" or ""))
end 

function Fupper(str)
    return (str:gsub("^%l", string.upper))
end  

 

 

então mas o script para de funcionar, eu falo o comando e não funciona

 

Spoiler

image.png.25af7e7f4a752cec9a85e9e6c626ef5b.png

 

Link para o post
Compartilhar em outros sites

mas é somente em 1 position? ou pode ser dentro de uma área com from/to position?

vodkart_logo.png

[*Ninguém será digno do sucesso se não usar suas derrotas para conquistá-lo.*]

 

DISCORDvodkart#6090

 

Link para o post
Compartilhar em outros sites
1 hora atrás, Vodkart disse:

mas é somente em 1 position? ou pode ser dentro de uma área com from/to position?

Quero apenas em uma posição. Vou explicar minha ideia.

Vai ter uma Quest, nessa quest chegaram em um corredor de apenas 1 tile esse corredor no final é fechado com uma placa explicando o comando e assim que falarem o comando nesse tile começaram a outra parte da quest, caso não encontrarem o portal certo no determinado tempo voltaram para o corredor e terão que refazer a essa parte novamente após 10 minutos

 

Link para o post
Compartilhar em outros sites
4 horas atrás, Thony D. Serv disse:
  Ocultar conteúdo

image.thumb.png.6db8a892b08299d0fd5532ba4d587a8f.png

 

faz sentido, segue:
 

Spoiler

local quests = {
    ["vipquest"] = {
        min_level = 500,
        enter_pos = {x = 1283, y = 191, z = 7}, 
        area = {fromPos = {x = 1263, y = 245, z = 7}, toPos = {x = 1525, y = 143, z = 7}}, 
        time_to_finish = {15, "min"}, 
        time_to_make_again = {15, "min"}
    -- },
    -- ["dragon"] = {
        -- min_level = 10,
        -- enter_pos = {x = 1, y = 1, z = 1}, 
        -- area = {fromPos = {x = 1, y = 1, z = 1}, toPos = {x = 1, y = 1, z = 1}}, 
        -- time_to_finish = {10, "min"}, 
        -- time_to_make_again = {1, "hour"}
    }
}

local position = {x = 655, y = 423, z = 7} -- Posição que o Player precisa para usar o comando

function onSay(cid, words, param, channel)
    local param, p, check = param:lower(), getPlayerPosition(cid), false
    if not param or param == "" then
        local str, n = '~~ [Available Quests] ~~\n\n', 1
        for quest, info in pairs(quests) do
            str = str .. n .. " - " .. Fupper(quest) .. " (Level: "..info.min_level..")\n"
            n = n + 1
        end
        doShowTextDialog(cid, 1955, str)
        return true
    end
    local t = quests[param]
    if not t then
        return doPlayerSendCancel(cid, "Quest not found.")
    end
    
    if (getCreaturePosition(cid) ~= position) then
        return doPlayerSendCancel(cid, "Wrong position.")
    end

    if getPlayerLevel(cid) < t.min_level then
        return doPlayerSendCancel(cid, "Only players level "..t.min_level.." or higher can go the "..param.." quest.")
    end
    if isInRange(p, t.area.fromPos, t.area.toPos) then
        return doPlayerSendCancel(cid, "You are already inside the "..param.." quest area.")
    end
    for quest, info in pairs(quests) do
        if isInRange(p, info.area.fromPos, info.area.toPos) then
            check = true
        end
    end
    if check then
        return doPlayerSendCancel(cid, "You cannot go to another quest inside a quest.")
    end
    local stor = getPlayerStorageValue(cid, time_storage)
    if stor > os.time() then
        return doPlayerSendCancel(cid, "Voce so podera entrar novamente na quest "..os.date("%d %B %Y %X", stor)..".")
    end
    if getPlayerPosition(cid).x == quests.position.x and getPlayerPosition(cid).y == quests.position.y and getPlayerPosition(cid).z == quests.position.z then

    doSendMagicEffect(p, CONST_ME_POFF)
    local destination = t.enter_pos
    doTeleportThing(cid, destination)
    doSendMagicEffect(destination, CONST_ME_TELEPORT)
    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Good luck in "..param.." quest! You have "..getStrTime(t.time_to_finish).." to finish or you will be kicked.")
    setPlayerStorageValue(cid, time_storage, mathtime(t.time_to_make_again) + os.time())
    addEvent(function()
        if isPlayer(cid) then
            if isInRange(getPlayerPosition(cid), t.area.fromPos, t.area.toPos) then
                doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
                local temple = getTownTemplePosition(getPlayerTown(cid))
                doTeleportThing(cid, temple)
                doSendMagicEffect(temple, CONST_ME_TELEPORT)
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "Your time is over!")
            end
        end
    end, mathtime(t.time_to_finish) * 1000)
    else
    doPlayerSendTextMessage(cid, 25, "wrong position")
    end
    return true
end

function mathtime(table) -- by dwarfer
local unit = {"sec", "min", "hour", "day"}
for i, v in pairs(unit) do
if v == table[2] then
return table[1]*(60^(v == unit[4] and 2 or i-1))*(v == unit[4] and 24 or 1)
end
end
return error("Bad declaration in mathtime function.")
end

function getStrTime(table) -- by dwarfer
local unit = {["sec"] = "second",["min"] = "minute",["hour"] = "hour",["day"] = "day"}
return tostring(table[1].." "..unit[table[2]]..(table[1] > 1 and "s" or ""))
end 

function Fupper(str)
    return (str:gsub("^%l", string.upper))
end  

 

 

Link para o post
Compartilhar em outros sites
  • Solução
local quests = {
    ["vipquest"] = {
        min_level = 500,
        enter_pos = {x = 1285, y = 191, z = 7}, 
        area = {fromPos = {x = 1263, y = 245, z = 7}, toPos = {x = 1525, y = 143, z = 7}}, 
        time_to_finish = {15, "min"}, 
        time_to_make_again = {15, "min"}
    -- },
    -- ["dragon"] = {
        -- min_level = 10,
        -- enter_pos = {x = 1, y = 1, z = 1}, 
        -- area = {fromPos = {x = 1, y = 1, z = 1}, toPos = {x = 1, y = 1, z = 1}}, 
        -- time_to_finish = {10, "min"}, 
        -- time_to_make_again = {1, "hour"}
    }
}

local time_storage = 87871 -- só modifique se necessário

function onSay(cid, words, param, channel)
    local param, p, check = param:lower(), getPlayerPosition(cid), false
    local npos = {x = 200, y = 200, z = 7}
    if not param or param == "" then
        local str, n = '~~ [Available Quests] ~~\n\n', 1
        for quest, info in pairs(quests) do
            str = str .. n .. " - " .. Fupper(quest) .. " (Level: "..info.min_level..")\n"
            n = n + 1
        end
        doShowTextDialog(cid, 1955, str)
        return true
    end
    local t = quests[param]
    if p.x ~= npos.x or p.y ~= npos.y or p.z ~= npos.z  then
        return doPlayerSendCancel(cid, "position errada: voce precisa estar dentro da quest para usar este comando.")
    end
    if not t then
        return doPlayerSendCancel(cid, "Quest not found.")
    end
    if getPlayerLevel(cid) < t.min_level then
        return doPlayerSendCancel(cid, "Only players level "..t.min_level.." or higher can go the "..param.." quest.")
    end
    if isInRange(p, t.area.fromPos, t.area.toPos) then
        return doPlayerSendCancel(cid, "You are already inside the "..param.." quest area.")
    end
    for quest, info in pairs(quests) do
        if isInRange(p, info.area.fromPos, info.area.toPos) then
            check = true
        end
    end
    if check then
        return doPlayerSendCancel(cid, "You cannot go to another quest inside a quest.")
    end
    local stor = getPlayerStorageValue(cid, time_storage)
    if stor > os.time() then
        return doPlayerSendCancel(cid, "Voce so podera entrar novamente na quest "..os.date("%d %B %Y %X", stor)..".")
    end
    doSendMagicEffect(p, CONST_ME_POFF)
    local destination = t.enter_pos
    doTeleportThing(cid, destination)
    doSendMagicEffect(destination, CONST_ME_TELEPORT)
    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Good luck in "..param.." quest! You have "..getStrTime(t.time_to_finish).." to finish or you will be kicked.")
    setPlayerStorageValue(cid, time_storage, mathtime(t.time_to_make_again) + os.time())
    addEvent(function()
        if isPlayer(cid) then
            if isInRange(getPlayerPosition(cid), t.area.fromPos, t.area.toPos) then
                doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
                local temple = getTownTemplePosition(getPlayerTown(cid))
                doTeleportThing(cid, temple)
                doSendMagicEffect(temple, CONST_ME_TELEPORT)
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "Your time is over!")
            end
        end
    end, mathtime(t.time_to_finish) * 1000)
    return true
end

function mathtime(table) -- by dwarfer
local unit = {"sec", "min", "hour", "day"}
for i, v in pairs(unit) do
if v == table[2] then
return table[1]*(60^(v == unit[4] and 2 or i-1))*(v == unit[4] and 24 or 1)
end
end
return error("Bad declaration in mathtime function.")
end

function getStrTime(table) -- by dwarfer
local unit = {["sec"] = "second",["min"] = "minute",["hour"] = "hour",["day"] = "day"}
return tostring(table[1].." "..unit[table[2]]..(table[1] > 1 and "s" or ""))
end 

function Fupper(str)
    return (str:gsub("^%l", string.upper))
end  

 

vodkart_logo.png

[*Ninguém será digno do sucesso se não usar suas derrotas para conquistá-lo.*]

 

DISCORDvodkart#6090

 

Link para o post
Compartilhar em outros sites

Participe da conversa

Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.

Visitante
Responder

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emojis são permitidos.

×   Seu link foi automaticamente incorporado.   Mostrar como link

×   Seu conteúdo anterior foi restaurado.   Limpar o editor

×   Não é possível colar imagens diretamente. Carregar ou inserir imagens do URL.

  • Quem Está Navegando   0 membros estão online

    Nenhum usuário registrado visualizando esta página.

×
×
  • Criar Novo...

Informação Importante

Confirmação de Termo