GM Oyun içi Tek Kodla Oyuncuya İtem Versin Sistemi

  • Konbuyu başlatan Konbuyu başlatan Admin
  • Başlangıç tarihi Başlangıç tarihi
  • Cevaplar Cevaplar 0
  • Görüntüleme Görüntüleme 48

Admin

Metin2Lobby
Yönetici
Founder
Katılım
6 Mayıs 2022
Mesajlar
52,647
Ticaret : 1 / 0 / 0
Mıgo sen artık panele girmekten atakserver kullanmaktan bıkmadadın mı bıktın bıktın. he işte sana göre sistem yancharına aktarma ha ox veya turnuvada birinci olan arkadaşa kod yazıp verebilirsin mesela.

GM Item Verme Komutu — C++


Kod:
#include <ctime>  // Zaman için ACMD(do_gm_itemver) {     if (!ch)         return;     // Yetki kontrolü     if (!ch->IsGM())     {         ch->ChatPacket(CHAT_TYPE_INFO, "Bu komutu kullanmak için yetkiniz yok.");         return;     }     char target_name[CHARACTER_NAME_MAX_LEN + 1];     int item_vnum = 0;     int amount = 0;     if (sscanf(argument, "%s %d %d", target_name, &item_vnum, &amount) != 3)     {         ch->ChatPacket(CHAT_TYPE_INFO, "Kullanım: /gmitemver <oyuncu_ismi> <item_vnum> <adet>");         return;     }     if (amount <= 0)     {         ch->ChatPacket(CHAT_TYPE_INFO, "Geçersiz adet.");         return;     }     LPCHARACTER target_char = CHARACTER_MANAGER::instance().FindPC(target_name);     if (!target_char)     {         ch->ChatPacket(CHAT_TYPE_INFO, "Oyuncu bulunamadı.");         return;     }     // Item validasyonu (örnek)     const auto& item_proto = ITEM_MANAGER::instance().GetTable(item_vnum);     if (item_proto == nullptr)     {         ch->ChatPacket(CHAT_TYPE_INFO, "Geçersiz item vnum.");         return;     }     // Item oluşturma     LPITEM item = ITEM_MANAGER::instance().CreateItem(item_vnum, amount);     if (!item)     {         ch->ChatPacket(CHAT_TYPE_INFO, "Item oluşturulamadı.");         return;     }     // Hedef oyuncuya item verme     if (!target_char->AutoGiveItem(item))     {         item->RemoveFromCharacter();         item->Destroy();         ch->ChatPacket(CHAT_TYPE_INFO, "Item verme başarısız.");         return;     }     ch->ChatPacket(CHAT_TYPE_INFO, "%s oyuncusuna %d adet item verildi (vnum: %d).", target_char->GetName(), amount, item_vnum);     target_char->ChatPacket(CHAT_TYPE_INFO, "%s tarafından %d adet item aldınız (vnum: %d).", ch->GetName(), amount, item_vnum);     // Loglama - işlem ve zaman     time_t now = time(nullptr);     struct tm* t = localtime(&now);     char log_time[32];     strftime(log_time, sizeof(log_time), "%Y-%m-%d %H:%M:%S", t);     sys_log(0, "[%s] GM_ITEM_GIVEN: %s gave %d x %d to %s", log_time, ch->GetName(), amount, item_vnum, target_char->GetName()); }


Özet​


[TABLE=full][TR]<th>Özellik</th><th>Açıklama</th>[/TR][TR][TD]Yetki Kontrolü[/TD][TD]IsGM() ile sadece GM kullanabilir (Mıgo sizin lsGM olmayabilir onu kontrol ederek düzenleyein[/TD][/TR][TR][TD]Item Validasyonu[/TD][TD]ITEM_MANAGER::GetTable() ile geçerli item kontrolü[/TD][/TR][TR][TD]mıgo buda benden sana[/TD][TD]oyuncular kullanmaz ha gmler tek kullanılır sistemi[/TD][/TR][/TABLE]
GM Oyun içi Tek Kodla Oyuncuya İtem Versin Sistemi


Metin2 özel sunucularında GM sistemleri, sunucu yöneticilerinin oyun içi deneyimi kolaylaştırmak ve oyunculara hızlı destek sağlamak için kritik öneme sahiptir. Bu bağlamda, GM komutları ile doğrudan oyuncuya item vermek büyük kolaylık sağlar. Bu yazıda, tek bir kod satırıyla bir oyuncuya item veren GM sistemi nasıl kurulur detaylıca ele alacağız.

Sistem Gereksinimleri

Bu sistemin çalışması için Python tarafında py root dosyalarında değişiklik yapılması gerekir. Ayrıca uiscript üzerinden GUI yaratılabilir veya doğrudan komut satırı üzerinden işlem yapılabilir. Game server tarafında item ID'lerin doğru tanımlanmış olması önemlidir. C++ tabanlı server src dosyalarında da gerekli fonksiyonların aktif olması gerekir.

Temel Komut Yapısı

Oyun içi GM komutları genellikle belirli bir formata göre tanımlanır. Örneğin:

/giveitem [oyuncu_adı] [item_id] [miktar]

Bu komut sayesinde GM, sadece bir satırda belirttiği oyuncuya belirtilen ID'ye sahip itemden istenen miktarda verebilir. Bu komut, hem yetkilendirme kontrolleriyle güvenli hem de kullanıcı dostu bir yapıya sahiptir.

Py Root Tarafında Uygulama

Py root klasöründe bulunan game.py dosyasına bu komutun tanıtılması gerekir. Örnek fonksiyon şu şekildedir:

Kod:
def GiveItemToPlayer(self, player_name, item_id, count):[BR][/BR]    player_pid = player.name_to_pid(player_name)[BR][/BR]    if player_pid != 0:[BR][/BR]        chr.AddItemToInventory(item_id, count, player_pid)[BR][/BR]        self.ChatBox('Item başarıyla verildi.', player_pid)[BR][/BR]    else:[BR][/BR]        self.ChatBox('Oyuncu bulunamadı.', player_pid)


Bu fonksiyon, belirtilen oyuncu adına göre PID'yi alır, envanterine item ekler ve geri bildirim verir.

Güvenlik Önlemleri

Her ne kadar sistem kolaylık sağlasa da, yetkisiz kullanım engellenmelidir. Bu nedenle komut sadece GM yetkisine sahip karakterler tarafından çalıştırılmalıdır. Yetki kontrolü için örnek yapı:

if player.GetStatus(STATUS_AUTHORITY) >= AUTH_GM:

Bu kontrol, komutun sadece GM yetkisi olan kullanıcılar tarafından çalıştırılmasını sağlar.

Sunucu Taraflı DB Kayıtları

Verilen itemlerin takibi için DB core üzerinden loglama yapılabilir. Bu sayede, hangi GM'nin hangi oyuncuya ne zaman ne verdiğini takip etmek mümkün olur. Bu tür işlemler game DB üzerinde özel tablolarla desteklenebilir.

Özet

GM oyun içi tek kodla oyuncuya item versin sistemi, Metin2 özel sunucularında verimli yönetim için oldukça kullanışlıdır. Py root, uiscript, C++ server src ve DB tarafında yapılan küçük ayarlarla bu sistem entegre edilebilir. Güvenlik önlemleri alınarak, hem GM'lerin işi kolaylaşır hem de sunucu güvenliği sağlanır. Daha fazla Metin2 geliştirici kaynağı için Metin2Lobby'e göz atabilirsiniz.


GM In-Game Single Command Item Giving System


GM systems in Metin2 private servers are crucial for server administrators to simplify the in-game experience and provide quick support to players. Within this context, GM commands that allow direct item distribution to players offer significant convenience. This article will detail how to set up a single command-based GM system to give items to players.

System Requirements

To make this system work, modifications must be made in py root files on the Python side. Additionally, GUIs can be created via uiscript, or operations can be performed directly through command lines. It's also important that item IDs are correctly defined on the game server side. The necessary functions must be active in C++-based server src files as well.

Basic Command Structure

In-game GM commands typically follow a specific format. For example:

/giveitem [player_name] [item_id] [count]

With this command, the GM can quickly give the specified amount of an item with the given ID to the named player by typing just one line. This command is both secure with authorization checks and user-friendly.

Implementation in Py Root

The command needs to be introduced into the game.py file located in the py root folder. An example function would look like this:

Kod:
def GiveItemToPlayer(self, player_name, item_id, count):[BR][/BR]    player_pid = player.name_to_pid(player_name)[BR][/BR]    if player_pid != 0:[BR][/BR]        chr.AddItemToInventory(item_id, count, player_pid)[BR][/BR]        self.ChatBox('Item successfully given.', player_pid)[BR][/BR]    else:[BR][/BR]        self.ChatBox('Player not found.', player_pid)


This function retrieves the PID based on the given player name, adds the item to their inventory, and sends feedback.

Security Measures

Although the system provides convenience, unauthorized usage must be prevented. Therefore, the command should only be executable by characters with GM authority. An example check for authorization:

if player.GetStatus(STATUS_AUTHORITY) >= AUTH_GM:

This check ensures the command runs only for users with GM privileges.

Server-Side DB Logging

For tracking distributed items, logging can be implemented via the DB core. This way, it becomes possible to track which GM gave what item to which player and when. Such operations can be supported with custom tables in the game DB.

Summary

GM in-game single command item giving system is highly useful for efficient management in Metin2 private servers. With minor adjustments in py root, uiscript, C++ server src, and DB, this system can be integrated seamlessly. By implementing security measures, both GM tasks become easier and server security is ensured. Visit Metin2Lobby for more Metin2 developer resources.
 

Şuan Bu Konuyu Görüntüleyen Kullanıcılar (Toplam : 0, Üye : 0, Misafir : 0)

Benzer konular

Geri
Üst Alt