PHP Code:
#include <sourcemod>
#include <sdktools>
#include <adminmenu>
#pragma semicolon 1
#define PREFIX "[\x05LANESS\x01]"
public Plugin:myinfo =
{
name = "Vote Kick System",
author = "",
description = "Made for Server",
version = "1.0.0",
url = ""
};
new g_Client[MAXPLAYERS+1];
new g_Target;
new String:g_Reason[256];
new bool:g_VoteKick;
public OnPluginStart()
{
RegConsoleCmd("sm_vk", Command_VoteKick);
}
public OnMapStart()
{
g_VoteKick = false;
}
public Action:Command_VoteKick(Client, args)
{
if(!g_VoteKick)
{
DisplayMenu_Target(Client);
}
else
{
PrintToChat(Client, "%s 이미 투표가 진행 중입니다.", PREFIX);
}
return Plugin_Handled;
}
DisplayMenu_Target(Client)
{
new Handle:MenuHandle = CreateMenu(MenuHandler_Target);
new bool:DisplayPlayer = false;
new String:Title[256];
Format(Title, sizeof(Title), "어떤 플레이어를 추방하시겠습니까?\n ");
SetMenuTitle(MenuHandle, Title);
for(new i = 1; i <= MaxClients; i++)
{
if(!IsClientInGame(i) || IsFakeClient(i) || i == Client)
{
continue;
}
new String:TargetID[32], String:TargetName[32];
IntToString(GetClientUserId(i), TargetID, sizeof(TargetID));
GetClientName(i, TargetName, sizeof(TargetName));
AddMenuItem(MenuHandle, TargetID, TargetName);
if(!DisplayPlayer) DisplayPlayer = true;
}
if(!DisplayPlayer)
{
AddMenuItem(MenuHandle, "플레이어가 없습니다.", "플레이어가 없습니다.", ITEMDRAW_DISABLED);
}
DisplayMenu(MenuHandle, Client, MENU_TIME_FOREVER);
}
public MenuHandler_Target(Handle:menu, MenuAction:action, Client, Select)
{
if(action == MenuAction_Select && !g_VoteKick)
{
new String:Info[256], Userid;
GetMenuItem(menu, Select, Info, sizeof(Info));
Userid = StringToInt(Info);
if((g_Client[Client] = GetClientOfUserId(Userid)) == 0)
{
PrintToChat(Client, "%s 해당 플레이어를 찾을 수 없습니다.", PREFIX);
}
else
{
DisplayMenu_Reason(Client);
}
}
if(action == MenuAction_End) CloseHandle(menu);
}
DisplayMenu_Reason(Client)
{
new Handle:MenuHandle = CreateMenu(MenuHandler_Reason);
new String:Title[256];
Format(Title, sizeof(Title), "해당 플레이어의 사유를 선택하세요.\n ");
SetMenuTitle(MenuHandle, Title);
AddMenuItem(MenuHandle, "사유", "사유");
AddMenuItem(MenuHandle, "사유", "사유");
SetMenuExitBackButton(MenuHandle, true);
DisplayMenu(MenuHandle, Client, MENU_TIME_FOREVER);
}
public MenuHandler_Reason(Handle:menu, MenuAction:action, Client, Select)
{
if(action == MenuAction_Select && !g_VoteKick)
{
new String:Info[256];
GetMenuItem(menu, Select, Info, sizeof(Info));
g_Target = g_Client[Client];
g_Reason = Info;
g_VoteKick = true;
PrintToChatAll("%s %N 님이 투표를 신청했습니다.", PREFIX, Client);
DisplayMenu_VoteKick();
}
if(action == MenuAction_Cancel && Select == MenuCancel_ExitBack)
{
DisplayMenu_Target(Client);
}
if(action == MenuAction_End) CloseHandle(menu);
}
DisplayMenu_VoteKick()
{
new Handle:MenuHandle = CreateMenu(MenuHandler_VoteKick);
new String:Title[256];
Format(Title, sizeof(Title), "%N 님을 추방하시겠습니까?\n사유: %s\n ", g_Target, g_Reason);
SetMenuTitle(MenuHandle, Title);
AddMenuItem(MenuHandle, "Yes", "ㅇㅋ");
AddMenuItem(MenuHandle, "No", "ㄴㄴ");
SetMenuExitButton(MenuHandle, false);
VoteMenuToAll(MenuHandle, 20);
}
public MenuHandler_VoteKick(Handle:menu, MenuAction:action, Client, Select)
{
if(action == MenuAction_VoteEnd)
{
new String:Info[32];
GetMenuItem(menu, Client, Info, sizeof(Info));
if(StrEqual(Info, "Yes", false))
{
if(IsClientInGame(g_Target))
{
PrintToChatAll("%s 투표 결과 과반수를 넘겨 %N 님이 추방되었습니다. (사유: %s)", PREFIX, g_Target, g_Reason);
KickClient(g_Target, "투표 결과 과반수를 넘겨 추방되었습니다.");
}
}
else
{
PrintToChatAll("%s 투표 결과 과반수를 넘지 못하여 무효 처리합니다.", PREFIX);
}
g_VoteKick = false;
}
}