updating some stuff, adding a hud, making some checks against admin abuse and afk teleports
This commit is contained in:
parent
67a528ee89
commit
7439a6b7eb
@ -1,7 +1,7 @@
|
||||
#pragma semicolon 1
|
||||
#define DEBUG
|
||||
#define PLUGIN_AUTHOR "jenz"
|
||||
#define PLUGIN_VERSION "1.4"
|
||||
#define PLUGIN_VERSION "1.5"
|
||||
#define g_dLength 256
|
||||
#define g_dIndex 65
|
||||
#include <sourcemod>
|
||||
@ -16,22 +16,23 @@ char g_cMapname[g_dLength];
|
||||
char g_cSpecialMapStart[g_dLength];
|
||||
char g_cSpecialMapEnd[g_dLength];
|
||||
static char g_sConfigzones[PLATFORM_MAX_PATH];
|
||||
float g_fRoundMinutes;
|
||||
int g_iRoundMinutes;
|
||||
float g_fRoundSeconds;
|
||||
float g_fMinutesIndividual[MAXPLAYERS + 1];
|
||||
int g_iMinutesIndividual[MAXPLAYERS + 1];
|
||||
float g_fSecondsIndividual[MAXPLAYERS + 1];
|
||||
float g_fRecordSeconds[g_dIndex + 1][100];
|
||||
float g_fClientVectors[MAXPLAYERS + 1][3];
|
||||
int g_iRecordMinutes[g_dIndex + 1][100];
|
||||
int g_iClientFrames[MAXPLAYERS + 1];
|
||||
int g_iClientSpeedInterval[MAXPLAYERS + 1];
|
||||
//100 because we have a total of 53 race zones right now
|
||||
int g_iRaceCount[MAXPLAYERS + 1];
|
||||
int g_iTableCountID;
|
||||
//testing
|
||||
int g_iClientStage[MAXPLAYERS + 1];
|
||||
int g_iClientChecking[MAXPLAYERS + 1];
|
||||
bool g_bMessage[g_dIndex + 1][MAXPLAYERS + 1];
|
||||
bool g_bDisplaySpecial;
|
||||
bool g_bRecentTimes[MAXPLAYERS + 1];
|
||||
bool g_bHumansAllowedTime[MAXPLAYERS + 1];
|
||||
Database g_dDatabase;
|
||||
Handle hText;
|
||||
public Plugin myinfo =
|
||||
{
|
||||
name = "UNLOZE_racetimer_css",
|
||||
@ -49,10 +50,11 @@ public void OnPluginStart()
|
||||
RegConsoleCmd("sm_toptime", cmd_timerCheckTop, "checking top 10");
|
||||
RegConsoleCmd("sm_mytime", cmd_timerCheckSelf, "checking your personal time");
|
||||
RegConsoleCmd("sm_stages", cmd_timerCheckStage, "Checking race stages");
|
||||
RegAdminCmd("sm_threadtestresult", cmd_threadtest, ADMFLAG_BAN);
|
||||
//hooks
|
||||
HookEvent("round_start", Event_RoundStart, EventHookMode_PostNoCopy);
|
||||
}
|
||||
//HUD
|
||||
hText = CreateHudSynchronizer();
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
@ -68,6 +70,13 @@ public void OnMapStart()
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public void OnPluginEnd()
|
||||
{
|
||||
CloseHandle(hText);
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public void startTimer()
|
||||
{
|
||||
char line[g_dLength];
|
||||
@ -95,7 +104,7 @@ public Action Timer_CountdownRace(Handle timer, any data)
|
||||
g_fRoundSeconds += 0.1;
|
||||
if (g_fRoundSeconds >= 60.0)
|
||||
{
|
||||
g_fRoundMinutes += 1.0;
|
||||
g_iRoundMinutes += 1;
|
||||
g_fRoundSeconds = 0.0;
|
||||
}
|
||||
}
|
||||
@ -104,17 +113,14 @@ public Action Timer_CountdownRace(Handle timer, any data)
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public void Event_RoundStart(Handle event, const char[] name, bool dontBroadcast)
|
||||
{
|
||||
g_fRoundMinutes = 0.0;
|
||||
g_iRoundMinutes = 0;
|
||||
g_fRoundSeconds = 0.0;
|
||||
int l_iRaceZoneCount = GetTotalRaceZones();
|
||||
for (int i = 1; i <= MaxClients; i++)
|
||||
if (IsValidClient(i))
|
||||
{
|
||||
MYSQLCheckRecord(i);
|
||||
for (int j = 0; j <= l_iRaceZoneCount; j++)
|
||||
g_bMessage[i][j] = false;
|
||||
}
|
||||
|
||||
g_bHumansAllowedTime[i] = false;
|
||||
}
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
@ -123,6 +129,7 @@ public void OnClientPostAdminCheck(int client)
|
||||
{
|
||||
resetClient(client);
|
||||
MYSQLCheckRecord(client);
|
||||
g_bHumansAllowedTime[client] = false;
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
@ -136,60 +143,144 @@ public void OnClientDisconnect(int client)
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public void resetClient(int client)
|
||||
{
|
||||
int l_iRaceZoneCount = GetTotalRaceZones();
|
||||
for (int j = 0; j <= l_iRaceZoneCount; j++)
|
||||
g_bMessage[client][j] = false;
|
||||
g_bRecentTimes[client] = false;
|
||||
g_fSecondsIndividual[client] = 0.0;
|
||||
g_fMinutesIndividual[client] = 0.0;
|
||||
g_iMinutesIndividual[client] = 0;
|
||||
g_iClientChecking[client] = 0;
|
||||
g_iClientStage[client] = 0;
|
||||
for (int i = 0; i < 100; i++)
|
||||
g_bHumansAllowedTime[client] = false;
|
||||
resetClientVectors(client);
|
||||
for (int iterator = 0; iterator < 100; iterator++)
|
||||
{
|
||||
g_iRecordMinutes[client][i] = 0;
|
||||
g_fRecordSeconds[client][i] = 0.0;
|
||||
g_iRecordMinutes[client][iterator] = 0;
|
||||
g_fRecordSeconds[client][iterator] = 0.0;
|
||||
}
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public Action OnPlayerRunCmd(int client, int &buttons, int &impulse, float vel[3], float angles[3], int &weapon, int &subtype, int &cmdnum, int &tickcount, int &seed, int mouse[2])
|
||||
{
|
||||
if (g_bHumansAllowedTime[client] && (GetClientTeam(client) == CS_TEAM_CT))
|
||||
{
|
||||
int frameCap = 11;
|
||||
if (g_iClientFrames[client] >= frameCap)
|
||||
{
|
||||
g_iClientFrames[client] = 0;
|
||||
float clientVectors[3];
|
||||
GetClientAbsOrigin(client, clientVectors);
|
||||
if (checkClientOrigin(g_fClientVectors[client], clientVectors, client, vel))
|
||||
{
|
||||
g_bHumansAllowedTime[client] = false;
|
||||
resetClientVectors(client);
|
||||
PrintToChat(client, "Disabled timer due to potential teleport abuse");
|
||||
return Plugin_Continue;
|
||||
}
|
||||
int speedCheckerCap = 10;
|
||||
if (g_iClientSpeedInterval[client] > speedCheckerCap)
|
||||
{
|
||||
g_iClientSpeedInterval[client] = 0;
|
||||
bool bNoclip = (GetEntityMoveType(client) == MOVETYPE_NOCLIP);
|
||||
if (bNoclip)
|
||||
{
|
||||
g_bHumansAllowedTime[client] = false;
|
||||
resetClientVectors(client);
|
||||
PrintToChat(client, "Disabled timer due to Noclip");
|
||||
return Plugin_Continue;
|
||||
}
|
||||
float speed = GetEntPropFloat(client, Prop_Data, "m_flLaggedMovementValue");
|
||||
if (speed > 1.0)
|
||||
{
|
||||
g_bHumansAllowedTime[client] = false;
|
||||
resetClientVectors(client);
|
||||
PrintToChat(client, "Disabled timer due to modified run speed");
|
||||
return Plugin_Continue;
|
||||
}
|
||||
float client_gravity = GetEntityGravity(client);
|
||||
ConVar gravity = FindConVar("sv_gravity");
|
||||
float gravityFloat = gravity.FloatValue;
|
||||
int minimalPermitedGravity = 650;
|
||||
//PrintToChat(client, "client_gravity: %f\ngravityFloat: %f", client_gravity, gravityFloat);
|
||||
if (!(client_gravity == 1.0 || client_gravity == 0.0000) || gravityFloat < minimalPermitedGravity)
|
||||
{
|
||||
g_bHumansAllowedTime[client] = false;
|
||||
resetClientVectors(client);
|
||||
PrintToChat(client, "Disabled timer due to modified gravity");
|
||||
return Plugin_Continue;
|
||||
}
|
||||
}
|
||||
g_fClientVectors[client] = clientVectors;
|
||||
{
|
||||
if (hText != INVALID_HANDLE)
|
||||
{
|
||||
SetHudTextParams(0.35, 0.7, 0.1, 125, 255, 255, 85);
|
||||
int l_iCalculateMins = CalculateValuesMinutes(client);
|
||||
float l_fCalculateSecs = CalculateValues(client);
|
||||
ShowSyncHudText(client, hText, "%N Time: 0%i:%.1f\nRecord: 0%i:%.1f\nMap: %s\nStage: %i", client, l_iCalculateMins,
|
||||
l_fCalculateSecs, g_iRecordMinutes[client][g_iClientStage[client]], g_fRecordSeconds[client][g_iClientStage[client]],
|
||||
g_cMapname, g_iClientStage[client]);
|
||||
}
|
||||
}
|
||||
g_iClientSpeedInterval[client]++;
|
||||
}
|
||||
g_iClientFrames[client]++;
|
||||
}
|
||||
return Plugin_Continue;
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public void resetClientVectors(int client)
|
||||
{
|
||||
g_fClientVectors[client][0] = 0.000000;
|
||||
g_fClientVectors[client][1] = 0.000000;
|
||||
g_fClientVectors[client][2] = 0.000000;
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public bool checkClientOrigin(float oldVals[3], float newVals[3], int client, float vel[3])
|
||||
{
|
||||
float zero = 0.000000;
|
||||
int velocityCap = 600;
|
||||
if ((oldVals[0] == zero && oldVals[1] == zero && oldVals[2] == zero) || (newVals[0] == zero && newVals[1] == zero && newVals[2] == zero))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
float teleport_range = 50000.0;
|
||||
float distance = GetVectorDistance(oldVals, newVals, true);
|
||||
//PrintToChatAll("distance: %f", distance);
|
||||
bool bInAir = (GetEntPropEnt(client, Prop_Send, "m_hGroundEntity") == -1);
|
||||
if (distance > teleport_range)
|
||||
{
|
||||
//PrintToChat(client, "distance: %f", distance);
|
||||
//PrintToChat(client, "vel[0] %f \nvel[1] %f \nvel[2] %f", vel[0], vel[1], vel[2]);
|
||||
if (StrContains(g_cMapname, "surf", false) != -1)
|
||||
return false;
|
||||
if ((vel[0] > velocityCap || vel[1] > velocityCap || vel[2] > velocityCap) && bInAir)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public void unloze_zoneEntry(int client, char[] zone)
|
||||
{
|
||||
int l_iZoneIndex = RetrieveZoneIndex(zone);
|
||||
int zoneIndex = RetrieveZoneIndex(zone);
|
||||
int l_iZoneCount = unloze_zoneCount();
|
||||
if (((GetClientTeam(client) == CS_TEAM_CT) && StrContains(zone, "ZONE_PREFIX_RACE") > -1) || StrEqual(zone, g_cSpecialMapEnd))
|
||||
if (((GetClientTeam(client) == CS_TEAM_CT && g_bHumansAllowedTime[client]) && StrContains(zone, "ZONE_PREFIX_RACE") > -1) || StrEqual(zone, g_cSpecialMapEnd))
|
||||
{
|
||||
/*
|
||||
PrintToChatAll("g_bMessage: %i", g_bMessage[client][g_iClientStage[client]]);
|
||||
PrintToChatAll("g_iClientStage[client]: %i", g_iClientStage[client]);
|
||||
PrintToChatAll("(l_iZoneIndex / 2 )-1: %i", (l_iZoneIndex / 2) -1);
|
||||
*/
|
||||
if (l_iZoneCount < 2 && !g_bMessage[client][0])
|
||||
if (l_iZoneCount < 2)
|
||||
{
|
||||
g_iClientStage[client] = 0;
|
||||
MYSQLCheckRecord(client);
|
||||
FinishedStageRaceZone(client);
|
||||
}
|
||||
else if (g_iClientStage[client] == ((l_iZoneIndex / 2 ) -1) && !g_bMessage[client][g_iClientStage[client]])
|
||||
if (g_iClientStage[client] == (zoneIndex / 2) || l_iZoneCount < 2)
|
||||
{
|
||||
MYSQLCheckRecord(client);
|
||||
FinishedStageRaceZone(client);
|
||||
}
|
||||
g_bHumansAllowedTime[client] = false;
|
||||
}
|
||||
/*
|
||||
* COMMENTS
|
||||
* forward checks if isValidClient
|
||||
*
|
||||
* individual seconds and minutes are zero if the client never left a zone with the name ZONE_PREFIX_START
|
||||
*
|
||||
* assuming each zone indexes one up RetrieveZoneIndex should match well since there has to be some kind
|
||||
* of structure for this, minimum is 2 for RetrieveZoneIndex so -1 works
|
||||
*
|
||||
* the else return statement means for example ZONE_PREFIX_START_1 but reached ZONE_PREFIX_RACE_3
|
||||
* or ZONE_PREFIX_START_2 but ZONE_PREFIX_RACE_1 where it would need to be 3
|
||||
*
|
||||
* l_iZoneIndex / 2 is stage zones, the only possible entries here are 2, 4, 6 etc etc
|
||||
*/
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
@ -199,13 +290,13 @@ public void unloze_zoneLeave(int client, char[] zone)
|
||||
//only maps with multiple zones need ZONE_PREFIX_START
|
||||
if (((GetClientTeam(client) == CS_TEAM_CT) && StrContains(zone, "ZONE_PREFIX_START") > -1) || StrEqual(zone, g_cSpecialMapStart))
|
||||
{
|
||||
resetClientVectors(client);
|
||||
g_fSecondsIndividual[client] = g_fRoundSeconds;
|
||||
g_fMinutesIndividual[client] = g_fRoundMinutes;
|
||||
/**
|
||||
* /2 is to ensure 1 + 1 / 2 = 1, 3 + 1 / 2 = 2, 5 + 1 / 2 = 3
|
||||
* - 1 for starting index at 0 and +1 for int parameter stage when inserting time to row since they start as stage 1 not stage 0
|
||||
*/
|
||||
g_iClientStage[client] = ((RetrieveZoneIndex(zone) + 1) / 2) - 1;
|
||||
g_iMinutesIndividual[client] = g_iRoundMinutes;
|
||||
float notRounded = float(RetrieveZoneIndex(zone));
|
||||
g_iClientStage[client] = RoundToCeil(notRounded / 2);
|
||||
g_bHumansAllowedTime[client] = true;
|
||||
CPrintToChat(client, "Timer started for stage: %i", g_iClientStage[client]);
|
||||
}
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
@ -232,7 +323,7 @@ public void CheckifAntiZones(int client, bool reset)
|
||||
{
|
||||
//adds 30 mins and 30 seconds to a client because thats simple and very effective
|
||||
g_fSecondsIndividual[client] = 30.0;
|
||||
g_fMinutesIndividual[client] = 30.0;
|
||||
g_iMinutesIndividual[client] = 30;
|
||||
}
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
@ -241,107 +332,109 @@ public void CheckifAntiZones(int client, bool reset)
|
||||
public int RetrieveZoneIndex(char[] zone)
|
||||
{
|
||||
//if you leave zone_2 you want the corresponding racezone to be zone_3
|
||||
int i = strlen(zone) - 1;
|
||||
int iterator = strlen(zone) - 1;
|
||||
char l_sZone[g_dIndex];
|
||||
Format(l_sZone, sizeof(l_sZone), zone);
|
||||
while (IsCharNumeric(l_sZone[i]))
|
||||
i--;
|
||||
i++;
|
||||
strcopy(l_sZone, sizeof(l_sZone), l_sZone[i]);
|
||||
return StringToInt(l_sZone[i]);
|
||||
while (IsCharNumeric(l_sZone[iterator]))
|
||||
iterator--;
|
||||
iterator++;
|
||||
strcopy(l_sZone, sizeof(l_sZone), l_sZone[iterator]);
|
||||
return StringToInt(l_sZone[iterator]);
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public void FinishedStageRaceZone(int client)
|
||||
{
|
||||
/*
|
||||
PrintToChatAll("g_iClientStage[client]: %i", g_iClientStage[client]);
|
||||
PrintToChatAll("g_iRecordMinutes[client][g_iClientStage[client]]: %i", g_iRecordMinutes[client][g_iClientStage[client]]);
|
||||
PrintToChatAll("g_fRecordSeconds[client][g_iClientStage[client]]: %f", g_fRecordSeconds[client][g_iClientStage[client]]);
|
||||
*/
|
||||
int l_iZoneCount = unloze_zoneCount();
|
||||
float l_fCalculateMins;
|
||||
int l_iCalculateMins;
|
||||
float l_fCalculateSecs;
|
||||
if (g_iRecordMinutes[client][g_iClientStage[client]] > 0 || g_fRecordSeconds[client][g_iClientStage[client]] > 0.0)
|
||||
CPrintToChat(client, "Your record: 0%i:%.1f \nCommand: !toptime !mytime !stages", g_iRecordMinutes[client][g_iClientStage[client]], g_fRecordSeconds[client][g_iClientStage[client]]);
|
||||
else
|
||||
{
|
||||
if (l_iZoneCount < 2)
|
||||
sendMYSQL(client, g_fRoundMinutes, g_fRoundSeconds, 0, 0.0, g_iClientStage[client]);
|
||||
sendMYSQL(client, g_iRoundMinutes, g_fRoundSeconds, 0, 0.0, g_iClientStage[client]);
|
||||
else
|
||||
{
|
||||
l_fCalculateMins = CalculateValues(client, 0);
|
||||
l_fCalculateSecs = CalculateValues(client, 1);
|
||||
sendMYSQL(client, l_fCalculateMins, l_fCalculateSecs, 0, 0.0, g_iClientStage[client]);
|
||||
l_iCalculateMins = CalculateValuesMinutes(client);
|
||||
l_fCalculateSecs = CalculateValues(client);
|
||||
sendMYSQL(client, l_iCalculateMins, l_fCalculateSecs, 0, 0.0, g_iClientStage[client]);
|
||||
}
|
||||
CPrintToChat(client, "Updated timer");
|
||||
}
|
||||
if (l_iZoneCount < 2)
|
||||
{
|
||||
//no start zone, we use round time
|
||||
CPrintToChat(client, "{green}[UNLOZE] Client: %N Time: 0%i:%.1f", client, RoundToFloor(g_fRoundMinutes), g_fRoundSeconds);
|
||||
if ((g_fRoundMinutes < g_iRecordMinutes[client][g_iClientStage[client]])
|
||||
|| (g_fRoundMinutes == g_iRecordMinutes[client][g_iClientStage[client]] && g_fRoundSeconds < g_fRecordSeconds[client][g_iClientStage[client]]))
|
||||
CPrintToChat(client, "{green}[UNLOZE] Client: %N Time: 0%i:%.1f", client, g_iRoundMinutes, g_fRoundSeconds);
|
||||
if ((g_iRoundMinutes < g_iRecordMinutes[client][g_iClientStage[client]])
|
||||
|| (g_iRoundMinutes == g_iRecordMinutes[client][g_iClientStage[client]] && g_fRoundSeconds < g_fRecordSeconds[client][g_iClientStage[client]]))
|
||||
{
|
||||
sendMYSQL(client, g_fRoundMinutes, g_fRoundSeconds, g_iRecordMinutes[client][g_iClientStage[client]], g_fRecordSeconds[client][g_iClientStage[client]], g_iClientStage[client]);
|
||||
sendMYSQL(client, g_iRoundMinutes, g_fRoundSeconds, g_iRecordMinutes[client][g_iClientStage[client]], g_fRecordSeconds[client][g_iClientStage[client]], g_iClientStage[client]);
|
||||
CPrintToChat(client, "Updated timer");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//uses start zone, we use time when leaving start zone
|
||||
l_fCalculateMins = CalculateValues(client, 0);
|
||||
l_fCalculateSecs = CalculateValues(client, 1);
|
||||
l_iCalculateMins = CalculateValuesMinutes(client);
|
||||
l_fCalculateSecs = CalculateValues(client);
|
||||
//tricking ppl !hehe
|
||||
CPrintToChat(client, "{green}[UNLOZE] Stage: %i", g_iClientStage[client] + 1);
|
||||
CPrintToChat(client, "{green}[UNLOZE] Client: %N Time: 0%i:%.1f", client, RoundToFloor(l_fCalculateMins), l_fCalculateSecs);
|
||||
if ((RoundToFloor(l_fCalculateMins) < g_iRecordMinutes[client][g_iClientStage[client]])
|
||||
|| (RoundToFloor(l_fCalculateMins) == g_iRecordMinutes[client][g_iClientStage[client]] && l_fCalculateSecs < g_fRecordSeconds[client][g_iClientStage[client]]))
|
||||
CPrintToChat(client, "{green}[UNLOZE] Stage: %i", g_iClientStage[client]);
|
||||
CPrintToChat(client, "{green}[UNLOZE] Client: %N Time: 0%i:%.1f", client, l_iCalculateMins, l_fCalculateSecs);
|
||||
if ((l_iCalculateMins < g_iRecordMinutes[client][g_iClientStage[client]])
|
||||
|| (l_iCalculateMins == g_iRecordMinutes[client][g_iClientStage[client]] && l_fCalculateSecs < g_fRecordSeconds[client][g_iClientStage[client]]))
|
||||
{
|
||||
sendMYSQL(client, l_fCalculateMins, l_fCalculateSecs, g_iRecordMinutes[client][g_iClientStage[client]], g_fRecordSeconds[client][g_iClientStage[client]], g_iClientStage[client]);
|
||||
sendMYSQL(client, l_iCalculateMins, l_fCalculateSecs, g_iRecordMinutes[client][g_iClientStage[client]], g_fRecordSeconds[client][g_iClientStage[client]], g_iClientStage[client]);
|
||||
CPrintToChat(client, "Updated timer");
|
||||
}
|
||||
}
|
||||
//matching the message
|
||||
MYSQLCheckRecord(client);
|
||||
g_bMessage[client][g_iClientStage[client]] = true;
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public float CalculateValues(int client, int state)
|
||||
public int CalculateValuesMinutes(int client)
|
||||
{
|
||||
float l_fRoundSeconds = g_fRoundSeconds;
|
||||
float l_fRoundSecondsIndividual = g_fSecondsIndividual[client];
|
||||
int l_iRoundMinutes = g_iRoundMinutes;
|
||||
int l_iRoundMinutesIndividual = g_iMinutesIndividual[client];
|
||||
if (l_iRoundMinutesIndividual > l_iRoundMinutes)
|
||||
return 0;
|
||||
l_iRoundMinutes = l_iRoundMinutes - l_iRoundMinutesIndividual;
|
||||
if (l_fRoundSeconds < l_fRoundSecondsIndividual)
|
||||
l_iRoundMinutes--;
|
||||
return l_iRoundMinutes;
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public float CalculateValues(int client)
|
||||
{
|
||||
// 2:24 enter with roundtime 5:29 = 3:05
|
||||
// 3:01 enter with roundtime 3:59 = 58 sec
|
||||
//example roundtime is 5 mins 40 seconds, client entered at 4 mins and 50 seconds, so 50 sec race
|
||||
float l_fRoundMinutes = g_fRoundMinutes;
|
||||
float l_fRoundMinutesIndividual = g_fMinutesIndividual[client];
|
||||
float l_fRoundSeconds = g_fRoundSeconds;
|
||||
float l_fRoundSecondsIndividual = g_fSecondsIndividual[client];
|
||||
float l_fSecAdd;
|
||||
if (l_fRoundMinutesIndividual > l_fRoundMinutes)
|
||||
return 0.0;
|
||||
if (!state)
|
||||
if (l_fRoundSeconds < l_fRoundSecondsIndividual)
|
||||
{
|
||||
l_fRoundMinutes = l_fRoundMinutes - l_fRoundMinutesIndividual;
|
||||
if (l_fRoundSeconds < l_fRoundSecondsIndividual)
|
||||
l_fRoundMinutes--;
|
||||
return l_fRoundMinutes;
|
||||
while (l_fRoundSecondsIndividual < 60)
|
||||
{
|
||||
l_fRoundSecondsIndividual++;
|
||||
l_fSecAdd++;
|
||||
}
|
||||
float returnvalue = l_fSecAdd + l_fRoundSeconds;
|
||||
//PrintToChat(client, "returnvalue float: %f", returnvalue);
|
||||
return returnvalue;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (l_fRoundSeconds < l_fRoundSecondsIndividual)
|
||||
{
|
||||
while (l_fRoundSecondsIndividual < 60)
|
||||
{
|
||||
l_fRoundSecondsIndividual++;
|
||||
l_fSecAdd++;
|
||||
}
|
||||
return l_fSecAdd + l_fRoundSeconds;
|
||||
}
|
||||
else
|
||||
return l_fRoundSeconds - l_fRoundSecondsIndividual;
|
||||
float returnvalueminus = l_fRoundSeconds - l_fRoundSecondsIndividual;
|
||||
//PrintToChat(client, "returnvalueminus float: %f", returnvalueminus);
|
||||
return returnvalueminus;
|
||||
}
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
@ -359,9 +452,9 @@ public void MYSQLCheckMapEntry()
|
||||
SQL_TQuery(g_dDatabase, TqueryThreadCallback, sQuery);
|
||||
}
|
||||
else
|
||||
for (int i = 0; i <= l_iZoneCount; i++)
|
||||
for (int iterator = 0; iterator <= l_iZoneCount; iterator++)
|
||||
{
|
||||
if (IsCorrectZone(i, l_cZoneIndexName[i][g_dLength -1], "ZONE_PREFIX_RACE"))
|
||||
if (IsCorrectZone(iterator, l_cZoneIndexName[iterator][g_dLength -1], "ZONE_PREFIX_RACE"))
|
||||
{
|
||||
l_iRaceCount++;
|
||||
Format(sQuery, sizeof(sQuery), "SELECT `%sS%i` FROM `zetimer_table` LIMIT 1", g_cMapname, l_iRaceCount);
|
||||
@ -372,50 +465,10 @@ public void MYSQLCheckMapEntry()
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public void TqueryThreadRecentCheckStageSteamID(Handle owner, Handle rs, const char[] error, any data)
|
||||
{
|
||||
int client = 0;
|
||||
if (!(client = GetClientOfUserId(data)))
|
||||
return;
|
||||
g_bRecentTimes[client] = false;
|
||||
if (SQL_GetRowCount(rs) > 0 && SQL_FetchRow(rs))
|
||||
{
|
||||
g_bRecentTimes[client] = true;
|
||||
g_iTableCountID = SQL_FetchInt(rs, 0);
|
||||
}
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose: we define the last 500 updated times as "recently", this indicates that recent times will display 500 and not more
|
||||
//---------------------------------------------------------------------------------------------------
|
||||
public void TqueryThreadRecentTimesCount(Handle owner, Handle rs, const char[] error, any data)
|
||||
{
|
||||
if (SQL_GetRowCount(rs) > 0 && SQL_FetchRow(rs))
|
||||
{
|
||||
int l_isize = SQL_GetRowCount(rs);
|
||||
if (l_isize >= 500)
|
||||
g_iTableCountID = 1;
|
||||
else
|
||||
g_iTableCountID = 0;
|
||||
}
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public void TqueryThreadRecentCount(Handle owner, Handle rs, const char[] error, any data)
|
||||
{
|
||||
if (SQL_GetRowCount(rs) > 0 && SQL_FetchRow(rs))
|
||||
{
|
||||
g_iTableCountID = SQL_FetchInt(rs, 0);
|
||||
}
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public void TqueryThreadCallback(Handle owner, Handle rs, const char[] error, any data)
|
||||
{
|
||||
int l_iRaceCount;
|
||||
int l_iZoneCount = unloze_zoneCount();
|
||||
int l_iCountFix = GetTotalRaceZones();
|
||||
int client = 0;
|
||||
float l_fRecordTotal;
|
||||
char sQuery[g_dLength];
|
||||
@ -433,9 +486,9 @@ public void TqueryThreadCallback(Handle owner, Handle rs, const char[] error, an
|
||||
else
|
||||
{
|
||||
//this might seem repetitive but one null check adds all required coloumns
|
||||
for (int i = 0; i <= l_iZoneCount; i++)
|
||||
for (int iterator = 0; iterator <= l_iZoneCount; iterator++)
|
||||
{
|
||||
if (IsCorrectZone(i, l_cZoneIndexName[i][g_dLength -1], "ZONE_PREFIX_RACE"))
|
||||
if (IsCorrectZone(iterator, l_cZoneIndexName[iterator][g_dLength -1], "ZONE_PREFIX_RACE"))
|
||||
{
|
||||
l_iRaceCount++;
|
||||
Format(sQuery, sizeof(sQuery), "ALTER TABLE `zetimer_table` ADD COLUMN `%sS%i` DECIMAL(13,3) NOT NULL", g_cMapname, l_iRaceCount);
|
||||
@ -447,22 +500,29 @@ public void TqueryThreadCallback(Handle owner, Handle rs, const char[] error, an
|
||||
}
|
||||
if (!(client = GetClientOfUserId(data)))
|
||||
return;
|
||||
if (l_iCountFix < g_iRaceCount[client])
|
||||
int rowsize = SQL_GetRowCount(rs);
|
||||
if (rowsize > 0 && SQL_FetchRow(rs))
|
||||
{
|
||||
g_iRaceCount[client] = 0;
|
||||
}
|
||||
if (SQL_GetRowCount(rs) > 0 && SQL_FetchRow(rs))
|
||||
{
|
||||
l_fRecordTotal = SQL_FetchFloat(rs, 0);
|
||||
g_iRecordMinutes[client][g_iRaceCount[client]] = (RoundToFloor(l_fRecordTotal));
|
||||
g_fRecordSeconds[client][g_iRaceCount[client]] = (l_fRecordTotal - g_iRecordMinutes[client][g_iRaceCount[client]]) * 100;
|
||||
g_iClientStage[client] = 0;
|
||||
int fieldSize = SQL_GetFieldCount(rs);
|
||||
for (int iterate = 0; iterate < fieldSize; iterate++)
|
||||
{
|
||||
l_fRecordTotal = SQL_FetchFloat(rs, iterate);
|
||||
g_iClientStage[client]++;
|
||||
g_iRecordMinutes[client][g_iClientStage[client]] = (RoundToFloor(l_fRecordTotal));
|
||||
g_fRecordSeconds[client][g_iClientStage[client]] = (l_fRecordTotal - g_iRecordMinutes[client][g_iClientStage[client]]) * 100;
|
||||
/*
|
||||
PrintToChat(client, "g_iRecordMinutes[client][g_iClientStage[client]]: %i\ng_fRecordSeconds[client][g_iClientStage[client]] %f",
|
||||
g_iRecordMinutes[client][g_iClientStage[client]], g_fRecordSeconds[client][g_iClientStage[client]]);
|
||||
PrintToChat(client, "g_iClientStage[client]: %i", g_iClientStage[client]);
|
||||
*/
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
g_iRecordMinutes[client][g_iRaceCount[client]] = 0;
|
||||
g_fRecordSeconds[client][g_iRaceCount[client]] = 0.0;
|
||||
g_iRecordMinutes[client][g_iClientStage[client]] = 0;
|
||||
g_fRecordSeconds[client][g_iClientStage[client]] = 0.0;
|
||||
}
|
||||
g_iRaceCount[client]++;
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose: TODO implement if needed
|
||||
@ -472,10 +532,10 @@ public int GetTotalRaceZones()
|
||||
int l_iZoneCount = unloze_zoneCount();
|
||||
char l_cIndexName[g_dLength];
|
||||
int l_iCountRace;
|
||||
for (int i = 0; i < l_iZoneCount; i++)
|
||||
for (int iterator = 0; iterator < l_iZoneCount; iterator++)
|
||||
{
|
||||
ZoneNameBasedOnIndex(i, l_cIndexName[i]);
|
||||
if (StrContains(l_cIndexName[i], "ZONE_PREFIX_RACE") > -1)
|
||||
ZoneNameBasedOnIndex(iterator, l_cIndexName[iterator]);
|
||||
if (StrContains(l_cIndexName[iterator], "ZONE_PREFIX_RACE") > -1)
|
||||
l_iCountRace++;
|
||||
}
|
||||
return l_iCountRace;
|
||||
@ -483,17 +543,16 @@ public int GetTotalRaceZones()
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public void sendMYSQL(int client, float minutes, float seconds, int oldminutes, float oldseconds, int stage)
|
||||
public void sendMYSQL(int client, int minutes, float seconds, int oldminutes, float oldseconds, int stage)
|
||||
{
|
||||
int l_iZoneCount = unloze_zoneCount();
|
||||
float l_fPlayerTime;
|
||||
float l_fPlayerTime = float(minutes);
|
||||
float l_fPlayerTimeOld;
|
||||
char sSID[g_dIndex];
|
||||
char l_cClientName[g_dIndex];
|
||||
char l_cStage[90];
|
||||
char sQuery[g_dLength];
|
||||
char sName[MAX_NAME_LENGTH];
|
||||
stage++;
|
||||
GetClientAuthId(client, AuthId_Steam2, sSID, sizeof(sSID));
|
||||
GetClientName(client, sName, sizeof(sName));
|
||||
int size2 = 2 * strlen(sName) + 1;
|
||||
@ -501,9 +560,8 @@ public void sendMYSQL(int client, float minutes, float seconds, int oldminutes,
|
||||
SQL_EscapeString(g_dDatabase, sName, sEscapedName, size2 + 1);
|
||||
Format(l_cClientName, sizeof(l_cClientName), sEscapedName);
|
||||
//STEAM_ID_STOP_IGNORING_RETVALS might be considered exploit?
|
||||
if (StrEqual(sSID, "STEAM_ID_STOP_IGNORING_RETVALS"))
|
||||
if (StrEqual(sSID, "STEAM_ID_STOP_IGNORING_RETVALS") || StrEqual(sSID, "STEAM_ID_PENDING"))
|
||||
return;
|
||||
l_fPlayerTime = minutes;
|
||||
l_fPlayerTime = l_fPlayerTime + (seconds / 100);
|
||||
if (oldminutes != 0 || oldseconds != 0.0)
|
||||
{
|
||||
@ -513,13 +571,13 @@ public void sendMYSQL(int client, float minutes, float seconds, int oldminutes,
|
||||
Format(l_cStage, sizeof(l_cStage), "%sS%i", g_cMapname, stage);
|
||||
else
|
||||
Format(l_cStage, sizeof(l_cStage), "%s", g_cMapname);
|
||||
MYSQLSafeTime(client, l_cStage, l_fPlayerTimeOld);
|
||||
}
|
||||
if (l_iZoneCount < 2)
|
||||
Format(sQuery, sizeof(sQuery), "INSERT INTO `zetimer_table` (`steam_auth`, `name`, `%s`) VALUES ('%s', '%s', '%f') ON DUPLICATE KEY UPDATE `name` = '%s', `%s` = '%f'", g_cMapname, sSID, l_cClientName, l_fPlayerTime, l_cClientName, g_cMapname, l_fPlayerTime);
|
||||
else
|
||||
Format(sQuery, sizeof(sQuery), "INSERT INTO `zetimer_table` (`steam_auth`, `name`, `%sS%i`) VALUES ('%s', '%s', '%f') ON DUPLICATE KEY UPDATE `name` = '%s', `%sS%i` = '%f'", g_cMapname, stage, sSID, l_cClientName, l_fPlayerTime, l_cClientName, g_cMapname, stage, l_fPlayerTime);
|
||||
SQL_TQuery(g_dDatabase, DummyCallbackSimple, sQuery);
|
||||
//PrintToChatAll("SEND MYSQL sQuery: %s", sQuery);
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
@ -537,86 +595,36 @@ public void SQL_StartConnection()
|
||||
char sQuery[g_dLength];
|
||||
Format(sQuery, sizeof(sQuery), "CREATE TABLE IF NOT EXISTS `zetimer_table` (`steam_auth` VARCHAR(254) NOT NULL, `name` VARCHAR(254) NOT NULL, PRIMARY KEY (`steam_auth`))");
|
||||
SQL_TQuery(g_dDatabase, DummyCallbackSimple, sQuery);
|
||||
Format(sQuery, sizeof(sQuery), "CREATE TABLE IF NOT EXISTS `unloze_racetimer_css`.`recenttimes_table` (`ID` INT NOT NULL AUTO_INCREMENT, `Steam_auth` VARCHAR(45) NOT NULL, `Stage` VARCHAR(90) NOT NULL, `Oldtime` VARCHAR(45) NOT NULL, PRIMARY KEY (`ID`)) ENGINE = InnoDB;");
|
||||
SQL_TQuery(g_dDatabase, DummyCallbackSimple, sQuery);
|
||||
Format(sQuery, sizeof(sQuery), "CREATE TABLE IF NOT EXISTS `unloze_racetimer_css`.`recenttimes_tableCount` (`ID` INT NOT NULL, PRIMARY KEY (`ID`)) ENGINE = InnoDB;");
|
||||
SQL_TQuery(g_dDatabase, DummyCallbackSimple, sQuery);
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public void MYSQLSafeTime(int client, char[] stage, float oldtime)
|
||||
{
|
||||
char sSID[g_dIndex];
|
||||
char sQuery[g_dLength];
|
||||
GetClientAuthId(client, AuthId_Steam2, sSID, sizeof(sSID));
|
||||
//maybe %f is questionable here
|
||||
//check if same steam ID on same Stage is present
|
||||
Format(sQuery, sizeof(sQuery), "SELECT * FROM `recenttimes_table` WHERE `Steam_auth` = '%s' AND `Stage` = '%s'", sSID, stage);
|
||||
SQL_TQuery(g_dDatabase, TqueryThreadRecentCheckStageSteamID, sQuery, client);
|
||||
if (g_bRecentTimes[client])
|
||||
{
|
||||
Format(sQuery, sizeof(sQuery), "UPDATE `recenttimes_table` SET `Steam_auth` = '%s', `Stage` = '%s', `Oldtime` = '%f' WHERE `ID`='%i'", sSID, stage, oldtime, g_iTableCountID);
|
||||
SQL_TQuery(g_dDatabase, DummyCallbackSimple, sQuery);
|
||||
}
|
||||
else
|
||||
{
|
||||
Format(sQuery, sizeof(sQuery), "SELECT * FROM `recenttimes_table`");
|
||||
SQL_TQuery(g_dDatabase, TqueryThreadRecentTimesCount, sQuery);
|
||||
if (!g_iTableCountID)
|
||||
{
|
||||
Format(sQuery, sizeof(sQuery), "INSERT INTO `recenttimes_table` (`ID`,`Steam_auth`,`Stage`,`Oldtime`) VALUES (NULL,'%s','%s','%f')", sSID, stage, oldtime);
|
||||
SQL_TQuery(g_dDatabase, DummyCallbackSimple, sQuery);
|
||||
}
|
||||
else
|
||||
{
|
||||
Format(sQuery, sizeof(sQuery), "SELECT * FROM `recenttimes_tableCount`");
|
||||
SQL_TQuery(g_dDatabase, TqueryThreadRecentCount, sQuery);
|
||||
if (g_iTableCountID <= 500)
|
||||
{
|
||||
Format(sQuery, sizeof(sQuery), "UPDATE `recenttimes_tableCount` SET `ID` = '%i'", g_iTableCountID + 1);
|
||||
SQL_TQuery(g_dDatabase, DummyCallbackSimple, sQuery);
|
||||
}
|
||||
else
|
||||
{
|
||||
Format(sQuery, sizeof(sQuery), "UPDATE `recenttimes_tableCount` SET `ID` = '1'");
|
||||
SQL_TQuery(g_dDatabase, DummyCallbackSimple, sQuery);
|
||||
g_iTableCountID = 1;
|
||||
}
|
||||
Format(sQuery, sizeof(sQuery), "UPDATE `recenttimes_table` SET `Steam_auth` = '%s', `Stage` = '%s', `Oldtime` = '%f' WHERE `ID`='%i'", sSID, stage, oldtime, g_iTableCountID);
|
||||
SQL_TQuery(g_dDatabase, DummyCallbackSimple, sQuery);
|
||||
}
|
||||
}
|
||||
MYSQLCheckMapEntry();
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public void MYSQLCheckRecord(int client)
|
||||
{
|
||||
g_iRaceCount[client] = 0;
|
||||
int l_iZoneCount = unloze_zoneCount();
|
||||
int l_iRaceCount;
|
||||
char sSID[g_dIndex];
|
||||
char sQuery[g_dLength];
|
||||
char l_cZoneIndexName[g_dIndex][g_dLength];
|
||||
int l_iZoneCount = unloze_zoneCount();
|
||||
//PrintToChat(client, "l_iZoneCount: %i", l_iZoneCount);
|
||||
GetClientAuthId(client, AuthId_Steam2, sSID, sizeof(sSID));
|
||||
if (l_iZoneCount < 2)
|
||||
StrCat(sQuery, sizeof(sQuery), "SELECT ");
|
||||
if (l_iZoneCount > 1)
|
||||
{
|
||||
Format(sQuery, sizeof(sQuery), "SELECT `%s` FROM `zetimer_table` WHERE steam_auth = '%s'", g_cMapname, sSID);
|
||||
SQL_TQuery(g_dDatabase, TqueryThreadCallback, sQuery, GetClientUserId(client));
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i <= l_iZoneCount; i++)
|
||||
for (int iterator = 0; iterator < l_iZoneCount / 2; iterator++)
|
||||
{
|
||||
if (IsCorrectZone(i, l_cZoneIndexName[i][g_dLength -1], "ZONE_PREFIX_RACE"))
|
||||
if (iterator > 0)
|
||||
{
|
||||
l_iRaceCount++;
|
||||
Format(sQuery, sizeof(sQuery), "SELECT `%sS%i` FROM `zetimer_table` WHERE steam_auth = '%s'", g_cMapname, l_iRaceCount, sSID);
|
||||
SQL_TQuery(g_dDatabase, TqueryThreadCallback, sQuery, GetClientUserId(client));
|
||||
StrCat(sQuery, sizeof(sQuery), ",");
|
||||
}
|
||||
char mapstage[g_dLength];
|
||||
Format(mapstage, sizeof(mapstage), "%sS%i", g_cMapname, iterator + 1);
|
||||
StrCat(sQuery, sizeof(sQuery), mapstage);
|
||||
}
|
||||
}
|
||||
} else { StrCat(sQuery, sizeof(sQuery), g_cMapname); }
|
||||
char endQuery[g_dLength];
|
||||
Format(endQuery, sizeof(endQuery), " FROM `zetimer_table` WHERE steam_auth = '%s'", sSID);
|
||||
StrCat(sQuery, sizeof(sQuery), endQuery);
|
||||
SQL_TQuery(g_dDatabase, TqueryThreadCallback, sQuery, GetClientUserId(client));
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
@ -625,7 +633,6 @@ public void DummyCallbackSimple(Handle hOwner, Handle hChild, const char[] err,
|
||||
{
|
||||
if (hOwner == null || hChild == null)
|
||||
LogError("Query error. (%s)", err);
|
||||
MYSQLCheckMapEntry();
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
@ -642,16 +649,18 @@ public void CheckTop(int client, int index, int autismstate)
|
||||
{
|
||||
int l_iZoneCount = unloze_zoneCount();
|
||||
char sQuery[g_dLength];
|
||||
if (!l_iZoneCount)
|
||||
//PrintToChatAll("checktop l_iZoneCount: %i", l_iZoneCount);
|
||||
if (l_iZoneCount < 1)
|
||||
{
|
||||
CPrintToChat(client, "[UNLOZE] Map does not support race timer");
|
||||
PrintToChat(client, "No zones active on this map");
|
||||
return;
|
||||
}
|
||||
if (l_iZoneCount > 1 && !autismstate)
|
||||
if (!autismstate)
|
||||
{
|
||||
CheckStagesOnMap(client, 0);
|
||||
return;
|
||||
}
|
||||
//we have index now from menu selection
|
||||
if (l_iZoneCount < 2)
|
||||
Format(sQuery, sizeof(sQuery), "SELECT name, %s FROM `zetimer_table` WHERE %s > 0.000 ORDER BY %s ASC LIMIT 10", g_cMapname, g_cMapname, g_cMapname);
|
||||
else
|
||||
@ -715,29 +724,6 @@ public Action cmd_timerCheckStage(int client, int args)
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public Action cmd_threadtest(int client, int args)
|
||||
{
|
||||
g_iRaceCount[client] = 0;
|
||||
int l_iRaceCount;
|
||||
int l_iZoneCount = unloze_zoneCount();
|
||||
char sQuery[g_dLength];
|
||||
char l_cZoneIndexName[g_dIndex][g_dLength];
|
||||
char sSID[g_dIndex];
|
||||
GetClientAuthId(client, AuthId_Steam2, sSID, sizeof(sSID));
|
||||
for (int i = 0; i <= l_iZoneCount; i++)
|
||||
{
|
||||
if (IsCorrectZone(i, l_cZoneIndexName[i][g_dLength -1], "ZONE_PREFIX_RACE"))
|
||||
{
|
||||
l_iRaceCount++;
|
||||
Format(sQuery, sizeof(sQuery), "SELECT `%sS%i` FROM `zetimer_table` WHERE steam_auth = '%s'", g_cMapname, l_iRaceCount, sSID);
|
||||
SQL_TQuery(g_dDatabase, TqueryThreadCallback, sQuery, GetClientUserId(client));
|
||||
}
|
||||
}
|
||||
return Plugin_Handled;
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public void CheckStagesOnMap(int client, int state)
|
||||
{
|
||||
int l_iCount;
|
||||
@ -755,19 +741,22 @@ public void CheckStagesOnMap(int client, int state)
|
||||
StageMenu.SetTitle("Stages on: %s", g_cMapname);
|
||||
if (g_bDisplaySpecial)
|
||||
{
|
||||
l_iCount++;
|
||||
Format(l_cMenuContent, sizeof(l_cMenuContent), "Stage: %i", l_iCount);
|
||||
StageMenu.AddItem("", l_cMenuContent);
|
||||
}
|
||||
else
|
||||
for (int i = 0; i <= l_iZoneCount; i++)
|
||||
{
|
||||
for (int Iterator = 0; Iterator <= l_iZoneCount; Iterator++)
|
||||
{
|
||||
if (IsCorrectZone(i, l_cZoneIndexName[i][g_dLength -1], "ZONE_PREFIX_RACE"))
|
||||
if (IsCorrectZone(Iterator, l_cZoneIndexName[Iterator][g_dLength -1], "ZONE_PREFIX_RACE"))
|
||||
{
|
||||
l_iCount++;
|
||||
Format(l_cMenuContent, sizeof(l_cMenuContent), "Stage: %i", l_iCount);
|
||||
StageMenu.AddItem("", l_cMenuContent);
|
||||
}
|
||||
}
|
||||
}
|
||||
StageMenu.ExitButton = true;
|
||||
StageMenu.Display(client, 0);
|
||||
}
|
||||
@ -822,9 +811,9 @@ public void Checkself(int client)
|
||||
char l_cQuery[g_dLength];
|
||||
char l_cSID[g_dIndex];
|
||||
GetClientAuthId(client, AuthId_Steam2, l_cSID, sizeof(l_cSID));
|
||||
if (!l_iZoneCount)
|
||||
if (l_iZoneCount < 1)
|
||||
{
|
||||
CPrintToChat(client, "[UNLOZE] Map does not support race timer");
|
||||
PrintToChat(client, "No zones active on this map");
|
||||
return;
|
||||
}
|
||||
if (l_iZoneCount < 2)
|
||||
|
@ -36,7 +36,7 @@ public int Native_Isspecialmap(Handle handler, int numParams)
|
||||
{
|
||||
CreateTimer(10.0, Timer_CheckStage, INVALID_HANDLE, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);
|
||||
GetCurrentMap(g_cMapname, sizeof(g_cMapname));
|
||||
if (StrEqual(g_cMapname, "ze_FFVII_Mako_Reactor_v5_3"))
|
||||
if (StrEqual(g_cMapname, "ze_FFVII_Mako_Reactor_v5_3", false))
|
||||
{
|
||||
g_bSpecialMap = true;
|
||||
return view_as<bool>(1);
|
||||
|
Loading…
Reference in New Issue
Block a user