#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <fakemeta>
#define MAX_MAPS 10
#define VOTE_DURATION 15 // Oy süresi (saniye)
#define REFRESH_INTERVAL 1.0 // Oylama durumunu güncelleme aralığı
new g_iRoundCount = 0
new bool:g_bTeamSwapped = false
new g_szMapList[MAX_MAPS][32]
new g_iMapCount = 0
new bool:g_bVoteStarted = false
new g_iVoteCount[MAX_MAPS]
new g_iTotalVotes = 0
new g_iVoteMenu[MAX_PLAYERS + 1]
new g_iVoteStatusMsg
public plugin_init() {
register_plugin("Tur Sistemi (Canlı Oylama)", "3.0", "SizinAdınız")
register_logevent("RoundEnd", 2, "1=Round_End")
register_event("HLTV", "NewRound", "a", "1=0", "2=0")
register_clcmd("say /oydurumu", "cmd_show_vote_status")
load_maplist()
g_iVoteStatusMsg = CreateHudSyncObj()
}
public load_maplist() {
new szFile[64]
get_configsdir(szFile, sizeof(szFile) - 1)
add(szFile, sizeof(szFile) - 1, "/maplist.ini")
if (!file_exists(szFile)) {
log_amx("Maplist dosyasi bulunamadi: %s", szFile)
return
}
new iFile = fopen(szFile, "rt")
if (!iFile) return
g_iMapCount = 0
while (!feof(iFile) && g_iMapCount < MAX_MAPS) {
fgets(iFile, g_szMapList[g_iMapCount], sizeof(g_szMapList[]) - 1)
trim(g_szMapList[g_iMapCount])
if (is_map_valid(g_szMapList[g_iMapCount])) {
g_iMapCount++
}
}
fclose(iFile)
}
public RoundEnd() {
g_iRoundCount++
if (g_iRoundCount == 15 && !g_bTeamSwapped) {
server_cmd("sv_restart 1")
swap_teams()
g_bTeamSwapped = true
}
if (g_iRoundCount == 30 && !g_bVoteStarted) {
freeze_all_players()
start_menu_vote()
g_bVoteStarted = true
}
}
public start_menu_vote() {
if (g_iMapCount < 2) return
reset_votes()
new players[32], num
get_players(players, num)
for (new i = 0; i < num; i++) {
show_vote_menu(players[i])
}
set_task(REFRESH_INTERVAL, "update_vote_status", _, _, _, "b")
set_task(float(VOTE_DURATION), "end_menu_vote")
}
public show_vote_menu(id) {
if (g_iVoteMenu[id]) {
menu_destroy(g_iVoteMenu[id])
}
new title[128]
formatex(title, sizeof(title) - 1, "\yHarita Oylaması^n\dKalan Süre: %d sn", VOTE_DURATION)
g_iVoteMenu[id] = menu_create(title, "vote_menu_handler")
for (new i = 0; i < g_iMapCount; i++) {
new item[64], percent
if (g_iTotalVotes > 0) {
percent = floatround((float(g_iVoteCount[i]) / float(g_iTotalVotes)) * 100.0)
} else {
percent = 0
}
formatex(item, sizeof(item) - 1, "%s \y(%d%%)", g_szMapList[i], percent)
menu_additem(g_iVoteMenu[id], item, "")
}
menu_setprop(g_iVoteMenu[id], MPROP_EXIT, MEXIT_NEVER)
menu_display(id, g_iVoteMenu[id])
}
public vote_menu_handler(id, menu, item) {
if (item == MENU_EXIT || !g_bVoteStarted) {
return PLUGIN_HANDLED
}
for (new i = 0; i < g_iMapCount; i++) {
if (g_iVoteCount[i] > 0) {
g_iVoteCount[i]--
g_iTotalVotes--
}
}
g_iVoteCount[item]++
g_iTotalVotes++
client_print(id, print_chat, "[SUNUCU] Oyunuz: %s", g_szMapList[item])
show_vote_menu(id)
return PLUGIN_HANDLED
}
public update_vote_status() {
if (!g_bVoteStarted) return
new status[512]
new len = formatex(status, sizeof(status) - 1, "Harita Oylaması Durumu:^n^n")
for (new i = 0; i < g_iMapCount; i++) {
new percent
if (g_iTotalVotes > 0) {
percent = floatround((float(g_iVoteCount[i]) / float(g_iTotalVotes)) * 100.0)
} else {
percent = 0
}
len += formatex(status[len], sizeof(status) - len - 1, "%s: %d%% (%d oy)^n", g_szMapList[i], percent, g_iVoteCount[i])
}
new players[32], num
get_players(players, num)
for (new i = 0; i < num; i++) {
set_hudmessage(0, 255, 0, 0.02, 0.25, 0, 0.0, REFRESH_INTERVAL + 0.1, 0.0, 0.0, -1)
ShowSyncHudMsg(players[i], g_iVoteStatusMsg, status)
}
}
public cmd_show_vote_status(id) {
if (g_bVoteStarted) {
update_vote_status()
} else {
client_print(id, print_chat, "[SUNUCU] Şu anda aktif bir oylama yok.")
}
}
public end_menu_vote() {
if (!g_bVoteStarted) return
remove_task()
new winner = 0
for (new i = 1; i < g_iMapCount; i++) {
if (g_iVoteCount[i] > g_iVoteCount[winner]) {
winner = i
}
}
new draw = 0
for (new i = 0; i < g_iMapCount; i++) {
if (i != winner && g_iVoteCount[i] == g_iVoteCount[winner]) {
draw = 1
}
}
if (draw) {
winner = random_num(0, g_iMapCount - 1)
client_print(0, print_chat, "[SUNUCU] Oylama berabere! Rastgele harita seçiliyor: %s", g_szMapList[winner])
} else {
new percent = floatround((float(g_iVoteCount[winner]) / float(g_iTotalVotes)) * 100.0)
client_print(0, print_chat, "[SUNUCU] Kazanan harita: %s (%d%%, %d oy)", g_szMapList[winner], percent, g_iVoteCount[winner])
}
// Menüleri kapat
new players[32], num
get_players(players, num)
for (new i = 0; i < num; i++) {
if (g_iVoteMenu[players[i]]) {
menu_destroy(g_iVoteMenu[players[i]])
g_iVoteMenu[players[i]] = 0
}
}
set_task(5.0, "change_map", winner)
}
public change_map(winner) {
server_cmd("changelevel %s", g_szMapList[winner])
}
public freeze_all_players() {
new players[32], num
get_players(players, num)
for (new i = 0; i < num; i++) {
new id = players[i]
set_pev(id, pev_flags, pev(id, pev_flags) | FL_FROZEN)
}
client_print(0, print_chat, "[SUNUCU] Harita oylaması başladı! Menü otomatik açılıyor...")
}
public swap_teams() {
new players[32], num
get_players(players, num)
for (new i = 0; i < num; i++) {
new id = players[i]
if (cs_get_user_team(id) == CS_TEAM_T) {
cs_set_user_team(id, CS_TEAM_CT)
} else if (cs_get_user_team(id) == CS_TEAM_CT) {
cs_set_user_team(id, CS_TEAM_T)
}
}
client_print(0, print_chat, "[SUNUCU] Takımlar değiştirildi!")
}
public reset_votes() {
for (new i = 0; i < MAX_MAPS; i++) {
g_iVoteCount[i] = 0
}
g_iTotalVotes = 0
}
public NewRound() {
if (g_iRoundCount >= 30) {
g_iRoundCount = 0
g_bTeamSwapped = false
g_bVoteStarted = false
reset_votes()
}
}
public client_disconnected(id) {
if (g_iVoteMenu[id]) {
menu_destroy(g_iVoteMenu[id])
g_iVoteMenu[id] = 0
}
} addons/amxmodx/configs/maplist.ini dosyasına harita ismi ekleyip denermisiniz