Oylama Sistemi [C++ Python]

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

Admin

Metin2Lobby
Yönetici
Founder
Katılım
6 Mayıs 2022
Mesajlar
52,647
Ticaret : 1 / 0 / 0

Oylama Akışı (60 saniye süreli):​


  1. <li data-xf-list-type="ol">GM /oylamaac yazar (veya NPC’den başlatır) <li data-xf-list-type="ol">Oy sayıları 0'lanır, oylama_aktif = 1 yapılır <li data-xf-list-type="ol">Her oyuncunun ekranına panel açılır (event_vote_open) <li data-xf-list-type="ol">Oyuncular 1 kez oy kullanabilir (/vote X) <li data-xf-list-type="ol">60 saniye sonra oylama_bitir tetiklenir <li data-xf-list-type="ol">Kazanan seçenek belirlenir ve duyurulur


<blockquote data-attributes="" data-quote="" data-source="" class="bbCodeBlock bbCodeBlock--expandable bbCodeBlock--quote js-expandWatch">
Kod:
quest event_vote begin     state start begin         function get_winner()             local oy1 = game.get_event_flag("oy1")             local oy2 = game.get_event_flag("oy2")             local oy3 = game.get_event_flag("oy3")             if oy1 &gt;= oy2 and oy1 &gt;= oy3 then                 return "Metin Yağmuru", oy1             elseif oy2 &gt;= oy1 and oy2 &gt;= oy3 then                 return "Boss Saldırısı", oy2             else                 return "2x EXP", oy3             end         end         when login begin             if game.get_event_flag("oylama_aktif") == 1 then                 command("event_vote_open")             end         end         when command "vote" begin             local vote = tonumber(arg1)             if game.get_event_flag("oylama_aktif") != 1 then                 chat("Şu anda aktif bir oylama yok.")                 return             end             if vote &gt;= 1 and vote &lt;= 3 then                 game.set_event_flag("oy"..vote, game.get_event_flag("oy"..vote) + 1)                 chat("Oy verdiğiniz için teşekkürler!")             else                 chat("Geçersiz oy!")             end         end         when 20011.chat."Oylamayı Elle Başlat" with pc.is_gm() begin             say_title("GM Paneli")             say("60 saniyelik oylamayı başlatmak istiyor musun?")             local s = select("Evet", "Hayır")             if s == 1 then                 notice_all("Oylama başladı! Etkinlik seçimini yapmayı unutma!")                 game.set_event_flag("oylama_aktif", 1)                 game.set_event_flag("oy1", 0)                 game.set_event_flag("oy2", 0)                 game.set_event_flag("oy3", 0)                 command("event_vote_open")                 timer("oylama_bitir", 60)             end         end         when oylama_bitir.timer begin             game.set_event_flag("oylama_aktif", 0)             local kazanan, oy = event_vote.get_winner()             notice_all("Oylama sona erdi!")             notice_all("Kazanan etkinlik: "..kazanan.." ("..oy.." oy)")         end     end end



Kod:
başa ekle // ACMD(do_oylamaac); komut yerine// { "oylamaac", do_oylamaac, GM_LOW_WIZARD },

cmd_general.cpp – Komut işlevi


Kod:
ACMD(do_oylamaac) {     // Sadece GM'ler kullanabilsin     if (!ch || ch-&gt;GetGMLevel() &lt; GM_LOW_WIZARD)         return;     // Quest flag'ları sıfırla (quest ile birlikte çalışır)     quest::CQuestManager::instance().RequestSetEventFlag("oylama_aktif", 1);     quest::CQuestManager::instance().RequestSetEventFlag("oy1", 0);     quest::CQuestManager::instance().RequestSetEventFlag("oy2", 0);     quest::CQuestManager::instance().RequestSetEventFlag("oy3", 0);     // Tüm aktif oyunculara client komutu gönder: "event_vote_open"     const DESC_MANAGER::DESC_SET&amp; clientSet = DESC_MANAGER::instance().GetClientSet();     for (const auto&amp; desc : clientSet)     {         if (desc &amp;&amp; desc-&gt;GetCharacter())         {             desc-&gt;GetCharacter()-&gt;ChatPacket(CHAT_TYPE_COMMAND, "event_vote_open");         }     }     // Komutu yazan GM'ye bilgi ver     ch-&gt;ChatPacket(CHAT_TYPE_INFO, "Oylama başlatıldı ve tüm oyunculara gönderildi."); }


Pack//

Pack'in root/ klasörüne uiEventVote.py adlı yeni bir dosya ekle. İçeriği şu şekilde:

Kod:
import ui import net import chat class EventVoteDialog(ui.Board):     def __init__(self):         ui.Board.__init__(self)         self.SetSize(270, 180)         self.SetCenterPosition()         self.AddFlag("movable")         self.AddFlag("float")         self.titleBar = ui.TitleBar()         self.titleBar.SetParent(self)         self.titleBar.MakeTitleBar(270, "Etkinlik Oylaması")         self.titleBar.Show()         self.CreateVoteButtons()     def CreateVoteButtons(self):         self.voteOptions = [             ("Metin Yağmuru", 1),             ("Boss Saldırısı", 2),             ("2x EXP", 3)         ]         for i, (text, vote_id) in enumerate(self.voteOptions):             button = ui.Button()             button.SetParent(self)             button.SetPosition(30, 40 + i * 40)             button.SetText(text)             button.SetEvent(lambda v=vote_id: self.SendVote(v))             button.Show()     def SendVote(self, vote_id):         net.SendChatPacket(f"/vote {vote_id}")         chat.AppendChat(chat.CHAT_TYPE_INFO, f"{vote_id}. seçeneğe oy verdiniz. Teşekkürler!")         self.Hide()


game.py içinde __ServerCommand_Build() fonksiyonunu bul.

Kod:
def __ServerCommand_Build(self):     serverCommandList = {         ...     }

Buraya aşağıdaki satırı ekle:


Kod:
"event_vote_open" : self.__VotePanelOpen,

__ServerCommand_Build fonksiyonu altına veya dosyanın uygun yerine şu yeni metodu ekle:


Kod:
def __VotePanelOpen(self):     import uiEventVote     self.voteDialog = uiEventVote.EventVoteDialog()     self.voteDialog.Show()

Oylama Sistemi Nedir?
Metin2 özel sunucularında kullanıcıların etkileşimini artırmak ve oyuncuların oyun içi aktivitelerini motive etmek için geliştirilen sistemlerden biridir. Oylama sistemi, oyuncuların belirli periyotlarda dış kaynaklardan (örneğin top.gg gibi sitelerden) sunucuya oy verebilmesini sağlar. Bu oy sayesinde oyunculara ödüller verilir ve sunucu popülaritesi artırılır. Bu yazıda, C++ ve Python tabanlı Metin2 özel sunucularında nasıl bir oylama sistemi entegrasyonu yapılabileceğini anlatacağız.

Oylama Sistemi Nasıl Çalışır?
Oylama sistemi temel olarak iki bileşenden oluşur: bir web arayüzü ve oyun içi entegrasyon. Web arayüzünde oyuncu oylar, IP tabanlı kontrol ve ödül sistemleri yer alır. Oyun içi sistem ise oyuncunun oyladığını doğrulayıp, gerekli ödülleri verir. Bu süreçte genellikle C++ sunucu tarafında (game/auth), Python ise istemci veya GUI arayüzlerinde kullanılır.

C++ Tarafında Oylama Entegrasyonu
C++ ile geliştirilen Metin2 sunucularında oylama sistemi genellikle 'packet' üzerinden entegre edilir. Oyuncu oyladığında, web tarafı bir API ile sunucuya istek gönderir. Sunucu, oyuncunun oyladığını doğrular ve ödülünü verir. Bu işlem sırasında DB (veritabanı) işlemleri de yapılır. Örneğin, 'player' tablosunda oyuncunun son oylama zamanı saklanabilir. Eğer oylama süresi dolmamışsa, oyuncuya tekrar ödül verilmez.

Python ile Web Arayüzü
Python GUI veya web tabanlı arayüzlerle birlikte kullanıldığında, oylama sisteminin yönetimini kolaylaştırır. Örneğin, 'PyQt' veya 'Tkinter' ile geliştirilen GUI uygulamalarında, adminler oylama durumlarını takip edebilir, ödülleri yönetebilir. Ayrıca Python ile yazılmış API sistemleri, oyuncuların oylama geçmişini analiz etmede büyük kolaylık sağlar.

Oylama Sistemine Ekstra Özellikler
Gelişmiş sistemlerde, oyunculara bonus ödüller, VIP üyelik süre uzatması, oylama sıralaması gibi ekstra özellikler eklenebilir. Bu tür eklemeler C++ ile yazılmış core dosyalarında değişiklik yapılmasını gerektirir. Aynı zamanda Python ile geliştirilen scriptlerle bu veriler daha kolay analiz edilip sunucu içi istatistiklere dönüştürülebilir.

Sonuç
Oylama sistemi, Metin2 özel sunucularında oyuncu sadakati ve sunucu popülaritesi için kritik öneme sahiptir. C++ ve Python dillerinin güçlü yanları kullanılarak gelişmiş ve güvenli sistemler kurulabilir. Bu tür sistemler, doğru şekilde entegre edildiğinde hem oyuncu hem de admin tarafında memnuniyet sağlar.


What is a Voting System?
In Metin2 private servers, the voting system is one of the features developed to increase user engagement and motivate players' in-game activities. The voting system allows players to vote for the server at regular intervals from external sources (such as top.gg). Through these votes, players receive rewards and the server's popularity increases. In this article, we will explain how to integrate a voting system in Metin2 private servers based on C++ and Python.

How Does the Voting System Work?
The voting system consists of two main components: a web interface and in-game integration. On the web interface, player votes, IP-based checks, and reward systems are managed. The in-game system verifies that the player has voted and delivers the rewards accordingly. In this process, languages like C++ are often used server-side (game/auth), while Python may be used for clients or GUI interfaces.

Voting Integration with C++
In Metin2 servers developed with C++, the voting system is usually integrated via 'packets'. When a player votes, the web side sends a request to the server via an API. The server validates the vote and awards the player. During this process, database operations are also performed. For example, the last voting time of a player can be stored in the 'player' table. If the voting cooldown hasn't expired, no additional reward is given to the player.

Web Interface with Python
When used together with GUI or web-based interfaces, Python simplifies the management of the voting system. For instance, GUI applications built with 'PyQt' or 'Tkinter' allow admins to track voting statuses and manage rewards. Additionally, APIs written in Python facilitate the analysis of players' voting history.

Extra Features for Voting Systems
In more advanced systems, extra features such as bonus rewards, VIP membership extensions, or voting leaderboards can be added. These additions require modifications to core files written in C++. At the same time, scripts written in Python allow easier analysis of this data and conversion into in-game statistics.

Conclusion
The voting system is critical for player loyalty and server popularity in Metin2 private servers. By utilizing the strengths of both C++ and Python, advanced and secure systems can be built. When properly integrated, such systems ensure satisfaction for both players and administrators.
 

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

Benzer konular

Geri
Üst Alt