Transitional Syntax for reservedslots.sp (#501)

This commit is contained in:
Maxim Telezhenko 2016-04-27 06:19:53 +03:00 committed by Nicholas Hastings
parent 40f2512317
commit 730a9a4a40

View File

@ -35,7 +35,7 @@
#include <sourcemod> #include <sourcemod>
public Plugin:myinfo = public Plugin myinfo =
{ {
name = "Reserved Slots", name = "Reserved Slots",
author = "AlliedModders LLC", author = "AlliedModders LLC",
@ -44,8 +44,8 @@ public Plugin:myinfo =
url = "http://www.sourcemod.net/" url = "http://www.sourcemod.net/"
}; };
new g_adminCount = 0; int g_adminCount = 0;
new bool:g_isAdmin[MAXPLAYERS+1]; bool g_isAdmin[MAXPLAYERS+1];
/* Handles to convars used by plugin */ /* Handles to convars used by plugin */
ConVar sm_reserved_slots; ConVar sm_reserved_slots;
@ -62,7 +62,7 @@ enum KickType
Kick_Random, Kick_Random,
}; };
public OnPluginStart() public void OnPluginStart()
{ {
LoadTranslations("reservedslots.phrases"); LoadTranslations("reservedslots.phrases");
@ -77,23 +77,23 @@ public OnPluginStart()
sm_hide_slots.AddChangeHook(SlotHideChanged); sm_hide_slots.AddChangeHook(SlotHideChanged);
} }
public OnPluginEnd() public void OnPluginEnd()
{ {
/* If the plugin has been unloaded, reset visiblemaxplayers. In the case of the server shutting down this effect will not be visible */ /* If the plugin has been unloaded, reset visiblemaxplayers. In the case of the server shutting down this effect will not be visible */
ResetVisibleMax(); ResetVisibleMax();
} }
public OnMapStart() public void OnMapStart()
{ {
CheckHiddenSlots(); CheckHiddenSlots();
} }
public OnConfigsExecuted() public void OnConfigsExecuted()
{ {
CheckHiddenSlots(); CheckHiddenSlots();
} }
public Action:OnTimedKick(Handle:timer, any:client) public Action OnTimedKick(Handle timer, any client)
{ {
if (!client || !IsClientInGame(client)) if (!client || !IsClientInGame(client))
{ {
@ -107,17 +107,17 @@ public Action:OnTimedKick(Handle:timer, any:client)
return Plugin_Handled; return Plugin_Handled;
} }
public OnClientPostAdminCheck(client) public void OnClientPostAdminCheck(int client)
{ {
new reserved = sm_reserved_slots.IntValue; int reserved = sm_reserved_slots.IntValue;
if (reserved > 0) if (reserved > 0)
{ {
new clients = GetClientCount(false); int clients = GetClientCount(false);
new limit = GetMaxHumanPlayers() - reserved; int limit = GetMaxHumanPlayers() - reserved;
new flags = GetUserFlagBits(client); int flags = GetUserFlagBits(client);
new type = sm_reserve_type.IntValue; int type = sm_reserve_type.IntValue;
if (type == 0) if (type == 0)
{ {
@ -140,7 +140,7 @@ public OnClientPostAdminCheck(client)
{ {
if (flags & ADMFLAG_ROOT || flags & ADMFLAG_RESERVATION) if (flags & ADMFLAG_ROOT || flags & ADMFLAG_RESERVATION)
{ {
new target = SelectKickClient(); int target = SelectKickClient();
if (target) if (target)
{ {
@ -169,7 +169,7 @@ public OnClientPostAdminCheck(client)
if (g_isAdmin[client]) if (g_isAdmin[client])
{ {
new target = SelectKickClient(); int target = SelectKickClient();
if (target) if (target)
{ {
@ -187,7 +187,7 @@ public OnClientPostAdminCheck(client)
} }
} }
public OnClientDisconnect_Post(client) public void OnClientDisconnect_Post(int client)
{ {
CheckHiddenSlots(); CheckHiddenSlots();
@ -198,10 +198,10 @@ public OnClientDisconnect_Post(client)
} }
} }
public SlotCountChanged(ConVar convar, const String:oldValue[], const String:newValue[]) public void SlotCountChanged(ConVar convar, const char[] oldValue, const char[] newValue)
{ {
/* Reserved slots or hidden slots have been disabled - reset sv_visiblemaxplayers */ /* Reserved slots or hidden slots have been disabled - reset sv_visiblemaxplayers */
new slotcount = convar.IntValue; int slotcount = convar.IntValue;
if (slotcount == 0) if (slotcount == 0)
{ {
ResetVisibleMax(); ResetVisibleMax();
@ -212,7 +212,7 @@ public SlotCountChanged(ConVar convar, const String:oldValue[], const String:new
} }
} }
public SlotHideChanged(ConVar convar, const String:oldValue[], const String:newValue[]) public void SlotHideChanged(ConVar convar, const char[] oldValue, const char[] newValue)
{ {
/* Reserved slots or hidden slots have been disabled - reset sv_visiblemaxplayers */ /* Reserved slots or hidden slots have been disabled - reset sv_visiblemaxplayers */
if (!convar.BoolValue) if (!convar.BoolValue)
@ -225,7 +225,7 @@ public SlotHideChanged(ConVar convar, const String:oldValue[], const String:newV
} }
} }
CheckHiddenSlots() void CheckHiddenSlots()
{ {
if (sm_hide_slots.BoolValue) if (sm_hide_slots.BoolValue)
{ {
@ -233,9 +233,9 @@ CheckHiddenSlots()
} }
} }
SetVisibleMaxSlots(clients, limit) void SetVisibleMaxSlots(int clients, int limit)
{ {
new num = clients; int num = clients;
if (clients == GetMaxHumanPlayers()) if (clients == GetMaxHumanPlayers())
{ {
@ -247,33 +247,33 @@ SetVisibleMaxSlots(clients, limit)
sv_visiblemaxplayers.IntValue = num; sv_visiblemaxplayers.IntValue = num;
} }
ResetVisibleMax() void ResetVisibleMax()
{ {
sv_visiblemaxplayers.IntValue = -1; sv_visiblemaxplayers.IntValue = -1;
} }
SelectKickClient() int SelectKickClient()
{ {
new KickType:type = KickType:sm_reserve_kicktype.IntValue; KickType type = view_as<KickType>(sm_reserve_kicktype.IntValue);
new Float:highestValue; float highestValue;
new highestValueId; int highestValueId;
new Float:highestSpecValue; float highestSpecValue;
new highestSpecValueId; int highestSpecValueId;
new bool:specFound; bool specFound;
new Float:value; float value;
for (new i=1; i<=MaxClients; i++) for (int i=1; i<=MaxClients; i++)
{ {
if (!IsClientConnected(i)) if (!IsClientConnected(i))
{ {
continue; continue;
} }
new flags = GetUserFlagBits(i); int flags = GetUserFlagBits(i);
if (IsFakeClient(i) || flags & ADMFLAG_ROOT || flags & ADMFLAG_RESERVATION || CheckCommandAccess(i, "sm_reskick_immunity", ADMFLAG_RESERVATION, true)) if (IsFakeClient(i) || flags & ADMFLAG_ROOT || flags & ADMFLAG_RESERVATION || CheckCommandAccess(i, "sm_reskick_immunity", ADMFLAG_RESERVATION, true))
{ {