Few dynamic menu bug fixes.
--HG-- branch : sourcemod-1.1.0 extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/branches/sourcemod-1.1.0%401829
This commit is contained in:
parent
f6b6dff4c0
commit
4ad308897f
@ -1,6 +1,5 @@
|
||||
"Commands"
|
||||
{
|
||||
"title" "Choose a Category"
|
||||
"Fun Commands"
|
||||
{
|
||||
"admin" "sm_ban"
|
||||
@ -10,7 +9,7 @@
|
||||
"execute" "player"
|
||||
"1"
|
||||
{
|
||||
"type" "teamplayer"
|
||||
"type" "groupplayer"
|
||||
"method" "name"
|
||||
"title" "Player/Team to Edit"
|
||||
|
||||
@ -62,7 +61,7 @@
|
||||
"execute" "player"
|
||||
"1"
|
||||
{
|
||||
"type" "teamplayer"
|
||||
"type" "groupplayer"
|
||||
"method" "name"
|
||||
"title" "Player/Team to Edit"
|
||||
|
||||
@ -85,7 +84,7 @@
|
||||
"execute" "player"
|
||||
"1"
|
||||
{
|
||||
"type" "teamplayer"
|
||||
"type" "groupplayer"
|
||||
"method" "name"
|
||||
"title" "Player/Team to Edit"
|
||||
|
||||
@ -110,7 +109,7 @@
|
||||
"execute" "player"
|
||||
"1"
|
||||
{
|
||||
"type" "teamplayer"
|
||||
"type" "groupplayer"
|
||||
"method" "name"
|
||||
"title" "Player/Team to Bury"
|
||||
|
||||
@ -122,7 +121,7 @@
|
||||
"execute" "player"
|
||||
"1"
|
||||
{
|
||||
"type" "teamplayer"
|
||||
"type" "groupplayer"
|
||||
"method" "name"
|
||||
"title" "Player/Team to UnBury"
|
||||
|
||||
@ -134,7 +133,7 @@
|
||||
"execute" "player"
|
||||
"1"
|
||||
{
|
||||
"type" "teamplayer"
|
||||
"type" "groupplayer"
|
||||
"method" "name"
|
||||
"title" "Player/Team to Respawn"
|
||||
|
||||
@ -146,7 +145,7 @@
|
||||
"execute" "player"
|
||||
"1"
|
||||
{
|
||||
"type" "teamplayer"
|
||||
"type" "groupplayer"
|
||||
"method" "name"
|
||||
"title" "Player/Team to Disarm"
|
||||
|
||||
@ -158,7 +157,7 @@
|
||||
"execute" "player"
|
||||
"1"
|
||||
{
|
||||
"type" "teamplayer"
|
||||
"type" "groupplayer"
|
||||
"method" "name"
|
||||
"title" "Player/Team to Burn"
|
||||
|
||||
@ -181,7 +180,7 @@
|
||||
"execute" "player"
|
||||
"1"
|
||||
{
|
||||
"type" "teamplayer"
|
||||
"type" "groupplayer"
|
||||
"method" "name"
|
||||
"title" "Player/Team to Edit"
|
||||
|
||||
@ -208,7 +207,7 @@
|
||||
"cmd" "sm_noclip #1 #2"
|
||||
"1"
|
||||
{
|
||||
"type" "teamplayer"
|
||||
"type" "groupplayer"
|
||||
}
|
||||
"2"
|
||||
{
|
||||
@ -224,7 +223,7 @@
|
||||
"cmd" "sm_god #1 #2"
|
||||
"1"
|
||||
{
|
||||
"type" "teamplayer"
|
||||
"type" "groupplayer"
|
||||
}
|
||||
"2"
|
||||
{
|
||||
@ -240,7 +239,7 @@
|
||||
"cmd" "sm_nv #1 #2"
|
||||
"1"
|
||||
{
|
||||
"type" "teamplayer"
|
||||
"type" "groupplayer"
|
||||
}
|
||||
"2"
|
||||
{
|
||||
@ -256,7 +255,7 @@
|
||||
"cmd" "sm_helmet #1 #2"
|
||||
"1"
|
||||
{
|
||||
"type" "teamplayer"
|
||||
"type" "groupplayer"
|
||||
}
|
||||
"2"
|
||||
{
|
||||
@ -272,7 +271,7 @@
|
||||
"cmd" "sm_defuser #1 #2"
|
||||
"1"
|
||||
{
|
||||
"type" "teamplayer"
|
||||
"type" "groupplayer"
|
||||
}
|
||||
"2"
|
||||
{
|
||||
|
@ -85,7 +85,7 @@ public OnConfigsExecuted()
|
||||
decl String:path[PLATFORM_MAX_PATH];
|
||||
decl String:error[256];
|
||||
|
||||
BuildPath(Path_SM, path, sizeof(path), "configs/dynamicmenu/adminmenu_sorting.txt");
|
||||
BuildPath(Path_SM, path, sizeof(path), "configs/adminmenu_sorting.txt");
|
||||
|
||||
if (!LoadTopMenuConfig(hAdminMenu, path, error, sizeof(error)))
|
||||
{
|
||||
|
@ -166,7 +166,7 @@ ParseConfigs()
|
||||
g_groupList[groupListCommand] = CreateArray(ARRAY_STRING_LENGTH);
|
||||
|
||||
decl String:configPath[256];
|
||||
BuildPath(Path_SM, configPath, sizeof(configPath), "configs/adminmenu_grouping.txt");
|
||||
BuildPath(Path_SM, configPath, sizeof(configPath), "configs/dynamicmenu/adminmenu_grouping.txt");
|
||||
|
||||
if (!FileExists(configPath))
|
||||
{
|
||||
@ -273,10 +273,11 @@ public ParamCheck(client)
|
||||
if (StrContains(g_command[client], buffer) != -1 || StrContains(g_command[client], buffer2) != -1)
|
||||
{
|
||||
//user has a parameter to fill. lets do it.
|
||||
Format(buffer, 5, "%i", g_currentPlace[client][Place_ReplaceNum]);
|
||||
KvJumpToKey(g_kvMenu, buffer); // Jump to current param
|
||||
KvJumpToKey(g_kvMenu, buffer[1]); // Jump to current param
|
||||
KvGetString(g_kvMenu, "type", type, sizeof(type),"list");
|
||||
|
||||
PrintToChatAll("Checking param %s - type %s", buffer[1], type);
|
||||
|
||||
new Handle:itemMenu = CreateMenu(Menu_Selection);
|
||||
|
||||
new String:title[NAME_LENGTH];
|
||||
@ -293,7 +294,8 @@ public ParamCheck(client)
|
||||
AddMenuItem(itemMenu, commandBuffer, nameBuffer);
|
||||
}
|
||||
}
|
||||
else if (strncmp(type,"mapcycle",8) == 0)
|
||||
|
||||
if (strncmp(type,"mapcycle",8) == 0)
|
||||
{
|
||||
decl String:path[200];
|
||||
KvGetString(g_kvMenu, "path", path, sizeof(path),"mapcycle.txt");
|
||||
@ -314,8 +316,10 @@ public ParamCheck(client)
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (StrContains(type, "player"))
|
||||
else if (StrContains(type, "player") != -1)
|
||||
{
|
||||
PrintToChatAll("Building Player List");
|
||||
|
||||
new PlayerMethod:playermethod;
|
||||
new String:method[NAME_LENGTH];
|
||||
|
||||
@ -357,37 +361,40 @@ public ParamCheck(client)
|
||||
if (IsClientInGame(i))
|
||||
{
|
||||
GetClientName(i, nameBuffer, 31);
|
||||
|
||||
if (playermethod == UserId)
|
||||
|
||||
switch (playermethod)
|
||||
{
|
||||
new userid = GetClientUserId(i);
|
||||
Format(infoBuffer, sizeof(infoBuffer), "#%i", userid);
|
||||
AddMenuItem(itemMenu, infoBuffer, nameBuffer);
|
||||
}
|
||||
if (playermethod == UserId2)
|
||||
{
|
||||
new userid = GetClientUserId(i);
|
||||
Format(infoBuffer, sizeof(infoBuffer), "%i", userid);
|
||||
AddMenuItem(itemMenu, infoBuffer, nameBuffer);
|
||||
}
|
||||
else if (playermethod == SteamId)
|
||||
{
|
||||
GetClientAuthString(i, infoBuffer, sizeof(infoBuffer));
|
||||
AddMenuItem(itemMenu, infoBuffer, nameBuffer);
|
||||
}
|
||||
else if (playermethod == IpAddress)
|
||||
{
|
||||
GetClientIP(i, infoBuffer, sizeof(infoBuffer));
|
||||
AddMenuItem(itemMenu, infoBuffer, nameBuffer);
|
||||
}
|
||||
else if (playermethod == Name)
|
||||
{
|
||||
AddMenuItem(itemMenu, nameBuffer, nameBuffer);
|
||||
}
|
||||
else //client id or none (so we'll give them the client id anyway)
|
||||
{
|
||||
Format(temp,3,"%i",i);
|
||||
AddMenuItem(itemMenu, temp, nameBuffer);
|
||||
case UserId:
|
||||
{
|
||||
new userid = GetClientUserId(i);
|
||||
Format(infoBuffer, sizeof(infoBuffer), "#%i", userid);
|
||||
AddMenuItem(itemMenu, infoBuffer, nameBuffer);
|
||||
}
|
||||
case UserId2:
|
||||
{
|
||||
new userid = GetClientUserId(i);
|
||||
Format(infoBuffer, sizeof(infoBuffer), "%i", userid);
|
||||
AddMenuItem(itemMenu, infoBuffer, nameBuffer);
|
||||
}
|
||||
case SteamId:
|
||||
{
|
||||
GetClientAuthString(i, infoBuffer, sizeof(infoBuffer));
|
||||
AddMenuItem(itemMenu, infoBuffer, nameBuffer);
|
||||
}
|
||||
case IpAddress:
|
||||
{
|
||||
GetClientIP(i, infoBuffer, sizeof(infoBuffer));
|
||||
AddMenuItem(itemMenu, infoBuffer, nameBuffer);
|
||||
}
|
||||
case Name:
|
||||
{
|
||||
AddMenuItem(itemMenu, nameBuffer, nameBuffer);
|
||||
}
|
||||
default: //assume client id
|
||||
{
|
||||
Format(temp,3,"%i",i);
|
||||
AddMenuItem(itemMenu, temp, nameBuffer);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -400,6 +407,8 @@ public ParamCheck(client)
|
||||
else
|
||||
{
|
||||
//list menu
|
||||
|
||||
PrintToChatAll("Building List Menu");
|
||||
|
||||
new String:temp[6];
|
||||
new String:value[NAME_LENGTH];
|
||||
@ -485,15 +494,15 @@ public Menu_Selection(Handle:menu, MenuAction:action, param1, param2)
|
||||
return;
|
||||
}
|
||||
|
||||
new String:buffer[5];
|
||||
new String:buffer[6];
|
||||
new String:infobuffer[NAME_LENGTH+2];
|
||||
Format(infobuffer, sizeof(infobuffer), "\"%s\"", info);
|
||||
|
||||
Format(buffer, 4, "#%i", g_currentPlace[param1][Place_ReplaceNum]);
|
||||
Format(buffer, 5, "#%i", g_currentPlace[param1][Place_ReplaceNum]);
|
||||
ReplaceString(g_command[param1], sizeof(g_command[]), buffer, infobuffer);
|
||||
//replace #num with the selected option (quoted)
|
||||
|
||||
Format(buffer, 4, "@%i", g_currentPlace[param1][Place_ReplaceNum]);
|
||||
Format(buffer, 5, "@%i", g_currentPlace[param1][Place_ReplaceNum]);
|
||||
ReplaceString(g_command[param1], sizeof(g_command[]), buffer, info);
|
||||
//replace @num with the selected option (unquoted)
|
||||
|
||||
|
@ -53,6 +53,10 @@ new Handle:sm_hide_slots;
|
||||
new Handle:sv_visiblemaxplayers;
|
||||
new Handle:sm_reserve_type;
|
||||
|
||||
/* Variables to keep track of admin count */
|
||||
new bool:g_hasReserved[MAXPLAYERS+1];
|
||||
new g_adminCount;
|
||||
|
||||
public OnPluginStart()
|
||||
{
|
||||
LoadTranslations("reservedslots.phrases");
|
||||
@ -64,6 +68,7 @@ public OnPluginStart()
|
||||
|
||||
HookConVarChange(sm_reserved_slots, SlotsChanged);
|
||||
HookConVarChange(sm_hide_slots, SlotsChanged);
|
||||
HookConVarChange(sm_reserve_type, TypeChanged);
|
||||
}
|
||||
|
||||
public OnPluginEnd()
|
||||
@ -119,6 +124,8 @@ public OnClientPostAdminCheck(client)
|
||||
|
||||
new type = GetConVarInt(sm_reserve_type);
|
||||
|
||||
|
||||
|
||||
if (type == 0)
|
||||
{
|
||||
if (clients <= limit || IsFakeClient(client) || flags & ADMFLAG_ROOT || flags & ADMFLAG_RESERVATION)
|
||||
@ -134,7 +141,7 @@ public OnClientPostAdminCheck(client)
|
||||
/* Kick player because there are no public slots left */
|
||||
CreateTimer(0.1, OnTimedKick, client);
|
||||
}
|
||||
else
|
||||
else if (type == 1)
|
||||
{
|
||||
if (clients > limit)
|
||||
{
|
||||
@ -155,6 +162,33 @@ public OnClientPostAdminCheck(client)
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (type == 2)
|
||||
{
|
||||
/* Skip the increment if hasReserved is already marked as true.
|
||||
* This could only occur if TypeChanged was called after a user is marked as 'ingame' but before they reach this point
|
||||
* In this case they will already have been counted.
|
||||
*/
|
||||
if ((!g_hasReserved[client]) && (flags & ADMFLAG_ROOT || flags & ADMFLAG_RESERVATION))
|
||||
{
|
||||
g_hasReserved[client] = true;
|
||||
g_adminCount++;
|
||||
}
|
||||
|
||||
if (g_adminCount >= reserved)
|
||||
{
|
||||
/* reserved slots are occupied by admins already so current slot must be a 'public' slot. No action */
|
||||
return;
|
||||
}
|
||||
|
||||
new slotsRemaining = g_MaxClients - clients;
|
||||
new reservedRemaining = reserved - g_adminCount;
|
||||
|
||||
if ((slotsRemaining < reservedRemaining) && (!g_hasReserved[client]))
|
||||
{
|
||||
/* Kick player because there are no public slots left */
|
||||
CreateTimer(0.1, OnTimedKick, client);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -164,6 +198,12 @@ public OnClientDisconnect_Post(client)
|
||||
{
|
||||
SetVisibleMaxSlots(GetClientCount(false), g_MaxClients - GetConVarInt(sm_reserved_slots));
|
||||
}
|
||||
|
||||
if (g_hasReserved[client])
|
||||
{
|
||||
g_adminCount--;
|
||||
g_hasReserved[client] = false;
|
||||
}
|
||||
}
|
||||
|
||||
public SlotsChanged(Handle:convar, const String:oldValue[], const String:newValue[])
|
||||
@ -175,6 +215,35 @@ public SlotsChanged(Handle:convar, const String:oldValue[], const String:newValu
|
||||
}
|
||||
}
|
||||
|
||||
public TypeChanged(Handle:convar, const String:oldValue[], const String:newValue[])
|
||||
{
|
||||
if (StringToInt(newValue) == 2)
|
||||
{
|
||||
g_adminCount = 0;
|
||||
new flags;
|
||||
|
||||
for (new i=1; i<=g_MaxClients; i++)
|
||||
{
|
||||
if (!IsClientInGame(i))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
flags = GetUserFlagBits(i);
|
||||
|
||||
if (flags & ADMFLAG_ROOT || flags & ADMFLAG_RESERVATION)
|
||||
{
|
||||
g_hasReserved[i] = true;
|
||||
g_adminCount++;
|
||||
}
|
||||
else
|
||||
{
|
||||
g_hasReserved[i] = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SetVisibleMaxSlots(clients, limit)
|
||||
{
|
||||
new num = clients;
|
||||
|
Loading…
Reference in New Issue
Block a user