LU
script

Reformulação de Script! Aparecer tempo que falta!

Por Luga03, 26 de jun. de 2015 em Scripts

resolvido
8
1.2k
Luga03L
29 de junho de 2015 às 09:12

Eae pessoal blz?? estou com o sistema de login Delay! eu dei uma adaptada pequena, uma configuração mt facil, mas eu tentei colocar para aparecer quando tempo falta exatamente! tipo eu logo, ai deslogo em menos de 5 segundos, aparece uma mensagem dizendo 5 segundos, e dps antes dos 5 segundos aparece a mesma mensagem! eu gostaria de reformular ele, para aparecer tipo assim:

[Pokémon X Timer] Aguarde 5 segundo(s) Para Poder Deslogar!.
[Pokémon X Timer] Aguarde 4 segundo(s) Para Poder Deslogar!.
[Pokémon X Timer] Aguarde 3 segundo(s) Para Poder Deslogar!.
[Pokémon X Timer] Aguarde 2 segundo(s) Para Poder Deslogar!.
[Pokémon X Timer] Aguarde 1 segundo(s) Para Poder Deslogar!.

ai fica aparecendo de acordo com o tempo que falta! ta ai o script:

local config = 
{
    segundos = 5,
    lerIP = "yes"
}
config.lerIP = getBooleanFromString(config.lerIP)
local m_lastLogin, m_lastIP = 0, 0
function onLogout(cid)
    local timeNow, playerIP = os.time(), getPlayerIp(cid)
doPlayerSendTextMessage(cid,19, "[Pokémon X Timer] Aguarde "..config.segundos.." segundo(s) Para Poder Deslogar!.")
        if(m_lastLogin + config.segundos >= timeNow and
            (config.lerIP == FALSE or m_lastIP == playerIP)) then
            return false
        end
    m_lastIP = playerIP
    m_lastLogin = timeNow
    return true
end


:p rep+ para quem conseguir me ajudar Pfv


UP

BrunoB
29 de junho de 2015 às 09:43

@

 

Não tenho certeza, mais tenta ai:

local config = {
    segundos = 5,
    lerIP = true
}

function sleep(n)
	local t = os.clock()
	while os.clock() - t <= n do end
end

function onLogout(cid)
    local timeNow, playerIP, m_lastLogin, m_lastIP, seg = os.time(), getPlayerIp(cid), 0, 0, config.segundos
	if m_lastLogin + config.segundos >= timeNow and (not config.lerIP or m_lastIP == playerIP) then
		for i = 1, config.segundos do
			doPlayerSendTextMessage(cid, 19, "[Pokémon X Timer] Aguarde "..seg.." segundo(s) Para Poder Deslogar!.")
			sleep(1)
			seg = seg - 1
		end
		return false
    end
    m_lastIP = playerIP
    m_lastLogin = timeNow
    return true
end

Editado Junho 29 por Bruno Minervino

Luga03L
05 de julho de 2015 às 18:42

Manow desculpa demorar é pq tive uns problemas, mas testei e não funcionou! nem mandou mensagem :p

08 de julho de 2015 às 22:53
Melhor resposta

@Zet

 

Não sei se era isso, mas da uma olhada:

local config =
{
	segundos = 5,
	lerIP = true,
	storage = 201507080001
}

function onLogout(cid)

	local timeNow = os.time()
	local totalTime = getPlayerLastLoginSaved(cid) + config.segundos

	if totalTime >= timeNow then
		if not config.lerIP or getPlayerStorageValue(cid, config.storage) == getPlayerIp(cid) then
			doPlayerSendTextMessage(cid, 19, "[Pokémon X Timer] Aguarde ".. totalTime - timeNow .." segundo(s) Para Poder Deslogar!.")
			return false
		end
	end

	setPlayerStorageValue(cid, config.storage, getPlayerIp(cid))
	return true
end



@Bruno

Acho que o seu sleep trava o servidor inteiro.

Luga03L
08 de julho de 2015 às 23:10

@Zet

 

Não sei se era isso, mas da uma olhada:

 

local config =
{
	segundos = 5,
	lerIP = true,
	storage = 201507080001
}

function onLogout(cid)

	local timeNow = os.time()
	local totalTime = getPlayerLastLoginSaved(cid) + config.segundos

	if totalTime >= timeNow then
		if not config.lerIP or getPlayerStorageValue(cid, config.storage) == getPlayerIp(cid) then
			doPlayerSendTextMessage(cid, 19, "[Pokémon X Timer] Aguarde ".. totalTime - timeNow .." segundo(s) Para Poder Deslogar!.")
			return false
		end
	end

	setPlayerStorageValue(cid, config.storage, getPlayerIp(cid))
	return true
end

 

 

@Bruno

 

Acho que o seu sleep trava o servidor inteiro.

Manow acabei de testar, e n funcionou! não deu erro, eu coloquei pra 20 segundos para eu poder testar, e não apareceu a mensagem e eu também podia deslogar do mesmo jeito, mesmo antes dos 20 segundos!

08 de julho de 2015 às 23:20

Eu não pude testar, pois não tenho nenhum ambiente de teste aqui, mas você chegou a testar mais de uma vez com o mesmo char? É que o script só vai começar a funcionar a partir da segunda vez que você deslogar.

 

Se mesmo assim não funcionar, ocorreu algum erro no console (executável)?

Editado Julho 8 por Demonbholder

Luga03L
09 de julho de 2015 às 01:18

o.O recoloquei o script, e funcionou! vlw aew mt obrigado

BrunoB
09 de julho de 2015 às 08:06

Tópico movido para a seção de dúvidas e pedidos resolvidos.