Ir para conteúdo

Featured Replies

Postado

.Qual servidor ou website você utiliza como base? 

tfs 0.4

Qual o motivo deste tópico? 

Gostaria de saber como ADICIONAR nesse sistema abaixo uma limitação de players.

O sistema considera todos os players online, porém, gostaria de uma verificação também onde ele descartaria os players exitados em trainer!

No caso, pode ser tanto uma limitação por Coordenadas, quanto por tiles(optional, pvp etc)

Você tem o código disponível? Se tiver publique-o aqui: 

Citar

 

 

 

Resolvido por Vodkart

Ir para solução
  • Respostas 6
  • Visualizações 875
  • Created
  • Última resposta

Top Posters In This Topic

Most Popular Posts

  • troca a função la do sistema por essa:     local function getOnlineParticipants() local players = {} for _, pid in pairs(getPlayersOnline()) do if getPlayerAccess(pid) &l

  • Justamente, por isso a adaptação...     usa o código lá do global events assim:     local config = { lottery_hour = "2 hours", -- Tempo ate a proxima loteria (Esse tempo

Postado
  • Este é um post popular.

troca a função la do sistema por essa:

 

 

local function getOnlineParticipants()
    local players = {}
    for _, pid in pairs(getPlayersOnline()) do
        if getPlayerAccess(pid) <= 2 and getPlayerStorageValue(pid, 281821) <= os.time() and  getPlayerStorageValue(pid, 281822) <= os.time() then
            table.insert(players, pid)
        end
    end
    if #players > 0 then
        return players
    end
    return false
end

 

 

e no creaturescript:

 

 

function onLogin(cid)
	registerCreatureEvent(cid, "LoterryTreiner")
	setPlayerStorageValue(cid, 281822, 0)
	return true
end
function onCombat(cid, target)
	local treiners = {"Trainer", "Training Monk"} -- nome dos trainera do seu ot
	if isPlayer(cid) and isMonster(target) and isInArray(treiners, getCreatureName(target)) then
		setPlayerStorageValue(cid, 281822, os.time()+15)
	end 	
	return true
end

 

vodkart_logo.png

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

 

DISCORDvodkart#6090

 

Postado
  • Autor
6 horas atrás, Vodkart disse:

troca a função la do sistema por essa:

 

 


local function getOnlineParticipants()
    local players = {}
    for _, pid in pairs(getPlayersOnline()) do
        if getPlayerAccess(pid) <= 2 and getPlayerStorageValue(pid, 281821) <= os.time() and  getPlayerStorageValue(pid, 281822) <= os.time() then
            table.insert(players, pid)
        end
    end
    if #players > 0 then
        return players
    end
    return false
end

 

 

e no creaturescript:

 

 


function onLogin(cid)
	registerCreatureEvent(cid, "LoterryTreiner")
	setPlayerStorageValue(cid, 281822, 0)
	return true
end
function onCombat(cid, target)
	local treiners = {"Trainer", "Training Monk"} -- nome dos trainera do seu ot
	if isPlayer(cid) and isMonster(target) and isInArray(treiners, getCreatureName(target)) then
		setPlayerStorageValue(cid, 281822, os.time()+15)
	end 	
	return true
end

 

 

Meio burro da minha parte, porém, onde seria isso do creaturescript?

O script em si não utiliza nada no mesmo ?

Postado
  • Solução
1 minuto atrás, Petergbc disse:

 

Meio burro da minha parte, porém, onde seria isso do creaturescript?

O script em si não utiliza nada no mesmo ?

 

Justamente, por isso a adaptação...

 

 

usa o código lá do global events assim:

 

 

local config = {
	lottery_hour = "2 hours", -- Tempo ate a proxima loteria (Esse tempo vai aparecer somente como broadcast message)
	rewards_id = {2494, 2472, 2514, 2160}, -- ID dos Itens Sorteados na Loteria
	crystal_counts = 10, -- Usado somente se a rewards_id for crystal coin (ID: 2160).
	website = "yes", -- Only if you have php scripts and table `lottery` in your database!
	days = {
		"Monday-08:00",
		"Monday-13:00",
		"Monday-19:30",
		
		"Tuesday-08:00",
		"Tuesday-13:00",
		"Tuesday-19:30",
		
		"Wednesday-08:00",
		"Wednesday-13:00",
		"Wednesday-19:30",
		
		"Thursday-08:00",
		"Thursday-13:00",
		"Thursday-19:30",
		
		"Friday-01:22",
		"Friday-13:00",
		"Friday-19:30",
		
		"Saturday-21:27",
		"Saturday-21:28",
		"Saturday-21:29",
		
		"Sunday-08:00",
		"Sunday-13:00",
		"Sunday-19:30"
	}
}
local function getPlayerWorldId(cid)
	if not(isPlayer(cid)) then
		return false
	end
	local pid = getPlayerGUID(cid)
	local worldPlayer = 0
	local result_plr = db.getResult("SELECT * FROM `players` WHERE `id` = "..pid..";")
	if(result_plr:getID() ~= -1) then
		worldPlayer = tonumber(result_plr:getDataInt("world_id"))
		result_plr:free()
		return worldPlayer
	end
	return false
end

local function getOnlineParticipants()
	local players = {}
	for _, pid in pairs(getPlayersOnline()) do
		if getPlayerAccess(pid) <= 2 and getPlayerStorageValue(pid, 281821) <= os.time() and getPlayerStorageValue(pid, 281822) <= os.time() then
			table.insert(players, pid)
		end
	end
	if #players > 0 then
		return players
	end
	return false
end

function onThink(cid, interval)
	if table.find(config.days, os.date("%A-%H:%M")) then
		if(getWorldCreatures(o) <= 0)then
			return true
		end
		
		local query = db.query or db.executeQuery
		local random_item = config.rewards_id[math.random(1, #config.rewards_id)]
		local item_name = getItemNameById(random_item) 
		local data = os.date("%d/%m/%Y - %H:%M:%S")
		local online = getOnlineParticipants()
		
		if online then
			local winner = online[math.random(1, #online)]
			local world = tonumber(getPlayerWorldId(winner))
			
			if(random_item == 2160) then
				doPlayerSetStorageValue(winner, 281821, os.time() + 3600 * 24)
				doPlayerAddItem(winner, random_item, config.crystal_counts)
				doBroadcastMessage("[LOTTERY SYSTEM] Winner: " .. getCreatureName(winner) .. ", Reward: " .. config.crystal_counts .." " .. getItemNameById(random_item) .. "s! Congratulations! (Next lottery in " .. config.lottery_hour .. ")")
			else
				doPlayerSetStorageValue(winner, 281821, os.time() + 3600 * 24)
				doBroadcastMessage("[LOTTERY SYSTEM] Winner: " .. getCreatureName(winner) .. ", Reward: " ..getItemNameById(random_item) .. "! Congratulations! (Next lottery in " .. config.lottery_hour .. ")")
				doPlayerAddItem(winner, random_item, 1)
			end
			if(config.website == "yes") then
				query("INSERT INTO `lottery` (`name`, `item`, `world_id`, `item_name`, `date`) VALUES ('".. getCreatureName(winner).."', '".. random_item .."', '".. world .."', '".. item_name .."', '".. data .."');")
			end
		else
			print("Ninguem OnLine pra ganhar na loteria")
		end
	end
	return true
end

 

 

 

e o script que eu te passei vc coloca em creaturescript

 

 

lotrainer.lua

function onLogin(cid)
	registerCreatureEvent(cid, "LoterryTreiner")
	setPlayerStorageValue(cid, 281822, 0)
	return true
end
function onCombat(cid, target)
	local treiners = {"Trainer", "Training Monk"} -- nome dos trainera do seu ot
	if isPlayer(cid) and isMonster(target) and isInArray(treiners, getCreatureName(target)) then
		setPlayerStorageValue(cid, 281822, os.time()+15)
	end 	
	return true
end

 

TAG no xml

 

	<event type="login" name="LoterryLogin" event="script" value="lotrainer.lua"/>
	<event type="combat" name="LoterryTreiner" event="script" value="lotrainer.lua"/>

 

vodkart_logo.png

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

 

DISCORDvodkart#6090

 

Postado
  • Autor
12 minutos atrás, Vodkart disse:

 

Justamente, por isso a adaptação...

 

 

usa o código lá do global events assim:

 

 


local config = {
	lottery_hour = "2 hours", -- Tempo ate a proxima loteria (Esse tempo vai aparecer somente como broadcast message)
	rewards_id = {2494, 2472, 2514, 2160}, -- ID dos Itens Sorteados na Loteria
	crystal_counts = 10, -- Usado somente se a rewards_id for crystal coin (ID: 2160).
	website = "yes", -- Only if you have php scripts and table `lottery` in your database!
	days = {
		"Monday-08:00",
		"Monday-13:00",
		"Monday-19:30",
		
		"Tuesday-08:00",
		"Tuesday-13:00",
		"Tuesday-19:30",
		
		"Wednesday-08:00",
		"Wednesday-13:00",
		"Wednesday-19:30",
		
		"Thursday-08:00",
		"Thursday-13:00",
		"Thursday-19:30",
		
		"Friday-01:22",
		"Friday-13:00",
		"Friday-19:30",
		
		"Saturday-21:27",
		"Saturday-21:28",
		"Saturday-21:29",
		
		"Sunday-08:00",
		"Sunday-13:00",
		"Sunday-19:30"
	}
}
local function getPlayerWorldId(cid)
	if not(isPlayer(cid)) then
		return false
	end
	local pid = getPlayerGUID(cid)
	local worldPlayer = 0
	local result_plr = db.getResult("SELECT * FROM `players` WHERE `id` = "..pid..";")
	if(result_plr:getID() ~= -1) then
		worldPlayer = tonumber(result_plr:getDataInt("world_id"))
		result_plr:free()
		return worldPlayer
	end
	return false
end

local function getOnlineParticipants()
	local players = {}
	for _, pid in pairs(getPlayersOnline()) do
		if getPlayerAccess(pid) <= 2 and getPlayerStorageValue(pid, 281821) <= os.time() and getPlayerStorageValue(pid, 281822) <= os.time() then
			table.insert(players, pid)
		end
	end
	if #players > 0 then
		return players
	end
	return false
end

function onThink(cid, interval)
	if table.find(config.days, os.date("%A-%H:%M")) then
		if(getWorldCreatures(o) <= 0)then
			return true
		end
		
		local query = db.query or db.executeQuery
		local random_item = config.rewards_id[math.random(1, #config.rewards_id)]
		local item_name = getItemNameById(random_item) 
		local data = os.date("%d/%m/%Y - %H:%M:%S")
		local online = getOnlineParticipants()
		
		if online then
			local winner = online[math.random(1, #online)]
			local world = tonumber(getPlayerWorldId(winner))
			
			if(random_item == 2160) then
				doPlayerSetStorageValue(winner, 281821, os.time() + 3600 * 24)
				doPlayerAddItem(winner, random_item, config.crystal_counts)
				doBroadcastMessage("[LOTTERY SYSTEM] Winner: " .. getCreatureName(winner) .. ", Reward: " .. config.crystal_counts .." " .. getItemNameById(random_item) .. "s! Congratulations! (Next lottery in " .. config.lottery_hour .. ")")
			else
				doPlayerSetStorageValue(winner, 281821, os.time() + 3600 * 24)
				doBroadcastMessage("[LOTTERY SYSTEM] Winner: " .. getCreatureName(winner) .. ", Reward: " ..getItemNameById(random_item) .. "! Congratulations! (Next lottery in " .. config.lottery_hour .. ")")
				doPlayerAddItem(winner, random_item, 1)
			end
			if(config.website == "yes") then
				query("INSERT INTO `lottery` (`name`, `item`, `world_id`, `item_name`, `date`) VALUES ('".. getCreatureName(winner).."', '".. random_item .."', '".. world .."', '".. item_name .."', '".. data .."');")
			end
		else
			print("Ninguem OnLine pra ganhar na loteria")
		end
	end
	return true
end

 

 

 

e o script que eu te passei vc coloca em creaturescript

 

 

lotrainer.lua


function onLogin(cid)
	registerCreatureEvent(cid, "LoterryTreiner")
	setPlayerStorageValue(cid, 281822, 0)
	return true
end
function onCombat(cid, target)
	local treiners = {"Trainer", "Training Monk"} -- nome dos trainera do seu ot
	if isPlayer(cid) and isMonster(target) and isInArray(treiners, getCreatureName(target)) then
		setPlayerStorageValue(cid, 281822, os.time()+15)
	end 	
	return true
end

 

TAG no xml

 


	<event type="login" name="LoterryLogin" event="script" value="lotrainer.lua"/>
	<event type="combat" name="LoterryTreiner" event="script" value="lotrainer.lua"/>

 

 

Adicionado sem erro algum!

Infelizmente será difícil testar na prática, pois os que ja estão exitados precisariam relogar para a storage resetar.

Resolvi também o "problema" de quando o player parar de atacar o player ele precisar relogar para a storage resetar, simplesmente coloquei para o teleport de saida reconectar o player logo em seguida!

 

Mas testando, na teoria é para funcionar, o script está perfeito e está também aplicando o tempo na storage 281822, duvido que irá dar algum erro.

Caso ocorra algo, aviso aqui.

 

Obrigado!

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.6k

Informação Importante

Confirmação de Termo