Ir para conteúdo

Featured Replies

Postado

Bom, eu tenho esse script que é de um last man standing, porem ele é por interval... modifiquei para onTime para acontecer tal hora...

porém acho que era preciso o onthink pro script ficar verificando quem é a ultima pessoa da sala determinada por {x,y,z}  {x,y,z}, mas eu queria por onTime... porque onthink é muito bbagunçado, depende muito da hora que abre o servidor, acredito eu.

resumindo o problema: como fazer para que o script verifique a quantidade de players da sala a todo momento e mesmo assim poder realizer o onTime para eu determinar o horario do evento?... vale lembrar que existe outro script onde cria teleport e manda para a sala... mas nao tem nada de necessario nele.
 

Spoiler

local t = {
 tmp = {
 {x = 1165, y = 1336, z = 7}, -- esquerda nort sala de espera
 {x = 1177, y = 1348, z = 7} -- sul direita sala de espera
 },
 arena = {
 {x = 1145, y = 1278, z = 7}, -- North west Corner of Arena
 {x = 1197, y = 1330, z = 7}, -- South East corner of Arena
 {x = 1171, y = 1304, z = 7} -- Center of Arena
 },
 
 from = {x = 1145, y = 1278, z = 7}, -- Top left cornor of the playground (random players teleportation)
 to = {x = 1197, y = 1330, z = 7}, -- Bottom right cornor of the playground (random players teleportation)
 
 minPlayers = 2, -- min players required to start the battle
 noPlayers = 1, -- Leave it as it is
 prize = {6527} -- Reward that player recives
 }
 local kick = 0
 
 function onTime()
 local arenaPlayers = {}
 
 for x = t.arena[1].x, t.arena[2].x do
 for y = t.arena[1].y, t.arena[2].y do
 for z = t.arena[1].z, t.arena[2].z do
 local pos = {x = x, y = y, z = z}
 local n = getTileInfo(pos).creatures
 if n ~= 0 then
 pos.stackpos = 1
 local c = getThingfromPos(pos)
 while c.uid ~= 0 do
 if c.itemid == 1 and c.type == 1 then
 table.insert(arenaPlayers, c.uid)
 if #arenaPlayers == n then
break
 end
 end
 pos.stackpos = pos.stackpos + 1
 c = getThingfromPos(pos)
 end
 end
 end
 end
 end
 
 if #arenaPlayers == 1 then
local p = getPlayerMasterPos(arenaPlayers[1])
 doTeleportThing(arenaPlayers[1], p)
 doSendMagicEffect(p, CONST_ME_TELEPORT)
 doPlayerSendTextMessage(arenaPlayers[1], MESSAGE_STATUS_CONSOLE_BLUE, "You have won the event and received your reward.")
 doBroadcastMessage(getCreatureName(arenaPlayers[1]) .." won a Last Man Standing Event.")
 doPlayerAddItem(arenaPlayers[1], t.prize[math.random(#t.prize)], 10)
kick = 0
 elseif #arenaPlayers > 1 then
if kick == 0 then
 kick = os.time()
 else
 if os.time() - kick >= 840 then
 kick = 0
 for i = 1, #arenaPlayers do
doTeleportThing(arenaPlayers, {x=160, y=54, z=7})
 doPlayerSendTextMessage(arenaPlayers, MESSAGE_STATUS_WARNING, "Too even, try harder next time.")
 end
 end
 end
 elseif #arenaPlayers == 0 then
kick = 0
 
 local players = {}
 for x = t.tmp[1].x, t.tmp[2].x do
 for y = t.tmp[1].y, t.tmp[2].y do
 for z = t.tmp[1].z, t.tmp[2].z do
 local c = getTopCreature({x = x, y = y, z = z})
 if c.type == 1 then
 table.insert(players, c.uid)
 end
 end
 end
 end
 
 if #players >= t.minPlayers then
for i = 1, #players do
local p = {x = math.random(t.from.x, t.to.x), y = math.random(t.from.y, t.to.y), z = math.random(t.from.z, t.to.z)}
 doTeleportThing(players, p)
 doSendMagicEffect(p, CONST_ME_TELEPORT)
 doPlayerSendTextMessage(players, MESSAGE_STATUS_WARNING, "The battle begins. Survive for glory!")
 end
else
 for i = 1, #players do
doTeleportThing(players, {x=160, y=54, z=7})
 doPlayerSendTextMessage(players, MESSAGE_STATUS_WARNING, "The event didn't start because there isn't enough players in area!")
 end
 end
 end
 return true
 end

 

Editado por pablobion (veja o histórico de edições)

Scriptszinhos:

 

Não abandone seu tópico, quando você tiver a dúvida resolvida sozinho tente ensinar aos outros como resolve-la (você pode não ser o único com o problema) e quando ela for resolvida por outra pessoa não se esqueça de marcar como melhor resposta e deixar o gostei.

  • Respostas 7
  • Visualizações 557
  • Created
  • Última resposta

Top Posters In This Topic

Most Popular Posts

  • @pablobion onThink é meio bagunçado ? Cara, era só usar os.date para iniciar o evento nos dias desejado, usava os.date para checkar a hora, e começava todo dia em tal hora, em qualquer hora, duas, trê

  • @pablobion sim li sim, você não compreendeu o que falei, mas esqueça. Esse arquivo que você deseja a modificação, realiza as checkagens, coloque nele um tempo de check, não não irá demorar, e que não

  • @pablobion você falou algo que está certo, seu pensamento foi de um verdadeiro programador, pensou nos erros que poderiam dar. Mas em fim: se você tem o onTime() que está iniciando o evento na ho

Postado

@pablobion onThink é meio bagunçado ? Cara, era só usar os.date para iniciar o evento nos dias desejado, usava os.date para checkar a hora, e começava todo dia em tal hora, em qualquer hora, duas, três vezes ao dia, configurando corretamente:

Ex: 

local dh = {
["Monday"] = {now = "11:20:00"},

["Wednesday"] = {now = "17:35:00"},

["Saturday"] = {now = "11:52:00"},

["Sunday"] = {now = "11:54:00"}
}

if dh[os.date("%A")] then
if os.date("%X") >= dh[os.date("%A")].now then
 TibiaKingSay("O Evento TibiaKing irá começar!")
  ----- Funçoes                                                                      
 end
end                                                                       

O evento iria iniciar nesses dias nesses horarios. Em fim, se entendi bem, o evento inicia perfeitamente em tal horário, mas não o onThink para realizar os checks corretamente certo ?

 

                                                              ezgif-1-98aab239f3.gif.1a897c9c3225228909e7b356a5cfb8e4.gif

Postado
  • Autor
2 minutos atrás, KotZletY disse:

@pablobion onThink é meio bagunçado ? Cara, era só usar os.date para iniciar o evento nos dias desejado, usava os.date para checkar a hora, e começava todo dia em tal hora, em qualquer hora, duas, três vezes ao dia, configurando corretamente:

Ex: 


local dh = {
["Monday"] = {now = "11:20:00"},

["Wednesday"] = {now = "17:35:00"},

["Saturday"] = {now = "11:52:00"},

["Sunday"] = {now = "11:54:00"}
}

if dh[os.date("%A")] then
if os.date("%X") >= dh[os.date("%A")].now then
 TibiaKingSay("O Evento TibiaKing irá começar!")
  ----- Funçoes                                                                      
 end
end                                                                       

O evento iria iniciar nesses dias nesses horarios. Em fim, se entendi bem, o evento inicia perfeitamente em tal horário, mas não o onThink para realizar os checks corretamente certo ?

 

 

2 minutos atrás, KotZletY disse:

@pablobion onThink é meio bagunçado ? Cara, era só usar os.date para iniciar o evento nos dias desejado, usava os.date para checkar a hora, e começava todo dia em tal hora, em qualquer hora, duas, três vezes ao dia, configurando corretamente:

Ex: 


local dh = {
["Monday"] = {now = "11:20:00"},

["Wednesday"] = {now = "17:35:00"},

["Saturday"] = {now = "11:52:00"},

["Sunday"] = {now = "11:54:00"}
}

if dh[os.date("%A")] then
if os.date("%X") >= dh[os.date("%A")].now then
 TibiaKingSay("O Evento TibiaKing irá começar!")
  ----- Funçoes                                                                      
 end
end                                                                       

O evento iria iniciar nesses dias nesses horarios. Em fim, se entendi bem, o evento inicia perfeitamente em tal horário, mas não o onThink para realizar os checks corretamente certo ?

 


Sim eu ja uso os.date falei ali no tópico que existe um script que ja inicia o evento.. mas usando date nesse ai so executa uma vez.. e nao fica checando a area para ver quando tem 1 player... mano vc leu o tópico?

Scriptszinhos:

 

Não abandone seu tópico, quando você tiver a dúvida resolvida sozinho tente ensinar aos outros como resolve-la (você pode não ser o único com o problema) e quando ela for resolvida por outra pessoa não se esqueça de marcar como melhor resposta e deixar o gostei.

Postado

@pablobion sim li sim, você não compreendeu o que falei, mas esqueça. Esse arquivo que você deseja a modificação, realiza as checkagens, coloque nele um tempo de check, não não irá demorar, e que não irá lagar, de 30s a 1 min, está ótimo, mas minha opinião não vale nada, então releve! hKaokspoaks

 

Spoiler

local t = {
 tmp = {
 {x = 1165, y = 1336, z = 7}, -- esquerda nort sala de espera
 {x = 1177, y = 1348, z = 7} -- sul direita sala de espera
 },
 arena = {
 {x = 1145, y = 1278, z = 7}, -- North west Corner of Arena
 {x = 1197, y = 1330, z = 7}, -- South East corner of Arena
 {x = 1171, y = 1304, z = 7} -- Center of Arena
 },
 
 from = {x = 1145, y = 1278, z = 7}, -- Top left cornor of the playground (random players teleportation)
 to = {x = 1197, y = 1330, z = 7}, -- Bottom right cornor of the playground (random players teleportation)
 
 minPlayers = 2, -- min players required to start the battle
 noPlayers = 1, -- Leave it as it is
 prize = {6527} -- Reward that player recives
 }
 local kick = 0
 
function onThink(interval)
 local arenaPlayers = {}
 
 for x = t.arena[1].x, t.arena[2].x do
 for y = t.arena[1].y, t.arena[2].y do
 for z = t.arena[1].z, t.arena[2].z do
 local pos = {x = x, y = y, z = z}
 local n = getTileInfo(pos).creatures
 if n ~= 0 then
 pos.stackpos = 1
 local c = getThingfromPos(pos)
 while c.uid ~= 0 do
 if c.itemid == 1 and c.type == 1 then
 table.insert(arenaPlayers, c.uid)
 if #arenaPlayers == n then
break
 end
 end
 pos.stackpos = pos.stackpos + 1
 c = getThingfromPos(pos)
 end
 end
 end
 end
 end
 
 if #arenaPlayers == 1 then
local p = getPlayerMasterPos(arenaPlayers[1])
 doTeleportThing(arenaPlayers[1], p)
 doSendMagicEffect(p, CONST_ME_TELEPORT)
 doPlayerSendTextMessage(arenaPlayers[1], MESSAGE_STATUS_CONSOLE_BLUE, "You have won the event and received your reward.")
 doBroadcastMessage(getCreatureName(arenaPlayers[1]) .." won a Last Man Standing Event.")
 doPlayerAddItem(arenaPlayers[1], t.prize[math.random(#t.prize)], 10)
kick = 0
 elseif #arenaPlayers > 1 then
if kick == 0 then
 kick = os.time()
 else
 if os.time() - kick >= 840 then
 kick = 0
 for i = 1, #arenaPlayers do
doTeleportThing(arenaPlayers, {x=160, y=54, z=7})
 doPlayerSendTextMessage(arenaPlayers, MESSAGE_STATUS_WARNING, "Too even, try harder next time.")
 end
 end
 end
 elseif #arenaPlayers == 0 then
kick = 0
 
 local players = {}
 for x = t.tmp[1].x, t.tmp[2].x do
 for y = t.tmp[1].y, t.tmp[2].y do
 for z = t.tmp[1].z, t.tmp[2].z do
 local c = getTopCreature({x = x, y = y, z = z})
 if c.type == 1 then
 table.insert(players, c.uid)
 end
 end
 end
 end
 
 if #players >= t.minPlayers then
for i = 1, #players do
local p = {x = math.random(t.from.x, t.to.x), y = math.random(t.from.y, t.to.y), z = math.random(t.from.z, t.to.z)}
 doTeleportThing(players, p)
 doSendMagicEffect(p, CONST_ME_TELEPORT)
 doPlayerSendTextMessage(players, MESSAGE_STATUS_WARNING, "The battle begins. Survive for glory!")
 end
else
 for i = 1, #players do
doTeleportThing(players, {x=160, y=54, z=7})
 doPlayerSendTextMessage(players, MESSAGE_STATUS_WARNING, "The event didn't start because there isn't enough players in area!")
 end
 end
 end
 return true
 end

 

 

<globalevent name="EventoNãoSeiOque" interval="60000" event="script" value="NomeDesseArquivo.lua"/>

 

                                                              ezgif-1-98aab239f3.gif.1a897c9c3225228909e7b356a5cfb8e4.gif

Postado
  • Autor
19 minutos atrás, KotZletY disse:

@pablobion sim li sim, você não compreendeu o que falei, mas esqueça. Esse arquivo que você deseja a modificação, realiza as checkagens, coloque nele um tempo de check, não não irá demorar, e que não irá lagar, de 30s a 1 min, está ótimo, mas minha opinião não vale nada, então releve! hKaokspoaks

 

  Ocultar conteúdo


local t = {
 tmp = {
 {x = 1165, y = 1336, z = 7}, -- esquerda nort sala de espera
 {x = 1177, y = 1348, z = 7} -- sul direita sala de espera
 },
 arena = {
 {x = 1145, y = 1278, z = 7}, -- North west Corner of Arena
 {x = 1197, y = 1330, z = 7}, -- South East corner of Arena
 {x = 1171, y = 1304, z = 7} -- Center of Arena
 },
 
 from = {x = 1145, y = 1278, z = 7}, -- Top left cornor of the playground (random players teleportation)
 to = {x = 1197, y = 1330, z = 7}, -- Bottom right cornor of the playground (random players teleportation)
 
 minPlayers = 2, -- min players required to start the battle
 noPlayers = 1, -- Leave it as it is
 prize = {6527} -- Reward that player recives
 }
 local kick = 0
 
function onThink(interval)
 local arenaPlayers = {}
 
 for x = t.arena[1].x, t.arena[2].x do
 for y = t.arena[1].y, t.arena[2].y do
 for z = t.arena[1].z, t.arena[2].z do
 local pos = {x = x, y = y, z = z}
 local n = getTileInfo(pos).creatures
 if n ~= 0 then
 pos.stackpos = 1
 local c = getThingfromPos(pos)
 while c.uid ~= 0 do
 if c.itemid == 1 and c.type == 1 then
 table.insert(arenaPlayers, c.uid)
 if #arenaPlayers == n then
break
 end
 end
 pos.stackpos = pos.stackpos + 1
 c = getThingfromPos(pos)
 end
 end
 end
 end
 end
 
 if #arenaPlayers == 1 then
local p = getPlayerMasterPos(arenaPlayers[1])
 doTeleportThing(arenaPlayers[1], p)
 doSendMagicEffect(p, CONST_ME_TELEPORT)
 doPlayerSendTextMessage(arenaPlayers[1], MESSAGE_STATUS_CONSOLE_BLUE, "You have won the event and received your reward.")
 doBroadcastMessage(getCreatureName(arenaPlayers[1]) .." won a Last Man Standing Event.")
 doPlayerAddItem(arenaPlayers[1], t.prize[math.random(#t.prize)], 10)
kick = 0
 elseif #arenaPlayers > 1 then
if kick == 0 then
 kick = os.time()
 else
 if os.time() - kick >= 840 then
 kick = 0
 for i = 1, #arenaPlayers do
doTeleportThing(arenaPlayers, {x=160, y=54, z=7})
 doPlayerSendTextMessage(arenaPlayers, MESSAGE_STATUS_WARNING, "Too even, try harder next time.")
 end
 end
 end
 elseif #arenaPlayers == 0 then
kick = 0
 
 local players = {}
 for x = t.tmp[1].x, t.tmp[2].x do
 for y = t.tmp[1].y, t.tmp[2].y do
 for z = t.tmp[1].z, t.tmp[2].z do
 local c = getTopCreature({x = x, y = y, z = z})
 if c.type == 1 then
 table.insert(players, c.uid)
 end
 end
 end
 end
 
 if #players >= t.minPlayers then
for i = 1, #players do
local p = {x = math.random(t.from.x, t.to.x), y = math.random(t.from.y, t.to.y), z = math.random(t.from.z, t.to.z)}
 doTeleportThing(players, p)
 doSendMagicEffect(p, CONST_ME_TELEPORT)
 doPlayerSendTextMessage(players, MESSAGE_STATUS_WARNING, "The battle begins. Survive for glory!")
 end
else
 for i = 1, #players do
doTeleportThing(players, {x=160, y=54, z=7})
 doPlayerSendTextMessage(players, MESSAGE_STATUS_WARNING, "The event didn't start because there isn't enough players in area!")
 end
 end
 end
 return true
 end

 

 


<globalevent name="EventoNãoSeiOque" interval="60000" event="script" value="NomeDesseArquivo.lua"/>

 


Fui tomar banho e fiquei pensando sobre... eu me equivoquei naquela mensagem ali e não tive tempo de editar kkkk consegui entender a linha de raciocínio... é que eu pensei que onthink era apenas por milissegundos e não pudesse usar hora e dias como o onTime, foi mal...

mas eu tenho uma duvida... fazendo isso ira fazer com que o globalevent execute a cada 1 min certo?
O teleport do evento fica aberto 5 min então tera 5 eventos? porque o player pode entrar por 5 min e o script executa a cada 1 min...

e também se eu colocar 5 min no interval pode acontecer de o interval acabar 30 segundos depois de abrir o tp do evento e os players que entraram nesses 30 segs vao fazer um evento apenas entre eles..

enfim confuso

vou tentar dar meu jeito... obrigado por me ensinar o time peno onthink :D rep

Editado por pablobion (veja o histórico de edições)

Scriptszinhos:

 

Não abandone seu tópico, quando você tiver a dúvida resolvida sozinho tente ensinar aos outros como resolve-la (você pode não ser o único com o problema) e quando ela for resolvida por outra pessoa não se esqueça de marcar como melhor resposta e deixar o gostei.

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.

Estatísticas dos Fóruns

  • Tópicos 96.9k
  • Posts 519.6k

Informação Importante

Confirmação de Termo