I'm trying to make a simple rules menu that pops up when the player joins the server. I would like it to give an Accept or Deny. Accept = enter server. Deny = kicks user from server. I'm also trying to figure out how to freeze the player until he presses accept or deny.
The menu and sm_rules does work. Deny does not seem to kick from teh server. It doesn't popup on join, and the accept/deny choice are on the wrong numbers. Am I going about it the wrong way?
PHP Code:
#include <sourcemod>
#pragma semicolon 1
public OnPluginStart()
{
RegConsoleCmd("sm_rules", Rules);
}
public Action:Rules(client, args)
{
new Handle:rules = CreateMenu(RulesFunction, MenuAction_Select | MenuAction_End | MenuAction_DisplayItem);
SetMenuTitle(rules, "Server Rules");
AddMenuItem(rules, "1", "Testing", ITEMDRAW_DISABLED);
AddMenuItem(rules, "2", "Da", ITEMDRAW_DISABLED);
AddMenuItem(rules, "3", "Rules", ITEMDRAW_DISABLED);
AddMenuItem(rules, "4", "Testing", ITEMDRAW_DISABLED);
AddMenuItem(rules, "ACCEPT", "Accept");
AddMenuItem(rules, "DENY", "Deny");
DisplayMenu(rules, client, MENU_TIME_FOREVER);
}
public RulesFunction(Handle:menu, MenuAction:action, client, item)
{
char name[32];
int target = -1;
GetCmdArg(1, name, sizeof(name));
for (int i=1; i<=MaxClients; i++)
{
if (!IsClientConnected(i))
{
continue;
}
char other[32];
GetClientName(i, other, sizeof(other));
if (StrEqual(name, other))
{
target = i;
}
}
switch(action)
{
case MenuAction_Select:
{
decl String:item_name[64];
GetMenuItem(menu, item, item_name, sizeof(item_name));
if(StrEqual(item_name, "ACCEPT"))
{
CloseHandle(menu);
}
else if(StrEqual(item_name, "DENY"))
{
ServerCommand("kickid %d", GetClientUserId(target));
}
}
}
}