Raphael Carnaúba 1 #1 Posted March 31, 2007 Fiz esse code a 2 dias atrás, mais não quiz liberar...depois de meus amigos pedirem descidi liberar pra OTNET (SVN) Vá em otserv.cpp e procure por : if(argc > 1) ip = argv[1]; else ip = g_config.getString(ConfigManager::IP); Substitua por: if( g_config.getString(ConfigManager::IP) == "auto" ) { if( gethostname( szHostName , 128) == 0 ) { struct hostent* he = gethostbyname( szHostName ); if( he != NULL ) { ip = inet_ntoa( * ( reinterpret_cast< in_addr* >( he->h_addr ))); } } } else{ if(argc > 1) ip = argv[1]; else ip = g_config.getString(ConfigManager::IP); } Se você usa Forgotten Server ou Evolutions: Procure por: ip = g_config.getString(ConfigManager::IP); Substitua por: if( g_config.getString(ConfigManager::IP) == "auto" ) { if( gethostname( szHostName , 128) == 0 ) { struct hostent* he = gethostbyname( szHostName ); if( he != NULL ) { ip = inet_ntoa( * ( reinterpret_cast< in_addr* >( he->h_addr ))); } } } else{ ip = g_config.getString(ConfigManager::IP); } Auto IP Terminado Agora se você quer algo diferente como por exemplo você colocar no seu ip no config.lua seuserver.servegame.com Use esse codigo: (SVN) Procure por: if(argc > 1) ip = argv[1]; else ip = g_config.getString(ConfigManager::IP); E substitua por : struct hostent* he = gethostbyname(g_config.getString(ConfigManager::IP)); if( he != NULL ) { ip = inet_ntoa( * ( reinterpret_cast< in_addr* >( he->h_addr ))); } else{ std::cout << "Could not resolve host address " << ip << std::endl; std::cout << "IP now is 127.0.0.1" << std::endl; ip = "127.0.0.1"; } Se você usa Evolutions ou Forgotten Server: Troque: ip = g_config.getString(ConfigManager::IP); por: struct hostent* he = gethostbyname(g_config.getString(ConfigManager::IP)); if( he != NULL ) { ip = inet_ntoa( * ( reinterpret_cast< in_addr* >( he->h_addr ))); } else{ std::cout << "Could not resolve host address " << ip << std::endl; std::cout << "IP now is 127.0.0.1" << std::endl; ip = "127.0.0.1"; } Creditos: Rappa Carnaúba Share this post Link to post
Guiminhah 0 #2 Posted March 31, 2007 Boaaaa Rappa! OT$ nele x]]] Outros servers já tinham, mais o seu code é o mais desenvolvido, prático, e "useful" x] Vlws ai Share this post Link to post
punkndisaster 0 #6 Posted April 1, 2007 Muito bom code cara. Como sempre você mandando muuuuito, mas muuuuito bem cara. Share this post Link to post
Raphael Carnaúba 1 #8 Posted April 1, 2007 Bom, deixe me explicar.... na 1 versão: Se você poe no seu config.lua ip = "auto" Ele pega seu ip dinamico da rede automaticamente.... Na 2 versão você coloca no config.lua ip = "otserv.com.br" Ele estabeleçe uma conexão com o otserv.com.br e pega o IP dinamico ou seja de host. então seu IP que ia ficar no config.lua no otserv agora é o ip dinamico do otserv.com.br Espero que você tenha entendido... Atenciosamente, Raphael. Share this post Link to post
Giko 0 #9 Posted April 1, 2007 @All Galera, evitem fazer comentários curtos em sem conteúdo... como por exemplo "Muito bom". Isso ajuda a controlar o flood e deixa o tópico mais limpo. Abraços. Share this post Link to post
Dorak manado 0 #10 Posted April 2, 2007 zero muito obrigado me ajudou mto estava precisando mesmo vlws Share this post Link to post
Raphael Carnaúba 1 #11 Posted April 2, 2007 @Up Zero? o.O não foi o zero que fez fui eu haha edita o post ae. Share this post Link to post
Lithium o original 0 #12 Posted April 2, 2007 @up eu tenho uma duvida tipo todo código de auto IP que eu já vi tem um bug que aparece a lista dos char da account mais quando vai entrar da concection refused você corrigiu isto nesse code? Share this post Link to post
Raphael Carnaúba 1 #13 Posted April 2, 2007 cara, ja testei o code ta funcionando direitinho...naum tem esse bug não eu garanto, mais se houver me diga que eu corrigo Abraços. Share this post Link to post
igoos 0 #14 Posted April 4, 2007 esse codigo é pra muda auto maticamente o ip do config lua né?? Share this post Link to post
Raphael Carnaúba 1 #15 Posted April 4, 2007 Não não...ele muda no OTServ! Se você está usando a 1 versão você poe ip = "auto" Ele quando abrir a conexão com o OTServ seu IP lá no OTServ vai ser seu IP dinamico da rede que vamos dizer é 222.222.118.19 Na 2 opção você poe seu IP Fixo como igoos.no-ip.info Ele vai se conectar ao seu IP e pegar o seu ip dinamico que é 222.222.118.19 entendeu? Abraços! Share this post Link to post
igoos 0 #16 Posted April 5, 2007 mas eu não tenho q ficar alterando o ip do config.lua pro ot pega?? então esse codigo faz isso né?? Share this post Link to post
Raphael Carnaúba 1 #17 Posted April 5, 2007 Isso! invês de você ficar toda hora o ip do otserv ele faz isso pra você. Pratico e simples não? Falow! Share this post Link to post
igoos 0 #18 Posted April 5, 2007 realmente muito legal, mas em q arquivo e pasta eu tenho q coloca isso seja mais específico por favor Share this post Link to post
Raphael Carnaúba 1 #19 Posted April 5, 2007 Bom, primeiramente você deve saber compilar um servidor..... Você pode ler o tutorial de como compilar no site oficial de otserv (inglês) http://www.otserv.org Lá você encontra o tutorial explicando como compilar. Abraços. Share this post Link to post
igoos 0 #20 Posted April 6, 2007 mas vc não poderia me fala q eu naum sei le inglÊs Share this post Link to post