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"
|
"Commands"
|
||||||
{
|
{
|
||||||
"title" "Choose a Category"
|
|
||||||
"Fun Commands"
|
"Fun Commands"
|
||||||
{
|
{
|
||||||
"admin" "sm_ban"
|
"admin" "sm_ban"
|
||||||
@ -10,7 +9,7 @@
|
|||||||
"execute" "player"
|
"execute" "player"
|
||||||
"1"
|
"1"
|
||||||
{
|
{
|
||||||
"type" "teamplayer"
|
"type" "groupplayer"
|
||||||
"method" "name"
|
"method" "name"
|
||||||
"title" "Player/Team to Edit"
|
"title" "Player/Team to Edit"
|
||||||
|
|
||||||
@ -62,7 +61,7 @@
|
|||||||
"execute" "player"
|
"execute" "player"
|
||||||
"1"
|
"1"
|
||||||
{
|
{
|
||||||
"type" "teamplayer"
|
"type" "groupplayer"
|
||||||
"method" "name"
|
"method" "name"
|
||||||
"title" "Player/Team to Edit"
|
"title" "Player/Team to Edit"
|
||||||
|
|
||||||
@ -85,7 +84,7 @@
|
|||||||
"execute" "player"
|
"execute" "player"
|
||||||
"1"
|
"1"
|
||||||
{
|
{
|
||||||
"type" "teamplayer"
|
"type" "groupplayer"
|
||||||
"method" "name"
|
"method" "name"
|
||||||
"title" "Player/Team to Edit"
|
"title" "Player/Team to Edit"
|
||||||
|
|
||||||
@ -110,7 +109,7 @@
|
|||||||
"execute" "player"
|
"execute" "player"
|
||||||
"1"
|
"1"
|
||||||
{
|
{
|
||||||
"type" "teamplayer"
|
"type" "groupplayer"
|
||||||
"method" "name"
|
"method" "name"
|
||||||
"title" "Player/Team to Bury"
|
"title" "Player/Team to Bury"
|
||||||
|
|
||||||
@ -122,7 +121,7 @@
|
|||||||
"execute" "player"
|
"execute" "player"
|
||||||
"1"
|
"1"
|
||||||
{
|
{
|
||||||
"type" "teamplayer"
|
"type" "groupplayer"
|
||||||
"method" "name"
|
"method" "name"
|
||||||
"title" "Player/Team to UnBury"
|
"title" "Player/Team to UnBury"
|
||||||
|
|
||||||
@ -134,7 +133,7 @@
|
|||||||
"execute" "player"
|
"execute" "player"
|
||||||
"1"
|
"1"
|
||||||
{
|
{
|
||||||
"type" "teamplayer"
|
"type" "groupplayer"
|
||||||
"method" "name"
|
"method" "name"
|
||||||
"title" "Player/Team to Respawn"
|
"title" "Player/Team to Respawn"
|
||||||
|
|
||||||
@ -146,7 +145,7 @@
|
|||||||
"execute" "player"
|
"execute" "player"
|
||||||
"1"
|
"1"
|
||||||
{
|
{
|
||||||
"type" "teamplayer"
|
"type" "groupplayer"
|
||||||
"method" "name"
|
"method" "name"
|
||||||
"title" "Player/Team to Disarm"
|
"title" "Player/Team to Disarm"
|
||||||
|
|
||||||
@ -158,7 +157,7 @@
|
|||||||
"execute" "player"
|
"execute" "player"
|
||||||
"1"
|
"1"
|
||||||
{
|
{
|
||||||
"type" "teamplayer"
|
"type" "groupplayer"
|
||||||
"method" "name"
|
"method" "name"
|
||||||
"title" "Player/Team to Burn"
|
"title" "Player/Team to Burn"
|
||||||
|
|
||||||
@ -181,7 +180,7 @@
|
|||||||
"execute" "player"
|
"execute" "player"
|
||||||
"1"
|
"1"
|
||||||
{
|
{
|
||||||
"type" "teamplayer"
|
"type" "groupplayer"
|
||||||
"method" "name"
|
"method" "name"
|
||||||
"title" "Player/Team to Edit"
|
"title" "Player/Team to Edit"
|
||||||
|
|
||||||
@ -208,7 +207,7 @@
|
|||||||
"cmd" "sm_noclip #1 #2"
|
"cmd" "sm_noclip #1 #2"
|
||||||
"1"
|
"1"
|
||||||
{
|
{
|
||||||
"type" "teamplayer"
|
"type" "groupplayer"
|
||||||
}
|
}
|
||||||
"2"
|
"2"
|
||||||
{
|
{
|
||||||
@ -224,7 +223,7 @@
|
|||||||
"cmd" "sm_god #1 #2"
|
"cmd" "sm_god #1 #2"
|
||||||
"1"
|
"1"
|
||||||
{
|
{
|
||||||
"type" "teamplayer"
|
"type" "groupplayer"
|
||||||
}
|
}
|
||||||
"2"
|
"2"
|
||||||
{
|
{
|
||||||
@ -240,7 +239,7 @@
|
|||||||
"cmd" "sm_nv #1 #2"
|
"cmd" "sm_nv #1 #2"
|
||||||
"1"
|
"1"
|
||||||
{
|
{
|
||||||
"type" "teamplayer"
|
"type" "groupplayer"
|
||||||
}
|
}
|
||||||
"2"
|
"2"
|
||||||
{
|
{
|
||||||
@ -256,7 +255,7 @@
|
|||||||
"cmd" "sm_helmet #1 #2"
|
"cmd" "sm_helmet #1 #2"
|
||||||
"1"
|
"1"
|
||||||
{
|
{
|
||||||
"type" "teamplayer"
|
"type" "groupplayer"
|
||||||
}
|
}
|
||||||
"2"
|
"2"
|
||||||
{
|
{
|
||||||
@ -272,7 +271,7 @@
|
|||||||
"cmd" "sm_defuser #1 #2"
|
"cmd" "sm_defuser #1 #2"
|
||||||
"1"
|
"1"
|
||||||
{
|
{
|
||||||
"type" "teamplayer"
|
"type" "groupplayer"
|
||||||
}
|
}
|
||||||
"2"
|
"2"
|
||||||
{
|
{
|
||||||
|
@ -85,7 +85,7 @@ public OnConfigsExecuted()
|
|||||||
decl String:path[PLATFORM_MAX_PATH];
|
decl String:path[PLATFORM_MAX_PATH];
|
||||||
decl String:error[256];
|
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)))
|
if (!LoadTopMenuConfig(hAdminMenu, path, error, sizeof(error)))
|
||||||
{
|
{
|
||||||
|
@ -166,7 +166,7 @@ ParseConfigs()
|
|||||||
g_groupList[groupListCommand] = CreateArray(ARRAY_STRING_LENGTH);
|
g_groupList[groupListCommand] = CreateArray(ARRAY_STRING_LENGTH);
|
||||||
|
|
||||||
decl String:configPath[256];
|
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))
|
if (!FileExists(configPath))
|
||||||
{
|
{
|
||||||
@ -273,10 +273,11 @@ public ParamCheck(client)
|
|||||||
if (StrContains(g_command[client], buffer) != -1 || StrContains(g_command[client], buffer2) != -1)
|
if (StrContains(g_command[client], buffer) != -1 || StrContains(g_command[client], buffer2) != -1)
|
||||||
{
|
{
|
||||||
//user has a parameter to fill. lets do it.
|
//user has a parameter to fill. lets do it.
|
||||||
Format(buffer, 5, "%i", g_currentPlace[client][Place_ReplaceNum]);
|
KvJumpToKey(g_kvMenu, buffer[1]); // Jump to current param
|
||||||
KvJumpToKey(g_kvMenu, buffer); // Jump to current param
|
|
||||||
KvGetString(g_kvMenu, "type", type, sizeof(type),"list");
|
KvGetString(g_kvMenu, "type", type, sizeof(type),"list");
|
||||||
|
|
||||||
|
PrintToChatAll("Checking param %s - type %s", buffer[1], type);
|
||||||
|
|
||||||
new Handle:itemMenu = CreateMenu(Menu_Selection);
|
new Handle:itemMenu = CreateMenu(Menu_Selection);
|
||||||
|
|
||||||
new String:title[NAME_LENGTH];
|
new String:title[NAME_LENGTH];
|
||||||
@ -293,7 +294,8 @@ public ParamCheck(client)
|
|||||||
AddMenuItem(itemMenu, commandBuffer, nameBuffer);
|
AddMenuItem(itemMenu, commandBuffer, nameBuffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (strncmp(type,"mapcycle",8) == 0)
|
|
||||||
|
if (strncmp(type,"mapcycle",8) == 0)
|
||||||
{
|
{
|
||||||
decl String:path[200];
|
decl String:path[200];
|
||||||
KvGetString(g_kvMenu, "path", path, sizeof(path),"mapcycle.txt");
|
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 PlayerMethod:playermethod;
|
||||||
new String:method[NAME_LENGTH];
|
new String:method[NAME_LENGTH];
|
||||||
|
|
||||||
@ -357,37 +361,40 @@ public ParamCheck(client)
|
|||||||
if (IsClientInGame(i))
|
if (IsClientInGame(i))
|
||||||
{
|
{
|
||||||
GetClientName(i, nameBuffer, 31);
|
GetClientName(i, nameBuffer, 31);
|
||||||
|
|
||||||
if (playermethod == UserId)
|
switch (playermethod)
|
||||||
{
|
{
|
||||||
new userid = GetClientUserId(i);
|
case UserId:
|
||||||
Format(infoBuffer, sizeof(infoBuffer), "#%i", userid);
|
{
|
||||||
AddMenuItem(itemMenu, infoBuffer, nameBuffer);
|
new userid = GetClientUserId(i);
|
||||||
}
|
Format(infoBuffer, sizeof(infoBuffer), "#%i", userid);
|
||||||
if (playermethod == UserId2)
|
AddMenuItem(itemMenu, infoBuffer, nameBuffer);
|
||||||
{
|
}
|
||||||
new userid = GetClientUserId(i);
|
case UserId2:
|
||||||
Format(infoBuffer, sizeof(infoBuffer), "%i", userid);
|
{
|
||||||
AddMenuItem(itemMenu, infoBuffer, nameBuffer);
|
new userid = GetClientUserId(i);
|
||||||
}
|
Format(infoBuffer, sizeof(infoBuffer), "%i", userid);
|
||||||
else if (playermethod == SteamId)
|
AddMenuItem(itemMenu, infoBuffer, nameBuffer);
|
||||||
{
|
}
|
||||||
GetClientAuthString(i, infoBuffer, sizeof(infoBuffer));
|
case SteamId:
|
||||||
AddMenuItem(itemMenu, infoBuffer, nameBuffer);
|
{
|
||||||
}
|
GetClientAuthString(i, infoBuffer, sizeof(infoBuffer));
|
||||||
else if (playermethod == IpAddress)
|
AddMenuItem(itemMenu, infoBuffer, nameBuffer);
|
||||||
{
|
}
|
||||||
GetClientIP(i, infoBuffer, sizeof(infoBuffer));
|
case IpAddress:
|
||||||
AddMenuItem(itemMenu, infoBuffer, nameBuffer);
|
{
|
||||||
}
|
GetClientIP(i, infoBuffer, sizeof(infoBuffer));
|
||||||
else if (playermethod == Name)
|
AddMenuItem(itemMenu, infoBuffer, nameBuffer);
|
||||||
{
|
}
|
||||||
AddMenuItem(itemMenu, nameBuffer, nameBuffer);
|
case Name:
|
||||||
}
|
{
|
||||||
else //client id or none (so we'll give them the client id anyway)
|
AddMenuItem(itemMenu, nameBuffer, nameBuffer);
|
||||||
{
|
}
|
||||||
Format(temp,3,"%i",i);
|
default: //assume client id
|
||||||
AddMenuItem(itemMenu, temp, nameBuffer);
|
{
|
||||||
|
Format(temp,3,"%i",i);
|
||||||
|
AddMenuItem(itemMenu, temp, nameBuffer);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -400,6 +407,8 @@ public ParamCheck(client)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
//list menu
|
//list menu
|
||||||
|
|
||||||
|
PrintToChatAll("Building List Menu");
|
||||||
|
|
||||||
new String:temp[6];
|
new String:temp[6];
|
||||||
new String:value[NAME_LENGTH];
|
new String:value[NAME_LENGTH];
|
||||||
@ -485,15 +494,15 @@ public Menu_Selection(Handle:menu, MenuAction:action, param1, param2)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
new String:buffer[5];
|
new String:buffer[6];
|
||||||
new String:infobuffer[NAME_LENGTH+2];
|
new String:infobuffer[NAME_LENGTH+2];
|
||||||
Format(infobuffer, sizeof(infobuffer), "\"%s\"", info);
|
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);
|
ReplaceString(g_command[param1], sizeof(g_command[]), buffer, infobuffer);
|
||||||
//replace #num with the selected option (quoted)
|
//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);
|
ReplaceString(g_command[param1], sizeof(g_command[]), buffer, info);
|
||||||
//replace @num with the selected option (unquoted)
|
//replace @num with the selected option (unquoted)
|
||||||
|
|
||||||
|
@ -53,6 +53,10 @@ new Handle:sm_hide_slots;
|
|||||||
new Handle:sv_visiblemaxplayers;
|
new Handle:sv_visiblemaxplayers;
|
||||||
new Handle:sm_reserve_type;
|
new Handle:sm_reserve_type;
|
||||||
|
|
||||||
|
/* Variables to keep track of admin count */
|
||||||
|
new bool:g_hasReserved[MAXPLAYERS+1];
|
||||||
|
new g_adminCount;
|
||||||
|
|
||||||
public OnPluginStart()
|
public OnPluginStart()
|
||||||
{
|
{
|
||||||
LoadTranslations("reservedslots.phrases");
|
LoadTranslations("reservedslots.phrases");
|
||||||
@ -64,6 +68,7 @@ public OnPluginStart()
|
|||||||
|
|
||||||
HookConVarChange(sm_reserved_slots, SlotsChanged);
|
HookConVarChange(sm_reserved_slots, SlotsChanged);
|
||||||
HookConVarChange(sm_hide_slots, SlotsChanged);
|
HookConVarChange(sm_hide_slots, SlotsChanged);
|
||||||
|
HookConVarChange(sm_reserve_type, TypeChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
public OnPluginEnd()
|
public OnPluginEnd()
|
||||||
@ -119,6 +124,8 @@ public OnClientPostAdminCheck(client)
|
|||||||
|
|
||||||
new type = GetConVarInt(sm_reserve_type);
|
new type = GetConVarInt(sm_reserve_type);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (type == 0)
|
if (type == 0)
|
||||||
{
|
{
|
||||||
if (clients <= limit || IsFakeClient(client) || flags & ADMFLAG_ROOT || flags & ADMFLAG_RESERVATION)
|
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 */
|
/* Kick player because there are no public slots left */
|
||||||
CreateTimer(0.1, OnTimedKick, client);
|
CreateTimer(0.1, OnTimedKick, client);
|
||||||
}
|
}
|
||||||
else
|
else if (type == 1)
|
||||||
{
|
{
|
||||||
if (clients > limit)
|
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));
|
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[])
|
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)
|
SetVisibleMaxSlots(clients, limit)
|
||||||
{
|
{
|
||||||
new num = clients;
|
new num = clients;
|
||||||
|
Loading…
Reference in New Issue
Block a user