Jump to content
Sign in to follow this  
Mock

Otserv checker em lua.

Recommended Posts

Mock    32
Mock

Eu fiz essa função so zuando mesmo :P ela ve se um server esta online e se tiver tras as informações em uma tabela.

function getOtservInfo(ip,port)
--- function by mock
local conect = socket.connect(ip,port)
if conect then
	conect:send(string.char(0x06,0x00,0xff,0xff)..'info')
	local _,status,b = conect:receive(1024)
	conect:close()
	if b and b ~= '' then
		info = {
		name = b:match('servername="(.-)"'),
		location = b:match('location="(.-)"'),
		site = b:match('url="(.-)"'),
		server = b:match('server="(.-)"'),
		server_version = b:match('version="(.-)"'),
		client = b:match('client="(.-)"'),
		online = b:match('online="(.-)"'),
		omax = b:match('max="(.-)"'),
		peak = b:match('peak="(.-)"'),
		motd = b:match('<motd>(.+)</motd>'),
		xml = b,
		}
		return info
	end
else
	return nil
end
end

na tabela eu nao coloquei todas as informaçoes mais a maioria tem, ainda coloquei pra retornar o XML que ele envia pra vc. mais se quiser pode mudar. auqi é um exemplo de um XML retornado por um otserv.

<?xml version="1.0"?>
<tsqp version="1.0"><serverinfo uptime="123" ip="localhost" servername="qq" port="7171" location="nemsei" url="otnet" server="tfs" version="0.2" client="8.12"/><owner name="www.com.br" email="[email protected]"/><players online="73" max="200" peak="203"/><monsters total="4664"/><map name="map" author="ADM" width="3456" height="4078"/>
<motd>
ririrairariairaari
</motd>
</tsqp>

Edited by Mickfern

Share this post


Link to post
Share on other sites
matheusmacena    0
matheusmacena

hmm, não entendi bem da pra explicar so meio novo

Share this post


Link to post
Share on other sites
god guizao    0
god guizao

Pois é, tbm não entendi direito

Share this post


Link to post
Share on other sites
Mock    32
Mock

gente isso aki n é conteudo pra iniciantes em scripting nao :S

Share this post


Link to post
Share on other sites
EcL    3
EcL

/\ [mockseachandomodeon/]

Ficou altus do pode cre mano, nem da pra acredita no que tu faz em lua *.*

Share this post


Link to post
Share on other sites
Marley_    0
Marley_

pra qe serve isso

Share this post


Link to post
Share on other sites
Mock    32
Mock

@Marley_

ler o topico ajuda viu?

nao o topico mais o nome do topico :coolface:

Share this post


Link to post
Share on other sites
Mock    32
Mock

@Marley_

ler o topico ajuda viu?

nao o topico mais o nome do topico :coolface:

Share this post


Link to post
Share on other sites
Conde2    0
Conde2

Vlw mock muito bom XD

Ruim que se for utilizar em servidor vai precisar da otal =s

Mais se for utilizar no Scite tem problema nao xD

 

Ow como vc descobriu os numeros que se tem que pedir pro servidor responder o que vc quer?

Fiquei intrigado com isso =O

Share this post


Link to post
Share on other sites
Mock    32
Mock

@[V]Conde2

otfans amigo :P

eu 1º vi la depois eu vi no otchecker em PHP

Share this post


Link to post
Share on other sites
Mock    32
Mock

@[V]Conde2

otfans amigo :P

eu 1º vi la depois eu vi no otchecker em PHP

Share this post


Link to post
Share on other sites
GDLib    2
GDLib

Só uma coisa: o protocolo do OpenTibia envia dados na forma binária, que é muito mais rápido. Deixe o XML para newbies ;D

Share this post


Link to post
Share on other sites
Mock    32
Mock

Sim nostra, eu fiquei curioso hoje demanhã para saber como era o protocol do tibia ai criei isso:

require('socket')
local skt = socket.bind('*',7171)
local tibia = skt:accept()
repeat
 s,b = tibia:receive(10)
print(s)
until b == 'closed'
print('closed')

e ele retornou isso:

ª,K‡,KÓ

ÃåJˆ©Ð¢ý”œ

G£5ôF›´`ÖÇ

d†|¹²´šd®

Ú£U¹Ë»Ò™*

ãW>3õ8®Å

¬Ò‡ß£bõ(ãV

£”

ʰ|LÒf

mT

 

ß t¼

Ј…âëU¿Ã

c¾šìˆðVuõ1

ÞÈ–9ªââàŒé

ž}kô¡ƒ

ì6

éuÁ[‡:ˆÒ

:P

Edited by Mickfern

Share this post


Link to post
Share on other sites
GDLib    2
GDLib

Veja a classe de status do POT, mas você terá de entender um pouco de PHP.

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×