Ir para conteúdo
  • Cadastre-se

(Resolvido)[SCRIPT] Por tempo na quest


Ir para solução Resolvido por Vodkart,

Posts Recomendados

Eae galera!!

Tem uma quest em meu servidor, similar a anihi, que preciso por tempo no uso da alavanca pois está entrando mais de um time por vez, se possível por a contagem na alavanca e uma mensagem no chat.

Ainda sou leigo no assunto se alguém poder me ajudar fico muito agradecido. desde já, OBRIGADO.

Segue abaixo a action script.

Citar

local level = 130
local redo = {status = false, storageValue = 61111} -- true para ilimitado, false para somente uma vez
 
local config = {
    {
        vocations = {3, 7},
        playerPos = {x=1117, y=1150, z=6}, -- Initial position in the Stone tile
        newPos = {x=1114, y=1142, z=8}, -- Position of the reward room.
    },
 
    {
        vocations = {2, 6},
        playerPos = {x=1123, y=1157, z=6}, -- Initial position in the Stone tile
        newPos = {x=1114, y=1142, z=8}, -- Position of the reward room.
    },
 
    {
        vocations = {1, 5},
        playerPos = {x=1127, y=1155, z=6}, -- Initial position in the Stone tile
        newPos = {x=1114, y=1142, z=8}, -- Position of the reward room.
    },
 
    {
        vocations = {4, 8},
        playerPos = {x=1123, y=1147, z=6}, -- Initial position in the Stone tile
        newPos = {x=1114, y=1142, z=8}, --Position of the reward room.
    }
}

local msgs = {
[1] = "Todos os jogadores devem estar em seus respectivos pisos!",
[2] = "Todos os players devem ser level " .. level .. " ou maior.",
[3] = "Um jogador em seu time ja fez a Fishing Rod and Pick Quest!",
[4] = "Não há jogadores suficientes."
}
 
function onUse(cid, fromPosition, toPosition)
    local players, msgID = {}, 0
    for i, v in pairs(config) do
        local player = getTopCreature(v.playerPos).uid
        if player ~= 0 and isPlayer(player) then
            if not isInArray(v.vocations, getPlayerVocation(player)) then
                msgID = 1
                break
            elseif getPlayerLevel(player) < level then
                msgID = 2
                break
            elseif not redo.status then
                if getPlayerStorageValue(player, redo.storageValue) ~= -1 then
                    msgID = 3
                    break
                end
            end
            table.insert(players, {player = player, newPos = v.newPos})
        end    
    end
    if msgID ~= 0 then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, msgs[msgID]) 
        return true
    end    
    if #players ~= #config then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, msgs[4]) 
        return true
    end
    
    for i = 1, #players do
        local p = players
        if not redo.status then
        end
        doSendMagicEffect(getPlayerPosition(p.player), CONST_ME_POFF)
        doTeleportThing(p.player, p.newPos)
        doSendMagicEffect(p.newPos, CONST_ME_TELEPORT)
    end
    return true
end

 

 

Link para o post
Compartilhar em outros sites

Tente assim

Edita as posições de acorda com a sala q quer verificar os players

local level = 130
local redo = {status = false, storageValue = 61111} -- true para ilimitado, false para somente uma vez
local posi = {x=xxxx, y=yyyy, z=z} -- posição topo esquerdo da sala
local posf = {x=xxxx, y=yyyy, z=z} -- posição parte inferior esquerda da sala
local pos = getCreaturePosition(cid)
local config = {
    {
        vocations = {3, 7},
        playerPos = {x=1117, y=1150, z=6}, -- Initial position in the Stone tile
        newPos = {x=1114, y=1142, z=8}, -- Position of the reward room.
    },
 
    {
        vocations = {2, 6},
        playerPos = {x=1123, y=1157, z=6}, -- Initial position in the Stone tile
        newPos = {x=1114, y=1142, z=8}, -- Position of the reward room.
    },
 
    {
        vocations = {1, 5},
        playerPos = {x=1127, y=1155, z=6}, -- Initial position in the Stone tile
        newPos = {x=1114, y=1142, z=8}, -- Position of the reward room.
    },
 
    {
        vocations = {4, 8},
        playerPos = {x=1123, y=1147, z=6}, -- Initial position in the Stone tile
        newPos = {x=1114, y=1142, z=8}, --Position of the reward room.
    }
}

local msgs = {
[1] = "Todos os jogadores devem estar em seus respectivos pisos!",
[2] = "Todos os players devem ser level " .. level .. " ou maior.",
[3] = "Um jogador em seu time ja fez a Fishing Rod and Pick Quest!",
[4] = "Não há jogadores suficientes.", 
[5] = "Já existe players na quest. Aguardem."
}
 
function onUse(cid, fromPosition, toPosition)
    local players, msgID = {}, 0
    for i, v in pairs(config) do
        local player = getTopCreature(v.playerPos).uid
        if player ~= 0 and isPlayer(player) then
            if not isInArray(v.vocations, getPlayerVocation(player)) then
                msgID = 1
                break
            elseif getPlayerLevel(player) < level then
                msgID = 2
                break          
            elseif isInArea(pos, posi, posf) and isPlayer(cid) == true then 
        		msgID = 5
                break
            elseif not redo.status then
                if getPlayerStorageValue(player, redo.storageValue) ~= -1 then
                    msgID = 3
                    break
                end
            end
            table.insert(players, {player = player, newPos = v.newPos})
        end    
    end
    if msgID ~= 0 then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, msgs[msgID]) 
        return true
    end    
    if #players ~= #config then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, msgs[4]) 
        return true
    end
    
    for i = 1, #players do
        local p = players
        if not redo.status then
        end
        doSendMagicEffect(getPlayerPosition(p.player), CONST_ME_POFF)
        doTeleportThing(p.player, p.newPos)
        doSendMagicEffect(p.newPos, CONST_ME_TELEPORT)
    end
    return true
end

 

Editado por Naze
bugs no codigo (veja o histórico de edições)

Discord: Naze#3578

 

Ter Linux Dentro de Windows com Acesso 'localhost' para testes e +

AutoLoot Otimizado Direto na Source (tfs 0.4/otx)

 

// Pirataria é crime, original é roubo, compartilhar é legal.

 

tumblr_muk78tEwDQ1qah4nko1_500.gif

Link para o post
Compartilhar em outros sites

@Naze 

Bom dia!

Deu o seguinte erro:

Citar

[23/02/2020 09:19:54] [Error - Action Interface] 
[23/02/2020 09:19:54] data/actions/scripts/quest/rodquest.lua
[23/02/2020 09:19:54] Description: 
[23/02/2020 09:19:54] (luaGetThingPosition) Thing not found
[23/02/2020 09:19:54] Reloaded actions.

O servidor é 8.6 TFS 0.4

Link para o post
Compartilhar em outros sites

Mudei a função tente agora.

 

local level = 130
local redo = {status = false, storageValue = 61111} -- true para ilimitado, false para somente uma vez
local posi = {x=xxxx, y=yyyy, z=z} -- posição topo esquerdo da sala
local posf = {x=xxxx, y=yyyy, z=z} -- posição parte inferior esquerda da sala

local function getPlayersInRange(pos1, pos2)
	local creaturesList = {}
	for px = pos1.x, pos2.x do
		for py = pos1.y, pos2.y do
			if not (x == 0 and y == 0) then
				local creature = getTopCreature({x = px, y = py, z = pos1.z})
				if creature.type == 1 then
					table.insert(creaturesList, creature.uid)
				end
			end
		end
	end
	return creaturesList
end

local config = {
    {
        vocations = {3, 7},
        playerPos = {x=1117, y=1150, z=6}, -- Initial position in the Stone tile
        newPos = {x=1114, y=1142, z=8}, -- Position of the reward room.
    },
 
    {
        vocations = {2, 6},
        playerPos = {x=1123, y=1157, z=6}, -- Initial position in the Stone tile
        newPos = {x=1114, y=1142, z=8}, -- Position of the reward room.
    },
 
    {
        vocations = {1, 5},
        playerPos = {x=1127, y=1155, z=6}, -- Initial position in the Stone tile
        newPos = {x=1114, y=1142, z=8}, -- Position of the reward room.
    },
 
    {
        vocations = {4, 8},
        playerPos = {x=1123, y=1147, z=6}, -- Initial position in the Stone tile
        newPos = {x=1114, y=1142, z=8}, --Position of the reward room.
    }
}

local msgs = {
[1] = "Todos os jogadores devem estar em seus respectivos pisos!",
[2] = "Todos os players devem ser level " .. level .. " ou maior.",
[3] = "Um jogador em seu time ja fez a Fishing Rod and Pick Quest!",
[4] = "Não há jogadores suficientes.", 
[5] = "Já existe players na quest. Aguardem."
}
 
function onUse(cid, fromPosition, toPosition)
    local players, msgID = {}, 0
    for i, v in pairs(config) do
        local player = getTopCreature(v.playerPos).uid
        if player ~= 0 and isPlayer(player) then
            if not isInArray(v.vocations, getPlayerVocation(player)) then
                msgID = 1
                break
            elseif getPlayerLevel(player) < level then
                msgID = 2
                break          
            elseif #getPlayersInRange(posi, posf) >= 1 then
				msgID = 5
                break
            elseif not redo.status then
                if getPlayerStorageValue(player, redo.storageValue) ~= -1 then
                    msgID = 3
                    break
                end
            end
            table.insert(players, {player = player, newPos = v.newPos})
        end    
    end
    if msgID ~= 0 then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, msgs[msgID]) 
        return true
    end    
    if #players ~= #config then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, msgs[4]) 
        return true
    end
    
    for i = 1, #players do
        local p = players
        if not redo.status then
        end
        doSendMagicEffect(getPlayerPosition(p.player), CONST_ME_POFF)
        doTeleportThing(p.player, p.newPos)
        doSendMagicEffect(p.newPos, CONST_ME_TELEPORT)
    end
    return true
end

 

Discord: Naze#3578

 

Ter Linux Dentro de Windows com Acesso 'localhost' para testes e +

AutoLoot Otimizado Direto na Source (tfs 0.4/otx)

 

// Pirataria é crime, original é roubo, compartilhar é legal.

 

tumblr_muk78tEwDQ1qah4nko1_500.gif

Link para o post
Compartilhar em outros sites

@Naze 

Eea. Deu o seguinte erro:

Citar

[23/02/2020 21:46:01] [Error - Action Interface] 
[23/02/2020 21:46:01] data/actions/scripts/quest/rodquest.lua:onUse
[23/02/2020 21:46:01] Description: 
[23/02/2020 21:46:01] attempt to index a nil value
[23/02/2020 21:46:01] stack traceback:
[23/02/2020 21:46:01]     [C]: in function 'doTeleportThing'
[23/02/2020 21:46:02]     data/actions/scripts/quest/rodquest.lua:92: in function <data/actions/scripts/quest/rodquest.lua:55>

Mano, eu estava pensando aqui em por só tempo de exhausted na alavanca, é mais uma gambiarra, porque ao rastrear o quadrado ela pega quem ta na city. A quest tem dois andares. Sacou?

 

Se quiser deixar isso para depois do carnaval não tem problema.

Link para o post
Compartilhar em outros sites
function convertTime(minutes,seconds)
	local hours = 0
	repeat
		if seconds >= 60 then
			minutes = minutes + 1; seconds = seconds - 60
		elseif minutes >= 60 then
			hours = hours + 1; minutes = minutes - 60
		end
	until seconds < 60 and minutes < 60
	return {hours = hours, seconds = seconds, minutes = minutes}
end
function doTeleportTimer(pos, seconds)
	local t = convertTime(0, seconds)
	doSendAnimatedText(pos, t.minutes > 0 and t.minutes..":"..t.seconds or t.seconds, 145)
	if seconds ~= 1 then addEvent(doTeleportTimer, 1000, pos, seconds-1) end
end

local storage, minutos = 48748, 10 -- 10 minutos
local level = 130
local redo = {status = false, storageValue = 61111} -- true para ilimitado, false para somente uma vez
local config = {
	{
		vocations = {3, 7},
		playerPos = {x=1117, y=1150, z=6}, -- Initial position in the Stone tile
		newPos = {x=1114, y=1142, z=8}, -- Position of the reward room.
	},
	
	{
		vocations = {2, 6},
		playerPos = {x=1123, y=1157, z=6}, -- Initial position in the Stone tile
		newPos = {x=1114, y=1142, z=8}, -- Position of the reward room.
	},
	
	{
		vocations = {1, 5},
		playerPos = {x=1127, y=1155, z=6}, -- Initial position in the Stone tile
		newPos = {x=1114, y=1142, z=8}, -- Position of the reward room.
	},
	
	{
		vocations = {4, 8},
		playerPos = {x=1123, y=1147, z=6}, -- Initial position in the Stone tile
		newPos = {x=1114, y=1142, z=8}, --Position of the reward room.
	}
}
local msgs = {
	[1] = "Todos os jogadores devem estar em seus respectivos pisos!",
	[2] = "Todos os players devem ser level " .. level .. " ou maior.",
	[3] = "Um jogador em seu time ja fez a Fishing Rod and Pick Quest!",
	[4] = "Não há jogadores suficientes."
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
	if getGlobalStorageValue(storage) - os.time() > 0 then
		doPlayerSendTextMessage(cid, 25, "Você não pode usar a alavanca agora.") return true
	end
	local players, msgID = {}, 0
	for i, v in pairs(config) do
		local player = getTopCreature(v.playerPos).uid
		if player ~= 0 and isPlayer(player) then
			if not isInArray(v.vocations, getPlayerVocation(player)) then
				msgID = 1
				break
			elseif getPlayerLevel(player) < level then
				msgID = 2
				break
			elseif not redo.status then
				if getPlayerStorageValue(player, redo.storageValue) ~= -1 then
					msgID = 3
					break
				end
			end
			table.insert(players, {player = player, newPos = v.newPos})
		end 
	end
	if msgID ~= 0 then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, msgs[msgID]) 
		return true
	end 
	if #players ~= #config then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, msgs[4]) 
		return true
	end
	for i = 1, #players do
		local p = players
		if not redo.status then
		end
		doSendMagicEffect(getPlayerPosition(p.player), CONST_ME_POFF)
		doTeleportThing(p.player, p.newPos)
		doSendMagicEffect(p.newPos, CONST_ME_TELEPORT)
	end
	setGlobalStorageValue(storage, os.time() + minutos*60)
	doTeleportTimer(toPosition, minutos*60)
	return true
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

@Vodkart 

Oi. Deu o seguinte erro:

Citar

[24/02/2020 17:31:12] [Error - Action Interface] 
[24/02/2020 17:31:12] data/actions/scripts/quest/rodquest.lua:onUse
[24/02/2020 17:31:12] Description: 
[24/02/2020 17:31:12] (luaGetThingPosition) Thing not found

[24/02/2020 17:31:12] [Error - Action Interface] 
[24/02/2020 17:31:12] data/actions/scripts/quest/rodquest.lua:onUse
[24/02/2020 17:31:12] Description: 
[24/02/2020 17:31:12] attempt to index a nil value
[24/02/2020 17:31:12] stack traceback:
[24/02/2020 17:31:12]     [C]: in function 'doTeleportThing'
[24/02/2020 17:31:12]     data/actions/scripts/quest/rodquest.lua:88: in function <data/actions/scripts/quest/rodquest.lua:52>

 

Link para o post
Compartilhar em outros sites

@OfWar mas não é da função que eu coloquei não, está dando erro na hora de teleportar os jogadores.

 

na verdade eu vou refazer esse código ai que está bem feio e já te mando assim que tiver tempo kk

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

------------------

 

local storage, minutos = 48748, 10 -- 10 minutos
local lvl = 130
local t = {
	{vocations = {1, 5}, Pos = {{x=1127, y=1155, z=6},{x=1114, y=1142, z=8}}}, --primeira pos é onde o jogador tem que estar e a segunda para onde ele vai ser teleportado
	{vocations = {2, 6}, Pos = {{x=1123, y=1157, z=6},{x=1114, y=1142, z=8}}},
	{vocations = {3, 7}, Pos = {{x=1117, y=1150, z=6},{x=1114, y=1142, z=8}}},
	{vocations = {4, 8}, Pos = {{x=1123, y=1147, z=6},{x=1114, y=1142, z=8}}}
}
function convertTime(minutes,seconds)
	local hours = 0
	repeat
		if seconds >= 60 then
			minutes = minutes + 1; seconds = seconds - 60
		elseif minutes >= 60 then
			hours = hours + 1; minutes = minutes - 60
		end
	until seconds < 60 and minutes < 60
	return {hours = hours, seconds = seconds, minutes = minutes}
end
function doTeleportTimer(pos, seconds)
	local t = convertTime(0, seconds)
	doSendAnimatedText(pos, t.minutes > 0 and t.minutes..":"..t.seconds or t.seconds, 145)
	if seconds ~= 1 then addEvent(doTeleportTimer, 1000, pos, seconds-1) end
end
function onUse(cid, item, fromPosition, itemEx, toPosition)
	local check = {}
	for _, k in ipairs(t) do
		local x = getTopCreature(k.Pos[1]).uid
		if x == 0 or not isPlayer(x) then
			doPlayerSendCancel(cid, 'Não há jogadores suficientes.') return true
		elseif not isInArray(k.vocations, getPlayerVocation(x)) then
			doPlayerSendCancel(cid, 'Todos os jogadores devem estar em seus respectivos pisos!') return true
		elseif getPlayerLevel(x) < lvl then
			doPlayerSendCancel(cid, 'Todos os players devem ser level ' .. lvl .. ' ou maior.') return true
		end
		table.insert(check, x)
	end
	for k, tid in ipairs(check) do
		doSendMagicEffect(getCreaturePosition(tid), CONST_ME_POFF)
		doTeleportThing(tid, t[k].Pos[2]) 
		doSendMagicEffect(getCreaturePosition(tid), CONST_ME_TELEPORT)
	end
	setGlobalStorageValue(storage, os.time() + minutos*60)
	doTeleportTimer(toPosition, minutos*60)
	doTransformItem(item.uid, item.itemid == 1945 and 1946 or 1945)
	return true
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

@Vodkart 

Eae cara, boa tarde.

A script teleportou e fez a contagem, mas continua entrando um team atrás do outro antes do tempo acabar.

É possível deixar a contagem em segundos?

Ela está assim: 9:59, 9:58... se possível em segundos, exemplo: 600, 599...

Obrigado pela ajuda. 

Link para o post
Compartilhar em outros sites
  • Solução

@OfWar Verdade, esqueci de adicionar a linha.

 

local storage, minutos = 48748, 10 -- 10 minutos
local lvl = 130
local t = {
	{vocations = {1, 5}, Pos = {{x=1127, y=1155, z=6},{x=1114, y=1142, z=8}}}, --primeira pos é onde o jogador tem que estar e a segunda para onde ele vai ser teleportado
	{vocations = {2, 6}, Pos = {{x=1123, y=1157, z=6},{x=1114, y=1142, z=8}}},
	{vocations = {3, 7}, Pos = {{x=1117, y=1150, z=6},{x=1114, y=1142, z=8}}},
	{vocations = {4, 8}, Pos = {{x=1123, y=1147, z=6},{x=1114, y=1142, z=8}}}
}
function doTeleportTimer(pos, seconds)
	doSendAnimatedText(pos, seconds, 145)
	if seconds ~= 1 then addEvent(doTeleportTimer, 1000, pos, seconds-1) end
end
function onUse(cid, item, fromPosition, itemEx, toPosition)
	if getGlobalStorageValue(storage) - os.time() > 0 then
		doPlayerSendTextMessage(cid, 25, "Você não pode usar a alavanca agora.") return true
	end
	local check = {}
	for _, k in ipairs(t) do
		local x = getTopCreature(k.Pos[1]).uid
		if x == 0 or not isPlayer(x) then
			doPlayerSendCancel(cid, 'Não há jogadores suficientes.') return true
		elseif not isInArray(k.vocations, getPlayerVocation(x)) then
			doPlayerSendCancel(cid, 'Todos os jogadores devem estar em seus respectivos pisos!') return true
		elseif getPlayerLevel(x) < lvl then
			doPlayerSendCancel(cid, 'Todos os players devem ser level ' .. lvl .. ' ou maior.') return true
		end
		table.insert(check, x)
	end
	for k, tid in ipairs(check) do
		doSendMagicEffect(getCreaturePosition(tid), CONST_ME_POFF)
		doTeleportThing(tid, t[k].Pos[2]) 
		doSendMagicEffect(getCreaturePosition(tid), CONST_ME_TELEPORT)
	end
	setGlobalStorageValue(storage, os.time() + minutos*60)
	doTeleportTimer(toPosition, minutos*60)
	doTransformItem(item.uid, item.itemid == 1945 and 1946 or 1945)
	return true
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.

×
×
  • Criar Novo...

Informação Importante

Confirmação de Termo