Ir para conteúdo

Featured Replies

Postado
Em 23/02/2021 em 18:31, MayconPhP disse:

Não precisa de uma gambiarra ? 

 

crie 1 arquivo em movements/scripts

questip.lua


local cfg = {
    interval = 24, -- Altere a quantidade de horas
    position = {x = 1000, y = 1000, z = 7} -- Local para onde o player será teleportado
}

function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor)

    local storage, interval = getPlayerIp(cid), cfg.interval
    if (getGlobalStorageValue(storage) > os.time()) then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Lamento mas você ja fez a quest com esse IP. Você poderá fazer novamente nas próximas 24 horas.")
        doTeleportThing(cid, fromPosition)
        return true
    end
    setGlobalStorageValue(storage, os.time() + (interval * 60 * 60))
    doTeleportThing(cid, cfg.position)
    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Você foi teleportado. Boa sorte!")
    return true
end

 

No movements.xml adicione a tag


<movevent type="StepIn" actionid="17500" event="script" value="questip.lua"/>

 

 

 

Uma observação, não seria melhor fazer com que em vez de IP, fosse por ACCOUNT storage, pois pensa no seguinte, o jogador fez a Quest no personagem dele no IP 192.168.1.100, se ele estiver com as configurações para IP estático, beleza esse script vai funcionar tranquilo, já que o IP estático é fixo, porem e se ele tiver com IP dinamico? e esse IP mudar para 192.168.1.101, ele vai conseguir refazer a quest, já por uma account storage, não ocorreria esse erro, tendo em vista que seria como Players Storage, só que em vez de ser por Player, vai ser por Account...

 

Projeto/Serviços que desenvolvi durante esse Tempo.

[SERVIDOR] - NTO By Madara Rinnegan - Criado em 2014

  • Respostas 11
  • Visualizações 1.8k
  • Created
  • Última resposta

Top Posters In This Topic

Most Popular Posts

  • Query para executar   CREATE TABLE `ip_storages` ( `ip` int NOT NULL default 0, `key` int NOT NULL default 0, `value` varchar(255) NOT NULL default 0 )  

  • function onSay(cid, words, param) local storage, ip = 18000, getPlayerIp(cid) return doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, getIpStorageValue(ip, storage) - os.time() <= 0 and "Voce

  • MatteusDeli
    MatteusDeli

    @Breniinx talkactions/scripts dailyQuestIpTime.lua:   local storage = 18000 -- Manter essa storage igual a que esta no bau local ip = getPlayerIp(cid) function onSay(cid, words, param)

Postado
  • Solução
  • Este é um post popular.

Query para executar

 

CREATE TABLE `ip_storages` (
        `ip` int NOT NULL default 0,
        `key` int NOT NULL default 0,
        `value` varchar(255) NOT NULL default 0
        )

 

 

funções para adicionar

 

function setIpStorageValue(ip, key, value)
	local func = db.executeQuery or db.query
	local query = db.getResult("SELECT `value` FROM `ip_storages` WHERE `key` = "..key.." AND `ip` = "..ip)
	if query:getID() == -1 then
		return func("INSERT INTO `ip_storages` (`ip`, `key`, `value`) VALUES ("..ip..", "..key..", "..value..")")
	end
	return func("UPDATE `ip_storages` SET `value` = "..value.." WHERE `key` = "..key.." AND `ip` = "..ip)
end
function getIpStorageValue(ip, key)
	local ret = db.getResult("SELECT `value` FROM `ip_storages` WHERE `ip` = "..ip.." AND `key` = "..key)
	if ret:getID() == -1 then
		return -1
	end
	return ret:getDataInt("value") or ret:getDataString("value")
end
function timeString(timeDiff)
	local dateFormat = {
		{"day", timeDiff / 60 / 60 / 24},
		{"hour", timeDiff / 60 / 60 % 24},
		{"minute", timeDiff / 60 % 60},
		{"second", timeDiff % 60}
	}
	local out = {}
	for k, t in ipairs(dateFormat) do
		local v = math.floor(t[2])
		if(v > 0) then
			table.insert(out, (k < #dateFormat and (#out > 0 and ', ' or '') or ' and ') .. v .. ' ' .. t[1] .. (v ~= 1 and 's' or ''))
		end
	end
	local ret = table.concat(out)
	if ret:len() < 16 and ret:find("second") then
		local a, b = ret:find(" and ")
		ret = ret:sub(b+1)
	end
	
	return ret
end

 

 

exemplo de báu:

 

function onUse(cid, item, fromPosition, itemEx, toPosition)
	local storage, hours = 18000, 24
	local ip = getPlayerIp(cid)
	local item = 2160
	if getIpStorageValue(ip, storage) - os.time() <= 0 then
		doPlayerSendTextMessage(cid,22,"Tome seu prêmio.")
		setIpStorageValue(ip, storage, os.time()+hours*3600)
		doPlayerAddItem(cid, item, 100) 
		return true
	end 
	return doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT,"Espere " .. timeString(getIpStorageValue(ip, storage) - os.time()) .. " para pegar um novo item!")
end

 

vodkart_logo.png

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

 

DISCORDvodkart#6090

 

Postado
31 minutos atrás, Vodkart disse:

Query para executar

 


CREATE TABLE `ip_storages` (
        `ip` int NOT NULL default 0,
        `key` int NOT NULL default 0,
        `value` varchar(255) NOT NULL default 0
        )

 

 

funções para adicionar

 


function setIpStorageValue(ip, key, value)
	local func = db.executeQuery or db.query
	local query = db.getResult("SELECT `value` FROM `ip_storages` WHERE `key` = "..key.." AND `ip` = "..ip)
	if query:getID() == -1 then
		return func("INSERT INTO `ip_storages` (`ip`, `key`, `value`) VALUES ("..ip..", "..key..", "..value..")")
	end
	return func("UPDATE `ip_storages` SET `value` = "..value.." WHERE `key` = "..key.." AND `ip` = "..ip)
end
function getIpStorageValue(ip, key)
	local ret = db.getResult("SELECT `value` FROM `ip_storages` WHERE `ip` = "..ip.." AND `key` = "..key)
	if ret:getID() == -1 then
		return -1
	end
	return ret:getDataInt("value") or ret:getDataString("value")
end
function timeString(timeDiff)
	local dateFormat = {
		{"day", timeDiff / 60 / 60 / 24},
		{"hour", timeDiff / 60 / 60 % 24},
		{"minute", timeDiff / 60 % 60},
		{"second", timeDiff % 60}
	}
	local out = {}
	for k, t in ipairs(dateFormat) do
		local v = math.floor(t[2])
		if(v > 0) then
			table.insert(out, (k < #dateFormat and (#out > 0 and ', ' or '') or ' and ') .. v .. ' ' .. t[1] .. (v ~= 1 and 's' or ''))
		end
	end
	local ret = table.concat(out)
	if ret:len() < 16 and ret:find("second") then
		local a, b = ret:find(" and ")
		ret = ret:sub(b+1)
	end
	
	return ret
end

 

 

exemplo de báu:

 


function onUse(cid, item, fromPosition, itemEx, toPosition)
	local storage, hours = 18000, 24
	local ip = getPlayerIp(cid)
	local item = 2160
	if getIpStorageValue(ip, storage) - os.time() <= 0 then
		doPlayerSendTextMessage(cid,22,"Tome seu prêmio.")
		setIpStorageValue(ip, storage, os.time()+hours*3600)
		doPlayerAddItem(cid, item, 100) 
		return true
	end 
	return doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT,"Espere " .. timeString(getIpStorageValue(ip, storage) - os.time()) .. " para pegar um novo item!")
end

 

sempre ele <3 

  • 6 months later...
Postado
  • Autor
Em 26/02/2021 em 23:04, Vodkart disse:

Query para executar

 


CREATE TABLE `ip_storages` (
        `ip` int NOT NULL default 0,
        `key` int NOT NULL default 0,
        `value` varchar(255) NOT NULL default 0
        )

 

 

funções para adicionar

 


function setIpStorageValue(ip, key, value)
	local func = db.executeQuery or db.query
	local query = db.getResult("SELECT `value` FROM `ip_storages` WHERE `key` = "..key.." AND `ip` = "..ip)
	if query:getID() == -1 then
		return func("INSERT INTO `ip_storages` (`ip`, `key`, `value`) VALUES ("..ip..", "..key..", "..value..")")
	end
	return func("UPDATE `ip_storages` SET `value` = "..value.." WHERE `key` = "..key.." AND `ip` = "..ip)
end
function getIpStorageValue(ip, key)
	local ret = db.getResult("SELECT `value` FROM `ip_storages` WHERE `ip` = "..ip.." AND `key` = "..key)
	if ret:getID() == -1 then
		return -1
	end
	return ret:getDataInt("value") or ret:getDataString("value")
end
function timeString(timeDiff)
	local dateFormat = {
		{"day", timeDiff / 60 / 60 / 24},
		{"hour", timeDiff / 60 / 60 % 24},
		{"minute", timeDiff / 60 % 60},
		{"second", timeDiff % 60}
	}
	local out = {}
	for k, t in ipairs(dateFormat) do
		local v = math.floor(t[2])
		if(v > 0) then
			table.insert(out, (k < #dateFormat and (#out > 0 and ', ' or '') or ' and ') .. v .. ' ' .. t[1] .. (v ~= 1 and 's' or ''))
		end
	end
	local ret = table.concat(out)
	if ret:len() < 16 and ret:find("second") then
		local a, b = ret:find(" and ")
		ret = ret:sub(b+1)
	end
	
	return ret
end

 

 

exemplo de báu:

 


function onUse(cid, item, fromPosition, itemEx, toPosition)
	local storage, hours = 18000, 24
	local ip = getPlayerIp(cid)
	local item = 2160
	if getIpStorageValue(ip, storage) - os.time() <= 0 then
		doPlayerSendTextMessage(cid,22,"Tome seu prêmio.")
		setIpStorageValue(ip, storage, os.time()+hours*3600)
		doPlayerAddItem(cid, item, 100) 
		return true
	end 
	return doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT,"Espere " .. timeString(getIpStorageValue(ip, storage) - os.time()) .. " para pegar um novo item!")
end

 

 

 

 

eu voltei a mexer no meu ot a pouco tempo, essas funções eu coloco em Creaturescript?

  • 7 months later...

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

Quem Está Navegando 0

  • Nenhum usuário registrado visualizando esta página.

Conteúdo Similar

Estatísticas dos Fóruns

  • Tópicos 96.9k
  • Posts 519.7k

Informação Importante

Confirmação de Termo