removed 2 dimensional array and instead use mysql calls

Got reported some cases of times not updating correctly, also added dev output
This commit is contained in:
jenzur 2020-04-04 23:56:31 +02:00
parent c0d529f492
commit ef265dfdb0

View File

@ -21,21 +21,21 @@ int g_iRoundMinutes;
float g_fRoundSeconds;
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
//testing
int g_iClientStage[MAXPLAYERS + 1];
int g_iClientChecking[MAXPLAYERS + 1];
bool g_bDisplaySpecial;
bool g_bHumansAllowedTime[MAXPLAYERS + 1];
bool g_bHideTimer[MAXPLAYERS + 1];
bool g_bDev[MAXPLAYERS + 1];
Handle g_hClientCookie = INVALID_HANDLE;
Database g_dDatabase;
Handle hText;
float playertime_leaving_zone[MAXPLAYERS + 1];
int player_stage[MAXPLAYERS + 1];
public Plugin myinfo =
{
name = "UNLOZE_racetimer_css",
@ -55,6 +55,7 @@ public void OnPluginStart()
RegConsoleCmd("sm_stages", cmd_timerCheckStage, "Checking race stages");
RegConsoleCmd("sm_hidetimer", cmd_hideTimerHUD, "Hides timer HUD");
RegAdminCmd("sm_cleantime", Cmd_timeReset, ADMFLAG_GENERIC);
RegAdminCmd("sm_devtime", Cmd_devtest, ADMFLAG_GENERIC);
//hooks
HookEvent("round_start", Event_RoundStart, EventHookMode_PostNoCopy);
//HUD
@ -116,11 +117,16 @@ public void startTimer()
//----------------------------------------------------------------------------------------------------
public Action Timer_CountdownRace(Handle timer, any data)
{
g_fRoundSeconds += 0.1;
if (g_fRoundSeconds > 59.9)
float l_milisecond = 0.0000;
while (l_milisecond < 0.1000)
{
g_iRoundMinutes += 1;
g_fRoundSeconds = 0.0;
l_milisecond += 0.0001;
g_fRoundSeconds += 0.0001;
if (g_fRoundSeconds > 59.9999)
{
g_iRoundMinutes += 1;
g_fRoundSeconds = 0.0000;
}
}
}
//----------------------------------------------------------------------------------------------------
@ -135,11 +141,13 @@ public void Event_RoundStart(Handle event, const char[] name, bool dontBroadcast
if (IsValidClient(i))
{
resetClientVectors(i);
MYSQLCheckRecord(i);
if (l_iZoneCount != 1)
g_bHumansAllowedTime[i] = false;
else
{
mysql_get_player_time(i, 0);
g_bHumansAllowedTime[i] = true;
}
}
}
//----------------------------------------------------------------------------------------------------
@ -148,8 +156,6 @@ public void Event_RoundStart(Handle event, const char[] name, bool dontBroadcast
public void OnClientPostAdminCheck(int client)
{
resetClient(client);
MYSQLCheckRecord(client);
g_bHumansAllowedTime[client] = false;
}
//----------------------------------------------------------------------------------------------------
// Purpose:
@ -175,14 +181,11 @@ public void resetClient(int client)
g_fSecondsIndividual[client] = 0.0;
g_iMinutesIndividual[client] = 0;
g_iClientChecking[client] = 0;
g_iClientStage[client] = 0;
g_bHumansAllowedTime[client] = false;
resetClientVectors(client);
for (int iterator = 0; iterator < 100; iterator++)
{
g_iRecordMinutes[client][iterator] = 0;
g_fRecordSeconds[client][iterator] = 0.0;
}
g_bDev[client] = false;
player_stage[client] = 0;
playertime_leaving_zone[client] = 0.0;
}
//----------------------------------------------------------------------------------------------------
// Purpose:
@ -197,7 +200,7 @@ public Action OnPlayerRunCmd(int client, int &buttons, int &impulse, float vel[3
g_iClientFrames[client] = 0;
float clientVectors[3];
GetClientAbsOrigin(client, clientVectors);
if (checkClientOrigin(g_fClientVectors[client], clientVectors, client))
if (checkClientOrigin(g_fClientVectors[client], clientVectors, client) && !g_bDev[client])
{
g_bHumansAllowedTime[client] = false;
resetClientVectors(client);
@ -205,7 +208,7 @@ public Action OnPlayerRunCmd(int client, int &buttons, int &impulse, float vel[3
return Plugin_Continue;
}
int speedCheckerCap = 10;
if (g_iClientSpeedInterval[client] > speedCheckerCap)
if (g_iClientSpeedInterval[client] > speedCheckerCap && !g_bDev[client])
{
g_iClientSpeedInterval[client] = 0;
bool bNoclip = (GetEntityMoveType(client) == MOVETYPE_NOCLIP);
@ -248,32 +251,37 @@ public Action OnPlayerRunCmd(int client, int &buttons, int &impulse, float vel[3
SetHudTextParams(0.35, 0.85, 0.1, 125, 255, 255, 85);
int l_iCalculateMins = CalculateValuesMinutes(client);
float l_fCalculateSecs = CalculateValues(client);
float leftover_seconds = playertime_leaving_zone[client] - RoundToFloor(playertime_leaving_zone[client]);
leftover_seconds = leftover_seconds * 100;
int minutes = RoundToFloor(playertime_leaving_zone[client]);
if (g_bDev[client])
{
//PrintToChat(client, "leftover_seconds: %f", leftover_seconds);
//PrintToChat(client, "minutes: %i", minutes);
}
if (l_fCalculateSecs < 10.0)
{
if (g_fRecordSeconds[client][g_iClientStage[client]] < 10.0)
if (leftover_seconds < 10.0)
{
ShowSyncHudText(client, hText, "%N Time: 0%i:0%.1f\nRecord: 0%i:0%.1f\nMap: %s\nCourse: %i", client, l_iCalculateMins,
l_fCalculateSecs, g_iRecordMinutes[client][g_iClientStage[client]], g_fRecordSeconds[client][g_iClientStage[client]],
g_cMapname, g_iClientStage[client]);
} else
ShowSyncHudText(client, hText, "%N Time: 0%i:0%.4f\nRecord: 0%i:0%.4f\nMap: %s\nCourse: %i", client, l_iCalculateMins,
l_fCalculateSecs, minutes, leftover_seconds, g_cMapname, player_stage[client]);
}
else
{
ShowSyncHudText(client, hText, "%N Time: 0%i:0%.1f\nRecord: 0%i:%.1f\nMap: %s\nCourse: %i", client, l_iCalculateMins,
l_fCalculateSecs, g_iRecordMinutes[client][g_iClientStage[client]], g_fRecordSeconds[client][g_iClientStage[client]],
g_cMapname, g_iClientStage[client]);
ShowSyncHudText(client, hText, "%N Time: 0%i:0%.4f\nRecord: 0%i:%.4f\nMap: %s\nCourse: %i", client, l_iCalculateMins,
l_fCalculateSecs, minutes, leftover_seconds, g_cMapname, player_stage[client]);
}
}
else
{
if (g_fRecordSeconds[client][g_iClientStage[client]] < 10.0)
if (leftover_seconds < 10.0)
{
ShowSyncHudText(client, hText, "%N Time: 0%i:%.1f\nRecord: 0%i:0%.1f\nMap: %s\nCourse: %i", client, l_iCalculateMins,
l_fCalculateSecs, g_iRecordMinutes[client][g_iClientStage[client]], g_fRecordSeconds[client][g_iClientStage[client]],
g_cMapname, g_iClientStage[client]);
ShowSyncHudText(client, hText, "%N Time: 0%i:%.4f\nRecord: 0%i:0%.4f\nMap: %s\nCourse: %i", client, l_iCalculateMins,
l_fCalculateSecs, minutes, leftover_seconds, g_cMapname, player_stage[client]);
} else
{
ShowSyncHudText(client, hText, "%N Time: 0%i:%.1f\nRecord: %i:%.1f\nMap: %s\nCourse: %i", client, l_iCalculateMins,
l_fCalculateSecs, g_iRecordMinutes[client][g_iClientStage[client]], g_fRecordSeconds[client][g_iClientStage[client]],
g_cMapname, g_iClientStage[client]);
ShowSyncHudText(client, hText, "%N Time: 0%i:%.4f\nRecord: 0%i:%.4f\nMap: %s\nCourse: %i", client, l_iCalculateMins,
l_fCalculateSecs, minutes, leftover_seconds, g_cMapname, player_stage[client]);
}
}
}
@ -335,18 +343,15 @@ public void unloze_zoneEntry(int client, char[] zone)
{
if (l_iZoneCount < 2)
{
g_iClientStage[client] = 0;
player_stage[client] = 0;
}
if (g_iClientStage[client] == (zoneIndex / 2) || l_iZoneCount < 2)
if (player_stage[client] == (zoneIndex / 2) || l_iZoneCount < 2)
{
FinishedStageRaceZone(client);
}
}
else
{
PrintToChat(client, "Timer not Saved Due to client being un-Authenticated, restart your game or steam.");
}
g_bHumansAllowedTime[client] = false;
if (!g_bDev[client])
g_bHumansAllowedTime[client] = false;
}
}
//----------------------------------------------------------------------------------------------------
@ -361,9 +366,10 @@ public void unloze_zoneLeave(int client, char[] zone)
g_fSecondsIndividual[client] = g_fRoundSeconds;
g_iMinutesIndividual[client] = g_iRoundMinutes;
float notRounded = float(RetrieveZoneIndex(zone));
g_iClientStage[client] = RoundToCeil(notRounded / 2);
player_stage[client] = RoundToCeil(notRounded / 2);
mysql_get_player_time(client, player_stage[client]);
g_bHumansAllowedTime[client] = true;
CPrintToChat(client, "Timer started for Course: %i", g_iClientStage[client]);
CPrintToChat(client, "Timer started for Course: %i", player_stage[client]);
}
}
//----------------------------------------------------------------------------------------------------
@ -387,9 +393,7 @@ public void CheckIfSpecialRoundZones(char[] resultstart, char[] resultend)
public void CheckifAntiZones(int client, bool reset)
{
if (reset)
{
g_bHumansAllowedTime[client] = false;
}
}
//----------------------------------------------------------------------------------------------------
// Purpose:
@ -414,25 +418,23 @@ public void FinishedStageRaceZone(int client)
int l_iZoneCount = unloze_zoneCount();
int l_iCalculateMins;
float l_fCalculateSecs;
if (g_fRecordSeconds[client][g_iClientStage[client]] < 10.0)
{
CPrintToChat(client, "Your record: 0%i:0%.1f \nCommand: !toptime !mytime !stages", g_iRecordMinutes[client][g_iClientStage[client]],
g_fRecordSeconds[client][g_iClientStage[client]]);
} else
{
CPrintToChat(client, "Your record: 0%i:%.1f \nCommand: !toptime !mytime !stages", g_iRecordMinutes[client][g_iClientStage[client]],
g_fRecordSeconds[client][g_iClientStage[client]]);
}
float leftover_seconds = playertime_leaving_zone[client] - RoundToFloor(playertime_leaving_zone[client]);
int minutes = RoundToFloor(playertime_leaving_zone[client]);
leftover_seconds = leftover_seconds * 100;
if (g_bDev[client])
PrintToChat(client, "leftover_seconds: %f", leftover_seconds);
if (leftover_seconds < 10.0)
CPrintToChat(client, "Your record: 0%i:0%.4f \nCommand: !toptime !mytime !stages", minutes, leftover_seconds);
else
CPrintToChat(client, "Your record: 0%i:%.4f \nCommand: !toptime !mytime !stages", minutes, leftover_seconds);
if (l_iZoneCount < 2)
{
//no start zone, we use round time
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]])
|| (g_iRecordMinutes[client][g_iClientStage[client]] == 0.0 && g_fRecordSeconds[client][g_iClientStage[client]] == 0.0))
CPrintToChat(client, "{green}[UNLOZE] Client: %N Time: 0%i:%.4f", client, g_iRoundMinutes, g_fRoundSeconds);
if ((g_iRoundMinutes < minutes) || (g_iRoundMinutes == minutes && g_fRoundSeconds > leftover_seconds)
|| (minutes == 0.0 && leftover_seconds == 0.0))
{
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");
sendMYSQL(client, g_iRoundMinutes, g_fRoundSeconds, player_stage[client]);
}
}
else
@ -441,18 +443,14 @@ public void FinishedStageRaceZone(int client)
l_iCalculateMins = CalculateValuesMinutes(client);
l_fCalculateSecs = CalculateValues(client);
//tricking ppl !hehe
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]])
|| (g_iRecordMinutes[client][g_iClientStage[client]] == 0.0 && g_fRecordSeconds[client][g_iClientStage[client]] == 0.0))
CPrintToChat(client, "{green}[UNLOZE] Stage: %i", player_stage[client]);
CPrintToChat(client, "{green}[UNLOZE] Client: %N Time: 0%i:%.4f", client, l_iCalculateMins, l_fCalculateSecs);
if ((l_iCalculateMins < minutes) || (l_iCalculateMins == minutes && l_fCalculateSecs > leftover_seconds)
|| (minutes == 0.0 && leftover_seconds == 0.0))
{
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");
sendMYSQL(client, l_iCalculateMins, l_fCalculateSecs, player_stage[client]);
}
}
//matching the message
MYSQLCheckRecord(client);
}
//----------------------------------------------------------------------------------------------------
// Purpose:
@ -499,6 +497,33 @@ public float CalculateValues(int client)
return returnvalueminus;
}
}
public void mysql_get_player_time(int client, int stage)
{
DBResultSet rs;
char query[g_dLength];
char steam_auth[g_dIndex];
GetClientAuthId(client, AuthId_Steam2, steam_auth, sizeof(steam_auth));
if (!stage)
Format(query, sizeof(query), "SELECT `%s` FROM `zetimer_table` where steam_auth = '%s'", g_cMapname, steam_auth);
else
Format(query, sizeof(query), "SELECT `%sS%i` FROM `zetimer_table` where steam_auth = '%s'", g_cMapname, stage, steam_auth);
if ((rs = SQL_Query(g_dDatabase, query)) == null)
{
delete rs;
return;
}
rs.FetchRow();
if (rs.RowCount > 0)
playertime_leaving_zone[client] = rs.FetchFloat(0);
if (g_bDev[client])
{
PrintToChat(client, "query: %s", query);
PrintToChat(client, "playertime_leaving_zone[client]: %f", playertime_leaving_zone[client]);
}
delete rs;
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
@ -531,18 +556,13 @@ public void TqueryThreadCallback(Handle owner, Handle rs, const char[] error, an
{
int l_iRaceCount;
int l_iZoneCount = unloze_zoneCount();
int client = 0;
float l_fRecordTotal;
char sQuery[g_dLength];
char l_cZoneIndexName[g_dIndex][g_dLength];
/*
*the null check is for MYSQLCheckMapEntry and MYSQLCheckRecord to check if tables exist
*/
if (rs == null)
{
if (l_iZoneCount == 1)
{
Format(sQuery, sizeof(sQuery), "ALTER TABLE `zetimer_table` ADD COLUMN `%s` DECIMAL(13,3) NOT NULL", g_cMapname);
Format(sQuery, sizeof(sQuery), "ALTER TABLE `zetimer_table` ADD COLUMN `%s` DECIMAL(8,7) NOT NULL DEFAULT 0.000000", g_cMapname);
SQL_FastQuery(g_dDatabase, sQuery);
}
else
@ -553,37 +573,11 @@ public void TqueryThreadCallback(Handle owner, Handle rs, const char[] error, an
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);
Format(sQuery, sizeof(sQuery), "ALTER TABLE `zetimer_table` ADD COLUMN `%sS%i` DECIMAL(8,7) NOT NULL DEFAULT 0.000000", g_cMapname, l_iRaceCount);
SQL_FastQuery(g_dDatabase, sQuery);
}
}
}
return;
}
if (!(client = GetClientOfUserId(data)))
return;
int rowsize = SQL_GetRowCount(rs);
if (rowsize > 0 && SQL_FetchRow(rs))
{
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_iClientStage[client]] = 0;
g_fRecordSeconds[client][g_iClientStage[client]] = 0.0;
}
}
//----------------------------------------------------------------------------------------------------
@ -605,15 +599,14 @@ public int GetTotalRaceZones()
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public void sendMYSQL(int client, int minutes, float seconds, int oldminutes, float oldseconds, int stage)
public void sendMYSQL(int client, int minutes, float seconds, int stage)
{
int l_iZoneCount = unloze_zoneCount();
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 sQuery2[g_dLength];
char sName[MAX_NAME_LENGTH];
GetClientAuthId(client, AuthId_Steam2, sSID, sizeof(sSID));
GetClientName(client, sName, sizeof(sName));
@ -625,20 +618,47 @@ public void sendMYSQL(int client, int minutes, float seconds, int oldminutes, fl
if (StrEqual(sSID, "STEAM_ID_STOP_IGNORING_RETVALS") || StrEqual(sSID, "STEAM_ID_PENDING"))
return;
l_fPlayerTime = l_fPlayerTime + (seconds / 100);
if (oldminutes != 0 || oldseconds != 0.0)
{
l_fPlayerTimeOld += oldminutes;
l_fPlayerTimeOld = l_fPlayerTimeOld + (oldseconds / 100);
if (l_iZoneCount > 1)
Format(l_cStage, sizeof(l_cStage), "%sS%i", g_cMapname, stage);
else
Format(l_cStage, sizeof(l_cStage), "%s", g_cMapname);
}
if (l_iZoneCount < 2)
{
Format(sQuery2, sizeof(sQuery2), "SELECT %s FROM unloze_racetimer_css.zetimer_table zt where steam_auth = '%s'", g_cMapname, sSID);
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(sQuery2, sizeof(sQuery2), "SELECT %sS%i FROM unloze_racetimer_css.zetimer_table zt where steam_auth = '%s'", g_cMapname, stage, sSID);
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);
}
DBResultSet rs;
if ((rs = SQL_Query(g_dDatabase, sQuery2)) == null)
{
delete rs;
return;
}
rs.FetchRow();
if (!rs.RowCount)
{
delete rs;
return;
}
float oldtime = rs.FetchFloat(0);
bool update_time = l_fPlayerTime < oldtime ? true : false;
if (!update_time)
update_time = oldtime == 0.0 ? true : false;
delete rs;
if (g_bDev[client])
{
PrintToChat(client, "sQuery: %s", sQuery);
PrintToChat(client, "sQuery2: %s", sQuery2);
PrintToChat(client, "update_time: %i", update_time);
PrintToChat(client, "l_fPlayerTime: %f", l_fPlayerTime);
PrintToChat(client, "oldtime: %f", oldtime);
return;
}
if (update_time)
{
SQL_TQuery(g_dDatabase, DummyCallbackSimple, sQuery);
CPrintToChat(client, "Updated timer");
}
//PrintToChatAll("SEND MYSQL sQuery: %s", sQuery);
}
//----------------------------------------------------------------------------------------------------
@ -662,35 +682,6 @@ public void SQL_StartConnection()
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public void MYSQLCheckRecord(int client)
{
char sSID[g_dIndex];
char sQuery[g_dLength];
int l_iZoneCount = unloze_zoneCount();
//PrintToChat(client, "l_iZoneCount: %i", l_iZoneCount);
GetClientAuthId(client, AuthId_Steam2, sSID, sizeof(sSID));
StrCat(sQuery, sizeof(sQuery), "SELECT ");
if (l_iZoneCount > 1)
{
for (int iterator = 0; iterator < l_iZoneCount / 2; iterator++)
{
if (iterator > 0)
{
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:
//----------------------------------------------------------------------------------------------------
public void DummyCallbackSimple(Handle hOwner, Handle hChild, const char[] err, DataPack pack1)
{
if (hOwner == null || hChild == null)
@ -734,7 +725,7 @@ public void CheckTop(int client, int index, int autismstate)
//----------------------------------------------------------------------------------------------------
public void SQL_SelectTop_Callback(Handle db, Handle results, const char[] error, any data)
{
int client = GetClientOfUserId(data);
int iclient = GetClientOfUserId(data);
int l_iMinutes;
int l_iPosition;
float l_fRecord;
@ -742,7 +733,7 @@ public void SQL_SelectTop_Callback(Handle db, Handle results, const char[] error
//Player Name
char[] g_cPlayerName = new char[MAX_NAME_LENGTH];
char g_cContent[g_dLength];
if (client == 0)
if (iclient == 0)
{
return;
}
@ -755,7 +746,7 @@ public void SQL_SelectTop_Callback(Handle db, Handle results, const char[] error
l_fRecord = SQL_FetchFloat(results, 1);
l_iMinutes = RoundToFloor(l_fRecord);
l_iSeconds = (l_fRecord - l_iMinutes) * 100;
Format(g_cContent, sizeof(g_cContent), "#%i: Time: 0%i:%.1f - %s", l_iPosition, l_iMinutes, l_iSeconds, g_cPlayerName);
Format(g_cContent, sizeof(g_cContent), "#%i: Time: 0%i:%.4f - %s", l_iPosition, l_iMinutes, l_iSeconds, g_cPlayerName);
menu.AddItem("-1", g_cContent, ITEMDRAW_DISABLED);
}
if (!l_iPosition)
@ -763,7 +754,7 @@ public void SQL_SelectTop_Callback(Handle db, Handle results, const char[] error
menu.AddItem("-1", "No results. Commands: !toptime !stages", ITEMDRAW_DISABLED);
}
menu.ExitButton = true;
menu.Display(client, 0);
menu.Display(iclient, 0);
}
//----------------------------------------------------------------------------------------------------
// Purpose:
@ -778,6 +769,17 @@ public int MenuHandler1(Menu menu, MenuAction action, int param1, int param2)
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public Action Cmd_devtest(int client, int args)
{
if (!IsValidClient(client))
return Plugin_Handled;
g_bDev[client] = !g_bDev[client];
PrintToChat(client, "dev mode: %i", g_bDev[client]);
return Plugin_Handled;
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public Action Cmd_timeReset(int client, int args)
{
if (!IsValidClient(client))
@ -961,8 +963,8 @@ public void TqueryCheckSelf(Handle db, Handle rs, const char[] error, any data)
float l_iSeconds;
char l_cMessageContent[g_dLength];
char[] l_cPlayerName = new char[MAX_NAME_LENGTH];
int client;
if ((client = GetClientOfUserId(data)) == 0)
int iclient;
if ((iclient = GetClientOfUserId(data)) == 0)
return;
if (SQL_GetRowCount(rs) > 0 && SQL_FetchRow(rs))
{
@ -970,16 +972,16 @@ public void TqueryCheckSelf(Handle db, Handle rs, const char[] error, any data)
l_fRecord = SQL_FetchFloat(rs, 1);
if (l_fRecord == 0.000)
{
CPrintToChat(client, "You have no time yet!");
CPrintToChat(iclient, "You have no time yet!");
return;
}
l_iMinutes = RoundToFloor(l_fRecord);
l_iSeconds = (l_fRecord - l_iMinutes) * 100;
Format(l_cMessageContent, sizeof(l_cMessageContent), "%i:%.1f - %s", l_iMinutes, l_iSeconds, l_cPlayerName);
CPrintToChat(client, "Your best time: 0%s", l_cMessageContent);
Format(l_cMessageContent, sizeof(l_cMessageContent), "%i:%.4f - %s", l_iMinutes, l_iSeconds, l_cPlayerName);
CPrintToChat(iclient, "Your best time: 0%s", l_cMessageContent);
}
else
CPrintToChat(client, "You have no time yet!");
CPrintToChat(iclient, "You have no time yet!");
}
//----------------------------------------------------------------------------------------------------
// Purpose: