StuckRequest: get rid of obselete bool and clean handle

This commit is contained in:
dogan 2020-07-24 02:37:53 +02:00
parent 1f3e7c8559
commit 05321cbc8d

View File

@ -8,7 +8,6 @@
#include <sdktools>
bool g_bStuckRequestAuto;
bool g_bStuckRequest;
int g_iStuckRequester;
@ -43,7 +42,7 @@ public void OnPluginStart()
AutoExecConfig(true, "plugin.StuckRequest");
g_iStuckRequester = -1;
g_iStuckRequester = 0;
}
public void g_cvStuckRequestAuto(ConVar convar, const char[] oldValue, const char[] newValue)
@ -72,9 +71,9 @@ public Action OnPlayerDeath(Event event, const char[] name, bool dontBroadcast)
}
}
g_iStuckRequester = -1;
g_bStuckRequest = false;
g_iStuckRequester = 0;
KillTimer(StuckRequestTimer);
StuckRequestTimer = INVALID_HANDLE;
}
}
@ -90,9 +89,9 @@ public void OnClientDisconnect(int client)
}
}
g_iStuckRequester = -1;
g_bStuckRequest = false;
g_iStuckRequester = 0;
KillTimer(StuckRequestTimer);
StuckRequestTimer = INVALID_HANDLE;
}
}
public Action Command_StuckRequest(int client, int args)
@ -115,7 +114,7 @@ public Action Command_StuckRequest(int client, int args)
return Plugin_Handled;
}
if(g_bStuckRequest)
if(g_iStuckRequester != 0)
{
CReplyToCommand(client, "{lightgreen}[StuckRequest]{yellow} Another Request is pending! Try again in couple seconds.");
return Plugin_Handled;
@ -141,7 +140,6 @@ public Action Command_StuckRequest(int client, int args)
CReplyToCommand(client, "{lightgreen}[StuckRequest]{yellow} Sent your Request to Admins!");
g_iStuckRequester = client;
g_bStuckRequest = true;
SendRequestToAdmin(g_iStuckRequester);
StuckRequestTimer = CreateTimer(g_fStuckRequestTimer, OnStuckRequest);
@ -155,7 +153,7 @@ public Action OnStuckRequest(Handle timer)
if(ZR_IsClientZombie(g_iStuckRequester))
ZR_HumanClient(g_iStuckRequester, false, false);
int iRandomHuman = -1;
int iRandomHuman = 0;
int PotentialTPCount;
int PotentialTPClient[64];
@ -172,8 +170,7 @@ public Action OnStuckRequest(Handle timer)
{
CPrintToChat(g_iStuckRequester, "{lightgreen}[StuckRequest]{yellow} Round ended while the Request was pending! Request aborted.");
g_iStuckRequester = -1;
g_bStuckRequest = false;
g_iStuckRequester = 0;
for(int i = 1; i <= MaxClients; i++)
{
@ -216,8 +213,7 @@ public Action OnStuckRequest(Handle timer)
}
}
g_iStuckRequester = -1;
g_bStuckRequest = false;
g_iStuckRequester = 0;
return Plugin_Handled;
}
@ -237,7 +233,7 @@ public Action SendRequestToAdmin(int client)
public Action Command_AcceptRequest(int client, int args)
{
if(!g_bStuckRequest)
if(g_iStuckRequester == 0)
{
CReplyToCommand(client, "{lightgreen}[StuckRequest]{yellow} There is no Request pending!");
return Plugin_Handled;
@ -246,7 +242,7 @@ public Action Command_AcceptRequest(int client, int args)
if(ZR_IsClientZombie(g_iStuckRequester))
ZR_HumanClient(g_iStuckRequester, false, false);
int iRandomHuman = -1;
int iRandomHuman = 0;
int PotentialTPCount;
int PotentialTPClient[64];
@ -263,9 +259,9 @@ public Action Command_AcceptRequest(int client, int args)
{
CPrintToChat(g_iStuckRequester, "{lightgreen}[StuckRequest]{yellow} Round ended while the Request was pending! Request aborted.");
g_iStuckRequester = -1;
g_bStuckRequest = false;
g_iStuckRequester = 0;
KillTimer(StuckRequestTimer);
StuckRequestTimer = INVALID_HANDLE;
for(int i = 1; i <= MaxClients; i++)
{
@ -295,16 +291,16 @@ public Action Command_AcceptRequest(int client, int args)
}
}
g_iStuckRequester = -1;
g_bStuckRequest = false;
g_iStuckRequester = 0;
KillTimer(StuckRequestTimer);
StuckRequestTimer = INVALID_HANDLE;
return Plugin_Handled;
}
public Action Command_DenyRequest(int client, int args)
{
if(!g_bStuckRequest)
if(g_iStuckRequester == 0)
{
CReplyToCommand(client, "{lightgreen}[StuckRequest]{yellow} There is no Request pending!");
return Plugin_Handled;
@ -320,9 +316,9 @@ public Action Command_DenyRequest(int client, int args)
}
}
g_iStuckRequester = -1;
g_bStuckRequest = false;
g_iStuckRequester = 0;
KillTimer(StuckRequestTimer);
StuckRequestTimer = INVALID_HANDLE;
return Plugin_Handled;
}