public Round_Start(Handle:event, const String:name[], bool:dontBroadcast) { if (voteTimer != INVALID_HANDLE) { KillTimer(voteTimer); voteTimer = INVALID_HANDLE; } if (voteMenu != INVALID_HANDLE) CloseHandle(voteMenu); if (START == 1) { voteMenu = CreateMenu(Select_Func); SetMenuTitle(voteMenu, "Выберите игрока\n \n"); SetMenuExitButton(voteMenu, false); decl String:StR_Id[25], String:StR_Name[MAX_NAME_LENGTH]; new players = 0; for (new i = 1; i <= MaxClients; i++) { if (IsClientInGame(i)) { SetEntProp(i, Prop_Data, "m_takedamage", 2); } voteOne[i] = 0; if (IsClientInGame(i) && GetClientTeam(i) == 3 && IsPlayerAlive(i)) { IntToString(GetClientUserId(i), StR_Id, sizeof(StR_Id)); GetClientName(i,StR_Name, sizeof(StR_Name)); AddMenuItem(voteMenu, StR_Id, StR_Name); players += 1; } } if (players > 0) { for (new i = 1; i <= MaxClients; i++) { if (IsClientInGame(i) && GetClientTeam(i) == 2) { decl String:StR_Id[15]; t = GetClientOfUserId(StringToInt(StR_Id)); t = i; DisplayMenu(voteMenu, i, 10); } } voteAll = 0; // сколько всего было голосов voteTimerSec = 10; // время голосования в сек. voteTimer = CreateTimer(1.0, Timer_Func, _, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE); } else { CloseHandle(voteMenu); voteMenu = INVALID_HANDLE; } if (cMenu != INVALID_HANDLE) CloseHandle(cMenu); if (Menu != INVALID_HANDLE) CloseHandle(Menu); UserFree = 0; Commander = 0; } } public Select_Func(Handle:menu, MenuAction:action, i, option) { if (action == MenuAction_Select) { decl String:StR_Id[25]; GetMenuItem(menu, option, StR_Id, sizeof(StR_Id)); Commander = GetClientOfUserId(StringToInt(StR_Id)); if (Commander > 0) { voteAll += 1; voteOne[Commander] += 1; decl Handle:h; if ((h = StartMessageAll("SayText2")) != INVALID_HANDLE) { BfWriteByte(h, t); BfWriteByte(h, true); decl String:xStR[150]; Format(xStR, sizeof(xStR), "\x03[\x01SG\x04: \x03Выборы\x03] \x04Игрок \x03%N \x04проголосовал за \x03%N", i, Commander); BfWriteString(h, xStR); EndMessage(); } } else PrintToChat(i, "\x05Игрок не найден =("); } } public Action:Timer_Func(Handle:timer, any:x) { voteTimerSec -= 1; if (voteTimerSec > 0) { PrintHintTextToAll("Определиться через:\n< %d сек >", voteTimerSec); return Plugin_Continue; } // Время истекло, голосование окончено voteTimer = INVALID_HANDLE; if (voteMenu != INVALID_HANDLE) { CloseHandle(voteMenu); voteMenu = INVALID_HANDLE; } PrintHintTextToAll("Голосование завершено (%d голосов)", voteAll); if (voteAll < 1) { Commander = GetRandomClient(); if (Commander > 0) { decl Handle:z; if ((z = StartMessageAll("SayText2")) != INVALID_HANDLE) { BfWriteByte(z, ct); BfWriteByte(z, true); decl String:xStR[150]; Format(xStR, sizeof(xStR), "\x01???\x03[\x01SG\x04:\x03] \x04Игрок \x03%N!\x01???", Commander); BfWriteString(z, xStR); EndMessage(); } SetEntProp(Commander, Prop_Send, "m_bHasHelmet", 1); SetEntProp(Commander, Prop_Send, "m_ArmorValue", 100); SetEntityModel(Commander, "models/player/sourcegaming.ru/jail/com/cop2.mdl"); Com_Menu(Commander); return Plugin_Stop; } return Plugin_Stop; } // Находим игрока, за которого больше всего проголосовали new vots = 0; for (new i = 1; i <= MaxClients; i++) { if (voteOne[i] > vots) { vots = voteOne[i]; Commander = i; } } if (Commander > 0 && IsClientInGame(Commander) && GetClientTeam(Commander) == 3 && IsPlayerAlive(Commander)) { decl Handle:k; if ((k = StartMessageAll("SayText2")) != INVALID_HANDLE) { BfWriteByte(k, ct); BfWriteByte(k, true); decl String:xStR[150]; Format(xStR, sizeof(xStR), "\x01???\x03[\x01SG\x04:] \x04Игрок \x03%N!\x01???", Commander); BfWriteString(k, xStR); EndMessage(); } SetEntProp(Commander, Prop_Send, "m_bHasHelmet", 1); SetEntProp(Commander, Prop_Send, "m_ArmorValue", 100); SetEntityModel(Commander, "models/player/sourcegaming.ru/jail/com/cop2.mdl"); Com_Menu(Commander); } else { Commander = GetRandomClient(); if (Commander > 0) { decl Handle:n; if ((n = StartMessageAll("SayText2")) != INVALID_HANDLE) { BfWriteByte(n, ct); BfWriteByte(n, true); decl String:xStR[150]; Format(xStR, sizeof(xStR), "\x03???\x04Игрок\x03 %N \x04!\x03???", Commander); BfWriteString(n, xStR); EndMessage(); } SetEntProp(Commander, Prop_Send, "m_bHasHelmet", 1); SetEntProp(Commander, Prop_Send, "m_ArmorValue", 100); SetEntityModel(Commander, "models/player/sourcegaming.ru/jail/com/cop2.mdl"); Com_Menu(Commander) } } return Plugin_Stop; }