many updates
This commit is contained in:
		
							parent
							
								
									d29f3fa2f1
								
							
						
					
					
						commit
						bd82e3947f
					
				@ -1,7 +1,7 @@
 | 
			
		||||
#pragma semicolon 1
 | 
			
		||||
#define DEBUG
 | 
			
		||||
#define PLUGIN_AUTHOR "jenz"
 | 
			
		||||
#define PLUGIN_VERSION "1.7"
 | 
			
		||||
#define PLUGIN_VERSION "1.8"
 | 
			
		||||
#define g_dLength 400
 | 
			
		||||
#define g_dIndex 65
 | 
			
		||||
#include <sourcemod>
 | 
			
		||||
@ -13,6 +13,7 @@
 | 
			
		||||
#include <cstrike>
 | 
			
		||||
#include <sdktools>
 | 
			
		||||
#include <sdkhooks>
 | 
			
		||||
#include <connect>
 | 
			
		||||
#include <outputinfo>
 | 
			
		||||
#pragma newdecls required
 | 
			
		||||
char g_cMapname[g_dLength];
 | 
			
		||||
@ -29,6 +30,7 @@ bool g_bDisplaySpecial;
 | 
			
		||||
bool g_bHumansAllowedTime[MAXPLAYERS + 1];
 | 
			
		||||
bool g_bhumans_finished[MAXPLAYERS + 1];
 | 
			
		||||
bool g_bHideTimer[MAXPLAYERS + 1];
 | 
			
		||||
int g_bAllowToLeave[MAXPLAYERS + 1];
 | 
			
		||||
bool g_bEventBool = false;
 | 
			
		||||
Handle g_hClientCookie = INVALID_HANDLE;
 | 
			
		||||
Database g_dDatabase;
 | 
			
		||||
@ -40,7 +42,7 @@ public Plugin myinfo =
 | 
			
		||||
{
 | 
			
		||||
	name = "UNLOZE_racetimer_css",
 | 
			
		||||
	author = PLUGIN_AUTHOR,
 | 
			
		||||
	description = "tracers times on race maps",
 | 
			
		||||
	description = "tracks times on race maps on ze",
 | 
			
		||||
	version = PLUGIN_VERSION,
 | 
			
		||||
	url = "www.unloze.com"
 | 
			
		||||
};
 | 
			
		||||
@ -78,6 +80,7 @@ public void trigger_teleport(const char[] output, int entity_index, int client,
 | 
			
		||||
{
 | 
			
		||||
    if (IsValidEdict(entity_index) && IsValidClient(client) && g_bHumansAllowedTime[client])
 | 
			
		||||
	{
 | 
			
		||||
        //if its surf maps there most likely are needed teleports
 | 
			
		||||
		if (StrContains(g_cMapname, "surf", false) == -1)
 | 
			
		||||
		{
 | 
			
		||||
			g_bHumansAllowedTime[client] = false;
 | 
			
		||||
@ -115,7 +118,7 @@ public bool origin_command_check(int entity_index)
 | 
			
		||||
            if (StrContains(buffer, "origin", true) != -1)
 | 
			
		||||
                return true;
 | 
			
		||||
        }
 | 
			
		||||
        for     (int i = 0; i < count_starttouch; i++)
 | 
			
		||||
        for(int i = 0; i < count_starttouch; i++)
 | 
			
		||||
        {
 | 
			
		||||
            char buffer[g_dLength];
 | 
			
		||||
            GetOutputParameter(entity_index, "m_OnStartTouch", i, buffer, sizeof(buffer));
 | 
			
		||||
@ -138,7 +141,7 @@ public void SQL_OnDatabaseConnect(Database db, const char[] error, any data)
 | 
			
		||||
    g_dDatabase = db;
 | 
			
		||||
    //create tables
 | 
			
		||||
    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`))");
 | 
			
		||||
    Format(sQuery, sizeof(sQuery), "CREATE TABLE IF NOT EXISTS `zetimer_table_new` (`steam_auth` VARCHAR(254) NOT NULL, `name` VARCHAR(254) NOT NULL, PRIMARY KEY (`steam_auth`))");
 | 
			
		||||
    g_dDatabase.Query(SQL_OnConnectFinished, sQuery, _, DBPrio_High);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -175,7 +178,7 @@ public void MYSQLCheckMapEntry()
 | 
			
		||||
        char l_cZoneIndexName[g_dIndex][g_dLength];
 | 
			
		||||
	if (l_iZoneCount == 1)
 | 
			
		||||
	{
 | 
			
		||||
		Format(sQuery, sizeof(sQuery), "ALTER TABLE `zetimer_table` ADD COLUMN IF NOT EXISTS `%s` TEXT DEFAULT '0.000' NOT NULL", g_cMapname);
 | 
			
		||||
		Format(sQuery, sizeof(sQuery), "ALTER TABLE `zetimer_table_new` ADD COLUMN IF NOT EXISTS `%s` REAL DEFAULT 0.000 NOT NULL", g_cMapname);
 | 
			
		||||
		DataPack hDataPack = new DataPack();
 | 
			
		||||
        	hDataPack.WriteString(sQuery);
 | 
			
		||||
		g_dDatabase.Query(SQL_FinishedQuery, sQuery, hDataPack, DBPrio_High);
 | 
			
		||||
@ -187,7 +190,7 @@ public void MYSQLCheckMapEntry()
 | 
			
		||||
			if (IsCorrectZone(iterator, l_cZoneIndexName[iterator][g_dLength -1], "ZONE_PREFIX_RACE"))
 | 
			
		||||
			{
 | 
			
		||||
				l_iRaceCount++;
 | 
			
		||||
				Format(sQuery, sizeof(sQuery), "ALTER TABLE `zetimer_table` ADD COLUMN IF NOT EXISTS `%sS%i` TEXT DEFAULT '0.000' NOT NULL", g_cMapname, l_iRaceCount);
 | 
			
		||||
				Format(sQuery, sizeof(sQuery), "ALTER TABLE `zetimer_table_new` ADD COLUMN IF NOT EXISTS `%sS%i` REAL DEFAULT 0.000 NOT NULL", g_cMapname, l_iRaceCount);
 | 
			
		||||
				DataPack hDataPack = new DataPack();
 | 
			
		||||
        			hDataPack.WriteString(sQuery);
 | 
			
		||||
				g_dDatabase.Query(SQL_FinishedQuery, sQuery, hDataPack, DBPrio_High);
 | 
			
		||||
@ -264,15 +267,16 @@ public void startTimer()
 | 
			
		||||
//----------------------------------------------------------------------------------------------------
 | 
			
		||||
public void Event_RoundStart(Handle event, const char[] name, bool dontBroadcast)
 | 
			
		||||
{
 | 
			
		||||
	int l_iZoneCount = unloze_zoneCount();
 | 
			
		||||
	if (!l_iZoneCount)
 | 
			
		||||
    int race_zone_count = GetTotalRaceZones();
 | 
			
		||||
    if (!race_zone_count)
 | 
			
		||||
        return;
 | 
			
		||||
    for (int i = 1; i <= MaxClients; i++)
 | 
			
		||||
        if (IsValidClient(i) && !IsFakeClient(i))
 | 
			
		||||
        {
 | 
			
		||||
            g_bhumans_finished[i] = false;
 | 
			
		||||
            resetClientVectors(i);
 | 
			
		||||
            if (l_iZoneCount != 1)
 | 
			
		||||
            g_bAllowToLeave[i] = 0;
 | 
			
		||||
            if (race_zone_count != 1)
 | 
			
		||||
                g_bHumansAllowedTime[i] = false;
 | 
			
		||||
            else
 | 
			
		||||
            {
 | 
			
		||||
@ -315,8 +319,10 @@ public void resetClient(int client)
 | 
			
		||||
    {
 | 
			
		||||
        g_iClientChecking[client] = 0; 
 | 
			
		||||
        g_bHumansAllowedTime[client] = false;
 | 
			
		||||
        g_bAllowToLeave[client] = 0;
 | 
			
		||||
        g_bhumans_finished[client] = false;
 | 
			
		||||
        resetClientVectors(client);
 | 
			
		||||
        g_fStartTime[client] = 0.0;
 | 
			
		||||
        player_stage[client] = 0;
 | 
			
		||||
        Format(g_csTime_record[client], sizeof(g_csTime_record[]), "0.000");
 | 
			
		||||
    }
 | 
			
		||||
@ -326,7 +332,9 @@ public void resetClient(int client)
 | 
			
		||||
//----------------------------------------------------------------------------------------------------
 | 
			
		||||
public void OnPlayerRunCmdPost(int client, int buttons, int impulse, const float vel[3], const float angles[3], int weapon, int subtype, int cmdnum, int tickcount, int seed, const int mouse[2])
 | 
			
		||||
{
 | 
			
		||||
	if (!IsValidClient(client) || !g_bHumansAllowedTime[client])
 | 
			
		||||
    if (!IsValidClient(client))
 | 
			
		||||
        return;
 | 
			
		||||
    if (!g_bHumansAllowedTime[client])
 | 
			
		||||
        return;
 | 
			
		||||
    //checks if event is going on
 | 
			
		||||
    if (g_bEventBool)
 | 
			
		||||
@ -348,12 +356,16 @@ public void OnPlayerRunCmdPost(int client, int buttons, int impulse, const float
 | 
			
		||||
            {
 | 
			
		||||
                g_bHumansAllowedTime[client] = false;
 | 
			
		||||
                g_bhumans_finished[client] = false;
 | 
			
		||||
                //called if teleported to some place far away or teleported from inside start zone to end zone
 | 
			
		||||
                CreateTimer(1.0, reset_permissions_for_leave, client);
 | 
			
		||||
                resetClientVectors(client);
 | 
			
		||||
                PrintToChat(client, "Disabled timer due to potential teleport abuse");
 | 
			
		||||
                return;
 | 
			
		||||
            }
 | 
			
		||||
            if (g_bhumans_finished[client])
 | 
			
		||||
            {
 | 
			
		||||
                CreateTimer(1.0, reset_permissions_for_leave, client);
 | 
			
		||||
                resetClientVectors(client);
 | 
			
		||||
                g_bhumans_finished[client] = false;
 | 
			
		||||
                g_bHumansAllowedTime[client] = false;
 | 
			
		||||
                FinishedStageRaceZone(client);
 | 
			
		||||
@ -404,9 +416,8 @@ public void OnPlayerRunCmdPost(int client, int buttons, int impulse, const float
 | 
			
		||||
            {
 | 
			
		||||
                SetHudTextParams(0.35, 0.85, 0.1, 125, 255, 255, 85);
 | 
			
		||||
                float total_time = client_current_race_time(client);
 | 
			
		||||
                char sTime[32];
 | 
			
		||||
                FormatPlayerTime(total_time, sTime, sizeof(sTime), false, 1);
 | 
			
		||||
                ShowSyncHudText(client, hText, "%N Time: %s\nRecord: %s\nMap: %s\nCourse: %i", client, sTime, g_csTime_record[client], g_cMapname, player_stage[client]);
 | 
			
		||||
                if (total_time != -1.0)
 | 
			
		||||
                    ShowSyncHudText(client, hText, "%N Time: %06.3f\nRecord: %s\nMap: %s\nCourse: %i", client, total_time, g_csTime_record[client], g_cMapname, player_stage[client]);
 | 
			
		||||
            }
 | 
			
		||||
            g_iClientSpeedInterval[client]++;
 | 
			
		||||
        }
 | 
			
		||||
@ -417,6 +428,8 @@ public void OnPlayerRunCmdPost(int client, int buttons, int impulse, const float
 | 
			
		||||
 | 
			
		||||
public float client_current_race_time(int i_client)
 | 
			
		||||
{
 | 
			
		||||
    if (g_fStartTime[i_client] == 0.0)
 | 
			
		||||
        return -1.0;
 | 
			
		||||
    return GetEngineTime() - g_fStartTime[i_client];
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -464,37 +477,67 @@ public bool checkClientOrigin(float oldVals[3], float newVals[3], int client)
 | 
			
		||||
public void unloze_zoneEntry(int client, char[] zone)
 | 
			
		||||
{
 | 
			
		||||
    int zoneIndex = RetrieveZoneIndex(zone);
 | 
			
		||||
    int race_zone_count = GetTotalRaceZones();
 | 
			
		||||
    if (!race_zone_count)
 | 
			
		||||
        return;
 | 
			
		||||
    int l_iZoneCount = unloze_zoneCount();
 | 
			
		||||
	
 | 
			
		||||
    if (GetClientTeam(client) == CS_TEAM_CT && g_bHumansAllowedTime[client])
 | 
			
		||||
    {
 | 
			
		||||
        if ((StrContains(zone, "ZONE_PREFIX_RACE") > -1) || StrEqual(zone, g_cSpecialMapEnd))
 | 
			
		||||
        {
 | 
			
		||||
            g_bHumansAllowedTime[client] = false;
 | 
			
		||||
            if (l_iZoneCount < 2)
 | 
			
		||||
                player_stage[client] = 0;
 | 
			
		||||
            if (player_stage[client] == (zoneIndex / 2) || l_iZoneCount < 2)
 | 
			
		||||
            {
 | 
			
		||||
                g_bHumansAllowedTime[client] = true;
 | 
			
		||||
                g_bAllowToLeave[client] = 1;
 | 
			
		||||
                g_bhumans_finished[client] = true;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
public Action reset_permissions_for_leave(Handle timer, int i)
 | 
			
		||||
{
 | 
			
		||||
    if (IsValidClient(i))
 | 
			
		||||
    {
 | 
			
		||||
        //if you start the timer and run inside the start zone again there are 3 options:
 | 
			
		||||
        //you leave the zone normally by running out of it which is fine
 | 
			
		||||
        //you get teleported out of the zone to a certain distance away by something like afk teleport, in that case your timer gets disabled
 | 
			
		||||
        //due to detected teleport abuse
 | 
			
		||||
 | 
			
		||||
        //Third option is you get teleported out of spawn zone to a end zone which after triggering Entry forward triggers Leave forward again
 | 
			
		||||
        //Therefore we need a cooldown when teleporting from inside of start zone to an entry zone as Leave forward is called right after again
 | 
			
		||||
        //which is a errornous way of starting the timer from the end zone, by having a second delay we ensure its not a problem when teleported from spawn
 | 
			
		||||
        //to a random place thats not an entry zone as this is handled seemingly correctly by the teleport abuse detection. Meanwhile to stop the timer from
 | 
			
		||||
        //starting when teleported from spawn to an Entry zone we need a cooldown 
 | 
			
		||||
        g_bAllowToLeave[i] = 0;
 | 
			
		||||
    }
 | 
			
		||||
    return Plugin_Continue;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
//----------------------------------------------------------------------------------------------------
 | 
			
		||||
// Purpose:
 | 
			
		||||
//----------------------------------------------------------------------------------------------------
 | 
			
		||||
public void unloze_zoneLeave(int client, char[] zone)
 | 
			
		||||
{
 | 
			
		||||
	//only maps with multiple zones need ZONE_PREFIX_START
 | 
			
		||||
	int l_iZoneCount = unloze_zoneCount();
 | 
			
		||||
    int race_zone_count = GetTotalRaceZones();
 | 
			
		||||
    if (!race_zone_count || g_bAllowToLeave[client])
 | 
			
		||||
        return;
 | 
			
		||||
 | 
			
		||||
    if (GetClientTeam(client) == CS_TEAM_CT)
 | 
			
		||||
    {
 | 
			
		||||
        if ((StrContains(zone, "ZONE_PREFIX_START") > -1) || StrEqual(zone, g_cSpecialMapStart))
 | 
			
		||||
        {
 | 
			
		||||
            if (!l_iZoneCount)
 | 
			
		||||
            char sAuthID[32];
 | 
			
		||||
            GetClientAuthId(client, AuthId_Steam2, sAuthID, sizeof(sAuthID), false);
 | 
			
		||||
            if (!SteamClientAuthenticated(sAuthID))
 | 
			
		||||
            {
 | 
			
		||||
                PrintToChat(client, "Not starting timer due to being listed as nosteamer");
 | 
			
		||||
                return;
 | 
			
		||||
            resetClientVectors(client);
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            g_fStartTime[client] = GetEngineTime();
 | 
			
		||||
            float notRounded = float(RetrieveZoneIndex(zone));
 | 
			
		||||
            player_stage[client] = RoundToCeil(notRounded / 2);
 | 
			
		||||
@ -505,37 +548,6 @@ public void unloze_zoneLeave(int client, char[] zone)
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
stock void FormatPlayerTime(float Time, char[] result, int maxlength, bool showDash, int precision)
 | 
			
		||||
{
 | 
			
		||||
	if(Time <= 0.0 && showDash == true)
 | 
			
		||||
	{
 | 
			
		||||
		Format(result, maxlength, "-");
 | 
			
		||||
		return;
 | 
			
		||||
	}
 | 
			
		||||
	int hours 	= RoundToFloor(Time/3600);
 | 
			
		||||
	Time         -= hours*3600;
 | 
			
		||||
	int minutes 	= RoundToFloor(Time/60);
 | 
			
		||||
	Time         -= minutes*60;
 | 
			
		||||
	float seconds = Time;
 | 
			
		||||
	
 | 
			
		||||
	char sPrecision[16];
 | 
			
		||||
	
 | 
			
		||||
	if(precision == 0)
 | 
			
		||||
		Format(sPrecision, sizeof(sPrecision), (hours > 0 || minutes > 0)?"%04.1f":"%.1f", seconds);
 | 
			
		||||
	else if(precision == 1)
 | 
			
		||||
		Format(sPrecision, sizeof(sPrecision), (hours > 0 || minutes > 0)?"%06.3f":"%.3f", seconds);
 | 
			
		||||
	else if(precision == 2)
 | 
			
		||||
		Format(sPrecision, sizeof(sPrecision), (hours > 0 || minutes > 0)?"%09.6f":"%.6f", seconds);
 | 
			
		||||
	
 | 
			
		||||
	if(hours > 0)
 | 
			
		||||
		Format(result, maxlength, "%d:%02d:%s", hours, minutes, sPrecision);
 | 
			
		||||
	else if(minutes > 0)
 | 
			
		||||
		Format(result, maxlength, "%d:%s", minutes, sPrecision);
 | 
			
		||||
	else
 | 
			
		||||
		Format(result, maxlength, "%s", sPrecision);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
//----------------------------------------------------------------------------------------------------
 | 
			
		||||
// Purpose:
 | 
			
		||||
//----------------------------------------------------------------------------------------------------
 | 
			
		||||
@ -598,11 +610,14 @@ public void FinishedStageRaceZone(int client)
 | 
			
		||||
 | 
			
		||||
    int l_iZoneCount = unloze_zoneCount();
 | 
			
		||||
    float client_time = client_current_race_time(client);
 | 
			
		||||
        char sTime[32];
 | 
			
		||||
        FormatPlayerTime(client_time, sTime, sizeof(sTime), false, 1);
 | 
			
		||||
    if (client_time == -1.0)
 | 
			
		||||
    {
 | 
			
		||||
        //if client disconnected we dont want to cary timer over to other client
 | 
			
		||||
        return;
 | 
			
		||||
    }
 | 
			
		||||
    if (l_iZoneCount > 1)
 | 
			
		||||
        CPrintToChat(client, "{green}[UNLOZE] Stage: %i", player_stage[client]);
 | 
			
		||||
        CPrintToChat(client, "{green}[UNLOZE] Client: %N Time: %s", client, sTime);
 | 
			
		||||
    CPrintToChat(client, "{green}[UNLOZE] Client: %N Time: %06.3f", client, client_time);
 | 
			
		||||
    int stage = player_stage[client];
 | 
			
		||||
    char sQuery[g_dLength];
 | 
			
		||||
    if (StrEqual(g_csTime_record[client], "0.000"))
 | 
			
		||||
@ -614,9 +629,9 @@ public void FinishedStageRaceZone(int client)
 | 
			
		||||
        CPrintToChat(client, "Your record: %s\nCommand: !toptime !mytime !stages", g_csTime_record[client]);
 | 
			
		||||
    }
 | 
			
		||||
    if (l_iZoneCount < 2)
 | 
			
		||||
		Format(sQuery, sizeof(sQuery), "UPDATE `zetimer_table` SET `%s` = '%s', name = '%s' WHERE steam_auth = '%s'", g_cMapname, sTime, sEscapedName, sSID);
 | 
			
		||||
        Format(sQuery, sizeof(sQuery), "UPDATE `zetimer_table_new` SET `%s` = '%06.3f', name = '%s' WHERE steam_auth = '%s'", g_cMapname, client_time, sEscapedName, sSID);
 | 
			
		||||
    else
 | 
			
		||||
		Format(sQuery, sizeof(sQuery), "UPDATE `zetimer_table` SET `%sS%i` = '%s', name = '%s' WHERE steam_auth = '%s'", g_cMapname, stage, sTime, sEscapedName, sSID);
 | 
			
		||||
        Format(sQuery, sizeof(sQuery), "UPDATE `zetimer_table_new` SET `%sS%i` = '%06.3f', name = '%s' WHERE steam_auth = '%s'", g_cMapname, stage, client_time, sEscapedName, sSID);
 | 
			
		||||
    int generic_length = 32;
 | 
			
		||||
    char[][] sPart = new char[2][generic_length];
 | 
			
		||||
    float old_client_time = 0.0;
 | 
			
		||||
@ -646,9 +661,9 @@ public void mysql_get_player_time(int client, int stage)
 | 
			
		||||
	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);
 | 
			
		||||
		Format(query, sizeof(query), "SELECT `%s` FROM `zetimer_table_new` 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);
 | 
			
		||||
		Format(query, sizeof(query), "SELECT `%sS%i` FROM `zetimer_table_new` where steam_auth = '%s'", g_cMapname, stage, steam_auth);
 | 
			
		||||
	DataPack hDataPack = new DataPack();
 | 
			
		||||
	hDataPack.WriteCell(GetClientSerial(client));
 | 
			
		||||
        hDataPack.WriteString(query);
 | 
			
		||||
@ -717,7 +732,7 @@ public void insertPlayerMYSQL(int client)
 | 
			
		||||
            PrintToChat(client, "Your steam ID is not working, not updating timer");
 | 
			
		||||
            return;
 | 
			
		||||
    }
 | 
			
		||||
	Format(sQuery, sizeof(sQuery), "INSERT INTO `zetimer_table` (`steam_auth`, `name`) VALUES ('%s', '%s') ON DUPLICATE KEY UPDATE `name` = '%s'", sSID, sEscapedName, sEscapedName);
 | 
			
		||||
    Format(sQuery, sizeof(sQuery), "INSERT INTO `zetimer_table_new` (`steam_auth`, `name`) VALUES ('%s', '%s') ON DUPLICATE KEY UPDATE `name` = '%s'", sSID, sEscapedName, sEscapedName);
 | 
			
		||||
    DataPack hDataPack = new DataPack();
 | 
			
		||||
    hDataPack.WriteString(sQuery);
 | 
			
		||||
    g_dDatabase.Query(SQL_FinishedQuery, sQuery, hDataPack, DBPrio_High);
 | 
			
		||||
@ -737,9 +752,9 @@ public void mysql_select_lowest_ordered(int client, int index, int length_increa
 | 
			
		||||
    int l_iZoneCount = unloze_zoneCount();
 | 
			
		||||
    char sQuery[g_dLength];
 | 
			
		||||
    if (l_iZoneCount < 2)
 | 
			
		||||
        Format(sQuery, sizeof(sQuery), "SELECT name, `%s` FROM `zetimer_table` WHERE LENGTH(`%s`) = (select min(LENGTH(`%s`) + %i) from unloze_racetimer_css.zetimer_table zt where `%s` != 0.000) and `%s` != 0.000 order by `%s` ASC LIMIT 10", g_cMapname, g_cMapname, g_cMapname, length_increase, g_cMapname, g_cMapname, g_cMapname);
 | 
			
		||||
        Format(sQuery, sizeof(sQuery), "select name, `%s` from `zetimer_table_new` where `%s` > 0 order by `%s` asc limit 10", g_cMapname, g_cMapname, g_cMapname);
 | 
			
		||||
    else
 | 
			
		||||
        Format(sQuery, sizeof(sQuery), "SELECT name, `%sS%i` FROM `zetimer_table` WHERE LENGTH(`%sS%i`) = (select min(LENGTH(`%sS%i`) + %i) from unloze_racetimer_css.zetimer_table zt where `%sS%i` != 0.000) and `%sS%i` != 0.000 order by `%sS%i` ASC LIMIT 10", g_cMapname, index, g_cMapname, index,  g_cMapname, index, length_increase, g_cMapname, index, g_cMapname, index, g_cMapname, index);
 | 
			
		||||
        Format(sQuery, sizeof(sQuery), "select name, `%sS%i` from `zetimer_table_new` where `%sS%i` > 0 order by `%sS%i` asc limit 10", g_cMapname, index, g_cMapname, index, g_cMapname, index);
 | 
			
		||||
    //LogMessage("sQuery: %s", sQuery);
 | 
			
		||||
    DataPack hDataPack = new DataPack();
 | 
			
		||||
    hDataPack.WriteCell(GetClientSerial(client));
 | 
			
		||||
@ -794,7 +809,6 @@ public void SQL_Select_Top_Callback(Database db, DBResultSet results, const char
 | 
			
		||||
    int iclient;
 | 
			
		||||
    if ((iclient = GetClientFromSerial(client_serial)) == 0)
 | 
			
		||||
        return;
 | 
			
		||||
    char sTime[g_dLength];
 | 
			
		||||
    //Player Name
 | 
			
		||||
    char[] g_cPlayerName = new char[MAX_NAME_LENGTH];
 | 
			
		||||
    char g_cContent[g_dLength];
 | 
			
		||||
@ -809,8 +823,8 @@ public void SQL_Select_Top_Callback(Database db, DBResultSet results, const char
 | 
			
		||||
        {
 | 
			
		||||
            l_iPosition++;
 | 
			
		||||
            results.FetchString(0, g_cPlayerName, MAX_NAME_LENGTH);
 | 
			
		||||
            results.FetchString(1, sTime, sizeof(sTime));
 | 
			
		||||
            Format(g_cContent, sizeof(g_cContent), "#%i: Time: %s - %s", l_iPosition, sTime, g_cPlayerName);
 | 
			
		||||
            float fTime = results.FetchFloat(1);
 | 
			
		||||
            Format(g_cContent, sizeof(g_cContent), "#%i: Time: %06.3f - %s", l_iPosition, fTime, g_cPlayerName);
 | 
			
		||||
            menu.AddItem("-1", g_cContent, ITEMDRAW_DISABLED);
 | 
			
		||||
        }
 | 
			
		||||
        delete results;
 | 
			
		||||
@ -967,9 +981,9 @@ public void deleteClientTime(char[] steam2, int stage)
 | 
			
		||||
	char l_cQuery[g_dLength];
 | 
			
		||||
	int l_iZoneCount = unloze_zoneCount();
 | 
			
		||||
	if (l_iZoneCount > 1)
 | 
			
		||||
		Format(l_cQuery, sizeof(l_cQuery), "UPDATE `zetimer_table` SET `%sS%i` = '0.000' WHERE steam_auth = '%s'", g_cMapname, stage, steam2);
 | 
			
		||||
		Format(l_cQuery, sizeof(l_cQuery), "UPDATE `zetimer_table_new` SET `%sS%i` = 0.000 WHERE steam_auth = '%s'", g_cMapname, stage, steam2);
 | 
			
		||||
	else
 | 
			
		||||
		Format(l_cQuery, sizeof(l_cQuery), "UPDATE `zetimer_table` SET `%s` = '0.000' WHERE steam_auth = '%s'", g_cMapname, steam2);
 | 
			
		||||
		Format(l_cQuery, sizeof(l_cQuery), "UPDATE `zetimer_table_new` SET `%s` = 0.000 WHERE steam_auth = '%s'", g_cMapname, steam2);
 | 
			
		||||
	DataPack hDataPack = new DataPack();
 | 
			
		||||
        hDataPack.WriteString(l_cQuery);
 | 
			
		||||
	g_dDatabase.Query(SQL_FinishedQuery, l_cQuery, hDataPack, DBPrio_High);
 | 
			
		||||
@ -990,7 +1004,7 @@ public void Checkself(int client)
 | 
			
		||||
	}
 | 
			
		||||
	if (l_iZoneCount < 2)
 | 
			
		||||
	{
 | 
			
		||||
		Format(l_cQuery, sizeof(l_cQuery), "SELECT name, `%s` FROM `zetimer_table` WHERE steam_auth = '%s'", g_cMapname, l_cSID);
 | 
			
		||||
		Format(l_cQuery, sizeof(l_cQuery), "SELECT name, `%s` FROM `zetimer_table_new` WHERE steam_auth = '%s'", g_cMapname, l_cSID);
 | 
			
		||||
		DataPack hDataPack = new DataPack();
 | 
			
		||||
		hDataPack.WriteCell(GetClientSerial(client));
 | 
			
		||||
        	hDataPack.WriteString(l_cQuery);
 | 
			
		||||
@ -1007,7 +1021,7 @@ public void CheckStageSelf(int client, int selection)
 | 
			
		||||
	char l_cQuery[g_dLength];
 | 
			
		||||
	char l_cSID[g_dIndex];
 | 
			
		||||
	GetClientAuthId(client, AuthId_Steam2, l_cSID, sizeof(l_cSID));
 | 
			
		||||
	Format(l_cQuery, sizeof(l_cQuery), "SELECT name, `%sS%i` FROM `zetimer_table` WHERE steam_auth = '%s'", g_cMapname, selection, l_cSID);
 | 
			
		||||
	Format(l_cQuery, sizeof(l_cQuery), "SELECT name, `%sS%i` FROM `zetimer_table_new` WHERE steam_auth = '%s'", g_cMapname, selection, l_cSID);
 | 
			
		||||
	DataPack hDataPack = new DataPack();
 | 
			
		||||
	hDataPack.WriteCell(GetClientSerial(client));
 | 
			
		||||
	hDataPack.WriteString(l_cQuery);
 | 
			
		||||
@ -1031,7 +1045,6 @@ public void SQL_CheckSelf(Database db, DBResultSet results, const char[] error,
 | 
			
		||||
        return;
 | 
			
		||||
    }
 | 
			
		||||
    delete data;
 | 
			
		||||
	char sTime[g_dLength];
 | 
			
		||||
    char l_cMessageContent[g_dLength];
 | 
			
		||||
    char[] l_cPlayerName = new char[MAX_NAME_LENGTH];
 | 
			
		||||
    int iclient;
 | 
			
		||||
@ -1040,13 +1053,14 @@ public void SQL_CheckSelf(Database db, DBResultSet results, const char[] error,
 | 
			
		||||
    if (results.RowCount && results.FetchRow())
 | 
			
		||||
    {
 | 
			
		||||
        results.FetchString(0, l_cPlayerName, MAX_NAME_LENGTH);
 | 
			
		||||
		results.FetchString(1, sTime, sizeof(sTime));
 | 
			
		||||
		if (StrEqual(sTime, "0.000", false))
 | 
			
		||||
        float fTime = results.FetchFloat(1);
 | 
			
		||||
        if (fTime == 0.0)
 | 
			
		||||
        {
 | 
			
		||||
            CPrintToChat(iclient, "You have no time yet!");
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
                Format(l_cMessageContent, sizeof(l_cMessageContent), "%s - %s", sTime, l_cPlayerName);
 | 
			
		||||
        fTime += 0.001;
 | 
			
		||||
        Format(l_cMessageContent, sizeof(l_cMessageContent), "%06.3f - %s", fTime, l_cPlayerName);
 | 
			
		||||
        CPrintToChat(iclient, "Your best time: %s", l_cMessageContent);
 | 
			
		||||
    }
 | 
			
		||||
    else
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user