diff --git a/addons/sourcemod/scripting/SurfTimer.sp b/addons/sourcemod/scripting/SurfTimer.sp index 1c1bd56e..27574bdb 100644 --- a/addons/sourcemod/scripting/SurfTimer.sp +++ b/addons/sourcemod/scripting/SurfTimer.sp @@ -78,7 +78,7 @@ public void OnLibraryAdded(const char[] name) return; int iOffset = GameConfGetOffset(hGameData, "Teleport"); delete hGameData; - + if (iOffset == -1) return; @@ -143,7 +143,7 @@ public void OnLibraryRemoved(const char[] name) } public void OnEntityCreated(int entity, const char[] classname) { - if( (classname[0] == 't' || classname[0] == 'l') ? (StrEqual(classname, "trigger_teleport", false) ) : false) + if ( (classname[0] == 't' || classname[0] == 'l') ? (StrEqual(classname, "trigger_teleport", false) ) : false) { SDKHook(entity, SDKHook_Use, IgnoreTriggers); SDKHook(entity, SDKHook_StartTouch, IgnoreTriggers); @@ -189,7 +189,7 @@ public void OnMapStart() /// Start Loading Server Settings ConVar cvHibernateWhenEmpty = FindConVar("sv_hibernate_when_empty"); - if(g_tables_converted) + if (g_tables_converted) { if (!g_bRenaming && !g_bInTransactionChain && (IsServerProcessing() || !cvHibernateWhenEmpty.BoolValue)) { @@ -488,6 +488,7 @@ public void OnClientPutInServer(int client) g_bLoadingSettings[client] = true; g_iSettingToLoad[client] = 0; LoadClientSetting(client, g_iSettingToLoad[client]); + db_InsertUpdatePlayersTable(client); } } @@ -602,9 +603,9 @@ public void OnClientDisconnect(int client) sv_noclipspeed.FloatValue = g_iDefaultNoclipSpeed; //PRINFO - if(IsValidClient(client) && !IsFakeClient(client)){ - for(int zonegroup = 0; zonegroup < MAXZONEGROUPS; zonegroup++){ - if(g_fTimeIncrement[client][zonegroup] != 0.0) + if (IsValidClient(client) && !IsFakeClient(client)) { + for(int zonegroup = 0; zonegroup < MAXZONEGROUPS; zonegroup++) { + if (g_fTimeIncrement[client][zonegroup] != 0.0) g_fTimeinZone[client][zonegroup] += g_fTimeIncrement[client][zonegroup]; db_UpdatePRinfo(client, g_szSteamID[client], zonegroup); } @@ -1235,4 +1236,4 @@ public void OnPluginStart() public Action ItemFoundMsg(UserMsg msg_id, Protobuf msg, const int[] players, int playersNum, bool reliable, bool init) { return Plugin_Handled; -} \ No newline at end of file +} diff --git a/addons/sourcemod/scripting/surftimer/api.sp b/addons/sourcemod/scripting/surftimer/api.sp index fdfdf97e..9090c030 100644 --- a/addons/sourcemod/scripting/surftimer/api.sp +++ b/addons/sourcemod/scripting/surftimer/api.sp @@ -129,7 +129,7 @@ public int Native_GetMapData(Handle plugin, int numParams) SetNativeString(1, szname, sizeof(szname), true); SetNativeString(2, sztime, sizeof(sztime), true); - if(g_fRecordMapTime >= 0) + if (g_fRecordMapTime >= 0) time = g_fRecordMapTime; else time = -1.0; @@ -152,13 +152,13 @@ public int Native_GetBonusData(Handle plugin, int numParams) Format(szname, sizeof(szname), g_szBonusFastest[zonegroup]); SetNativeString(2, szname, sizeof(szname), true); - if(g_fBonusFastest[zonegroup] > 0) + if (g_fBonusFastest[zonegroup] > 0) WRtime = g_fBonusFastest[zonegroup]; else WRtime = -1.0; SetNativeCellRef(3, WRtime); - if(g_fPersonalRecordBonus[zonegroup][client] > 0) + if (g_fPersonalRecordBonus[zonegroup][client] > 0) PBtime = g_fPersonalRecordBonus[zonegroup][client]; else PBtime = -1.0; @@ -181,13 +181,13 @@ public int Native_GetStageData(Handle plugin, int numParams) Format(szname, sizeof(szname), g_szStageRecordPlayer[stage]); SetNativeString(2, szname, sizeof(szname), true); - if(g_fStageRecord[stage] != 0.0) + if (g_fStageRecord[stage] != 0.0) WRtime = g_fStageRecord[stage]; else WRtime = -1.0; SetNativeCellRef(3, WRtime); - if(g_fWrcpRecord[client][stage][g_iCurrentStyle[client]] != -1.0) + if (g_fWrcpRecord[client][stage][g_iCurrentStyle[client]] != -1.0) PBtime = g_fWrcpRecord[client][stage][g_iCurrentStyle[client]]; else PBtime = -1.0; @@ -254,10 +254,10 @@ public int Native_GetClientStyle(Handle plugin, int numParams) int style; if (IsValidClient(client)) { - if(!IsFakeClient(client)) { + if (!IsFakeClient(client)) { style = g_iCurrentStyle[client]; } - else{ + else { if (client == g_RecordBot) style = g_iSelectedReplayStyle; else if (client == g_BonusBot) diff --git a/addons/sourcemod/scripting/surftimer/buttonpress.sp b/addons/sourcemod/scripting/surftimer/buttonpress.sp index df0d0ace..0c9f8996 100644 --- a/addons/sourcemod/scripting/surftimer/buttonpress.sp +++ b/addons/sourcemod/scripting/surftimer/buttonpress.sp @@ -300,7 +300,7 @@ public void CL_OnEndTimerPress(int client) if (style == 0) { //ADD LAST TIME TO CP DATA - if(g_bhasStages) + if (g_bhasStages) g_fCheckpointTimesNew[zGroup][client][g_TotalStages-1] = g_fFinalTime[client]; else g_fCheckpointTimesNew[zGroup][client][g_iTotalCheckpoints] = g_fFinalTime[client]; @@ -825,7 +825,7 @@ public void CL_OnStartWrcpTimerPress(int client) if (!g_bSpectate[client] && !g_bNoClip[client] && ((GetGameTime() - g_fLastTimeNoClipUsed[client]) > 2.0)) { int zGroup = g_iClientInZone[client][2]; - if(zGroup != 0) + if (zGroup != 0) { return; } @@ -905,7 +905,7 @@ public void CL_OnStartWrcpTimerPress(int client) continue; int ObserverMode = GetEntProp(i, Prop_Send, "m_iObserverMode"); - if(ObserverMode != 4 && ObserverMode != 5) + if (ObserverMode != 4 && ObserverMode != 5) continue; int ObserverTarget = GetEntPropEnt(i, Prop_Send, "m_hObserverTarget"); @@ -1048,7 +1048,7 @@ public void CL_OnStartPracSrcpTimerPress(int client) int zGroup = g_iClientInZone[client][2]; - if(zGroup != 0) + if (zGroup != 0) { return; } diff --git a/addons/sourcemod/scripting/surftimer/commands.sp b/addons/sourcemod/scripting/surftimer/commands.sp index 33f3b0f8..975dc49f 100644 --- a/addons/sourcemod/scripting/surftimer/commands.sp +++ b/addons/sourcemod/scripting/surftimer/commands.sp @@ -259,11 +259,11 @@ public Action Command_ToggleNcTriggers(int client, int args) { } public Action Command_CenterSpeed(int client, int args) { - if (g_bCenterSpeedDisplay[client]){ + if (g_bCenterSpeedDisplay[client]) { g_bCenterSpeedDisplay[client] = false; CPrintToChat(client, "%t", "CenterSpeedOff", g_szChatPrefix); } - else{ + else { g_bCenterSpeedDisplay[client] = true; CPrintToChat(client, "%t", "CenterSpeedOn", g_szChatPrefix); } @@ -406,9 +406,9 @@ public Action Command_ToggleHints(int client, int args) return Plugin_Handled; } -public Action Command_PRinfo_help(int client, int args){ +public Action Command_PRinfo_help(int client, int args) { - if(IsValidClient(client)){ + if (IsValidClient(client)) { PrintToConsole(client, "%t", "PRinfo_help"); CPrintToChat(client, "%t", "PRinfo_help_chat", g_szChatPrefix); } @@ -419,7 +419,7 @@ public Action Command_PRinfo_help(int client, int args){ public Action Command_DeleteRecords(int client, int args) { - if(args > 0) + if (args > 0) { char sqlStripped[128]; GetCmdArg(1, sqlStripped, 128); @@ -445,7 +445,7 @@ public void ShowMainDeleteMenu(int client) public int ShowMainDeleteMenuHandler(Menu menu, MenuAction action, int client, int key) { - if(action == MenuAction_Select) + if (action == MenuAction_Select) { g_SelectedEditOption[client] = key; g_SelectedStyle[client] = 0; @@ -474,9 +474,9 @@ public int ShowMainDeleteMenuHandler(Menu menu, MenuAction action, int client, i } // PrintToServer(szQuery); // Can we please NOT do this? - SQL_TQuery(g_hDb, sql_DeleteMenuView, szQuery, GetClientSerial(client)); + g_hDb.Query(sql_DeleteMenuView, szQuery, GetClientSerial(client)); } - else if(action == MenuAction_End) + else if (action == MenuAction_End) delete menu; return 0; @@ -1364,7 +1364,7 @@ public Action Command_ToStage(int client, int args) int StageId = StringToInt(arg1); if (StageId == 3) { - if(getZoneID(0, StageId) == -1) { + if (getZoneID(0, StageId) == -1) { CPrintToChat(client, "%T", "InvalidMapNoStages", client, g_szChatPrefix); return Plugin_Handled; } @@ -1815,9 +1815,9 @@ public Action Command_ckNoClip(int client, int args) return Plugin_Handled; } -public Action Client_CountryTop_Help(int client, int args){ +public Action Client_CountryTop_Help(int client, int args) { - if(IsValidClient(client)){ + if (IsValidClient(client)) { CPrintToChat(client, "%t", "ctop_help_chat", g_szChatPrefix); PrintToConsole(client, "%t", "ctop_help"); } @@ -1825,9 +1825,9 @@ public Action Client_CountryTop_Help(int client, int args){ return Plugin_Handled; } -public Action Client_CountryRank_Help(int client, int args){ +public Action Client_CountryRank_Help(int client, int args) { - if(IsValidClient(client)){ + if (IsValidClient(client)) { CPrintToChat(client, "%t", "crank_help_chat", g_szChatPrefix); PrintToConsole(client, "%t", "crank_help"); } @@ -1836,9 +1836,9 @@ public Action Client_CountryRank_Help(int client, int args){ } -public Action Client_ContinentTop_Help(int client, int args){ +public Action Client_ContinentTop_Help(int client, int args) { - if(IsValidClient(client)){ + if (IsValidClient(client)) { CPrintToChat(client, "%t", "continenttop_help_chat", g_szChatPrefix); PrintToConsole(client, "%t", "ctop_help"); } @@ -1846,9 +1846,9 @@ public Action Client_ContinentTop_Help(int client, int args){ return Plugin_Handled; } -public Action Client_ContinentRank_Help(int client, int args){ +public Action Client_ContinentRank_Help(int client, int args) { - if(IsValidClient(client)){ + if (IsValidClient(client)) { CPrintToChat(client, "%t", "continentrank_help_chat", g_szChatPrefix); PrintToConsole(client, "%t", "crank_help"); } @@ -1857,9 +1857,9 @@ public Action Client_ContinentRank_Help(int client, int args){ } -public Action Client_StyleAcronyms(int client, int args){ +public Action Client_StyleAcronyms(int client, int args) { - if(IsValidClient(client)){ + if (IsValidClient(client)) { CPrintToChat(client, "%t", "style_acronyms_help_chat", g_szChatPrefix); PrintToConsole(client, "%t", "style_acronyms_help"); } @@ -1868,9 +1868,9 @@ public Action Client_StyleAcronyms(int client, int args){ } -public Action Client_ContinentAcronyms(int client, int args){ +public Action Client_ContinentAcronyms(int client, int args) { - if(IsValidClient(client)){ + if (IsValidClient(client)) { CPrintToChat(client, "%t", "continent_acronyms_help_chat", g_szChatPrefix); PrintToConsole(client, "%t", "continent_acronyms_help"); } @@ -1881,10 +1881,10 @@ public Action Client_ContinentAcronyms(int client, int args){ public Action Client_CountryRank(int client, int args) { - if(!IsValidClient(client)) + if (!IsValidClient(client)) return Plugin_Handled; - switch (args){ + switch (args) { case 0 : { char szClientName[MAX_NAME_LENGTH]; GetClientName(client, szClientName, sizeof szClientName); @@ -2109,25 +2109,25 @@ public void CountryTopMenuStyleSelect(int client, char szBuffer[256]) ExplodeString(szBuffer, "-", splits, sizeof(splits), sizeof(splits[])); //INSERTED COUNTRY - if( strcmp(splits[0], "none", false) != 0 ) { + if ( strcmp(splits[0], "none", false) != 0 ) { szCountryName = splits[0]; } //INSERTED STYLE - if( strcmp(splits[1], "none", false) != 0 ) { + if ( strcmp(splits[1], "none", false) != 0 ) { style = StringToInt(splits[1]); } //IF PLAYER INPUTS COUNTRY NAME AND STYLE THERE IS NO NEED DISPLAY THIS MENU //CALL 'db_SelectCountryTOP' STRAIGHT AWAY - if( strcmp(splits[0], "none", false) != 0 && strcmp(splits[1], "none", false) != 0 ){ + if ( strcmp(splits[0], "none", false) != 0 && strcmp(splits[1], "none", false) != 0 ) { db_SelectCountryTOP(client, szCountryName, style); return; } //IF PLAYER INPUTS STYLE THERE IS NO NEED DISPLAY THIS MENU //CALL 'db_GetCountriesNames' STRAIGHT AWAY - if( strcmp(splits[0], "none", false) == 0 && strcmp(splits[1], "none", false) != 0 ){ + if ( strcmp(splits[0], "none", false) == 0 && strcmp(splits[1], "none", false) != 0 ) { db_GetCountriesNames(client, StringToInt(splits[1])); return; } @@ -2167,7 +2167,7 @@ public int CountryTopMenuStyleSelectHandler(Handle menu, MenuAction action, int char splits[2][256]; ExplodeString(szBuffer, "-", splits, sizeof(splits), sizeof(splits[])); - if( strcmp(splits[0], "none", false) == 0 ) + if ( strcmp(splits[0], "none", false) == 0 ) db_GetCountriesNames(param1, StringToInt(splits[1])); else db_SelectCountryTOP(param1, splits[0], StringToInt(splits[1])); @@ -2182,10 +2182,10 @@ public int CountryTopMenuStyleSelectHandler(Handle menu, MenuAction action, int public Action Client_ContinentRank(int client, int args) { - if(!IsValidClient(client)) + if (!IsValidClient(client)) return Plugin_Handled; - switch (args){ + switch (args) { case 0 : { char szClientName[MAX_NAME_LENGTH]; GetClientName(client, szClientName, sizeof szClientName); @@ -2332,7 +2332,7 @@ public Action Client_ContinentTOP(int client, int args) char szContinentName[100]; char szContinentCode[3]; Format(szContinentCode, sizeof szContinentCode, "%s", arg1); - if( !GetContinentName(szContinentCode, szContinentName, sizeof szContinentName) ) { + if ( !GetContinentName(szContinentCode, szContinentName, sizeof szContinentName) ) { CPrintToChat(client, "%t", "continenttop_help_chat", g_szChatPrefix); PrintToConsole(client, "%t", "continenttop_help" ); PrintToConsole(client, "%t", "continent_acronyms_help"); @@ -2374,7 +2374,7 @@ public Action Client_ContinentTOP(int client, int args) char szContinentName[100]; char szContinentCode[3]; Format(szContinentCode, sizeof szContinentCode, "%s", arg2); - if( !GetContinentName(szContinentCode, szContinentName, sizeof szContinentName) ) { + if ( !GetContinentName(szContinentCode, szContinentName, sizeof szContinentName) ) { CPrintToChat(client, "%t", "continenttop_help_chat", g_szChatPrefix); PrintToConsole(client, "%t", "continenttop_help"); PrintToConsole(client, "%t", "continent_acronyms_help"); @@ -2409,7 +2409,7 @@ public Action Client_ContinentTOP(int client, int args) char szContinentName[100]; char szContinentCode[3]; Format(szContinentCode, sizeof szContinentCode, "%s", arg1); - if( !GetContinentName(szContinentCode, szContinentName, sizeof szContinentName) ) { + if ( !GetContinentName(szContinentCode, szContinentName, sizeof szContinentName) ) { CPrintToChat(client, "%t", "continenttop_help_chat", g_szChatPrefix); PrintToConsole(client, "%t", "continenttop_help"); PrintToConsole(client, "%t", "continent_acronyms_help"); @@ -2446,25 +2446,25 @@ public void ContinentTopMenuStyleSelect(int client, char szBuffer[256]) ExplodeString(szBuffer, "-", splits, sizeof(splits), sizeof(splits[])); //INSERTED CONTINENT - if( strcmp(splits[0], "zz", false) != 0 ) { + if ( strcmp(splits[0], "zz", false) != 0 ) { Format(szContinentCode, sizeof szContinentCode, "%s", splits[0]); } //INSERTED STYLE - if( strcmp(splits[1], "none", false) != 0 ) { + if ( strcmp(splits[1], "none", false) != 0 ) { style = StringToInt(splits[1]); } //IF PLAYER INPUTS CONTINENT NAME AND STYLE THERE IS NO NEED DISPLAY THIS MENU //CALL 'db_SelectContinentTOP' STRAIGHT AWAY - if( strcmp(splits[0], "zz", false) != 0 && strcmp(splits[1], "none", false) != 0 ){ + if ( strcmp(splits[0], "zz", false) != 0 && strcmp(splits[1], "none", false) != 0 ) { db_SelectContinentTOP(client, szContinentCode, style); return; } //IF PLAYER INPUTS STYLE THERE IS NO NEED DISPLAY THIS MENU //CALL 'db_GetContinentNames' STRAIGHT AWAY - if( strcmp(splits[0], "zz", false) == 0 && strcmp(splits[1], "none", false) != 0 ){ + if ( strcmp(splits[0], "zz", false) == 0 && strcmp(splits[1], "none", false) != 0 ) { db_GetContinentNames(client, StringToInt(splits[1])); return; } @@ -2504,7 +2504,7 @@ public int ContinentTopMenuStyleSelectHandler(Handle menu, MenuAction action, in char splits[2][256]; ExplodeString(szBuffer, "-", splits, sizeof(splits), sizeof(splits[])); - if( strcmp(splits[0], "zz", false) == 0 ) + if ( strcmp(splits[0], "zz", false) == 0 ) db_GetContinentNames(param1, StringToInt(splits[1])); else { char szContinentCode[3]; @@ -3024,7 +3024,7 @@ void SpeedMode(int client, bool menu = false) void CSD_PosX(int client, bool menu = false) { - if (g_fCSD_POS_X[client] < 1.0){ + if (g_fCSD_POS_X[client] < 1.0) { g_fCSD_POS_X[client] += 0.1; } else @@ -3081,13 +3081,13 @@ void PreSpeedMode(int client, bool menu = false) void CenterSpeedDisplay(int client, bool menu = false) { //only swap values if the call comes from the "options" menu OR using the "sm_centerspeed" command - if(menu) + if (menu) g_bCenterSpeedDisplay[client] = !g_bCenterSpeedDisplay[client]; //THE LOWER THE NUMBER THE FASTER THE UPDATING IS int update_rate; - if(g_bCenterSpeedDisplay[client]){ - switch(g_iCSDUpdateRate[client]){ + if (g_bCenterSpeedDisplay[client]) { + switch(g_iCSDUpdateRate[client]) { case 0: update_rate = 15; case 1: update_rate = 10; case 2: update_rate = 5; @@ -3095,7 +3095,7 @@ void CenterSpeedDisplay(int client, bool menu = false) } } - if(g_iClientTick[client] - g_iCurrentTick[client] >= update_rate) + if (g_iClientTick[client] - g_iCurrentTick[client] >= update_rate) { g_iCurrentTick[client] += update_rate; if (IsValidClient(client) && !IsFakeClient(client) && g_bCenterSpeedDisplay[client]) @@ -3103,11 +3103,11 @@ void CenterSpeedDisplay(int client, bool menu = false) float fCSD_PosX; float fCSD_PosY; - switch(g_fCSD_POS_X[client]){ + switch(g_fCSD_POS_X[client]) { case 0.5: fCSD_PosX = -1.0; default: fCSD_PosX = g_fCSD_POS_X[client]; } - switch(g_fCSD_POS_Y[client]){ + switch(g_fCSD_POS_Y[client]) { case 0.5: fCSD_PosY = -1.0; default: fCSD_PosY = g_fCSD_POS_Y[client]; } @@ -3118,9 +3118,9 @@ void CenterSpeedDisplay(int client, bool menu = false) // player alive if (IsPlayerAlive(client)) { - if(g_SpeedGradient[client] != 6) + if (g_SpeedGradient[client] != 6) displayColor = GetSpeedColourCSD(client, RoundToNearest(g_fLastSpeed[client]), g_SpeedGradient[client]); - else{ + else { displayColor[0] = g_iCSD_R[client]; displayColor[1] = g_iCSD_G[client]; displayColor[2] = g_iCSD_B[client]; @@ -3152,11 +3152,11 @@ void CenterSpeedDisplay(int client, bool menu = false) GetEntPropVector(ObservedUser, Prop_Data, "m_vecVelocity", fSpeed); float fSpeedHUD; - if(g_SpeedMode[client] == 0) //XY + if (g_SpeedMode[client] == 0) //XY fSpeedHUD = SquareRoot(Pow(fSpeed[0], 2.0) + Pow(fSpeed[1], 2.0)); - else if(g_SpeedMode[client] == 1) //XYZ + else if (g_SpeedMode[client] == 1) //XYZ fSpeedHUD = SquareRoot(Pow(fSpeed[0], 2.0) + Pow(fSpeed[1], 2.0) + Pow(fSpeed[2], 2.0)); - else if(g_SpeedMode[client] == 2) //Z + else if (g_SpeedMode[client] == 2) //Z fSpeedHUD = SquareRoot(Pow(fSpeed[2], 2.0)); if (ObservedUser == g_RecordBot) @@ -3182,9 +3182,9 @@ void CenterSpeedDisplay(int client, bool menu = false) } } - if(g_SpeedGradient[client] != 6) + if (g_SpeedGradient[client] != 6) displayColor = GetSpeedColourCSD(client, RoundToNearest(fSpeedHUD), g_SpeedGradient[client]); - else{ + else { displayColor[0] = g_iCSD_R[client]; displayColor[1] = g_iCSD_G[client]; displayColor[2] = g_iCSD_B[client]; @@ -3196,9 +3196,9 @@ void CenterSpeedDisplay(int client, bool menu = false) } // spec'ing player else { - if(g_SpeedGradient[client] != 6) + if (g_SpeedGradient[client] != 6) displayColor = GetSpeedColourCSD(client, RoundToNearest(g_fLastSpeed[ObservedUser]), g_SpeedGradient[client]); - else{ + else { displayColor[0] = g_iCSD_R[client]; displayColor[1] = g_iCSD_G[client]; displayColor[2] = g_iCSD_B[client]; @@ -3290,7 +3290,7 @@ public Action Client_Help(int client, int args) } else if ((StrContains(desc, "[vip]", false) != -1)) { - if(!IsPlayerVip(client)) + if (!IsPlayerVip(client)) continue; } @@ -4425,7 +4425,7 @@ public void CSDOptions(int client) AddMenuItem(menu, "", "[BLUE] Speed Gradient"); else if (g_SpeedGradient[client] == 4) AddMenuItem(menu, "", "[YELLOW] Speed Gradient"); - else if(g_SpeedGradient[client] == 5) + else if (g_SpeedGradient[client] == 5) AddMenuItem(menu, "", "[MOMENTUM] Speed Gradient"); else AddMenuItem(menu, "", "[Custom] Speed Gradient"); @@ -5918,8 +5918,8 @@ public Action Command_ResetStartpos(int client, int args) if (!IsValidClient(client)) return Plugin_Handled; - if(g_iClientInZone[client][0] == 3){ - if(g_bStageStartposUsed[client][g_iClientInZone[client][1]]) + if (g_iClientInZone[client][0] == 3) { + if (g_bStageStartposUsed[client][g_iClientInZone[client][1]]) g_bStageStartposUsed[client][g_iClientInZone[client][1]] = false; } else @@ -5940,7 +5940,7 @@ public void Startpos(int client) g_bStartposUsed[client][g_iClientInZone[client][2]] = true; CPrintToChat(client, "%t", "Commands68", g_szChatPrefix); } - else if(IsPlayerAlive(client) && g_bInStageZone[client] && GetEntityFlags(client) & FL_ONGROUND)//STAGE START + else if (IsPlayerAlive(client) && g_bInStageZone[client] && GetEntityFlags(client) & FL_ONGROUND)//STAGE START { GetClientAbsOrigin(client, g_fStageStartposLocation[client][g_Stage[0][client]-2]); GetClientEyeAngles(client, g_fStageStartposAngle[client][g_Stage[0][client]-2]); @@ -6084,11 +6084,11 @@ public Action Command_PRinfo(int client, int args) if (!IsValidClient(client)) return Plugin_Handled; - switch(args){ + switch(args) { //WORKS //prinfo (in map zone) || (in bonus zone) case 0:{ - if(g_iClientInZone[client][2] == 0) + if (g_iClientInZone[client][2] == 0) db_selectPRinfoUnknown(client, g_MapRank[client], 0, g_szSteamID[client]); else db_selectPRinfoUnknown(client, g_MapRankBonus[g_iClientInZone[client][2]][client], g_iClientInZone[client][2], g_szSteamID[client]); @@ -6112,7 +6112,7 @@ public Action Command_PRinfo(int client, int args) //db_selectPRinfoUnknownWithMap(client, rank, g_szMapName, 0); - if(g_iClientInZone[client][2] == 0) + if (g_iClientInZone[client][2] == 0) db_GetRankSteamID(client, g_szMapName, rank, 0); else db_GetRankSteamID(client, g_szMapName , rank, g_iClientInZone[client][2]); @@ -6139,13 +6139,13 @@ public Action Command_PRinfo(int client, int args) if (StrContains(arg1, "surf_", true) != -1) { - if (StrContains(arg2, "@") != -1){ + if (StrContains(arg2, "@") != -1) { ReplaceString(arg2, sizeof(arg2), "@", ""); int rank = StringToInt(arg2); db_GetRankSteamID(client, arg1, rank, 0); //db_selectPRinfoUnknownWithMap(client, rank, arg1, 0); } - else if(arg2[0] == 'b'){ + else if (arg2[0] == 'b') { ReplaceString(arg2, sizeof(arg2), "b", ""); int bonus_number = StringToInt(arg2); @@ -6157,14 +6157,14 @@ public Action Command_PRinfo(int client, int args) } else if (arg1[0] == '@') { - if (StrContains(arg2, "surf_") != -1){ + if (StrContains(arg2, "surf_") != -1) { ReplaceString(arg1, sizeof(arg1), "@", ""); int rank = StringToInt(arg1); //db_selectPRinfoUnknownWithMap(client, rank, arg2, 0); db_GetRankSteamID(client, arg2, rank, 0); } - else if(StrContains(arg2, "b") != -1){ + else if (StrContains(arg2, "b") != -1) { ReplaceString(arg1, sizeof(arg1), "@", ""); int rank = StringToInt(arg1); @@ -6181,7 +6181,7 @@ public Action Command_PRinfo(int client, int args) } else if (arg1[0] == 'b') { - if (StrContains(arg2, "surf_") != -1){ + if (StrContains(arg2, "surf_") != -1) { ReplaceString(arg1, sizeof(arg1), "b", ""); int bonus_number = StringToInt(arg1); @@ -6190,7 +6190,7 @@ public Action Command_PRinfo(int client, int args) else CPrintToChat(client, "%t", "InvalidBonusID", g_szChatPrefix, bonus_number); } - else if(StrContains(arg2, "@") != -1){ + else if (StrContains(arg2, "@") != -1) { ReplaceString(arg1, sizeof(arg1), "b", ""); int bonus_number = StringToInt(arg1); @@ -6216,7 +6216,7 @@ public Action Command_PRinfo(int client, int args) GetCmdArg(2, arg2, sizeof(arg2)); GetCmdArg(3, arg3, sizeof(arg3)); - if( (StrContains(arg1, "surf_") != -1) && (arg2[0] == 'b') && (arg3[0] == '@')){ + if ( (StrContains(arg1, "surf_") != -1) && (arg2[0] == 'b') && (arg3[0] == '@')) { ReplaceString(arg2, sizeof(arg2), "b", ""); int bonus_number = StringToInt(arg2); @@ -6231,7 +6231,7 @@ public Action Command_PRinfo(int client, int args) CPrintToChat(client, "%t", "InvalidBonusID", g_szChatPrefix, bonus_number); } - else{ + else { CPrintToChat(client, "%t", "BonusPRinfoUsage", g_szChatPrefix); } } @@ -6250,9 +6250,9 @@ public Action Command_CCP(int client, int args) if (!IsValidClient(client)) return Plugin_Handled; - switch(args){ + switch(args) { case 0:{ - if(g_bhasStages) + if (g_bhasStages) db_viewCCP_GetMapRank(client, g_szSteamID[client], g_szMapName); else CPrintToChat(client, "%t", "CCP_01", g_szChatPrefix); @@ -6271,7 +6271,7 @@ public Action Command_CCP(int client, int args) ReplaceString(arg1, 32, "@", ""); int rank = StringToInt(arg1); - if(g_bhasStages) + if (g_bhasStages) db_viewCCP_WithMapRank(client, g_szSteamID[client], g_szMapName, rank); else CPrintToChat(client, "%t", "CCP_01", g_szChatPrefix); @@ -6536,7 +6536,7 @@ public void PlayRecordCPMenu(int client, char szBuffer[128]) Format(szTitle, sizeof(szTitle), "Play Record: Map Replay"); int cp_count; - if(!g_bhasStages) + if (!g_bhasStages) cp_count = g_iTotalCheckpoints; else cp_count = g_TotalStages - 1; @@ -6545,14 +6545,14 @@ public void PlayRecordCPMenu(int client, char szBuffer[128]) if ((StrContains(szBuffer, "style", false)) == -1) for(int i = 0; i <= cp_count; i++) { - if(i == 0){ + if (i == 0) { Format(szItem, sizeof(szItem), "Map Start"); Format(szBuffer_menu, sizeof(szBuffer_menu), "mapstart"); AddMenuItem(menu_replay_cp, szBuffer_menu, szItem); } - else{ + else { if (g_bReplayTickFound[0]) { - if(!g_bhasStages) + if (!g_bhasStages) Format(szItem, sizeof(szItem), "Checkpoint %d ", i); else Format(szItem, sizeof(szItem), "Stage %d ", i + 1); @@ -6561,7 +6561,7 @@ public void PlayRecordCPMenu(int client, char szBuffer[128]) } } } - else{ + else { char szBuffer2[2][128]; ExplodeString(szBuffer, "style-", szBuffer2, 2, sizeof(szBuffer2)); int style = StringToInt(szBuffer2[1]); @@ -6570,15 +6570,15 @@ public void PlayRecordCPMenu(int client, char szBuffer[128]) //PrintToChatAll("style %d", style); for (int i = 0; i <= cp_count; i++) - if (g_bMapReplay[style]){ - if(i == 0){ + if (g_bMapReplay[style]) { + if (i == 0) { Format(szItem, sizeof(szItem), "%s | Map Start", g_szStyleMenuPrint[style]); Format(szBuffer_menu, sizeof(szBuffer_menu), "style-%i-mapstart", style); AddMenuItem(menu_replay_cp, szBuffer_menu, szItem); } - else{ - if (g_bReplayTickFound[g_iSelectedReplayStyle]){ - if(!g_bhasStages) + else { + if (g_bReplayTickFound[g_iSelectedReplayStyle]) { + if (!g_bhasStages) Format(szItem, sizeof(szItem), "%s | Checkpoint %d ", g_szStyleMenuPrint[style], i); else Format(szItem, sizeof(szItem), "%s | Stage %d ", g_szStyleMenuPrint[style], i + 1); @@ -6606,20 +6606,20 @@ public int PlayRecordCPMenuHandler(Handle menu, MenuAction action, int param1, i int selected_CP; int style; - if ((StrContains(szBuffer, "style", false)) != -1){ + if ((StrContains(szBuffer, "style", false)) != -1) { - if((StrContains(szBuffer, "checkpoint", false)) != -1){ + if ((StrContains(szBuffer, "checkpoint", false)) != -1) { ExplodeString(szBuffer, "-", szBuffer_CP_split, 4, 128); selected_CP = StringToInt(szBuffer_CP_split[3]); style = StringToInt(szBuffer_CP_split[1]); } - else{ + else { ExplodeString(szBuffer, "-", szBuffer_CP_split, 3, 128); selected_CP = 0; style = StringToInt(szBuffer_CP_split[1]); } } - else{ + else { ExplodeString(szBuffer, "-", szBuffer_CP_split, 2, 128); selected_CP = StringToInt(szBuffer_CP_split[1]); } @@ -6635,7 +6635,7 @@ public int PlayRecordCPMenuHandler(Handle menu, MenuAction action, int param1, i bSpec = false; CPrintToChat(param1, "%t", "BotInUse", g_szChatPrefix, "Map"); } - else{ + else { // Check for style replay if ((StrContains(szBuffer, "style", false)) != -1) @@ -6654,7 +6654,7 @@ public int PlayRecordCPMenuHandler(Handle menu, MenuAction action, int param1, i PlayRecord(bot, 0, 0, selected_CP); } } - if(bSpec){ + if (bSpec) { Handle pack; CreateDataTimer(0.2, SpecBot, pack); WritePackCell(pack, GetClientUserId(param1)); diff --git a/addons/sourcemod/scripting/surftimer/db/queries.sp b/addons/sourcemod/scripting/surftimer/db/queries.sp index cf236587..565cbe84 100644 --- a/addons/sourcemod/scripting/surftimer/db/queries.sp +++ b/addons/sourcemod/scripting/surftimer/db/queries.sp @@ -7,13 +7,13 @@ char sql_createAnnouncements[] = "CREATE TABLE IF NOT EXISTS `ck_announcements` // ck_bonus char sql_createBonus[] = "CREATE TABLE IF NOT EXISTS ck_bonus (steamid VARCHAR(32), name VARCHAR(64), mapname VARCHAR(32), runtime decimal(12,6) NOT NULL DEFAULT '-1.000000', velStartXY SMALLINT(6) NOT NULL DEFAULT 0, velStartXYZ SMALLINT(6) NOT NULL DEFAULT 0, velStartZ SMALLINT(6) NOT NULL DEFAULT 0, zonegroup INT(12) NOT NULL DEFAULT 1, style INT(11) NOT NULL DEFAULT 0, PRIMARY KEY(steamid, mapname, zonegroup, style)) DEFAULT CHARSET=utf8mb4;"; -char sql_createBonusIndex[] = "CREATE INDEX bonusrank ON ck_bonus (mapname,runtime,zonegroup,style);"; +char sql_createBonusIndex[] = "CREATE INDEX bonusrank ON ck_bonus (mapname,runtime,zonegroup,style)"; char sql_insertBonus[] = "INSERT INTO ck_bonus (steamid, name, mapname, runtime, zonegroup, velStartXY, velStartXYZ, velStartZ) VALUES ('%s', '%s', '%s', '%f', '%i', '%i', '%i', '%i')"; char sql_updateBonus[] = "UPDATE ck_bonus SET runtime = '%f', name = '%s', velStartXY = %i, velStartXYZ = %i, velStartZ = %i WHERE steamid = '%s' AND mapname = '%s' AND zonegroup = %i AND style = 0"; char sql_selectBonusCount[] = "SELECT zonegroup, style, count(1) FROM ck_bonus WHERE mapname = '%s' GROUP BY zonegroup, style;"; char sql_selectPersonalBonusRecords[] = "SELECT runtime, zonegroup, style FROM ck_bonus WHERE steamid = '%s' AND mapname = '%s' AND runtime > '0.0'"; char sql_selectPlayerRankBonus[] = "SELECT name FROM ck_bonus WHERE runtime <= (SELECT runtime FROM ck_bonus WHERE steamid = '%s' AND mapname= '%s' AND runtime > 0.0 AND zonegroup = %i AND style = 0) AND mapname = '%s' AND zonegroup = %i AND style = 0;"; -char sql_selectFastestBonus[] = "SELECT t1.name, t1.runtime, t1.zonegroup, t1.style, t1.velStartXY, t1.velStartXYZ, t1.velstartZ from ck_bonus t1 where t1.mapname = '%s' and t1.runtime = (select min(t2.runtime) from ck_bonus t2 where t2.mapname = t1.mapname and t2.zonegroup = t1.zonegroup and t2.style = t1.style);"; +char sql_selectFastestBonus[] = "SELECT t1.name, t1.runtime, t1.zonegroup, t1.style, t1.velStartXY, t1.velStartXYZ, t1.velstartZ from ck_bonus t1 where t1.mapname = '%s' and t1.runtime = (select min(t2.runtime) from ck_bonus t2 where t2.mapname = t1.mapname and t2.zonegroup = t1.zonegroup and t2.style = t1.style)"; char sql_deleteBonus[] = "DELETE FROM ck_bonus WHERE mapname = '%s'"; char sql_selectAllBonusTimesinMap[] = "SELECT zonegroup, runtime from ck_bonus WHERE mapname = '%s';"; char sql_selectTopBonusSurfers[] = "SELECT db2.steamid, db1.name, db2.runtime as overall, db1.steamid, db2.mapname FROM ck_bonus as db2 INNER JOIN ck_playerrank as db1 on db2.steamid = db1.steamid WHERE db2.mapname = '%s' AND db2.style = %i AND db1.style = %i AND db2.runtime > -1.0 AND zonegroup = %i ORDER BY overall ASC LIMIT 100;"; @@ -31,19 +31,19 @@ char sql_selectStageAttempts[] = "SELECT cp, stage_attempts FROM ck_checkpoints // ck_latestrecords char sql_createLatestRecords[] = "CREATE TABLE IF NOT EXISTS ck_latestrecords (steamid VARCHAR(32), name VARCHAR(64), runtime decimal(12,6) NOT NULL DEFAULT '-1.000000', map VARCHAR(32), date TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY(steamid,map,date)) DEFAULT CHARSET=utf8mb4;"; -char sql_insertLatestRecords[] = "INSERT INTO ck_latestrecords (steamid, name, runtime, map) VALUES('%s','%s','%f','%s');"; +char sql_insertLatestRecords[] = "INSERT INTO ck_latestrecords (steamid, name, runtime, map) VALUES('%s','%s','%f','%s')"; char sql_selectLatestRecords[] = "SELECT name, runtime, map, date FROM ck_latestrecords ORDER BY date DESC LIMIT 50"; // ck_maptier char sql_createMapTier[] = "CREATE TABLE IF NOT EXISTS ck_maptier (mapname VARCHAR(54) NOT NULL, tier INT(12), maxvelocity FLOAT NOT NULL DEFAULT '3500.0', announcerecord INT(11) NOT NULL DEFAULT '0', gravityfix INT(11) NOT NULL DEFAULT '1', ranked INT(11) NOT NULL DEFAULT '1', PRIMARY KEY(mapname)) DEFAULT CHARSET=utf8mb4;"; char sql_selectMapTier[] = "SELECT tier, ranked, mapper FROM ck_maptier WHERE mapname = '%s'"; -char sql_insertmaptier[] = "INSERT INTO ck_maptier (mapname, tier) VALUES ('%s', '%i');"; +char sql_insertmaptier[] = "INSERT INTO ck_maptier (mapname, tier) VALUES ('%s', '%i')"; char sql_updatemaptier[] = "UPDATE ck_maptier SET tier = %i WHERE mapname ='%s'"; char sql_updateMapperName[] = "UPDATE ck_maptier SET mapper = '%s' WHERE mapname = '%s'"; // ck_playeroptions2 char sql_createPlayerOptions[] = "CREATE TABLE IF NOT EXISTS `ck_playeroptions2` (`steamid` varchar(32) NOT NULL DEFAULT '', `timer` int(11) NOT NULL DEFAULT '1', `hide` int(11) NOT NULL DEFAULT '0', `sounds` int(11) NOT NULL DEFAULT '1', `chat` int(11) NOT NULL DEFAULT '0', `viewmodel` int(11) NOT NULL DEFAULT '1', `autobhop` int(11) NOT NULL DEFAULT '1', `checkpoints` int(11) NOT NULL DEFAULT '1', `gradient` int(11) NOT NULL DEFAULT '3', `speedmode` int(11) NOT NULL DEFAULT '0', `centrespeed` int(11) NOT NULL DEFAULT '0', `centrehud` int(11) NOT NULL DEFAULT '1', teleside int(11) NOT NULL DEFAULT '0', `module1c` int(11) NOT NULL DEFAULT '1', `module2c` int(11) NOT NULL DEFAULT '2', `module3c` int(11) NOT NULL DEFAULT '3', `module4c` int(11) NOT NULL DEFAULT '4', `module5c` int(11) NOT NULL DEFAULT '5', `module6c` int(11) NOT NULL DEFAULT '6', `sidehud` int(11) NOT NULL DEFAULT '1', `module1s` int(11) NOT NULL DEFAULT '5', `module2s` int(11) NOT NULL DEFAULT '0', `module3s` int(11) NOT NULL DEFAULT '0', `module4s` int(11) NOT NULL DEFAULT '0', `module5s` int(11) NOT NULL DEFAULT '0', prestrafe int(11) NOT NULL DEFAULT '0', cpmessages int(11) NOT NULL DEFAULT '1', wrcpmessages int(11) NOT NULL DEFAULT '1', hints int(11) NOT NULL DEFAULT '1', csd_update_rate int(11) NOT NULL DEFAULT '1' , csd_pos_x float(11) NOT NULL DEFAULT '0.5' , csd_pos_y float(11) NOT NULL DEFAULT '0.3' , csd_r int(11) NOT NULL DEFAULT '255', csd_g int(11) NOT NULL DEFAULT '255', csd_b int(11) NOT NULL DEFAULT '255', PRIMARY KEY (`steamid`)) DEFAULT CHARSET=utf8mb4;"; -char sql_insertPlayerOptions[] = "INSERT INTO ck_playeroptions2 (steamid) VALUES ('%s');"; +char sql_insertPlayerOptions[] = "INSERT INTO ck_playeroptions2 (steamid) VALUES ('%s')"; char sql_selectPlayerOptions[] = "SELECT timer, hide, sounds, chat, viewmodel, autobhop, checkpoints, gradient, speedmode, centrespeed, centrehud, teleside, module1c, module2c, module3c, module4c, module5c, module6c, sidehud, module1s, module2s, module3s, module4s, module5s, prestrafe, cpmessages, wrcpmessages, hints, csd_update_rate, csd_pos_x, csd_pos_y, csd_r, csd_g, csd_b, prespeedmode FROM ck_playeroptions2 where steamid = '%s';"; char sql_updatePlayerOptions[] = "UPDATE ck_playeroptions2 SET timer = %i, hide = %i, sounds = %i, chat = %i, viewmodel = %i, autobhop = %i, checkpoints = %i, gradient = %i, speedmode = %i, centrespeed = %i, centrehud = %i, teleside = %i, module1c = %i, module2c = %i, module3c = %i, module4c = %i, module5c = %i, module6c = %i, sidehud = %i, module1s = %i, module2s = %i, module3s = %i, module4s = %i, module5s = %i, prestrafe = %i, cpmessages = %i, wrcpmessages = %i, hints = %i, csd_update_rate = %i, csd_pos_x = %f, csd_pos_y = %f, csd_r= %i, csd_g = %i, csd_b = %i, prespeedmode = %i where steamid = '%s'"; @@ -66,16 +66,16 @@ char sql_selectPlayerProfile[] = "SELECT steamid, steamid64, name, country, poin // ck_playertemp char sql_createPlayertmp[] = "CREATE TABLE IF NOT EXISTS ck_playertemp (steamid VARCHAR(32), mapname VARCHAR(32), cords1 FLOAT NOT NULL DEFAULT '-1.0', cords2 FLOAT NOT NULL DEFAULT '-1.0', cords3 FLOAT NOT NULL DEFAULT '-1.0', angle1 FLOAT NOT NULL DEFAULT '-1.0',angle2 FLOAT NOT NULL DEFAULT '-1.0',angle3 FLOAT NOT NULL DEFAULT '-1.0', EncTickrate INT(12) DEFAULT '-1.0', runtimeTmp decimal(12,6) NOT NULL DEFAULT '-1.000000', Stage INT, zonegroup INT NOT NULL DEFAULT 0, PRIMARY KEY(steamid,mapname)) DEFAULT CHARSET=utf8mb4;"; -char sql_insertPlayerTmp[] = "INSERT INTO ck_playertemp (cords1, cords2, cords3, angle1,angle2,angle3,runtimeTmp,steamid,mapname,EncTickrate,Stage,zonegroup) VALUES ('%f','%f','%f','%f','%f','%f','%f','%s', '%s', '%i', %i, %i);"; +char sql_insertPlayerTmp[] = "INSERT INTO ck_playertemp (cords1, cords2, cords3, angle1,angle2,angle3,runtimeTmp,steamid,mapname,EncTickrate,Stage,zonegroup) VALUES ('%f','%f','%f','%f','%f','%f','%f','%s', '%s', '%i', %i, %i)"; char sql_updatePlayerTmp[] = "UPDATE ck_playertemp SET cords1 = '%f', cords2 = '%f', cords3 = '%f', angle1 = '%f', angle2 = '%f', angle3 = '%f', runtimeTmp = '%f', mapname ='%s', EncTickrate='%i', Stage = %i, zonegroup = %i WHERE steamid = '%s';"; char sql_deletePlayerTmp[] = "DELETE FROM ck_playertemp where steamid = '%s';"; char sql_selectPlayerTmp[] = "SELECT cords1,cords2,cords3, angle1, angle2, angle3,runtimeTmp, EncTickrate, Stage, zonegroup FROM ck_playertemp WHERE steamid = '%s' AND mapname = '%s';"; // ck_playertimes char sql_createPlayertimes[] = "CREATE TABLE IF NOT EXISTS ck_playertimes (steamid VARCHAR(32), mapname VARCHAR(32), name VARCHAR(64), runtimepro decimal(12,6) NOT NULL DEFAULT '-1.000000', velStartXY SMALLINT(6) NOT NULL DEFAULT 0, velStartXYZ SMALLINT(6) NOT NULL DEFAULT 0, velStartZ SMALLINT(6) NOT NULL DEFAULT 0, style INT(11) NOT NULL DEFAULT '0', PRIMARY KEY(steamid, mapname, style)) DEFAULT CHARSET=utf8mb4;"; -char sql_createPlayertimesIndex[] = "CREATE INDEX maprank ON ck_playertimes (mapname, runtimepro, style);"; -char sql_insertPlayer[] = "INSERT INTO ck_playertimes (steamid, mapname, name) VALUES('%s', '%s', '%s');"; -char sql_insertPlayerTime[] = "INSERT INTO ck_playertimes (steamid, mapname, name, runtimepro, style, velStartXY, velStartXYZ, velStartZ) VALUES('%s', '%s', '%s', '%f', %i, %i, %i, %i);"; +char sql_createPlayertimesIndex[] = "CREATE INDEX maprank ON ck_playertimes (mapname, runtimepro, style)"; +char sql_insertPlayer[] = "INSERT INTO ck_playertimes (steamid, mapname, name) VALUES('%s', '%s', '%s')"; +char sql_insertPlayerTime[] = "INSERT INTO ck_playertimes (steamid, mapname, name, runtimepro, style, velStartXY, velStartXYZ, velStartZ) VALUES('%s', '%s', '%s', '%f', %i, %i, %i, %i)"; char sql_updateRecordPro[] = "UPDATE ck_playertimes SET name = '%s', runtimepro = '%f', velStartXY = '%i', velStartXYZ = '%i', velStartZ = '%i' WHERE steamid = '%s' AND mapname = '%s' AND style = %i;"; char sql_selectPlayer[] = "SELECT steamid FROM ck_playertimes WHERE steamid = '%s' AND mapname = '%s';"; char sql_selectMapRecord[] = "SELECT t1.runtimepro, t1.name, t1.steamid, t1.style, t1.velStartXY, t1.velStartXYZ, t1.velstartZ FROM ck_playertimes t1 JOIN ( SELECT MIN(runtimepro) AS min_runtime, style, mapname FROM ck_playertimes GROUP BY mapname, style ) AS t2 ON t1.runtimepro = t2.min_runtime AND t1.mapname = t2.mapname AND t1.style = t2.style WHERE t1.mapname = '%s'"; @@ -89,7 +89,7 @@ char sql_selectAllMapTimesinMap[] = "SELECT runtimepro from ck_playertimes WHERE char sql_selectMapRankUnknownWithMap[] = "SELECT `steamid`, `name`, `mapname`, `runtimepro` FROM `ck_playertimes` WHERE `mapname` = '%s' AND style = 0 ORDER BY `runtimepro` ASC LIMIT %i, 1;"; // ck_spawnlocations char sql_createSpawnLocations[] = "CREATE TABLE IF NOT EXISTS ck_spawnlocations (mapname VARCHAR(54) NOT NULL, pos_x FLOAT NOT NULL, pos_y FLOAT NOT NULL, pos_z FLOAT NOT NULL, ang_x FLOAT NOT NULL, ang_y FLOAT NOT NULL, ang_z FLOAT NOT NULL, `vel_x` float NOT NULL DEFAULT '0', `vel_y` float NOT NULL DEFAULT '0', `vel_z` float NOT NULL DEFAULT '0', zonegroup INT(12) DEFAULT 0, stage INT(12) DEFAULT 0, teleside INT(11) DEFAULT 0, PRIMARY KEY(mapname, zonegroup, stage, teleside)) DEFAULT CHARSET=utf8mb4;"; -char sql_insertSpawnLocations[] = "INSERT INTO ck_spawnlocations (mapname, pos_x, pos_y, pos_z, ang_x, ang_y, ang_z, vel_x, vel_y, vel_z, zonegroup, teleside) VALUES ('%s', '%f', '%f', '%f', '%f', '%f', '%f', '%f', '%f', '%f', %i, %i);"; +char sql_insertSpawnLocations[] = "INSERT INTO ck_spawnlocations (mapname, pos_x, pos_y, pos_z, ang_x, ang_y, ang_z, vel_x, vel_y, vel_z, zonegroup, teleside) VALUES ('%s', '%f', '%f', '%f', '%f', '%f', '%f', '%f', '%f', '%f', %i, %i)"; char sql_updateSpawnLocations[] = "UPDATE ck_spawnlocations SET pos_x = '%f', pos_y = '%f', pos_z = '%f', ang_x = '%f', ang_y = '%f', ang_z = '%f', vel_x = '%f', vel_y = '%f', vel_z = '%f' WHERE mapname = '%s' AND zonegroup = %i AND teleside = %i;"; char sql_selectSpawnLocations[] = "SELECT mapname, pos_x, pos_y, pos_z, ang_x, ang_y, ang_z, vel_x, vel_y, vel_z, zonegroup, stage, teleside FROM ck_spawnlocations WHERE mapname ='%s';"; char sql_deleteSpawnLocations[] = "DELETE FROM ck_spawnlocations WHERE mapname = '%s' AND zonegroup = %i AND stage = 1 AND teleside = %i;"; @@ -121,15 +121,11 @@ char sql_MainDeleteQeury[] = "DELETE From %s where mapname='%s' and style='%i' a //ck_prinfo char sql_CreatePrinfo[] = "CREATE TABLE IF NOT EXISTS ck_prinfo (steamid VARCHAR(32), name VARCHAR(64), mapname VARCHAR(32), runtime decimal(12,6) NOT NULL DEFAULT '-1.000000', zonegroup INT(12) NOT NULL DEFAULT '0', PRtimeinzone decimal(12,6) NOT NULL DEFAULT '-1.000000', PRcomplete FLOAT NOT NULL DEFAULT '0.0', PRattempts FLOAT NOT NULL DEFAULT '0.0', PRstcomplete FLOAT NOT NULL DEFAULT '0.0', PRIMARY KEY(steamid, mapname, zonegroup)) DEFAULT CHARSET=utf8mb4;"; - char sql_selectPR[] = "SELECT steamid, name, mapname, zonegroup, PRtimeinzone, PRcomplete, PRattempts, PRstcomplete FROM ck_prinfo WHERE steamid = '%s' AND mapname = '%s' AND zonegroup= '%i';"; -char sql_insertPR[] = "INSERT INTO ck_prinfo (steamid, name, mapname, runtime, zonegroup, PRtimeinzone, PRcomplete, PRattempts, PRstcomplete) VALUES('%s', '%s', '%s', '%f', '%i', '%f', '%f', '%f', '%f');"; - +char sql_insertPR[] = "INSERT INTO ck_prinfo (steamid, name, mapname, runtime, zonegroup, PRtimeinzone, PRcomplete, PRattempts, PRstcomplete) VALUES('%s', '%s', '%s', '%f', '%i', '%f', '%f', '%f', '%f')"; char sql_selectBonusPR[] = "SELECT steamid, name, mapname, zonegroup, PRtimeinzone, PRcomplete, PRattempts, PRstcomplete FROM ck_prinfo WHERE steamid = '%s' AND mapname = '%s' AND zonegroup = '%i';"; - char sql_updatePrinfo[] = "UPDATE ck_prinfo SET PRtimeinzone = '%f', PRcomplete = '%f', PRattempts = '%f', PRstcomplete = '%f' WHERE steamid = '%s' AND mapname = '%s' AND zonegroup = '%i';"; char sql_updatePrinfo_withruntime[] = "UPDATE ck_prinfo SET PRtimeinzone = '%f', PRcomplete = '%f', PRattempts = '%f', PRstcomplete = '%f', runtime = '%f' WHERE steamid = '%s' AND mapname = '%s' AND zonegroup = '%i';"; - char sql_clearPRruntime[] = "UPDATE ck_prinfo SET runtime = '0.0' WHERE steamid = '%s' AND mapname = '%s' AND zonegroup = '%i';"; //ck_replays @@ -137,5 +133,13 @@ char sql_createReplays[] = "CREATE TABLE IF NOT EXISTS ck_replays (mapname VARCH char sql_selectReplayCPTicksAll[] = "SELECT cp, frame, style FROM ck_replays WHERE mapname = '%s' AND style = '%i' ORDER BY cp ASC;"; char sql_insertReplayCPTicks[] = "INSERT INTO ck_replays (mapname, cp, frame, style) VALUES ('%s', '%i', '%i', '%i')"; char sql_updateReplayCPTicks[] = "UPDATE ck_replays SET frame='%i' WHERE mapname='%s' AND cp ='%i' AND style='%i';"; + //check tables data type char sql_checkDataType[] = "SELECT DATA_TYPE, NUMERIC_PRECISION, NUMERIC_SCALE FROM information_schema.COLUMNS WHERE TABLE_SCHEMA='%s' AND TABLE_NAME='%s' AND COLUMN_NAME='%s' HAVING DATA_TYPE = 'decimal' AND NUMERIC_PRECISION = 12 AND NUMERIC_SCALE = 6;"; + +// ck_players +char sql_createPlayers[] = "CREATE TABLE IF NOT EXISTS ck_players (accountid INT NOT NULL, steamid2 VARCHAR(32) NULL, steamid64 VARCHAR(64) NULL, name VARCHAR(64) NULL, PRIMARY KEY(accountid)) DEFAULT CHARSET=utf8mb4;"; +char sql_insertPlayersAS2[] = "INSERT ck_players (accountid, steamid2) VALUES ('%d', '%s') ON DUPLICATE KEY UPDATE steamid2 = '%s'"; +char sql_insertPlayersAS2N[] = "INSERT ck_players (accountid, steamid2, name) VALUES ('%d', '%s', '%s') ON DUPLICATE KEY UPDATE steamid2 = '%s', name = '%s'"; +char sql_insertPlayersAS2S64[] = "INSERT ck_players (accountid, steamid2, steamid64) VALUES ('%d', '%s', '%s') ON DUPLICATE KEY UPDATE steamid2 = '%s', steamid64 = '%s'"; +char sql_insertUpdatePlayersAll[] = "INSERT ck_players (accountid, steamid2, steamid64, name) VALUES ('%d', '%s', '%s', '%s') ON DUPLICATE KEY UPDATE steamid2 = '%s', steamid64 = '%s', name = '%s'"; diff --git a/addons/sourcemod/scripting/surftimer/db/updater.sp b/addons/sourcemod/scripting/surftimer/db/updater.sp index f3dc8c45..7cf2981e 100644 --- a/addons/sourcemod/scripting/surftimer/db/updater.sp +++ b/addons/sourcemod/scripting/surftimer/db/updater.sp @@ -16,7 +16,7 @@ void CheckDatabaseForUpdates() return; } - if(!SQL_FastQuery(g_hDb, "SELECT ranked FROM ck_maptier LIMIT 1") || !SQL_FastQuery(g_hDb, "SELECT style FROM ck_playerrank LIMIT 1;")) + if (!SQL_FastQuery(g_hDb, "SELECT ranked FROM ck_maptier LIMIT 1") || !SQL_FastQuery(g_hDb, "SELECT style FROM ck_playerrank LIMIT 1;")) { db_upgradeDatabase(1); return; @@ -99,10 +99,21 @@ void CheckDatabaseForUpdates() delete results; return; } - // Version 13 - End - LogMessage("Version 13 looks good."); + if (!SQL_FastQuery(g_hDb, "SELECT accountid FROM ck_players LIMIT 1")) + { + db_upgradeDatabase(14, true); + return; + } + + if (!SQL_FastQuery(g_hDb, "SELECT accountid FROM ck_vipadmins LIMIT 1")) // TODO: Check for name/steamid64 column if exists or no more + { + db_upgradeDatabase(15); + return; + } + + LogMessage("Version 15 looks good."); } } @@ -181,14 +192,14 @@ void db_upgradeDatabase(int ver, bool skipErrorCheck = false) //ALREADY CONVERTED char sQuery[512]; Format(sQuery, sizeof(sQuery), sql_checkDataType, g_sDatabaseName, "ck_checkpoints", "cp1"); - if(SQL_FastQuery(g_hDb_Updates, sql_checkDataType)){ + if (SQL_FastQuery(g_hDb_Updates, sql_checkDataType)) { SQL_FastQuery(g_hDb_Updates, "CREATE TABLE IF NOT EXISTS `ck_checkpointsnew` (`steamid` varchar(32) NOT NULL, `mapname` varchar(32) NOT NULL, `cp` int(11) NOT NULL DEFAULT '0', `time` decimal(12, 6) NOT NULL DEFAULT '0.000000', `zonegroup` int(12) NOT NULL DEFAULT '0.0', PRIMARY KEY (`steamid`,`mapname`,`cp`,`zonegroup`)) DEFAULT CHARSET=utf8mb4;"); SQL_FastQuery(g_hDb_Updates, "REPLACE INTO ck_checkpointsnew (steamid, mapname, cp, time, zonegroup) SELECT * FROM ( SELECT steamid, mapname, 1 AS cp, cp1 AS time, zonegroup FROM ck_checkpoints UNION ALL SELECT steamid, mapname, 2 AS cp, cp2, zonegroup FROM ck_checkpoints UNION ALL SELECT steamid, mapname, 3 AS cp, cp3, zonegroup FROM ck_checkpoints UNION ALL SELECT steamid, mapname, 4 AS cp, cp4, zonegroup FROM ck_checkpoints UNION ALL SELECT steamid, mapname, 5 AS cp, cp5, zonegroup FROM ck_checkpoints UNION ALL SELECT steamid, mapname, 6 AS cp, cp6, zonegroup FROM ck_checkpoints UNION ALL SELECT steamid, mapname, 7 AS cp, cp7, zonegroup FROM ck_checkpoints UNION ALL SELECT steamid, mapname, 8 AS cp, cp8, zonegroup FROM ck_checkpoints UNION ALL SELECT steamid, mapname, 9 AS cp, cp9, zonegroup FROM ck_checkpoints UNION ALL SELECT steamid, mapname, 10 AS cp, cp10, zonegroup FROM ck_checkpoints UNION ALL SELECT steamid, mapname, 11 AS cp, cp11, zonegroup FROM ck_checkpoints UNION ALL SELECT steamid, mapname, 12 AS cp, cp12, zonegroup FROM ck_checkpoints UNION ALL SELECT steamid, mapname, 13 AS cp, cp13, zonegroup FROM ck_checkpoints UNION ALL SELECT steamid, mapname, 14 AS cp, cp14, zonegroup FROM ck_checkpoints UNION ALL SELECT steamid, mapname, 15 AS cp, cp15, zonegroup FROM ck_checkpoints UNION ALL SELECT steamid, mapname, 16 AS cp, cp16, zonegroup FROM ck_checkpoints UNION ALL SELECT steamid, mapname, 17 AS cp, cp17, zonegroup FROM ck_checkpoints UNION ALL SELECT steamid, mapname, 18 AS cp, cp18, zonegroup FROM ck_checkpoints UNION ALL SELECT steamid, mapname, 19 AS cp, cp19, zonegroup FROM ck_checkpoints UNION ALL SELECT steamid, mapname, 20 AS cp, cp20, zonegroup FROM ck_checkpoints UNION ALL SELECT steamid, mapname, 21 AS cp, cp21, zonegroup FROM ck_checkpoints UNION ALL SELECT steamid, mapname, 22 AS cp, cp22, zonegroup FROM ck_checkpoints UNION ALL SELECT steamid, mapname, 23 AS cp, cp23, zonegroup FROM ck_checkpoints UNION ALL SELECT steamid, mapname, 24 AS cp, cp24, zonegroup FROM ck_checkpoints UNION ALL SELECT steamid, mapname, 25 AS cp, cp25, zonegroup FROM ck_checkpoints UNION ALL SELECT steamid, mapname, 26 AS cp, cp26, zonegroup FROM ck_checkpoints UNION ALL SELECT steamid, mapname, 27 AS cp, cp27, zonegroup FROM ck_checkpoints UNION ALL SELECT steamid, mapname, 28 AS cp, cp28, zonegroup FROM ck_checkpoints UNION ALL SELECT steamid, mapname, 29 AS cp, cp29, zonegroup FROM ck_checkpoints UNION ALL SELECT steamid, mapname, 30 AS cp, cp30, zonegroup FROM ck_checkpoints UNION ALL SELECT steamid, mapname, 31 AS cp, cp31, zonegroup FROM ck_checkpoints UNION ALL SELECT steamid, mapname, 32 AS cp, cp32, zonegroup FROM ck_checkpoints UNION ALL SELECT steamid, mapname, 33 AS cp, cp33, zonegroup FROM ck_checkpoints UNION ALL SELECT steamid, mapname, 34 AS cp, cp34, zonegroup FROM ck_checkpoints UNION ALL SELECT steamid, mapname, 35 AS cp, cp35, zonegroup FROM ck_checkpoints) v HAVING time > 0;"); SQL_FastQuery(g_hDb_Updates, "ALTER TABLE ck_checkpoints RENAME TO ck_checkpointsold;"); SQL_FastQuery(g_hDb_Updates, "ALTER TABLE ck_checkpointsnew RENAME TO ck_checkpoints;"); } //NOT CONVERTED - else{ + else { SQL_FastQuery(g_hDb_Updates, "CREATE TABLE IF NOT EXISTS `ck_checkpointsnew` (`steamid` varchar(32) NOT NULL, `mapname` varchar(32) NOT NULL, `cp` int(11) NOT NULL DEFAULT '0', `time` FLOAT NOT NULL DEFAULT '0.0', `zonegroup` int(12) NOT NULL DEFAULT '0.0', PRIMARY KEY (`steamid`,`mapname`,`cp`,`zonegroup`)) DEFAULT CHARSET=utf8mb4;"); SQL_FastQuery(g_hDb_Updates, "REPLACE INTO ck_checkpointsnew (steamid, mapname, cp, time, zonegroup) SELECT * FROM ( SELECT steamid, mapname, 1 AS cp, cp1 AS time, zonegroup FROM ck_checkpoints UNION ALL SELECT steamid, mapname, 2 AS cp, cp2, zonegroup FROM ck_checkpoints UNION ALL SELECT steamid, mapname, 3 AS cp, cp3, zonegroup FROM ck_checkpoints UNION ALL SELECT steamid, mapname, 4 AS cp, cp4, zonegroup FROM ck_checkpoints UNION ALL SELECT steamid, mapname, 5 AS cp, cp5, zonegroup FROM ck_checkpoints UNION ALL SELECT steamid, mapname, 6 AS cp, cp6, zonegroup FROM ck_checkpoints UNION ALL SELECT steamid, mapname, 7 AS cp, cp7, zonegroup FROM ck_checkpoints UNION ALL SELECT steamid, mapname, 8 AS cp, cp8, zonegroup FROM ck_checkpoints UNION ALL SELECT steamid, mapname, 9 AS cp, cp9, zonegroup FROM ck_checkpoints UNION ALL SELECT steamid, mapname, 10 AS cp, cp10, zonegroup FROM ck_checkpoints UNION ALL SELECT steamid, mapname, 11 AS cp, cp11, zonegroup FROM ck_checkpoints UNION ALL SELECT steamid, mapname, 12 AS cp, cp12, zonegroup FROM ck_checkpoints UNION ALL SELECT steamid, mapname, 13 AS cp, cp13, zonegroup FROM ck_checkpoints UNION ALL SELECT steamid, mapname, 14 AS cp, cp14, zonegroup FROM ck_checkpoints UNION ALL SELECT steamid, mapname, 15 AS cp, cp15, zonegroup FROM ck_checkpoints UNION ALL SELECT steamid, mapname, 16 AS cp, cp16, zonegroup FROM ck_checkpoints UNION ALL SELECT steamid, mapname, 17 AS cp, cp17, zonegroup FROM ck_checkpoints UNION ALL SELECT steamid, mapname, 18 AS cp, cp18, zonegroup FROM ck_checkpoints UNION ALL SELECT steamid, mapname, 19 AS cp, cp19, zonegroup FROM ck_checkpoints UNION ALL SELECT steamid, mapname, 20 AS cp, cp20, zonegroup FROM ck_checkpoints UNION ALL SELECT steamid, mapname, 21 AS cp, cp21, zonegroup FROM ck_checkpoints UNION ALL SELECT steamid, mapname, 22 AS cp, cp22, zonegroup FROM ck_checkpoints UNION ALL SELECT steamid, mapname, 23 AS cp, cp23, zonegroup FROM ck_checkpoints UNION ALL SELECT steamid, mapname, 24 AS cp, cp24, zonegroup FROM ck_checkpoints UNION ALL SELECT steamid, mapname, 25 AS cp, cp25, zonegroup FROM ck_checkpoints UNION ALL SELECT steamid, mapname, 26 AS cp, cp26, zonegroup FROM ck_checkpoints UNION ALL SELECT steamid, mapname, 27 AS cp, cp27, zonegroup FROM ck_checkpoints UNION ALL SELECT steamid, mapname, 28 AS cp, cp28, zonegroup FROM ck_checkpoints UNION ALL SELECT steamid, mapname, 29 AS cp, cp29, zonegroup FROM ck_checkpoints UNION ALL SELECT steamid, mapname, 30 AS cp, cp30, zonegroup FROM ck_checkpoints UNION ALL SELECT steamid, mapname, 31 AS cp, cp31, zonegroup FROM ck_checkpoints UNION ALL SELECT steamid, mapname, 32 AS cp, cp32, zonegroup FROM ck_checkpoints UNION ALL SELECT steamid, mapname, 33 AS cp, cp33, zonegroup FROM ck_checkpoints UNION ALL SELECT steamid, mapname, 34 AS cp, cp34, zonegroup FROM ck_checkpoints UNION ALL SELECT steamid, mapname, 35 AS cp, cp35, zonegroup FROM ck_checkpoints) v HAVING time > 0;"); SQL_FastQuery(g_hDb_Updates, "ALTER TABLE ck_checkpoints RENAME TO ck_checkpointsold;"); @@ -214,6 +225,84 @@ void db_upgradeDatabase(int ver, bool skipErrorCheck = false) SQL_FastQuery(g_hDb, "ALTER TABLE ck_wrcps MODIFY name VARCHAR(64);"); SQL_FastQuery(g_hDb, "ALTER TABLE ck_prinfo MODIFY name VARCHAR(64);"); } + else if (ver == 14) + { + // Cleanup tables with invalid steamids + char sQuery[512]; + for (int i = 0; i < sizeof(g_sSteamIdTablesCleanup); i++) + { + FormatEx(sQuery, sizeof(sQuery), "DELETE FROM %s WHERE steamid = \"STEAM_ID_STOP_IGNORING_RETVALS\";", g_sSteamIdTablesCleanup[i]); + SQL_FastQuery(g_hDb, sQuery); + } + + if (SQL_FastQuery(g_hDb, sql_createPlayers)) + { + // Add accountid column to tables, because we can use the next SELECT queries for adding accountid to all 10 tables too... + for (int i = 0; i < sizeof(g_sSteamIdTablesCleanup); i++) + { + FormatEx(sQuery, sizeof(sQuery), "ALTER TABLE %s ADD COLUMN accountid INT NOT NULL AFTER steamid;", g_sSteamIdTablesCleanup[i]); + SQL_FastQuery(g_hDb, sQuery); + } + + // Wait a frame fixed for me the "Lost Connection" error... + // maybe it was a random thing, but I'll keep it for now. + RequestFrame(StartLoadingPlayerStuff); + return; + } + } + else if (ver == 15) + { + // Drop table keys and steamid columns... + char sQuery[512]; + for (int i = 0; i < sizeof(g_sSteamIdTablesCleanup); i++) + { + FormatEx(sQuery, sizeof(sQuery), "ALTER TABLE %s DROP PRIMARY KEY;", g_sSteamIdTablesCleanup[i]); + SQL_FastQuery(g_hDb, sQuery); + + FormatEx(sQuery, sizeof(sQuery), "ALTER TABLE %s DROP COLUMN steamid;", g_sSteamIdTablesCleanup[i]); + SQL_FastQuery(g_hDb, sQuery); + + if (g_sSteamIdTablesCleanup[i][3] == 'v') + { + SQL_FastQuery(g_hDb, "DROP INDEX vip ON ck_vipadmins;"); + } + } + + SQL_FastQuery(g_hDb, "ALTER TABLE ck_bonus DROP COLUMN name;"); + SQL_FastQuery(g_hDb, "ALTER TABLE ck_latestrecords DROP COLUMN name;"); + SQL_FastQuery(g_hDb, "ALTER TABLE ck_playertimes DROP COLUMN name;"); + SQL_FastQuery(g_hDb, "ALTER TABLE ck_prinfo DROP COLUMN name;"); + SQL_FastQuery(g_hDb, "ALTER TABLE ck_playerrank DROP COLUMN steamid64;"); + SQL_FastQuery(g_hDb, "ALTER TABLE ck_wrcps DROP COLUMN name;"); + /* + Steps left (maybe more): + - add (primary) keys back + + + Keys: + ck_bonus + PRIMARY KEY(`steamid`, `mapname`, `zonegroup`, `style`) + ck_checkpoints + PRIMARY KEY(`steamid`, `mapname`, `cp`, `zonegroup`) + ck_latestrecords + PRIMARY KEY(`steamid`, `map`, `date`) + ck_playeroptions2 + PRIMARY KEY (`steamid`) + ck_playerrank + PRIMARY KEY (`steamid`, `style`) + ck_playertemp + PRIMARY KEY(`steamid`,`mapname`) + ck_playertimes + PRIMARY KEY(`steamid`, `mapname`, `style`) + ck_prinfo + PRIMARY KEY(`steamid`, `mapname`, `zonegroup`) + ck_wrcps + PRIMARY KEY (`steamid`,`mapname`,`stage`,`style`) + ck_vipadmins + PRIMARY KEY (`steamid`) + KEY `vip` (`steamid`,`vip`,`admin`,`zoner`) + */ + } CheckDatabaseForUpdates(); } @@ -246,7 +335,7 @@ void CheckDataType(const char[] table, const char[] column) pack.WriteString(table); pack.WriteString(sColumn); - SQL_TQuery(g_hDb_Updates, SQLCheckDataType, sQuery, pack); + g_hDb_Updates.Query(SQLCheckDataType, sQuery, pack); } public void SQLCheckDataType(Handle owner, Handle hndl, const char[] error, DataPack pack) @@ -304,7 +393,7 @@ public void SQLCheckDataType(Handle owner, Handle hndl, const char[] error, Data { LogError("Unsupported table, column and datatype combination. Please open up an issue. Table: %s, Column: %s, DataType: %s, Precision: %d, Scale: %d", sTable, sColumn, sDataType, iPrecision, iScale); } - else if (sDataType[0] == 'd' && iPrecision == 12 && iScale == 6 && (strcmp(g_sDecimalTables[sizeof(g_sDecimalTables)-1][0], sTable) == 0) && !g_tables_converted){ + else if (sDataType[0] == 'd' && iPrecision == 12 && iScale == 6 && (strcmp(g_sDecimalTables[sizeof(g_sDecimalTables)-1][0], sTable) == 0) && !g_tables_converted) { g_tables_converted = true; /// Start Loading Server Settings @@ -324,7 +413,7 @@ public void SQLCheckDataType(Handle owner, Handle hndl, const char[] error, Data void ConvertDataTypeToDecimal(const char[] table, const char[] column, int precision, int scale) { - PrintToServer("Converting %s-%s to decimal(%d, %d)...", table, column, precision, scale); + LogMessage("Converting %s-%s to decimal(%d, %d)...", table, column, precision, scale); char sQuery[128]; Format(sQuery, sizeof(sQuery), "ALTER TABLE %s MODIFY %s DECIMAL(%d, %d);", table, column, precision, scale); @@ -333,7 +422,7 @@ void ConvertDataTypeToDecimal(const char[] table, const char[] column, int preci pack.WriteString(table); pack.WriteString(column); - SQL_TQuery(g_hDb_Updates, SQLChangeDataType, sQuery, pack); + g_hDb_Updates.Query(SQLChangeDataType, sQuery, pack); } public void SQLChangeDataType(Handle owner, Handle hndl, const char[] error, DataPack pack) @@ -357,21 +446,307 @@ public void SQLChangeDataType(Handle owner, Handle hndl, const char[] error, Dat CheckDataType(sTable, sColumn); } -void CleanUpTablesRetvalsSteamId() +public void SQLCleanUpTables(Handle owner, Handle hndl, const char[] error, any data) { - char sQuery[512]; - for (int i = 0; i < sizeof(g_sSteamIdTablesCleanup); i++) + if (owner == null || strlen(error) > 0) { - FormatEx(sQuery, sizeof(sQuery), "DELETE FROM %s WHERE steamid = \"STEAM_ID_STOP_IGNORING_RETVALS\";", g_sSteamIdTablesCleanup[i]); - SQL_TQuery(g_hDb_Updates, SQLCleanUpTables, sQuery); + SetFailState("[SQLCleanUpTables] Error while cleaning up tables... Error: %s", error); + return; } } -public void SQLCleanUpTables(Handle owner, Handle hndl, const char[] error, any data) +public void StartLoadingPlayerStuff() { - if (owner == null || strlen(error) > 0) + SelectPlayersStuff(); +} + +void SelectPlayersStuff() +{ + Transaction tTransaction = new Transaction(); + + char sQuery[256]; + FormatEx(sQuery, sizeof(sQuery), "SELECT steamid, name FROM ck_bonus GROUP BY steamid;"); + tTransaction.AddQuery(sQuery, 0); + + FormatEx(sQuery, sizeof(sQuery), "SELECT steamid FROM ck_checkpoints GROUP BY steamid;"); + tTransaction.AddQuery(sQuery, 1); + + FormatEx(sQuery, sizeof(sQuery), "SELECT steamid, name FROM ck_latestrecords GROUP BY steamid;"); + tTransaction.AddQuery(sQuery, 2); + + FormatEx(sQuery, sizeof(sQuery), "SELECT steamid FROM ck_playeroptions2 GROUP BY steamid;"); + tTransaction.AddQuery(sQuery, 3); + + FormatEx(sQuery, sizeof(sQuery), "SELECT steamid, steamid64 FROM ck_playerrank GROUP BY steamid;"); + tTransaction.AddQuery(sQuery, 4); + + FormatEx(sQuery, sizeof(sQuery), "SELECT steamid FROM ck_playertemp GROUP BY steamid;"); + tTransaction.AddQuery(sQuery, 5); + + FormatEx(sQuery, sizeof(sQuery), "SELECT steamid, name FROM ck_playertimes GROUP BY steamid;"); + tTransaction.AddQuery(sQuery, 6); + + FormatEx(sQuery, sizeof(sQuery), "SELECT steamid, name FROM ck_prinfo GROUP BY steamid;"); + tTransaction.AddQuery(sQuery, 7); + + FormatEx(sQuery, sizeof(sQuery), "SELECT steamid, name FROM ck_wrcps GROUP BY steamid;"); + tTransaction.AddQuery(sQuery, 8); + + FormatEx(sQuery, sizeof(sQuery), "SELECT steamid FROM ck_vipadmins GROUP BY steamid;"); + tTransaction.AddQuery(sQuery, 9); + + SQL_ExecuteTransaction(g_hDb, tTransaction, SQLTxn_GetPlayerDataSuccess, SQLTxn_GetPlayerDataFailed, .priority=DBPrio_High); +} + +public void SQLTxn_GetPlayerDataSuccess(Database db, any data, int numQueries, DBResultSet[] results, any[] queryData) +{ + int iQueries = 0; + Transaction tTransaction = new Transaction(); + + for (int i = 0; i < numQueries; i++) { - SetFailState("[SQLCleanUpTables] Error while cleaning up tables... Error: %s", error); + char sSteamId2[32], sName[64], sSteamId64[128], sQuery[1024]; + // ck_bonus + if (g_sSteamIdTablesCleanup[i][3] == 'b') + { + while (results[i].FetchRow()) + { + results[i].FetchString(0, sSteamId2, sizeof(sSteamId2)); + results[i].FetchString(1, sName, sizeof(sName)); + + int iAccountId = SteamId2ToAccountId(sSteamId2); + + // Insert into ck_players + FormatEx(sQuery, sizeof(sQuery), sql_insertPlayersAS2N, iAccountId, sSteamId2, sName, sSteamId2, sName); + tTransaction.AddQuery(sQuery); + iQueries++; + + // Update table and adding account + FormatEx(sQuery, sizeof(sQuery), "UPDATE %s SET accountid = %d WHERE steamid = '%s';", g_sSteamIdTablesCleanup[i], iAccountId, sSteamId2); + tTransaction.AddQuery(sQuery); + iQueries++; + } + } + // ck_checkpoints + else if (g_sSteamIdTablesCleanup[i][3] == 'c') + { + while (results[i].FetchRow()) + { + results[i].FetchString(0, sSteamId2, sizeof(sSteamId2)); + + int iAccountId = SteamId2ToAccountId(sSteamId2); + + // Insert into ck_players + FormatEx(sQuery, sizeof(sQuery), sql_insertPlayersAS2, iAccountId, sSteamId2, sSteamId2); + tTransaction.AddQuery(sQuery); + iQueries++; + + // Update table and adding account + FormatEx(sQuery, sizeof(sQuery), "UPDATE %s SET accountid = %d WHERE steamid = '%s';", g_sSteamIdTablesCleanup[i], iAccountId, sSteamId2); + tTransaction.AddQuery(sQuery); + iQueries++; + } + } + // ck_latestrecords + else if (g_sSteamIdTablesCleanup[i][3] == 'l') + { + while (results[i].FetchRow()) + { + results[i].FetchString(0, sSteamId2, sizeof(sSteamId2)); + results[i].FetchString(1, sName, sizeof(sName)); + + int iAccountId = SteamId2ToAccountId(sSteamId2); + + // Insert into ck_players + FormatEx(sQuery, sizeof(sQuery), sql_insertPlayersAS2N, iAccountId, sSteamId2, sName, sSteamId2, sName); + tTransaction.AddQuery(sQuery); + iQueries++; + + // Update table and adding account + FormatEx(sQuery, sizeof(sQuery), "UPDATE %s SET accountid = %d WHERE steamid = '%s';", g_sSteamIdTablesCleanup[i], iAccountId, sSteamId2); + tTransaction.AddQuery(sQuery); + iQueries++; + } + } + // ck_playeroptions2 + else if (g_sSteamIdTablesCleanup[i][3] == 'p' && g_sSteamIdTablesCleanup[i][10] == 'p') + { + while (results[i].FetchRow()) + { + results[i].FetchString(0, sSteamId2, sizeof(sSteamId2)); + + int iAccountId = SteamId2ToAccountId(sSteamId2); + + // Insert into ck_players + FormatEx(sQuery, sizeof(sQuery), sql_insertPlayersAS2, iAccountId, sSteamId2, sSteamId2); + tTransaction.AddQuery(sQuery); + iQueries++; + + // Update table and adding account + FormatEx(sQuery, sizeof(sQuery), "UPDATE %s SET accountid = %d WHERE steamid = '%s';", g_sSteamIdTablesCleanup[i], iAccountId, sSteamId2); + tTransaction.AddQuery(sQuery); + iQueries++; + } + } + // ck_playerrank + else if (g_sSteamIdTablesCleanup[i][3] == 'p' && g_sSteamIdTablesCleanup[i][10] == 'a') + { + while (results[i].FetchRow()) + { + results[i].FetchString(0, sSteamId2, sizeof(sSteamId2)); + results[i].FetchString(1, sSteamId64, sizeof(sSteamId64)); + + int iAccountId = SteamId2ToAccountId(sSteamId2); + + // Insert into ck_players + FormatEx(sQuery, sizeof(sQuery), sql_insertPlayersAS2S64, iAccountId, sSteamId2, sSteamId64, sSteamId2, sSteamId64); + tTransaction.AddQuery(sQuery); + iQueries++; + + // Update table and adding account + FormatEx(sQuery, sizeof(sQuery), "UPDATE %s SET accountid = %d WHERE steamid = '%s';", g_sSteamIdTablesCleanup[i], iAccountId, sSteamId2); + tTransaction.AddQuery(sQuery); + iQueries++; + } + } + // ck_playertemp + else if (g_sSteamIdTablesCleanup[i][3] == 'p' && g_sSteamIdTablesCleanup[i][10] == 'e') + { + while (results[i].FetchRow()) + { + results[i].FetchString(0, sSteamId2, sizeof(sSteamId2)); + + int iAccountId = SteamId2ToAccountId(sSteamId2); + + // Insert into ck_players + FormatEx(sQuery, sizeof(sQuery), sql_insertPlayersAS2, iAccountId, sSteamId2, sSteamId2); + tTransaction.AddQuery(sQuery); + iQueries++; + + // Update table and adding account + FormatEx(sQuery, sizeof(sQuery), "UPDATE %s SET accountid = %d WHERE steamid = '%s';", g_sSteamIdTablesCleanup[i], iAccountId, sSteamId2); + tTransaction.AddQuery(sQuery); + iQueries++; + } + } + // ck_playertimes + else if (g_sSteamIdTablesCleanup[i][3] == 'p' && g_sSteamIdTablesCleanup[i][10] == 'i') + { + while (results[i].FetchRow()) + { + results[i].FetchString(0, sSteamId2, sizeof(sSteamId2)); + results[i].FetchString(1, sName, sizeof(sName)); + + int iAccountId = SteamId2ToAccountId(sSteamId2); + + // Insert into ck_players + FormatEx(sQuery, sizeof(sQuery), sql_insertPlayersAS2N, iAccountId, sSteamId2, sName, sSteamId2, sName); + tTransaction.AddQuery(sQuery); + iQueries++; + + // Update table and adding account + FormatEx(sQuery, sizeof(sQuery), "UPDATE %s SET accountid = %d WHERE steamid = '%s';", g_sSteamIdTablesCleanup[i], iAccountId, sSteamId2); + tTransaction.AddQuery(sQuery); + iQueries++; + } + } + // ck_prinfo + else if (g_sSteamIdTablesCleanup[i][3] == 'p' && g_sSteamIdTablesCleanup[i][4] == 'r') + { + while (results[i].FetchRow()) + { + results[i].FetchString(0, sSteamId2, sizeof(sSteamId2)); + results[i].FetchString(1, sName, sizeof(sName)); + + int iAccountId = SteamId2ToAccountId(sSteamId2); + + // Insert into ck_players + FormatEx(sQuery, sizeof(sQuery), sql_insertPlayersAS2N, iAccountId, sSteamId2, sName, sSteamId2, sName); + tTransaction.AddQuery(sQuery); + iQueries++; + + // Update table and adding account + FormatEx(sQuery, sizeof(sQuery), "UPDATE %s SET accountid = %d WHERE steamid = '%s';", g_sSteamIdTablesCleanup[i], iAccountId, sSteamId2); + tTransaction.AddQuery(sQuery); + iQueries++; + } + } + // ck_wrcps + else if (g_sSteamIdTablesCleanup[i][3] == 'w') + { + while (results[i].FetchRow()) + { + results[i].FetchString(0, sSteamId2, sizeof(sSteamId2)); + results[i].FetchString(1, sName, sizeof(sName)); + + int iAccountId = SteamId2ToAccountId(sSteamId2); + + // Insert into ck_players + FormatEx(sQuery, sizeof(sQuery), sql_insertPlayersAS2N, iAccountId, sSteamId2, sName, sSteamId2, sName); + tTransaction.AddQuery(sQuery); + iQueries++; + + // Update table and adding account + FormatEx(sQuery, sizeof(sQuery), "UPDATE %s SET accountid = %d WHERE steamid = '%s';", g_sSteamIdTablesCleanup[i], iAccountId, sSteamId2); + tTransaction.AddQuery(sQuery); + iQueries++; + } + } + // ck_vipadmins + else if (g_sSteamIdTablesCleanup[i][3] == 'v') + { + while (results[i].FetchRow()) + { + results[i].FetchString(0, sSteamId2, sizeof(sSteamId2)); + + int iAccountId = SteamId2ToAccountId(sSteamId2); + + // Insert into ck_players + FormatEx(sQuery, sizeof(sQuery), sql_insertPlayersAS2, iAccountId, sSteamId2, sSteamId2); + tTransaction.AddQuery(sQuery); + iQueries++; + + // Update table and adding account + FormatEx(sQuery, sizeof(sQuery), "UPDATE %s SET accountid = %d WHERE steamid = '%s';", g_sSteamIdTablesCleanup[i], iAccountId, sSteamId2); + tTransaction.AddQuery(sQuery); + iQueries++; + } + } + + PrintToServer("Added %d Queries to Transaction for table %s", iQueries, g_sSteamIdTablesCleanup[i]); + } + + if (iQueries == 0) + { + CheckDatabaseForUpdates(); return; } + + PrintToServer("Transaction started with %d queries started...", iQueries); + SQL_ExecuteTransaction(g_hDb, tTransaction, SQLTxn_InsertToPlayersSuccess, SQLTxn_InsertToPlayersFailed, .priority=DBPrio_High); +} + +public void SQLTxn_InsertToPlayersSuccess(Database db, any data, int numQueries, DBResultSet[] results, any[] queryData) +{ + CheckDatabaseForUpdates(); +} + +public void SQLTxn_InsertToPlayersFailed(Database db, any data, int numQueries, const char[] error, int failIndex, any[] queryData) +{ + SQL_FastQuery(g_hDb, "DROP TABLE IF EXISTS ck_players;"); + + SetFailState("[SurfTimer] Failed while adding data to table ck_players! Error: %s", error); +} + +public void SQLTxn_GetPlayerDataFailed(Database db, any data, int numQueries, const char[] error, int failIndex, any[] queryData) +{ + SQL_FastQuery(g_hDb, "DROP TABLE IF EXISTS ck_players;"); + + if (failIndex == -1) + { + SetFailState("[SurfTimer] Failed while getting data! Error: %s", error); + return; + } + + SetFailState("[SurfTimer] Failed while getting data from table %s! Error: %s", g_sSteamIdTablesCleanup[failIndex], error); } diff --git a/addons/sourcemod/scripting/surftimer/globals.sp b/addons/sourcemod/scripting/surftimer/globals.sp index 82a361ff..4cb9ac1c 100644 --- a/addons/sourcemod/scripting/surftimer/globals.sp +++ b/addons/sourcemod/scripting/surftimer/globals.sp @@ -704,8 +704,8 @@ GlobalForward g_StageFinishForward; /*---------- SQL Variables ----------*/ // SQL driver -Handle g_hDb = null; -Handle g_hDb_Updates = null; +Database g_hDb = null; +Database g_hDb_Updates = null; // Database type int g_DbType; @@ -1581,7 +1581,8 @@ char g_sSteamIdTablesCleanup[][] = { "ck_playerrank", "ck_playertemp", "ck_playertimes", - "ck_prinfo", + "ck_prinfo", + "ck_wrcps", "ck_vipadmins" }; diff --git a/addons/sourcemod/scripting/surftimer/hooks.sp b/addons/sourcemod/scripting/surftimer/hooks.sp index c544de23..7ff3d216 100644 --- a/addons/sourcemod/scripting/surftimer/hooks.sp +++ b/addons/sourcemod/scripting/surftimer/hooks.sp @@ -154,7 +154,7 @@ public Action Event_OnPlayerSpawn(Handle event, const char[] name, bool dontBroa return Plugin_Continue; } - else{ + else { //PRINFO TIME INCREMENT for(int zonegroup = 0; zonegroup < MAXZONEGROUPS; zonegroup++) g_fTimeIncrement[client][zonegroup] = 0.0; @@ -189,9 +189,9 @@ public Action Event_OnPlayerSpawn(Handle event, const char[] name, bool dontBroa CreateTimer(1.5, CenterMsgTimer, client, TIMER_FLAG_NO_MAPCHANGE); //THIS "FIXES" A BUG WHERE THE TIMEINCREMENT WOULD BE CHANGED IN THE BEGINNING FOR FUCK ALL REASON... - if(!IsFakeClient(client)){ - for(int zonegroup = 0; zonegroup < MAXZONEGROUPS; zonegroup++){ - if(g_fTimeIncrement[client][zonegroup] != 0.0) + if (!IsFakeClient(client)) { + for(int zonegroup = 0; zonegroup < MAXZONEGROUPS; zonegroup++) { + if (g_fTimeIncrement[client][zonegroup] != 0.0) g_fTimeIncrement[client][zonegroup] = 0.0; } } @@ -389,7 +389,7 @@ public Action Say_Hook(int client, const char[] command, int argc) } } - SQL_TQuery(g_hDb, sql_DeleteMenuView, szQuery, GetClientSerial(client)); + g_hDb.Query(sql_DeleteMenuView, szQuery, GetClientSerial(client)); } case ColorValue: { @@ -397,12 +397,12 @@ public Action Say_Hook(int client, const char[] command, int argc) int color_value = StringToInt(sText); //KEEP VALUES BETWEEN 0-255 - if(color_value > 255) + if (color_value > 255) color_value = 255; - else if(color_value < 0) + else if (color_value < 0) color_value = 0; - switch(g_iColorChangeIndex[client]){ + switch(g_iColorChangeIndex[client]) { case 0: g_iCSD_R[client] = color_value; case 1: g_iCSD_G[client] = color_value; case 2: g_iCSD_B[client] = color_value; @@ -547,7 +547,7 @@ public void CGetRankColor(char[] sMsg, int iSize) // edit from CProcessVariables String_ToLower(sCode, sCode, iSize); if (CGetColor(sCode, sColor, iSize)) { - if(dev == 1) { + if (dev == 1) { break; } dev++; @@ -676,7 +676,7 @@ static void RemoveRagdoll(int client) { int iEntity = GetEntPropEnt(client, Prop_Send, "m_hRagdoll"); - if(iEntity != INVALID_ENT_REFERENCE) + if (iEntity != INVALID_ENT_REFERENCE) { AcceptEntityInput(iEntity, "Kill"); } @@ -884,13 +884,13 @@ public Action OnPlayerRunCmd(int client, int &buttons, int &impulse, float vel[3 bool bMoveRight = ((buttons & IN_MOVERIGHT) > 0 && vel[1] >= 100.0); if (!g_bInStartZone[client] && !g_bInStageZone[client]) { - if((bForward || bBack) && !(bMoveLeft || bMoveRight)) + if ((bForward || bBack) && !(bMoveLeft || bMoveRight)) { vel[0] = 0.0; buttons &= ~IN_FORWARD; buttons &= ~IN_BACK; } - if((bMoveLeft || bMoveRight) && !(bForward || bBack)) + if ((bMoveLeft || bMoveRight) && !(bForward || bBack)) { vel[1] = 0.0; buttons &= ~IN_MOVELEFT; @@ -933,7 +933,7 @@ public Action OnPlayerRunCmd(int client, int &buttons, int &impulse, float vel[3 { // don't check if we're below the threshold, or not pressing anything. // this should solve resets happening on wall collisions and ladders - if(bInputs && fSpeedSqr > fSpeedThres * fSpeedThres) + if (bInputs && fSpeedSqr > fSpeedThres * fSpeedThres) { g_iCurrentStyle[client] = 0; g_KeyCount[client] = 0; @@ -1007,12 +1007,12 @@ public Action OnPlayerRunCmd(int client, int &buttons, int &impulse, float vel[3 } //PRINFO - if (!IsFakeClient(client) && g_iCurrentStyle[client] == 0 && !g_bPracticeMode[client] && (g_bTimerRunning[client] || g_bWrcpTimeractivated[client])){ + if (!IsFakeClient(client) && g_iCurrentStyle[client] == 0 && !g_bPracticeMode[client] && (g_bTimerRunning[client] || g_bWrcpTimeractivated[client])) { //PLAYER IS IN A RUN - if(g_bTimerRunning[client]) + if (g_bTimerRunning[client]) g_fTimeIncrement[client][g_iClientInZone[client][2]] = g_fCurrentRunTime[client]; //PLAYER IS JUST DOING STAGES - else if(g_bWrcpTimeractivated[client]) + else if (g_bWrcpTimeractivated[client]) g_fTimeIncrement[client][g_iClientInZone[client][2]] = g_fCurrentWrcpRunTime[client]; } diff --git a/addons/sourcemod/scripting/surftimer/mapsettings.sp b/addons/sourcemod/scripting/surftimer/mapsettings.sp index ee7c81fa..958ce08b 100644 --- a/addons/sourcemod/scripting/surftimer/mapsettings.sp +++ b/addons/sourcemod/scripting/surftimer/mapsettings.sp @@ -273,7 +273,7 @@ public void db_viewMapSettings() { char szQuery[2048]; Format(szQuery, 2048, "SELECT `mapname`, `maxvelocity`, `announcerecord`, `gravityfix` FROM `ck_maptier` WHERE `mapname` = '%s'", g_szMapName); - SQL_TQuery(g_hDb, sql_viewMapSettingsCallback, szQuery, GetGameTime(), DBPrio_High); + g_hDb.Query(sql_viewMapSettingsCallback, szQuery, GetGameTime(), DBPrio_High); } public void sql_viewMapSettingsCallback(Handle owner, Handle hndl, const char[] error, float time) @@ -313,21 +313,21 @@ public void db_updateMapSettings() { char szQuery[512]; Format(szQuery, 512, "UPDATE `ck_maptier` SET `maxvelocity` = '%f', `announcerecord` = '%f', `gravityfix` = %i WHERE `mapname` = '%s';", g_fMaxVelocity, g_fAnnounceRecord, view_as(g_bGravityFix), g_szMapName); - SQL_TQuery(g_hDb, sql_insertMapSettingsCallback, szQuery, _, DBPrio_Low); + g_hDb.Query(sql_insertMapSettingsCallback, szQuery, _, DBPrio_Low); } public void db_unlimitAllStages(char[] szMapName) { char szQuery[256]; Format(szQuery, 256, "UPDATE ck_zones SET prespeed = 0.0 WHERE mapname = '%s' AND zonetype = 3;", g_szMapName); - SQL_TQuery(g_hDb, SQL_UnlimitAllStagesCallback, szQuery, _, DBPrio_Low); + g_hDb.Query(SQL_UnlimitAllStagesCallback, szQuery, _, DBPrio_Low); } public void db_removeOnejumplimit(char[] szMapName) { char szQuery[256]; Format(szQuery, 256, "UPDATE ck_zones SET onejumplimit = 0 WHERE mapname = '%s';", g_szMapName); - SQL_TQuery(g_hDb, SQL_removeOnejumplimitCallback, szQuery, _, DBPrio_Low); + g_hDb.Query(SQL_removeOnejumplimitCallback, szQuery, _, DBPrio_Low); } public void SQL_UnlimitAllStagesCallback(Handle owner, Handle hndl, const char[] error, any data) diff --git a/addons/sourcemod/scripting/surftimer/misc.sp b/addons/sourcemod/scripting/surftimer/misc.sp index c97535be..402964f3 100644 --- a/addons/sourcemod/scripting/surftimer/misc.sp +++ b/addons/sourcemod/scripting/surftimer/misc.sp @@ -135,7 +135,7 @@ public void teleportClient(int client, int zonegroup, int zone, bool stopTime) return; // dpexx stop teleporting if in trigger_multiple - /* if (g_TeleInTriggerMultiple[client]){ + /* if (g_TeleInTriggerMultiple[client]) { PrintToChat(client, "Teleport blocked"); return; } */ @@ -183,7 +183,7 @@ public void teleportClient(int client, int zonegroup, int zone, bool stopTime) int zoneID = getZoneID(zonegroup, zone); // Check if requested zone teleport is valid (non-linear map) - if(zoneID == -1) { + if (zoneID == -1) { CPrintToChat(client, "%T", "InvalidMapNoStages", client, g_szChatPrefix); return; } @@ -321,7 +321,7 @@ public void teleportClient(int client, int zonegroup, int zone, bool stopTime) // Set spawn location to the destination zone: //TP TO STAGE - if(zone > 1 && zonegroup == 0 && g_bStageStartposUsed[client][zone-2] && g_fCurrentRunTime[client] <= 0.0 && g_bTimerEnabled[client]){ + if (zone > 1 && zonegroup == 0 && g_bStageStartposUsed[client][zone-2] && g_fCurrentRunTime[client] <= 0.0 && g_bTimerEnabled[client]) { Array_Copy(g_fStageStartposLocation[client][zone-2] , g_fTeleLocation[client], 3); destinationFound = true; @@ -353,7 +353,7 @@ public void teleportClient(int client, int zonegroup, int zone, bool stopTime) float fLocation[3]; //TP TO STAGE - if(zone > 1 && zonegroup == 0 && g_bStageStartposUsed[client][zone-2] && g_fCurrentRunTime[client] <= 0.0 && g_bTimerEnabled[client]){ + if (zone > 1 && zonegroup == 0 && g_bStageStartposUsed[client][zone-2] && g_fCurrentRunTime[client] <= 0.0 && g_bTimerEnabled[client]) { Array_Copy(g_fStageStartposLocation[client][zone-2], fLocation, 3); Array_Copy(g_fStageStartposAngle[client][zone-2], ang, 3); @@ -1418,12 +1418,12 @@ public void SetPrestrafe(int client, int zone, int style, bool map, bool bonus, g_iPreStrafeBonus[1][zone][style][client] = RoundToNearest(SquareRoot(Pow(fVelocity[0], 2.0) + Pow(fVelocity[1], 2.0) + Pow(fVelocity[2], 2.0))); g_iPreStrafeBonus[2][zone][style][client] = RoundToNearest(fVelocity[2]); } - else if(map) { + else if (map) { g_iPreStrafe[0][zone][style][client] = RoundToNearest(SquareRoot(Pow(fVelocity[0], 2.0) + Pow(fVelocity[1], 2.0))); g_iPreStrafe[1][zone][style][client] = RoundToNearest(SquareRoot(Pow(fVelocity[0], 2.0) + Pow(fVelocity[1], 2.0) + Pow(fVelocity[2], 2.0))); g_iPreStrafe[2][zone][style][client] = RoundToNearest(fVelocity[2]); } - else if(stage) { + else if (stage) { g_iPreStrafeStage[0][zone][style][client] = RoundToNearest(SquareRoot(Pow(fVelocity[0], 2.0) + Pow(fVelocity[1], 2.0))); g_iPreStrafeStage[1][zone][style][client] = RoundToNearest(SquareRoot(Pow(fVelocity[0], 2.0) + Pow(fVelocity[1], 2.0) + Pow(fVelocity[2], 2.0))); g_iPreStrafeStage[2][zone][style][client] = RoundToNearest(fVelocity[2]); @@ -1436,12 +1436,12 @@ public void SetNewRecordPrestrafe(int client, int zone, int style, bool map, boo g_iRecordPreStrafeBonus[1][zone][style] = g_iPreStrafeBonus[1][zone][style][client]; g_iRecordPreStrafeBonus[2][zone][style] = g_iPreStrafeBonus[2][zone][style][client]; } - else if(map) { + else if (map) { g_iRecordPreStrafe[0][zone][style] = g_iPreStrafe[0][zone][style][client]; g_iRecordPreStrafe[1][zone][style] = g_iPreStrafe[1][zone][style][client]; g_iRecordPreStrafe[2][zone][style] = g_iPreStrafe[2][zone][style][client]; } - else if(stage) { + else if (stage) { g_iRecordPreStrafeStage[0][zone][style] = g_iPreStrafeStage[0][zone][style][client]; g_iRecordPreStrafeStage[1][zone][style] = g_iPreStrafeStage[1][zone][style][client]; g_iRecordPreStrafeStage[2][zone][style] = g_iPreStrafeStage[2][zone][style][client]; @@ -1455,12 +1455,12 @@ public void SetNewPersonalRecordPrestrafe(int client, int zone, int style, bool g_iPersonalRecordPreStrafeBonus[client][1][zone][style] = g_iPreStrafeBonus[1][zone][style][client]; g_iPersonalRecordPreStrafeBonus[client][2][zone][style] = g_iPreStrafeBonus[2][zone][style][client]; } - else if(map) { + else if (map) { g_iPersonalRecordPreStrafe[client][0][zone][style] = g_iPreStrafe[0][zone][style][client]; g_iPersonalRecordPreStrafe[client][1][zone][style] = g_iPreStrafe[1][zone][style][client]; g_iPersonalRecordPreStrafe[client][2][zone][style] = g_iPreStrafe[2][zone][style][client]; } - else if(stage) { + else if (stage) { g_iPersonalRecordPreStrafeStage[client][0][zone][style] = g_iPreStrafeStage[0][zone][style][client]; g_iPersonalRecordPreStrafeStage[client][1][zone][style] = g_iPreStrafeStage[1][zone][style][client]; g_iPersonalRecordPreStrafeStage[client][2][zone][style] = g_iPreStrafeStage[2][zone][style][client]; @@ -2319,11 +2319,11 @@ public void FormatTimeFloat(int client, float time, int type, char[] string, int else Format(szMilli, 16, "%dms", imilli); - if(idays > 0){ + if (idays > 0) { Format(szDays, 16, "%dd", idays); Format(string, 32, "%s %s %s %s %s", szDays, szHours, szMinutes, szSeconds, szMilli); } - else{ + else { Format(string, 32, "%s %s %s %s", szHours, szMinutes, szSeconds, szMilli); } @@ -2921,7 +2921,7 @@ public void AutoBhopFunction(int client, int &buttons) public void SpecListMenuDead(int client) // What Spectators see { - if(!g_bSideHud[client]) + if (!g_bSideHud[client]) { return; } @@ -3238,7 +3238,7 @@ public void SetInfoBotName(int ent) public void CenterHudDead(int client) { - if(!g_bCentreHud[client]) + if (!g_bCentreHud[client]) { return; } @@ -3299,22 +3299,22 @@ public void CenterHudDead(int client) float fSpeed[3]; GetEntPropVector(ObservedUser, Prop_Data, "m_vecVelocity", fSpeed); float fSpeedHUD; - if(g_SpeedMode[client] == 0) //XY + if (g_SpeedMode[client] == 0) //XY fSpeedHUD = SquareRoot(Pow(fSpeed[0], 2.0) + Pow(fSpeed[1], 2.0)); - else if(g_SpeedMode[client] == 1) //XYZ + else if (g_SpeedMode[client] == 1) //XYZ fSpeedHUD = SquareRoot(Pow(fSpeed[0], 2.0) + Pow(fSpeed[1], 2.0) + Pow(fSpeed[2], 2.0)); - else if(g_SpeedMode[client] == 2) //Z + else if (g_SpeedMode[client] == 2) //Z fSpeedHUD = SquareRoot(Pow(fSpeed[2], 2.0)); if (ObservedUser == g_RecordBot) { Format(obsAika, sizeof(obsAika), "%s", g_szReplayTime); - if(g_iSelectedReplayStyle == 5) + if (g_iSelectedReplayStyle == 5) { fSpeedHUD /= 0.5; } - else if(g_iSelectedReplayStyle == 6) + else if (g_iSelectedReplayStyle == 6) { fSpeedHUD /= 1.5; } @@ -3323,11 +3323,11 @@ public void CenterHudDead(int client) { Format(obsAika, sizeof(obsAika), "%s", g_szBonusTime); - if(g_iSelectedBonusReplayStyle == 5) + if (g_iSelectedBonusReplayStyle == 5) { fSpeedHUD /= 0.5; } - else if(g_iSelectedBonusReplayStyle == 6) + else if (g_iSelectedBonusReplayStyle == 6) { fSpeedHUD /= 1.5; } @@ -4722,7 +4722,7 @@ public void TeleportToSaveloc(int client, int id) g_bPracSrcpTimerActivated[client] = true; // Allows you to go from saveloc in map to bonus and visa-versa and use correct times/hud - if(g_iSaveLocInBonus[client][id] > 0) + if (g_iSaveLocInBonus[client][id] > 0) { g_bInBonus[client] = true; g_iInBonus[client] = g_iSaveLocInBonus[client][id]; @@ -5304,7 +5304,7 @@ stock bool Entity_Kill(int kenny, bool killChildren=false) return true; } - if(killChildren){ + if (killChildren) { return AcceptEntityInput(kenny, "KillHierarchy"); } else { @@ -5378,7 +5378,7 @@ stock bool Entity_IsPlayer(int entity) stock void EmitSoundToClientNoPreCache(int client, const char[] szPath, bool addPlay = true) { char szBuffer[256]; - if(addPlay) + if (addPlay) { Format(szBuffer, sizeof szBuffer, "play %s", szPath); } @@ -5463,7 +5463,7 @@ public bool GetContinentName(char code[3], char[] name, int length) return false; } -public void resetCCPDefaults(int client){ +public void resetCCPDefaults(int client) { for(int i = 0; i < CPLIMIT; i++) { diff --git a/addons/sourcemod/scripting/surftimer/newmaps.sp b/addons/sourcemod/scripting/surftimer/newmaps.sp index 3f071913..6fc760b2 100644 --- a/addons/sourcemod/scripting/surftimer/newmaps.sp +++ b/addons/sourcemod/scripting/surftimer/newmaps.sp @@ -32,7 +32,7 @@ public int NewMapMenuHandler(Menu menu, MenuAction action, int param1, int param public void db_ViewNewestMaps(int client) { char sql_selectNewestMaps[] = "SELECT mapname, date FROM ck_newmaps ORDER BY date DESC LIMIT 50"; - SQL_TQuery(g_hDb, sql_selectNewestMapsCallback, sql_selectNewestMaps, client, DBPrio_Low); + g_hDb.Query(sql_selectNewestMapsCallback, sql_selectNewestMaps, client, DBPrio_Low); } public void sql_selectNewestMapsCallback(Handle owner, Handle hndl, const char[] error, any data) @@ -77,7 +77,7 @@ public void db_InsertNewestMaps() char sql_insertNewestMaps[] = "INSERT INTO ck_newmaps (mapname) VALUES('%s');"; char szQuery[512]; Format(szQuery, sizeof(szQuery), sql_insertNewestMaps, g_szMapName); - SQL_TQuery(g_hDb, SQL_CheckCallback, szQuery, _, DBPrio_Low); + g_hDb.Query(SQL_CheckCallback, szQuery, __LINE__, DBPrio_Low); } //update Database just incase diff --git a/addons/sourcemod/scripting/surftimer/replay.sp b/addons/sourcemod/scripting/surftimer/replay.sp index 9d06d8ee..cac072b5 100644 --- a/addons/sourcemod/scripting/surftimer/replay.sp +++ b/addons/sourcemod/scripting/surftimer/replay.sp @@ -224,7 +224,7 @@ public void SaveRecording(int client, int zgroup, int style) StopRecording(client); } - if(zgroup == 0) { + if (zgroup == 0) { for(int j = 0; j < CPLIMIT; j++) { @@ -562,7 +562,7 @@ public void PlayRecord(int client, int type, int style, int use_CP) g_aReplayFrame[client] = header.Frames; g_iReplayVersion[client] = header.BinaryFormatVersion; - if(use_CP > 0) + if (use_CP > 0) g_iReplayTick[client] = g_iCPStartFrame[style][use_CP-1]; else g_iReplayTick[client] = 0; @@ -625,7 +625,7 @@ public bool WriteRecordToDisk(const char[] sPath, FileHeader header) aWriteData[(sizeof(frame_t) * iFramesWritten) + j] = aFrameData[j]; } - if(++iFramesWritten == 100 || i == header.Frames.Length - 1) + if (++iFramesWritten == 100 || i == header.Frames.Length - 1) { fFile.Write(aWriteData, sizeof(frame_t) * iFramesWritten, 4); @@ -687,7 +687,7 @@ public bool LoadRecordFromFile(const char[] path, FileHeader header, bool header strcopy(sNewPath, FindCharInString(path, '.', true) + 1, path); StrCat(sNewPath, sizeof(sNewPath), "_broken.rec"); - if(FileExists(sNewPath)) + if (FileExists(sNewPath)) { DeleteFile(sNewPath); } @@ -713,7 +713,7 @@ public bool LoadRecordFromFile(const char[] path, FileHeader header, bool header for(int i = 0; i < header.TickCount; i++) { - if(fFile.Read(aReplayData, sizeof(frame_t), 4) >= 0) + if (fFile.Read(aReplayData, sizeof(frame_t), 4) >= 0) { header.Frames.SetArray(i, aReplayData, sizeof(frame_t)); } @@ -1024,7 +1024,7 @@ public void Replay_Playback(int client, int &buttons, int &subtype, int &seed, i return; } - if(g_iReplayVersion[client] >= BINARY_FORMAT_VERSION) + if (g_iReplayVersion[client] >= BINARY_FORMAT_VERSION) { // origin[3], angles[2], buttons, flags, movetype frame_t aFrame; @@ -1047,13 +1047,13 @@ public void Replay_Playback(int client, int &buttons, int &subtype, int &seed, i bool bWalk = true; - if(aFrame.flags & FL_ONGROUND) + if (aFrame.flags & FL_ONGROUND) { MoveType mt = MOVETYPE_WALK; - if(GetVectorLength(vecVelocity) > 300.0) + if (GetVectorLength(vecVelocity) > 300.0) { TR_TraceRay(aFrame.pos, vecCurrentPosition, MASK_PLAYERSOLID, RayType_EndPoint); - if(TR_DidHit()) + if (TR_DidHit()) { bWalk = false; mt = MOVETYPE_NOCLIP; @@ -1073,7 +1073,7 @@ public void Replay_Playback(int client, int &buttons, int &subtype, int &seed, i // bot is on ground.. // if the distance between the previous position is much bigger (1.5x) than the expected according to the bot's velocity, // teleport to avoid sync issues - if((GetVectorLength(vecVelocity) > 15000.0 || + if ((GetVectorLength(vecVelocity) > 15000.0 || (bWalk && GetVectorDistance(vecCurrentPosition, aFrame.pos) > GetVectorLength(vecVelocity) / g_fTickrate * 1.5))) { TeleportEntity(client, aFrame.pos, ang, NULL_VECTOR); diff --git a/addons/sourcemod/scripting/surftimer/sql.sp b/addons/sourcemod/scripting/surftimer/sql.sp index 43b44854..998e4fe6 100644 --- a/addons/sourcemod/scripting/surftimer/sql.sp +++ b/addons/sourcemod/scripting/surftimer/sql.sp @@ -8,8 +8,8 @@ public void db_setupDatabase() = INIT CONNECTION TO DATABASE = ===================================*/ char szError[255]; - g_hDb = SQL_Connect("surftimer", false, szError, 255); - g_hDb_Updates = SQL_Connect("surftimer", false, szError, 255); + g_hDb = view_as(SQL_Connect("surftimer", false, szError, 255)); + g_hDb_Updates = view_as(SQL_Connect("surftimer", false, szError, 255)); if (g_hDb == null) { @@ -18,7 +18,7 @@ public void db_setupDatabase() } char szIdent[8]; - SQL_ReadDriver(g_hDb, szIdent, 8); + g_hDb.Driver.GetIdentifier(szIdent, sizeof(szIdent)); if (strcmp(szIdent, "mysql", false) == 0) { @@ -40,8 +40,7 @@ public void db_setupDatabase() } // If updating from a previous version - SQL_LockDatabase(g_hDb); - SQL_FastQuery(g_hDb, "SET NAMES 'utf8mb4'"); + g_hDb.SetCharset("utf8mb4"); // Check if tables need to be Created or database needs to be upgraded g_bRenaming = false; @@ -49,11 +48,7 @@ public void db_setupDatabase() GetDatabaseName(g_sDatabaseName, sizeof(g_sDatabaseName)); CheckDatabaseForUpdates(); - - SQL_UnlockDatabase(g_hDb); - SQL_UnlockDatabase(g_hDb_Updates); LoopFloatDecimalTables(); - CleanUpTablesRetvalsSteamId(); for (int i = 0; i < sizeof(g_failedTransactions); i++) g_failedTransactions[i] = 0; @@ -83,6 +78,7 @@ public void db_createTables() SQL_AddQuery(createTableTnx, sql_createVipAdmins); SQL_AddQuery(createTableTnx, sql_createWrcps); SQL_AddQuery(createTableTnx, sql_CreatePrinfo); + SQL_AddQuery(createTableTnx, sql_createPlayers); SQL_ExecuteTransaction(g_hDb, createTableTnx, SQLTxn_CreateDatabaseSuccess, SQLTxn_CreateDatabaseFailed); @@ -111,7 +107,7 @@ public void sql_DeleteMenuView(Handle owner, Handle hndl, const char[] error, an FormatEx(menuFormat, sizeof(menuFormat), "Style: %s\nâ–º Press the menu item to change the style\n ", g_EditStyles[g_SelectedStyle[client]]); editing.AddItem("0", menuFormat); - if(g_SelectedEditOption[client] > 0) + if (g_SelectedEditOption[client] > 0) { FormatEx(menuFormat, sizeof(menuFormat), "%s: %i\nâ–º Press the menu item to change the %s\n ", g_SelectedEditOption[client] == 1 ? "Stage":"Bonus", g_SelectedType[client], g_SelectedEditOption[client] == 1 ? "stage":"bonus"); editing.AddItem("0", menuFormat); @@ -152,11 +148,11 @@ public void sql_DeleteMenuView(Handle owner, Handle hndl, const char[] error, an public int callback_DeleteRecord(Menu menu, MenuAction action, int client, int key) { - if(action == MenuAction_Select) + if (action == MenuAction_Select) { - if(key == 0) + if (key == 0) { - if(g_SelectedStyle[client] < MAX_STYLES - 1) + if (g_SelectedStyle[client] < MAX_STYLES - 1) g_SelectedStyle[client]++; else g_SelectedStyle[client] = 0; @@ -183,11 +179,11 @@ public int callback_DeleteRecord(Menu menu, MenuAction action, int client, int k } } - SQL_TQuery(g_hDb, sql_DeleteMenuView, szQuery, GetClientSerial(client)); + g_hDb.Query(sql_DeleteMenuView, szQuery, GetClientSerial(client)); return 0; } - if(g_SelectedEditOption[client] > 0 && key == 1) + if (g_SelectedEditOption[client] > 0 && key == 1) { g_iWaitingForResponse[client] = ClientEdit; CPrintToChat(client, "%t", "DeleteRecordsNewValue", g_szChatPrefix); @@ -220,7 +216,7 @@ public int callback_DeleteRecord(Menu menu, MenuAction action, int client, int k if (key == MenuCancel_Exit) ShowMainDeleteMenu(client); } - else if(action == MenuAction_End) + else if (action == MenuAction_End) delete menu; return 0; @@ -228,9 +224,9 @@ public int callback_DeleteRecord(Menu menu, MenuAction action, int client, int k public int callback_Confirm(Menu menu, MenuAction action, int client, int key) { - if(action == MenuAction_Select) + if (action == MenuAction_Select) { - if(key == 1) + if (key == 1) { char steamID[32]; menu.GetItem(key, steamID, 32); @@ -257,10 +253,10 @@ public int callback_Confirm(Menu menu, MenuAction action, int client, int key) char BonusPRruntime[512]; Format(BonusPRruntime, sizeof(BonusPRruntime), sql_clearPRruntime, steamID, g_EditingMap[client], g_SelectedType[client]); - SQL_TQuery(g_hDb, SQL_CheckCallback, BonusPRruntime, .prio=DBPrio_Low); + g_hDb.Query(SQL_CheckCallback, BonusPRruntime, __LINE__, DBPrio_Low); } } - SQL_TQuery(g_hDb, SQL_CheckCallback, szQuery, .prio=DBPrio_Low); + g_hDb.Query(SQL_CheckCallback, szQuery, __LINE__, DBPrio_Low); // Looking for online player to refresh his record after deleting it. char player_steamID[32]; @@ -270,7 +266,7 @@ public int callback_Confirm(Menu menu, MenuAction action, int client, int key) continue; GetClientAuthId(i, AuthId_Steam2, player_steamID, 32, true); - if(StrEqual(player_steamID,steamID)) + if (StrEqual(player_steamID,steamID)) { g_bSettingsLoaded[client] = false; g_bLoadingSettings[client] = true; @@ -287,7 +283,7 @@ public int callback_Confirm(Menu menu, MenuAction action, int client, int key) } } - else if(action == MenuAction_End) + else if (action == MenuAction_End) delete menu; return 0; @@ -388,7 +384,7 @@ public void db_deleteSpawnLocations(int zGrp, int teleside) g_bGotSpawnLocation[zGrp][1][teleside] = false; char szQuery[128]; Format(szQuery, sizeof(szQuery), sql_deleteSpawnLocations, g_szMapName, zGrp, teleside); - SQL_TQuery(g_hDb, SQL_CheckCallback, szQuery, _, DBPrio_Low); + g_hDb.Query(SQL_CheckCallback, szQuery, __LINE__, DBPrio_Low); } @@ -396,14 +392,14 @@ public void db_updateSpawnLocations(float position[3], float angle[3], float vel { char szQuery[512]; Format(szQuery, 512, sql_updateSpawnLocations, position[0], position[1], position[2], angle[0], angle[1], angle[2], vel[0], vel[1], vel[2], g_szMapName, zGrp, teleside); - SQL_TQuery(g_hDb, db_editSpawnLocationsCallback, szQuery, zGrp, DBPrio_Low); + g_hDb.Query(db_editSpawnLocationsCallback, szQuery, zGrp, DBPrio_Low); } public void db_insertSpawnLocations(float position[3], float angle[3], float vel[3], int zGrp, int teleside) { char szQuery[512]; Format(szQuery, 512, sql_insertSpawnLocations, g_szMapName, position[0], position[1], position[2], angle[0], angle[1], angle[2], vel[0], vel[1], vel[2], zGrp, teleside); - SQL_TQuery(g_hDb, db_editSpawnLocationsCallback, szQuery, zGrp, DBPrio_Low); + g_hDb.Query(db_editSpawnLocationsCallback, szQuery, zGrp, DBPrio_Low); } public void db_editSpawnLocationsCallback(Handle owner, Handle hndl, const char[] error, any data) @@ -429,7 +425,7 @@ public void db_selectSpawnLocations() char szQuery[254]; Format(szQuery, 254, sql_selectSpawnLocations, g_szMapName); - SQL_TQuery(g_hDb, db_selectSpawnLocationsCallback, szQuery, GetGameTime(), DBPrio_Low); + g_hDb.Query(db_selectSpawnLocationsCallback, szQuery, GetGameTime(), DBPrio_Low); } public void db_selectSpawnLocationsCallback(Handle owner, Handle hndl, const char[] error, float time) @@ -478,7 +474,7 @@ public void db_viewMapProRankCount() g_MapTimesCount = 0; char szQuery[512]; Format(szQuery, 512, sql_selectPlayerProCount, g_szMapName); - SQL_TQuery(g_hDb, sql_selectPlayerProCountCallback, szQuery, GetGameTime(), DBPrio_Low); + g_hDb.Query(sql_selectPlayerProCountCallback, szQuery, GetGameTime(), DBPrio_Low); } public void sql_selectPlayerProCountCallback(Handle owner, Handle hndl, const char[] error, float time) @@ -532,7 +528,7 @@ public void db_viewMapRankPro(int client) // "SELECT COUNT(*) FROM ck_playertimes WHERE runtimepro <= (SELECT runtimepro FROM ck_playertimes WHERE steamid = '%s' AND mapname = '%s' AND runtimepro > -1.0) AND mapname = '%s' AND runtimepro > -1.0"; Format(szQuery, 512, sql_selectPlayerRankProTime, g_szSteamID[client], g_szMapName, g_szMapName); - SQL_TQuery(g_hDb, db_viewMapRankProCallback, szQuery, client, DBPrio_Low); + g_hDb.Query(db_viewMapRankProCallback, szQuery, client, DBPrio_Low); } public void db_viewMapRankProCallback(Handle owner, Handle hndl, const char[] error, any client) @@ -560,7 +556,7 @@ public void db_updateStat(int client, int style) // "UPDATE ck_playerrank SET finishedmaps ='%i', finishedmapspro='%i', multiplier ='%i' where steamid='%s'"; Format(szQuery, 512, sql_updatePlayerRank, g_pr_finishedmaps[client], g_pr_finishedmaps[client], g_szSteamID[client], style); - SQL_TQuery(g_hDb, SQL_UpdateStatCallback, szQuery, pack, DBPrio_Low); + g_hDb.Query(SQL_UpdateStatCallback, szQuery, pack, DBPrio_Low); } @@ -597,7 +593,7 @@ public void RecalcPlayerRank(int client, char steamid[128]) Handle pack = CreateDataPack(); WritePackCell(pack, i); WritePackCell(pack, client); - SQL_TQuery(g_hDb, sql_selectPlayerNameCallback, szQuery, pack); + g_hDb.Query(sql_selectPlayerNameCallback, szQuery, pack); } } @@ -637,7 +633,7 @@ public void CalculatePlayerRank(int client, int style) WritePackCell(pack, style); Format(szQuery, 255, "SELECT name FROM ck_playerrank WHERE steamid = '%s' AND style = '%i';", szSteamId, style); - SQL_TQuery(g_hDb, sql_CalcuatePlayerRankCallback, szQuery, pack, DBPrio_Low); + g_hDb.Query(sql_CalcuatePlayerRankCallback, szQuery, pack, DBPrio_Low); } // 2. See if player exists, insert new player into the database @@ -677,7 +673,7 @@ public void sql_CalcuatePlayerRankCallback(Handle owner, Handle hndl, const char // Next up, calculate bonus points: char szQuery[512]; Format(szQuery, 512, "SELECT mapname, (SELECT count(1)+1 FROM ck_bonus b WHERE a.mapname=b.mapname AND a.runtime > b.runtime AND a.zonegroup = b.zonegroup AND b.style = %i) AS `rank`, (SELECT count(1) FROM ck_bonus b WHERE a.mapname = b.mapname AND a.zonegroup = b.zonegroup AND b.style = %i) as total FROM ck_bonus a WHERE steamid = '%s' AND style = %i;", style, style, szSteamId, style); - SQL_TQuery(g_hDb, sql_CountFinishedBonusCallback, szQuery, pack, DBPrio_Low); + g_hDb.Query(sql_CountFinishedBonusCallback, szQuery, pack, DBPrio_Low); } else { @@ -700,7 +696,7 @@ public void sql_CalcuatePlayerRankCallback(Handle owner, Handle hndl, const char // "INSERT INTO ck_playerrank (steamid, name, country) VALUES('%s', '%s', '%s');"; // No need to continue calculating, as the doesn't have any records. Format(szQuery, 512, sql_insertPlayerRank, szSteamId, szSteamId64, szName, g_szCountry[client], g_szCountryCode[client], g_szContinentCode[client], GetTime(), style); - SQL_TQuery(g_hDb, SQL_InsertPlayerCallBack, szQuery, client, DBPrio_Low); + g_hDb.Query(SQL_InsertPlayerCallBack, szQuery, client, DBPrio_Low); g_pr_finishedmaps[client][style] = 0; g_pr_finishedmaps_perc[client][style] = 0.0; @@ -877,7 +873,7 @@ public void sql_CountFinishedBonusCallback(Handle owner, Handle hndl, const char // Next up: Points from stages char szQuery[512]; Format(szQuery, 512, "SELECT mapname, stage, (select count(1)+1 from ck_wrcps b where a.mapname=b.mapname and a.runtimepro > b.runtimepro and a.style = b.style and a.stage = b.stage) AS `rank` FROM ck_wrcps a where steamid = '%s' AND style = %i;", szSteamId, style); - SQL_TQuery(g_hDb, sql_CountFinishedStagesCallback, szQuery, pack, DBPrio_Low); + g_hDb.Query(sql_CountFinishedStagesCallback, szQuery, pack, DBPrio_Low); } // @@ -940,7 +936,7 @@ public void sql_CountFinishedStagesCallback(Handle owner, Handle hndl, const cha // Next up: Points from maps char szQuery[512]; Format(szQuery, 512, "SELECT mapname, (select count(1)+1 from ck_playertimes b where a.mapname=b.mapname and a.runtimepro > b.runtimepro AND b.style = %i) AS `rank`, (SELECT count(1) FROM ck_playertimes b WHERE a.mapname = b.mapname AND b.style = %i) as total, (SELECT tier FROM `ck_maptier` b WHERE a.mapname = b.mapname) as tier FROM ck_playertimes a where steamid = '%s' AND style = %i;", style, style, szSteamId, style); - SQL_TQuery(g_hDb, sql_CountFinishedMapsCallback, szQuery, pack, DBPrio_Low); + g_hDb.Query(sql_CountFinishedMapsCallback, szQuery, pack, DBPrio_Low); } // 5. Count the points gained from regular maps @@ -1314,7 +1310,7 @@ public void db_updatePoints(int client, int style) { SQL_EscapeString(g_hDb, g_pr_szName[client], szName, MAX_NAME_LENGTH * 2 + 1); Format(szQuery, 512, sql_updatePlayerRankPoints, szName, g_pr_points[client][style], g_Points[client][style][3], g_Points[client][style][4], g_Points[client][style][6], g_Points[client][style][5], g_Points[client][style][2], g_Points[client][style][0], g_Points[client][style][1], g_pr_finishedmaps[client][style], g_pr_finishedbonuses[client][style], g_pr_finishedstages[client][style], g_WRs[client][style][0], g_WRs[client][style][1], g_WRs[client][style][2], g_Top10Maps[client][style], g_GroupMaps[client][style], g_pr_szSteamID[client], style); - SQL_TQuery(g_hDb, sql_updatePlayerRankPointsCallback, szQuery, pack, DBPrio_Low); + g_hDb.Query(sql_updatePlayerRankPointsCallback, szQuery, pack, DBPrio_Low); } else { @@ -1323,7 +1319,7 @@ public void db_updatePoints(int client, int style) GetClientName(client, szName, MAX_NAME_LENGTH); GetClientAuthId(client, AuthId_Steam2, szSteamId, MAX_NAME_LENGTH, true); Format(szQuery, 512, sql_updatePlayerRankPoints2, szName, g_pr_points[client][style], g_Points[client][style][3], g_Points[client][style][4], g_Points[client][style][6], g_Points[client][style][5], g_Points[client][style][2], g_Points[client][style][0], g_Points[client][style][1], g_pr_finishedmaps[client][style], g_pr_finishedbonuses[client][style], g_pr_finishedstages[client][style], g_WRs[client][style][0], g_WRs[client][style][1], g_WRs[client][style][2], g_Top10Maps[client][style], g_GroupMaps[client][style], g_szCountry[client], g_szCountryCode[client], g_szContinentCode[client], szSteamId, style); - SQL_TQuery(g_hDb, sql_updatePlayerRankPointsCallback, szQuery, pack, DBPrio_Low); + g_hDb.Query(sql_updatePlayerRankPointsCallback, szQuery, pack, DBPrio_Low); } } } @@ -1466,7 +1462,7 @@ public void db_viewPlayerPoints(int client) // "SELECT steamid, name, points, finishedmapspro, country, lastseen, timealive, timespec, connections from ck_playerrank where steamid='%s'"; Format(szQuery, 255, sql_selectRankedPlayer, g_szSteamID[client]); - SQL_TQuery(g_hDb, db_viewPlayerPointsCallback, szQuery, client, DBPrio_Low); + g_hDb.Query(db_viewPlayerPointsCallback, szQuery, client, DBPrio_Low); } public void db_viewPlayerPointsCallback(Handle owner, Handle hndl, const char[] error, any client) @@ -1501,7 +1497,7 @@ public void db_viewPlayerPointsCallback(Handle owner, Handle hndl, const char[] char updateConnections[1024]; Format(updateConnections, sizeof(updateConnections), "UPDATE ck_playerrank SET connections = connections + 1 WHERE steamid = '%s';", g_szSteamID[client]); - SQL_TQuery(g_hDb, SQL_CheckCallback, updateConnections, _, DBPrio_Low); + g_hDb.Query(SQL_CheckCallback, updateConnections, __LINE__, DBPrio_Low); // Debug g_fTick[client][1] = GetGameTime(); @@ -1535,7 +1531,7 @@ public void db_viewPlayerPointsCallback(Handle owner, Handle hndl, const char[] GetClientAuthId(client, AuthId_SteamID64, szSteamId64, MAX_NAME_LENGTH, true); Format(szQuery, sizeof(szQuery), sql_insertPlayerRank, g_szSteamID[client], szSteamId64, szName, g_szCountry[client], g_szCountryCode[client], g_szContinentCode[client], GetTime()); - SQL_TQuery(g_hDb, SQL_CheckCallback, szQuery, _, DBPrio_Low); + g_hDb.Query(SQL_CheckCallback, szQuery, __LINE__, DBPrio_Low); // Play time g_iPlayTimeAlive[client] = 0; @@ -1564,7 +1560,7 @@ public void db_GetPlayerRank(int client, int style) char szQuery[512]; // "SELECT name FROM ck_playerrank WHERE points >= (SELECT points FROM ck_playerrank WHERE steamid = '%s') ORDER BY points"; Format(szQuery, 512, sql_selectRankedPlayersRank, style, g_szSteamID[client], style); - SQL_TQuery(g_hDb, sql_selectRankedPlayersRankCallback, szQuery, pack, DBPrio_Low); + g_hDb.Query(sql_selectRankedPlayersRankCallback, szQuery, pack, DBPrio_Low); } public void sql_selectRankedPlayersRankCallback(Handle owner, Handle hndl, const char[] error, any pack) @@ -1653,13 +1649,13 @@ public void db_viewPlayerProfile(int client, int style, char szSteamId[32], bool { // "SELECT name FROM ck_playerrank WHERE style = %i AND points >= (SELECT points FROM ck_playerrank WHERE steamid = '%s' AND style = %i) ORDER BY points"; Format(szQuery, 512, sql_selectRankedPlayersRank, style, szSteamId, style); - SQL_TQuery(g_hDb, sql_selectPlayerRankCallback, szQuery, pack, DBPrio_Low); + g_hDb.Query(sql_selectPlayerRankCallback, szQuery, pack, DBPrio_Low); } else { // "SELECT steamid, steamid64, name, country, points, wrpoints, wrbpoints, top10points, groupspoints, mappoints, bonuspoints, finishedmapspro, finishedbonuses, finishedstages, wrs, wrbs, wrcps, top10s, groups, lastseen FROM ck_playerrank WHERE name LIKE '%c%s%c' AND style = '%i';"; sql_selectUnknownProfile Format(szQuery, sizeof(szQuery), "SELECT steamid FROM ck_playerrank WHERE style = %i AND name LIKE '%c%s%c' LIMIT 1;", style, PERCENT, szName, PERCENT); - SQL_TQuery(g_hDb, sql_selectUnknownPlayerCallback, szQuery, pack, DBPrio_Low); + g_hDb.Query(sql_selectUnknownPlayerCallback, szQuery, pack, DBPrio_Low); } } @@ -1693,7 +1689,7 @@ public void sql_selectUnknownPlayerCallback (Handle owner, Handle hndl, const ch // "SELECT name FROM ck_playerrank WHERE style = %i AND points >= (SELECT points FROM ck_playerrank WHERE steamid = '%s' AND style = %i) ORDER BY points"; char szQuery[512]; Format(szQuery, 512, sql_selectRankedPlayersRank, style, szSteamId, style); - SQL_TQuery(g_hDb, sql_selectPlayerRankCallback, szQuery, pack, DBPrio_Low); + g_hDb.Query(sql_selectPlayerRankCallback, szQuery, pack, DBPrio_Low); } else { @@ -1725,7 +1721,7 @@ public void sql_selectPlayerRankCallback (Handle owner, Handle hndl, const char[ // "SELECT steamid, steamid64, name, country, points, wrpoints, wrbpoints, wrcppoints, top10points, groupspoints, mappoints, bonuspoints, finishedmapspro, finishedbonuses, finishedstages, wrs, wrbs, wrcps, top10s, groups, lastseen FROM ck_playerrank WHERE steamid = '%s' AND style = '%i';"; char szQuery[512]; Format(szQuery, sizeof(szQuery), sql_selectPlayerProfile, szSteamId, style); - SQL_TQuery(g_hDb, sql_selectPlayerProfileCallback, szQuery, pack, DBPrio_Low); + g_hDb.Query(sql_selectPlayerProfileCallback, szQuery, pack, DBPrio_Low); } else { @@ -2007,7 +2003,7 @@ public void db_GetMapRecord_Pro() char szQuery[512]; // SELECT MIN(runtimepro), name, steamid, style FROM ck_playertimes WHERE mapname = '%s' AND runtimepro > -1.0 GROUP BY style Format(szQuery, 512, sql_selectMapRecord, g_szMapName); - SQL_TQuery(g_hDb, sql_selectMapRecordCallback, szQuery, GetGameTime(), DBPrio_Low); + g_hDb.Query(sql_selectMapRecordCallback, szQuery, GetGameTime(), DBPrio_Low); } public void sql_selectMapRecordCallback(Handle owner, Handle hndl, const char[] error, float time) @@ -2105,7 +2101,7 @@ public void db_selectTopSurfers(int client, char mapname[128]) WritePackCell(pack, client); WritePackString(pack, mapname); WritePackCell(pack, 0); - SQL_TQuery(g_hDb, sql_selectTopSurfersCallback, szQuery, pack, DBPrio_Low); + g_hDb.Query(sql_selectTopSurfersCallback, szQuery, pack, DBPrio_Low); } public void db_selectMapTopSurfers(int client, char mapname[128]) @@ -2117,7 +2113,7 @@ public void db_selectMapTopSurfers(int client, char mapname[128]) WritePackCell(pack, client); WritePackString(pack, mapname); WritePackCell(pack, type); - SQL_TQuery(g_hDb, sql_selectTopSurfersCallback, szQuery, pack, DBPrio_Low); + g_hDb.Query(sql_selectTopSurfersCallback, szQuery, pack, DBPrio_Low); } public void sql_selectTopSurfersCallback(Handle owner, Handle hndl, const char[] error, any data) @@ -2212,7 +2208,7 @@ public void db_selectBonusesInMap(int client, char mapname[128]) // SELECT mapname, zonegroup, zonename FROM `ck_zones` WHERE mapname LIKE '%c%s%c' AND zonegroup > 0 GROUP BY zonegroup; char szQuery[512]; Format(szQuery, 512, sql_selectBonusesInMap, PERCENT, mapname, PERCENT); - SQL_TQuery(g_hDb, db_selectBonusesInMapCallback, szQuery, client, DBPrio_Low); + g_hDb.Query(db_selectBonusesInMapCallback, szQuery, client, DBPrio_Low); } public void db_selectBonusesInMapCallback(Handle owner, Handle hndl, const char[] error, any client) @@ -2304,7 +2300,7 @@ public void db_selectBonusTopSurfers(int client, char mapname[128], int zGrp, in WritePackCell(pack, client); WritePackString(pack, mapname); WritePackCell(pack, zGrp); - SQL_TQuery(g_hDb, sql_selectTopBonusSurfersCallback, szQuery, pack, DBPrio_Low); + g_hDb.Query(sql_selectTopBonusSurfersCallback, szQuery, pack, DBPrio_Low); } public void sql_selectTopBonusSurfersCallback(Handle owner, Handle hndl, const char[] error, any data) @@ -2382,7 +2378,7 @@ public void db_currentRunRank(int client, int style) char szQuery[512]; Format(szQuery, 512, "SELECT count(runtimepro)+1 FROM ck_playertimes WHERE mapname = '%s' AND runtimepro < '%f' AND style = '%i';", g_szMapName, runtime, style); - SQL_TQuery(g_hDb, SQL_CurrentRunRankCallback, szQuery, client, DBPrio_Low); + g_hDb.Query(SQL_CurrentRunRankCallback, szQuery, client, DBPrio_Low); } public void SQL_CurrentRunRankCallback(Handle owner, Handle hndl, const char[] error, any client) @@ -2399,25 +2395,25 @@ public void SQL_CurrentRunRankCallback(Handle owner, Handle hndl, const char[] e rank = SQL_FetchInt(hndl, 0); } - if(g_bPracticeModeRun[client]) + if (g_bPracticeModeRun[client]) { float runtime = g_fCurrentRunTime[client]; float f_srDiff; char sz_srDiff[128]; - if(g_fRecordMapTime != 9999999.0) + if (g_fRecordMapTime != 9999999.0) f_srDiff = (g_fRecordMapTime - runtime); else f_srDiff = runtime; FormatTimeFloat(client, f_srDiff, 3, sz_srDiff, 128); - if(f_srDiff == runtime) + if (f_srDiff == runtime) Format(sz_srDiff, 128, "SR: N/A", sz_srDiff); else if (f_srDiff > 0.0) Format(sz_srDiff, 128, "%cSR: %c-%s%c", WHITE, LIGHTGREEN, sz_srDiff, WHITE); - else if(f_srDiff <= 0.0) + else if (f_srDiff <= 0.0) Format(sz_srDiff, 128, "%cSR: %c+%s%c", WHITE, RED, sz_srDiff, WHITE); char szSpecMessage[512]; @@ -2445,7 +2441,7 @@ public void db_currentRunRank_StagePrac(int client, int style, int stage, float char szQuery[1024]; Format(szQuery, 1024, "SELECT count(runtimepro)+1 FROM ck_wrcps WHERE mapname = '%s' AND stage = '%i' AND style = '%i' AND runtimepro < '%f';", g_szMapName, stage, style, g_fCurrentRunTime[client]); - SQL_TQuery(g_hDb, SQL_CurrentRunRank_StagePracCallback, szQuery, data_srcp, DBPrio_Low); + g_hDb.Query(SQL_CurrentRunRank_StagePracCallback, szQuery, data_srcp, DBPrio_Low); } @@ -2487,7 +2483,7 @@ public void db_selectRecord(int client) char szQuery[255]; Format(szQuery, 255, "SELECT runtimepro FROM ck_playertimes WHERE steamid = '%s' AND mapname = '%s' AND runtimepro > -1.0 AND style = 0;", g_szSteamID[client], g_szMapName); - SQL_TQuery(g_hDb, sql_selectRecordCallback, szQuery, client, DBPrio_Low); + g_hDb.Query(sql_selectRecordCallback, szQuery, client, DBPrio_Low); } public void sql_selectRecordCallback(Handle owner, Handle hndl, const char[] error, any data) @@ -2529,7 +2525,7 @@ public void sql_selectRecordCallback(Handle owner, Handle hndl, const char[] err // "INSERT INTO ck_playertimes (steamid, mapname, name, runtimepro, style) VALUES('%s', '%s', '%s', '%f', %i);"; Format(szQuery, 512, sql_insertPlayerTime, g_szSteamID[data], g_szMapName, szName, g_fFinalTime[data], 0, g_iPreStrafe[0][0][0][data], g_iPreStrafe[1][0][0][data], g_iPreStrafe[2][0][0][data]); - SQL_TQuery(g_hDb, SQL_UpdateRecordProCallback, szQuery, pack, DBPrio_Low); + g_hDb.Query(SQL_UpdateRecordProCallback, szQuery, pack, DBPrio_Low); g_bInsertNewTime = true; } @@ -2557,7 +2553,7 @@ public void db_updateRecordPro(int client) char szQuery[1024]; // "UPDATE ck_playertimes SET name = '%s', runtimepro = '%f' WHERE steamid = '%s' AND mapname = '%s' AND style = %i;"; Format(szQuery, 1024, sql_updateRecordPro, szName, g_fFinalTime[client], g_iPreStrafe[0][0][0][client], g_iPreStrafe[1][0][0][client], g_iPreStrafe[2][0][0][client], g_szSteamID[client], g_szMapName, 0); - SQL_TQuery(g_hDb, SQL_UpdateRecordProCallback, szQuery, pack, DBPrio_Low); + g_hDb.Query(SQL_UpdateRecordProCallback, szQuery, pack, DBPrio_Low); } @@ -2579,7 +2575,7 @@ public void SQL_UpdateRecordProCallback(Handle owner, Handle hndl, const char[] // Find out how many times are are faster than the players time char szQuery[512]; Format(szQuery, sizeof(szQuery), "SELECT count(runtimepro) FROM `ck_playertimes` WHERE `mapname` = '%s' AND `runtimepro` < %f AND style = 0;", g_szMapName, time); - SQL_TQuery(g_hDb, SQL_UpdateRecordProCallback2, szQuery, client, DBPrio_Low); + g_hDb.Query(SQL_UpdateRecordProCallback2, szQuery, client, DBPrio_Low); } } @@ -2619,7 +2615,7 @@ public void db_viewAllRecords(int client, char szSteamId[32]) Format(szQuery, 1024, sql_selectPersonalAllRecords, szSteamId, g_ProfileStyleSelect[client], g_ProfileStyleSelect[client]); if ((StrContains(szSteamId, "STEAM_") != -1)) - SQL_TQuery(g_hDb, SQL_ViewAllRecordsCallback, szQuery, client, DBPrio_Low); + g_hDb.Query(SQL_ViewAllRecordsCallback, szQuery, client, DBPrio_Low); else if (IsClientInGame(client)) CPrintToChat(client, "%t", "SQL3", g_szChatPrefix); } @@ -2689,7 +2685,7 @@ public void SQL_ViewAllRecordsCallback(Handle owner, Handle hndl, const char[] e WritePackCell(pack, data); WritePackCell(pack, tier); Format(szQuery, 1024, sql_selectPlayerRankProTime, szSteamId, szMapName, szMapName); - SQL_TQuery(g_hDb, SQL_ViewAllRecordsCallback2, szQuery, pack, DBPrio_Low); + g_hDb.Query(SQL_ViewAllRecordsCallback2, szQuery, pack, DBPrio_Low); mapfound = true; continue; } @@ -2757,7 +2753,7 @@ public void SQL_ViewAllRecordsCallback2(Handle owner, Handle hndl, const char[] ReadPackString(data, szMapName, 128); Format(szQuery, 512, sql_selectPlayerProCount, szMapName); - SQL_TQuery(g_hDb, SQL_ViewAllRecordsCallback3, szQuery, data, DBPrio_Low); + g_hDb.Query(SQL_ViewAllRecordsCallback3, szQuery, data, DBPrio_Low); } } @@ -2852,7 +2848,7 @@ public void db_viewTop10Records(int client, char szSteamId[32], int type) Format(szQuery, 1024, sql_selectPersonalAllRecords, szSteamId, g_ProfileStyleSelect[client], g_ProfileStyleSelect[client]); if ((StrContains(szSteamId, "STEAM_") != -1)) - SQL_TQuery(g_hDb, SQL_ViewTop10RecordsCallback, szQuery, data, DBPrio_Low); + g_hDb.Query(SQL_ViewTop10RecordsCallback, szQuery, data, DBPrio_Low); else if (IsClientInGame(client)) CPrintToChat(client, "%t", "SQL3", g_szChatPrefix); } @@ -2922,7 +2918,7 @@ public void SQL_ViewTop10RecordsCallback(Handle owner, Handle hndl, const char[] WritePackCell(pack2, type); Format(szQuery, 1024, sql_selectPlayerRankProTime, szSteamId, szMapName, szMapName); - SQL_TQuery(g_hDb, SQL_ViewTop10RecordsCallback2, szQuery, pack2, DBPrio_Low); + g_hDb.Query(SQL_ViewTop10RecordsCallback2, szQuery, pack2, DBPrio_Low); mapfound = true; continue; } @@ -2992,7 +2988,7 @@ public void SQL_ViewTop10RecordsCallback2(Handle owner, Handle hndl, const char[ ReadPackString(data, szMapName, 128); Format(szQuery, 512, sql_selectPlayerProCount, szMapName); - SQL_TQuery(g_hDb, SQL_ViewTop10RecordsCallback3, szQuery, data, DBPrio_Low); + g_hDb.Query(SQL_ViewTop10RecordsCallback3, szQuery, data, DBPrio_Low); } } @@ -3059,7 +3055,7 @@ public void db_selectPlayer(int client) if (!IsValidClient(client)) return; Format(szQuery, 255, sql_selectPlayer, g_szSteamID[client], g_szMapName); - SQL_TQuery(g_hDb, SQL_SelectPlayerCallback, szQuery, client, DBPrio_Low); + g_hDb.Query(SQL_SelectPlayerCallback, szQuery, client, DBPrio_Low); } public void SQL_SelectPlayerCallback(Handle owner, Handle hndl, const char[] error, any data) @@ -3087,7 +3083,7 @@ public void db_insertPlayer(int client) char szName[MAX_NAME_LENGTH * 2 + 1]; SQL_EscapeString(g_hDb, szUName, szName, MAX_NAME_LENGTH * 2 + 1); Format(szQuery, 255, sql_insertPlayer, g_szSteamID[client], g_szMapName, szName); - SQL_TQuery(g_hDb, SQL_InsertPlayerCallBack, szQuery, client, DBPrio_Low); + g_hDb.Query(SQL_InsertPlayerCallBack, szQuery, client, DBPrio_Low); } // Getting player settings starts here @@ -3102,7 +3098,7 @@ public void db_viewPersonalRecords(int client, char szSteamId[32], char szMapNam char szQuery[1024]; Format(szQuery, 1024, "SELECT runtimepro, style FROM ck_playertimes WHERE steamid = '%s' AND mapname = '%s' AND runtimepro > 0.0;", szSteamId, szMapName); - SQL_TQuery(g_hDb, SQL_selectPersonalRecordsCallback, szQuery, client, DBPrio_Low); + g_hDb.Query(SQL_selectPersonalRecordsCallback, szQuery, client, DBPrio_Low); } @@ -3186,7 +3182,7 @@ public void db_deleteTmp(int client) if (!IsValidClient(client)) return; Format(szQuery, sizeof(szQuery), sql_deletePlayerTmp, g_szSteamID[client]); - SQL_TQuery(g_hDb, SQL_CheckCallback, szQuery, _, DBPrio_Low); + g_hDb.Query(SQL_CheckCallback, szQuery, __LINE__, DBPrio_Low); } public void db_selectLastRun(int client) @@ -3195,7 +3191,7 @@ public void db_selectLastRun(int client) if (!IsValidClient(client)) return; Format(szQuery, 512, sql_selectPlayerTmp, g_szSteamID[client], g_szMapName); - SQL_TQuery(g_hDb, SQL_LastRunCallback, szQuery, client, DBPrio_Low); + g_hDb.Query(SQL_LastRunCallback, szQuery, client, DBPrio_Low); } public void SQL_LastRunCallback(Handle owner, Handle hndl, const char[] error, any data) @@ -3284,7 +3280,7 @@ public void db_viewRecordCheckpointInMap() // "SELECT c.zonegroup, c.cp1, c.cp2, c.cp3, c.cp4, c.cp5, c.cp6, c.cp7, c.cp8, c.cp9, c.cp10, c.cp11, c.cp12, c.cp13, c.cp14, c.cp15, c.cp16, c.cp17, c.cp18, c.cp19, c.cp20, c.cp21, c.cp22, c.cp23, c.cp24, c.cp25, c.cp26, c.cp27, c.cp28, c.cp29, c.cp30, c.cp31, c.cp32, c.cp33, c.cp34, c.cp35 FROM ck_checkpoints c WHERE steamid = '%s' AND mapname='%s' UNION SELECT a.zonegroup, b.cp1, b.cp2, b.cp3, b.cp4, b.cp5, b.cp6, b.cp7, b.cp8, b.cp9, b.cp10, b.cp11, b.cp12, b.cp13, b.cp14, b.cp15, b.cp16, b.cp17, b.cp18, b.cp19, b.cp20, b.cp21, b.cp22, b.cp23, b.cp24, b.cp25, b.cp26, b.cp27, b.cp28, b.cp29, b.cp30, b.cp31, b.cp32, b.cp33, b.cp34, b.cp35 FROM ck_bonus a LEFT JOIN ck_checkpoints b ON a.steamid = b.steamid AND a.zonegroup = b.zonegroup WHERE a.mapname = '%s' GROUP BY a.zonegroup"; char szQuery[1028]; Format(szQuery, 1028, sql_selectRecordCheckpoints, g_szRecordMapSteamID, g_szMapName, g_szMapName); - SQL_TQuery(g_hDb, sql_selectRecordCheckpointsCallback, szQuery, GetGameTime(), DBPrio_Low); + g_hDb.Query(sql_selectRecordCheckpointsCallback, szQuery, GetGameTime(), DBPrio_Low); } public void sql_selectRecordCheckpointsCallback(Handle owner, Handle hndl, const char[] error, float time) @@ -3309,7 +3305,7 @@ public void sql_selectRecordCheckpointsCallback(Handle owner, Handle hndl, const zonegroup = SQL_FetchInt(hndl, 0); cp = SQL_FetchInt(hndl, 1); - if(zonegroup == 0) { + if (zonegroup == 0) { g_fCheckpointServerRecord[zonegroup][cp-1] = SQL_FetchFloat(hndl, 2); if (!g_bCheckpointRecordFound[zonegroup] && g_fCheckpointServerRecord[zonegroup][cp-1] > 0.0) g_bCheckpointRecordFound[zonegroup] = true; @@ -3327,7 +3323,7 @@ public void db_viewCheckpoints(int client, char szSteamID[32], char szMapName[12 { char szQuery[1024]; Format(szQuery, sizeof(szQuery), sql_selectCheckpoints, szMapName, szSteamID); - SQL_TQuery(g_hDb, SQL_selectCheckpointsCallback, szQuery, client, DBPrio_Low); + g_hDb.Query(SQL_selectCheckpointsCallback, szQuery, client, DBPrio_Low); } public void SQL_selectCheckpointsCallback(Handle owner, Handle hndl, const char[] error, any client) @@ -3379,7 +3375,7 @@ public void db_LoadCCP_StageTimes(int client) { char szQuery[1024]; Format(szQuery, sizeof(szQuery), sql_selectStageTimes, g_szMapName, g_szSteamID[client]); - SQL_TQuery(g_hDb, SQL_LoadCCP_StageTimesCallback, szQuery, client, DBPrio_Low); + g_hDb.Query(SQL_LoadCCP_StageTimesCallback, szQuery, client, DBPrio_Low); } public void SQL_LoadCCP_StageTimesCallback(Handle owner, Handle hndl, const char[] error, any client) @@ -3410,11 +3406,11 @@ public void SQL_LoadCCP_StageTimesCallback(Handle owner, Handle hndl, const char } -public void db_LoadStageAttempts(int client){ +public void db_LoadStageAttempts(int client) { char szQuery[1024]; Format(szQuery, sizeof(szQuery), sql_selectStageAttempts, g_szMapName, g_szSteamID[client]); - SQL_TQuery(g_hDb, SQL_LoadStageAttemptsCallback, szQuery, client, DBPrio_Low); + g_hDb.Query(SQL_LoadStageAttemptsCallback, szQuery, client, DBPrio_Low); } @@ -3455,14 +3451,14 @@ public void db_viewReplayCPTicks(char szMapName[128]) { char szQuery[1024]; - for(int style = 0; style < MAX_STYLES; style++){ + for(int style = 0; style < MAX_STYLES; style++) { g_bReplayTickFound[style] = false; Format(szQuery, sizeof(szQuery), sql_selectReplayCPTicksAll, szMapName, style); DataPack pack = new DataPack() pack.WriteCell(style); pack.WriteFloat(GetGameTime()); - SQL_TQuery(g_hDb, SQL_selectReplayCPTicksCallback, szQuery, pack, DBPrio_Low); + g_hDb.Query(SQL_selectReplayCPTicksCallback, szQuery, pack, DBPrio_Low); } } @@ -3490,7 +3486,7 @@ public void SQL_selectReplayCPTicksCallback(Handle owner, Handle hndl, const cha int frame; int style; - while(SQL_FetchRow(hndl)){ + while(SQL_FetchRow(hndl)) { cp = SQL_FetchInt(hndl, 0); frame = SQL_FetchInt(hndl, 1); style = SQL_FetchInt(hndl, 2); @@ -3501,7 +3497,7 @@ public void SQL_selectReplayCPTicksCallback(Handle owner, Handle hndl, const cha g_bReplayTickFound[style] = true; } } - else{ + else { for(int i = 0; i < MAX_STYLES; i++) for(int j = 0; j < CPLIMIT; j++) g_iCPStartFrame[i][j] = 0; @@ -3517,26 +3513,26 @@ public void SQL_selectReplayCPTicksCallback(Handle owner, Handle hndl, const cha } } -public void db_UpdateReplaysTick(int client, int style){ +public void db_UpdateReplaysTick(int client, int style) { char szQuery[1024]; int cp_count; - if(!g_bhasStages) + if (!g_bhasStages) cp_count = g_iTotalCheckpoints; else cp_count = g_TotalStages - 1; Transaction TicksTransaction = new Transaction(); - if(!g_bReplayTickFound[style]){ + if (!g_bReplayTickFound[style]) { g_bReplayTickFound[style] = true; - for(int i = 0; i < cp_count; i++){ + for(int i = 0; i < cp_count; i++) { Format(szQuery, sizeof(szQuery), sql_insertReplayCPTicks, g_szMapName, i+1, g_iCPStartFrame[style][i], style); TicksTransaction.AddQuery(szQuery); } } - else{ - for(int i = 0; i < cp_count; i++){ + else { + for(int i = 0; i < cp_count; i++) { Format(szQuery, sizeof(szQuery), sql_updateReplayCPTicks, g_iCPStartFrame[style][i], g_szMapName, i+1, style); TicksTransaction.AddQuery(szQuery); } @@ -3565,7 +3561,7 @@ public void db_viewCheckpointsinZoneGroup(int client, char szSteamID[32], char s WritePackCell(pack, zonegroup); Format(szQuery, 1024, sql_selectCheckpointsinZoneGroup, szMapName, szSteamID, zonegroup); - SQL_TQuery(g_hDb, db_viewCheckpointsinZoneGroupCallback, szQuery, pack, DBPrio_Low); + g_hDb.Query(db_viewCheckpointsinZoneGroupCallback, szQuery, pack, DBPrio_Low); } public void db_viewCheckpointsinZoneGroupCallback(Handle owner, Handle hndl, const char[] error, any pack) @@ -3588,14 +3584,14 @@ public void db_viewCheckpointsinZoneGroupCallback(Handle owner, Handle hndl, con { int cp; - while(SQL_FetchRow(hndl)){ + while(SQL_FetchRow(hndl)) { g_bCheckpointsFound[zonegrp][client] = true; cp = SQL_FetchInt(hndl, 0); g_fCheckpointTimesRecord[zonegrp][client][cp-1] = SQL_FetchFloat(hndl, 1); } - if(g_bhasStages) + if (g_bhasStages) db_LoadCCP(client); } else @@ -3611,7 +3607,7 @@ public void db_InsertOrUpdateCheckpoints(int client, char szSteamID[32], int zGr WritePackCell(pack, zGroup); int cp_count; - if(!g_bhasStages) + if (!g_bhasStages) cp_count = g_iTotalCheckpoints; else cp_count = g_TotalStages - 1; @@ -3622,7 +3618,7 @@ public void db_InsertOrUpdateCheckpoints(int client, char szSteamID[32], int zGr Transaction tAction = new Transaction(); for (int i = 0; i < cp_count; i++) { - if(g_bhasStages) + if (g_bhasStages) Format(szQuery, sizeof(szQuery), sql_InsertOrUpdateCheckpoints, szSteamID, g_szMapName, i+1, g_fCheckpointTimesNew[zGroup][client][i], g_fStageTimesNew[client][i], g_iStageAttemptsNew[client][i], zGroup, g_fCheckpointTimesNew[zGroup][client][i], g_fStageTimesNew[client][i], g_iStageAttemptsNew[client][i]); else Format(szQuery, sizeof(szQuery), sql_InsertOrUpdateCheckpoints, szSteamID, g_szMapName, i+1, g_fCheckpointTimesNew[zGroup][client][i], -1.0, -1, zGroup, g_fCheckpointTimesNew[zGroup][client][i], -1.0, -1); @@ -3653,7 +3649,7 @@ public void db_deleteCheckpoints() { char szQuery[258]; Format(szQuery, 258, sql_deleteCheckpoints, g_szMapName); - SQL_TQuery(g_hDb, SQL_deleteCheckpointsCallback, szQuery, 1, DBPrio_Low); + g_hDb.Query(SQL_deleteCheckpointsCallback, szQuery, 1, DBPrio_Low); } public void SQL_deleteCheckpointsCallback(Handle owner, Handle hndl, const char[] error, any data) @@ -3678,7 +3674,7 @@ public void db_viewPRinfo(int client, char szSteamID[32], char szMapName[128]) char szQuery[1024]; Format(szQuery, 1024, sql_selectPR, szSteamID, szMapName, 0); //PrintToConsole(client,szQuery); - SQL_TQuery(g_hDb, db_viewPRinfoCallback, szQuery, pack, DBPrio_Low); + g_hDb.Query(db_viewPRinfoCallback, szQuery, pack, DBPrio_Low); } public void db_viewPRinfoCallback(Handle owner, Handle hndl, const char[] error, DataPack pack) @@ -3700,12 +3696,12 @@ public void db_viewPRinfoCallback(Handle owner, Handle hndl, const char[] error, return; } - if (!IsValidClient(client)){ + if (!IsValidClient(client)) { CloseHandle(pack); return; } - if(SQL_HasResultSet(hndl) && SQL_FetchRow(hndl)){ + if (SQL_HasResultSet(hndl) && SQL_FetchRow(hndl)) { CloseHandle(pack); @@ -3715,7 +3711,7 @@ public void db_viewPRinfoCallback(Handle owner, Handle hndl, const char[] error, g_fstComplete[client][0] = SQL_FetchFloat(hndl, 7); } - else{ + else { char szQuery[1024]; g_fTimeinZone[client][0] = 0.0; @@ -3725,14 +3721,14 @@ public void db_viewPRinfoCallback(Handle owner, Handle hndl, const char[] error, Format(szQuery, 1024, "SELECT runtimepro FROM ck_playertimes WHERE steamid = '%s' AND style = 0 AND mapname = '%s';", szSteamID, szMapName); //PrintToConsole(client,szQuery); - SQL_TQuery(g_hDb, db_prinforuntimecallback, szQuery, pack, DBPrio_Low); + g_hDb.Query(db_prinforuntimecallback, szQuery, pack, DBPrio_Low); } //SETUP BONUS PRINFO - if(g_bhasBonus){ + if (g_bhasBonus) { db_viewBonusPRinfo(client, szSteamID, szMapName); } - else{ + else { if (!g_bSettingsLoaded[client]) { g_fTick[client][1] = GetGameTime(); @@ -3799,11 +3795,11 @@ public void db_prinforuntimecallback(Handle owner, Handle hndl, const char[] err return; } - if (!IsValidClient(client)){ + if (!IsValidClient(client)) { return; } - if(SQL_HasResultSet(hndl) && SQL_FetchRow(hndl)){ + if (SQL_HasResultSet(hndl) && SQL_FetchRow(hndl)) { float runtime = SQL_FetchFloat(hndl, 0); @@ -3814,9 +3810,9 @@ public void db_prinforuntimecallback(Handle owner, Handle hndl, const char[] err char szQuery[1024]; Format(szQuery, sizeof(szQuery), sql_insertPR, szSteamID, szName, szMapName, runtime, 0, 0.0, 0.0, 0.0, 0.0); - SQL_TQuery(g_hDb, SQL_CheckCallback, szQuery, _, DBPrio_Low); + g_hDb.Query(SQL_CheckCallback, szQuery, __LINE__, DBPrio_Low); } - else{ + else { // Escape name for SQL injection protection char szName[MAX_NAME_LENGTH * 2 + 1], szUName[MAX_NAME_LENGTH]; @@ -3826,7 +3822,7 @@ public void db_prinforuntimecallback(Handle owner, Handle hndl, const char[] err char szQuery[1024]; Format(szQuery, sizeof(szQuery), sql_insertPR, szSteamID, szName, szMapName, 0.0, 0, 0.0, 0.0, 0.0, 0.0); - SQL_TQuery(g_hDb, SQL_CheckCallback, szQuery, _, DBPrio_Low); + g_hDb.Query(SQL_CheckCallback, szQuery, __LINE__, DBPrio_Low); } return; @@ -3840,7 +3836,7 @@ public void db_viewBonusPRinfo(int client, char szSteamID[32], char szMapName[32 if (!IsValidClient(client)) return; - for(int zonegroup = 1; zonegroup < g_mapZoneGroupCount; zonegroup++){ + for(int zonegroup = 1; zonegroup < g_mapZoneGroupCount; zonegroup++) { Format(szQuery, sizeof(szQuery), sql_selectBonusPR, szSteamID, szMapName, zonegroup); //PrintToConsole(client,szQuery); @@ -3850,7 +3846,7 @@ public void db_viewBonusPRinfo(int client, char szSteamID[32], char szMapName[32 WritePackString(pack, szMapName); WritePackCell(pack, zonegroup); - SQL_TQuery(g_hDb, db_viewBonusPRinfoCallback, szQuery, pack, DBPrio_Low); + g_hDb.Query(db_viewBonusPRinfoCallback, szQuery, pack, DBPrio_Low); } } @@ -3873,12 +3869,12 @@ public void db_viewBonusPRinfoCallback(Handle owner, Handle hndl, const char[] e return; } - if (!IsValidClient(client)){ + if (!IsValidClient(client)) { CloseHandle(pack); return; } - if(SQL_HasResultSet(hndl) && SQL_FetchRow(hndl)){ + if (SQL_HasResultSet(hndl) && SQL_FetchRow(hndl)) { CloseHandle(pack); @@ -3890,7 +3886,7 @@ public void db_viewBonusPRinfoCallback(Handle owner, Handle hndl, const char[] e g_fstComplete[client][zonegroup] = SQL_FetchFloat(hndl, 7); } - else{ + else { char szQuery[1024]; int zonegroup = ReadPackCell(pack); @@ -3903,7 +3899,7 @@ public void db_viewBonusPRinfoCallback(Handle owner, Handle hndl, const char[] e Format(szQuery, 1024, "SELECT runtime, zonegroup FROM ck_bonus WHERE steamid = '%s' AND mapname = '%s' AND zonegroup = '%i';", szSteamID, szMapName, zonegroup); //PrintToConsole(client,szQuery); - SQL_TQuery(g_hDb, db_bonusprinforuntimecallback, szQuery, pack, DBPrio_Low); + g_hDb.Query(db_bonusprinforuntimecallback, szQuery, pack, DBPrio_Low); } if (!g_bSettingsLoaded[client]) @@ -3971,12 +3967,12 @@ public void db_bonusprinforuntimecallback(Handle owner, Handle hndl, const char[ return; } - if (!IsValidClient(client)){ + if (!IsValidClient(client)) { CloseHandle(pack); return; } - if(SQL_HasResultSet(hndl) && SQL_FetchRow(hndl)){ + if (SQL_HasResultSet(hndl) && SQL_FetchRow(hndl)) { //PrintToConsole(client,"ALREADY EXISTS"); float runtime; @@ -3992,10 +3988,10 @@ public void db_bonusprinforuntimecallback(Handle owner, Handle hndl, const char[ zonegroup = SQL_FetchInt(hndl, 1); Format(szQuery, sizeof(szQuery), sql_insertPR, szSteamID, szName, szMapName, runtime, zonegroup, 0.0, 0.0, 0.0, 0.0); - SQL_TQuery(g_hDb, SQL_CheckCallback, szQuery, _, DBPrio_Low); + g_hDb.Query(SQL_CheckCallback, szQuery, __LINE__, DBPrio_Low); } - else{ + else { //PrintToConsole(client,"NEW ENTRY"); // Escape name for SQL injection protection @@ -4008,7 +4004,7 @@ public void db_bonusprinforuntimecallback(Handle owner, Handle hndl, const char[ char szQuery[1024]; Format(szQuery, sizeof(szQuery), sql_insertPR, szSteamID, szName, szMapName, 0.0, zonegroup, 0.0, 0.0, 0.0, 0.0); - SQL_TQuery(g_hDb, SQL_CheckCallback, szQuery, _, DBPrio_Low); + g_hDb.Query(SQL_CheckCallback, szQuery, __LINE__, DBPrio_Low); } @@ -4024,7 +4020,7 @@ public void db_UpdatePRinfo_WithRuntime(int client, char szSteamID[32], int zGro char szQuery[2048]; //PrintToConsole(client, "%f || %f || %f || %f || %f\n", g_fTimeinZone[client][zGroup], g_fCompletes[client][zGroup], g_fAttempts[client][zGroup], g_fstComplete[client][zGroup], runtime); Format(szQuery, sizeof(szQuery), sql_updatePrinfo_withruntime, g_fTimeinZone[client][zGroup], g_fCompletes[client], g_fAttempts[client][zGroup], g_fstComplete[client][zGroup], runtime, szSteamID, g_szMapName, zGroup); - SQL_TQuery(g_hDb, SQL_CheckCallback, szQuery, .prio=DBPrio_Low); + g_hDb.Query(SQL_CheckCallback, szQuery, __LINE__, DBPrio_Low); } //this is called whenever the player's time stops and he is not in a end zone (map/bonus/stage) public void db_UpdatePRinfo(int client, char szSteamID[32], int zGroup) @@ -4035,7 +4031,7 @@ public void db_UpdatePRinfo(int client, char szSteamID[32], int zGroup) char szQuery[2048]; //PrintToConsoleAll("%f || %f || %f || %f\n", g_fTimeinZone[client][zGroup], g_fCompletes[client][zGroup], g_fAttempts[client][zGroup], g_fstComplete[client][zGroup]); Format(szQuery, sizeof(szQuery), sql_updatePrinfo, g_fTimeinZone[client][zGroup], g_fCompletes[client][zGroup], g_fAttempts[client][zGroup], g_fstComplete[client][zGroup], szSteamID, g_szMapName, zGroup); - SQL_TQuery(g_hDb, SQL_CheckCallback, szQuery, .prio=DBPrio_Low); + g_hDb.Query(SQL_CheckCallback, szQuery, __LINE__, DBPrio_Low); } /*=================================== @@ -4055,13 +4051,13 @@ public void db_insertMapperName(int client, char arg1[64]) { CReplyToCommand(client, "%t", "UpdateMapperName", g_szChatPrefix, arg1); Format(szQuery, sizeof(szQuery), sql_updateMapperName, arg1, g_szMapName); - SQL_TQuery(g_hDb, db_insertMapperNameCallback, szQuery, 1, DBPrio_Low); + g_hDb.Query(db_insertMapperNameCallback, szQuery, 1, DBPrio_Low); } else { CReplyToCommand(client, "%t", "InsertMapperName", g_szChatPrefix, arg1); Format(szQuery, sizeof(szQuery), sql_updateMapperName, arg1, g_szMapName); - SQL_TQuery(g_hDb, db_insertMapperNameCallback, szQuery, 1, DBPrio_Low); + g_hDb.Query(db_insertMapperNameCallback, szQuery, 1, DBPrio_Low); } } @@ -4082,12 +4078,12 @@ public void db_insertMapTier(int tier) if (g_bTierEntryFound) { Format(szQuery, sizeof(szQuery), sql_updatemaptier, tier, g_szMapName); - SQL_TQuery(g_hDb, db_insertMapTierCallback, szQuery, 1, DBPrio_Low); + g_hDb.Query(db_insertMapTierCallback, szQuery, 1, DBPrio_Low); } else { Format(szQuery, sizeof(szQuery), sql_insertmaptier, g_szMapName, tier); - SQL_TQuery(g_hDb, db_insertMapTierCallback, szQuery, 1, DBPrio_Low); + g_hDb.Query(db_insertMapTierCallback, szQuery, 1, DBPrio_Low); } } @@ -4113,7 +4109,7 @@ public void isLinear(int client, char szSteamID[32], char szMapName[32]) char szQuery[1024]; Format(szQuery, 1024, "SELECT COUNT(zonetype) FROM ck_zones WHERE mapname LIKE '%s' AND zonetype = 3;", szMapName); - SQL_TQuery(g_hDb, SQL_isLinearCallback, szQuery, pack, DBPrio_Low); + g_hDb.Query(SQL_isLinearCallback, szQuery, pack, DBPrio_Low); } public void SQL_isLinearCallback(Handle owner, Handle hndl, const char[] error, any data) @@ -4133,12 +4129,12 @@ public void SQL_isLinearCallback(Handle owner, Handle hndl, const char[] error, ReadPackString(data, szMapName, sizeof(szMapName)); CloseHandle(data); - if (SQL_HasResultSet(hndl) && SQL_FetchRow(hndl)){ + if (SQL_HasResultSet(hndl) && SQL_FetchRow(hndl)) { int stages = SQL_FetchInt(hndl, 0); //IF THE MAP HAS STAGE ZONES - if(stages > 0){ + if (stages > 0) { //GET PLAYERS RANK db_viewCCP_GetMapRank(client, szSteamID, szMapName); } @@ -4154,7 +4150,7 @@ public void db_selectMapTier() char szQuery[1024]; Format(szQuery, 1024, sql_selectMapTier, g_szMapName); - SQL_TQuery(g_hDb, SQL_selectMapTierCallback, szQuery, GetGameTime(), DBPrio_Low); + g_hDb.Query(SQL_selectMapTierCallback, szQuery, GetGameTime(), DBPrio_Low); } public void SQL_selectMapTierCallback(Handle owner, Handle hndl, const char[] error, float time) @@ -4250,7 +4246,7 @@ public void db_currentBonusRunRank(int client, int style, int zGroup) float runtime = g_fCurrentRunTime[client]; Format(szQuery, 512, "SELECT count(runtime)+1 FROM ck_bonus WHERE mapname = '%s' AND zonegroup = '%i' AND runtime < '%f' AND style = '%i';", g_szMapName, zGroup, runtime, style); - SQL_TQuery(g_hDb, db_viewBonusRunRank, szQuery, pack, DBPrio_Low); + g_hDb.Query(db_viewBonusRunRank, szQuery, pack, DBPrio_Low); } public void db_viewBonusRunRank(Handle owner, Handle hndl, const char[] error, any pack) @@ -4271,24 +4267,24 @@ public void db_viewBonusRunRank(Handle owner, Handle hndl, const char[] error, a rank = SQL_FetchInt(hndl, 0); } - if(g_bPracticeModeRun[client]) + if (g_bPracticeModeRun[client]) { float runtime = g_fCurrentRunTime[client]; char sz_srDiff[128]; float f_srDiff; - if(g_fBonusFastest[g_iClientInZone[client][2]] != 9999999.0) + if (g_fBonusFastest[g_iClientInZone[client][2]] != 9999999.0) f_srDiff = (g_fBonusFastest[g_iClientInZone[client][2]] - runtime); else f_srDiff = runtime; FormatTimeFloat(client, f_srDiff, 3, sz_srDiff, 128); - if(f_srDiff == runtime) + if (f_srDiff == runtime) Format(sz_srDiff, 128, "SR: N/A", sz_srDiff); else if (f_srDiff > 0.0) Format(sz_srDiff, 128, "%cSR: %c-%s%c", WHITE, LIGHTGREEN, sz_srDiff, WHITE); - else if(f_srDiff <= 0.0) + else if (f_srDiff <= 0.0) Format(sz_srDiff, 128, "%cSR: %c+%s%c", WHITE, RED, sz_srDiff, WHITE); char szSpecMessage[512]; @@ -4311,7 +4307,7 @@ public void db_viewMapRankBonus(int client, int zgroup, int type) WritePackCell(pack, type); Format(szQuery, 1024, sql_selectPlayerRankBonus, g_szSteamID[client], g_szMapName, zgroup, g_szMapName, zgroup); - SQL_TQuery(g_hDb, db_viewMapRankBonusCallback, szQuery, pack, DBPrio_Low); + g_hDb.Query(db_viewMapRankBonusCallback, szQuery, pack, DBPrio_Low); } public void db_viewMapRankBonusCallback(Handle owner, Handle hndl, const char[] error, any data) @@ -4362,7 +4358,7 @@ public void db_viewPersonalBonusRecords(int client, char szSteamId[32]) char szQuery[1024]; // "SELECT runtime, zonegroup, style FROM ck_bonus WHERE steamid = '%s AND mapname = '%s' AND runtime > '0.0'"; Format(szQuery, 1024, sql_selectPersonalBonusRecords, szSteamId, g_szMapName); - SQL_TQuery(g_hDb, SQL_selectPersonalBonusRecordsCallback, szQuery, client, DBPrio_Low); + g_hDb.Query(SQL_selectPersonalBonusRecordsCallback, szQuery, client, DBPrio_Low); } public void SQL_selectPersonalBonusRecordsCallback(Handle owner, Handle hndl, const char[] error, any client) @@ -4446,7 +4442,7 @@ public void db_viewFastestBonus() char szQuery[1024]; // SELECT name, MIN(runtime), zonegroup, style FROM ck_bonus WHERE mapname = '%s' GROUP BY zonegroup, style; Format(szQuery, 1024, sql_selectFastestBonus, g_szMapName); - SQL_TQuery(g_hDb, SQL_selectFastestBonusCallback, szQuery, GetGameTime(), DBPrio_High); + g_hDb.Query(SQL_selectFastestBonusCallback, szQuery, GetGameTime(), DBPrio_High); } public void SQL_selectFastestBonusCallback(Handle owner, Handle hndl, const char[] error, float time) @@ -4534,14 +4530,14 @@ public void db_deleteBonus() { char szQuery[1024]; Format(szQuery, 1024, sql_deleteBonus, g_szMapName); - SQL_TQuery(g_hDb, SQL_deleteBonusCallback, szQuery, 1, DBPrio_Low); + g_hDb.Query(SQL_deleteBonusCallback, szQuery, 1, DBPrio_Low); } public void db_viewBonusTotalCount() { char szQuery[1024]; // SELECT zonegroup, style, count(1) FROM ck_bonus WHERE mapname = '%s' GROUP BY zonegroup, style; Format(szQuery, 1024, sql_selectBonusCount, g_szMapName); - SQL_TQuery(g_hDb, SQL_selectBonusTotalCountCallback, szQuery, GetGameTime(), DBPrio_Low); + g_hDb.Query(SQL_selectBonusTotalCountCallback, szQuery, GetGameTime(), DBPrio_Low); } public void SQL_selectBonusTotalCountCallback(Handle owner, Handle hndl, const char[] error, float time) @@ -4592,7 +4588,7 @@ public void db_insertBonus(int client, char szSteamId[32], char szUName[128], fl WritePackCell(pack, client); WritePackCell(pack, zoneGrp); Format(szQuery, 1024, sql_insertBonus, szSteamId, szName, g_szMapName, FinalTime, zoneGrp, g_iPreStrafeBonus[0][zoneGrp][0][client], g_iPreStrafeBonus[1][zoneGrp][0][client], g_iPreStrafeBonus[2][zoneGrp][0][client]); - SQL_TQuery(g_hDb, SQL_insertBonusCallback, szQuery, pack, DBPrio_Low); + g_hDb.Query(SQL_insertBonusCallback, szQuery, pack, DBPrio_Low); } public void SQL_insertBonusCallback(Handle owner, Handle hndl, const char[] error, any data) @@ -4625,7 +4621,7 @@ public void db_updateBonus(int client, char szSteamId[32], char szUName[128], fl WritePackCell(datapack, zoneGrp); SQL_EscapeString(g_hDb, szUName, szName, MAX_NAME_LENGTH * 2 + 1); Format(szQuery, 1024, sql_updateBonus,FinalTime, szName, g_iPreStrafeBonus[0][zoneGrp][0][client], g_iPreStrafeBonus[1][zoneGrp][0][client], g_iPreStrafeBonus[2][zoneGrp][0][client], szSteamId, g_szMapName, zoneGrp); - SQL_TQuery(g_hDb, SQL_updateBonusCallback, szQuery, datapack, DBPrio_Low); + g_hDb.Query(SQL_updateBonusCallback, szQuery, datapack, DBPrio_Low); } @@ -4660,7 +4656,7 @@ public void db_selectBonusCount() { char szQuery[258]; Format(szQuery, 258, sql_selectTotalBonusCount); - SQL_TQuery(g_hDb, SQL_selectBonusCountCallback, szQuery, 1, DBPrio_Low); + g_hDb.Query(SQL_selectBonusCountCallback, szQuery, 1, DBPrio_Low); } public void SQL_selectBonusCountCallback(Handle owner, Handle hndl, const char[] error, any data) @@ -4708,7 +4704,7 @@ public void db_setZoneNames(int client, char szName[128]) WritePackString(pack, szEscapedName); // UPDATE ck_zones SET zonename = '%s' WHERE mapname = '%s' AND zonegroup = '%i'; Format(szQuery, 512, sql_setZoneNames, szEscapedName, g_szMapName, g_CurrentSelectedZoneGroup[client]); - SQL_TQuery(g_hDb, sql_setZoneNamesCallback, szQuery, pack, DBPrio_Low); + g_hDb.Query(sql_setZoneNamesCallback, szQuery, pack, DBPrio_Low); } public void sql_setZoneNamesCallback(Handle owner, Handle hndl, const char[] error, any data) @@ -4749,7 +4745,7 @@ public void db_checkAndFixZoneIds() GetCurrentMap(g_szMapName, 128); Format(szQuery, 512, sql_selectZoneIds, g_szMapName); - SQL_TQuery(g_hDb, db_checkAndFixZoneIdsCallback, szQuery, 1, DBPrio_Low); + g_hDb.Query(db_checkAndFixZoneIdsCallback, szQuery, 1, DBPrio_Low); } public void db_checkAndFixZoneIdsCallback(Handle owner, Handle hndl, const char[] error, any data) @@ -4800,7 +4796,7 @@ public void db_checkAndFixZoneIdsCallback(Handle owner, Handle hndl, const char[ { char szQuery[256]; Format(szQuery, sizeof(szQuery), sql_deleteMapZones, g_szMapName); - SQL_TQuery(g_hDb, SQL_CheckCallback, szQuery, _, DBPrio_Low); + g_hDb.Query(SQL_CheckCallback, szQuery, __LINE__, DBPrio_Low); // SQL_FastQuery(g_hDb, szQuery); for (int k = 0; k < checker; k++) @@ -4828,7 +4824,7 @@ public void db_insertZoneCheap(int zoneid, int zonetype, int zonetypeid, float p char szQuery[1024]; // "INSERT INTO ck_zones (mapname, zoneid, zonetype, zonetypeid, pointa_x, pointa_y, pointa_z, pointb_x, pointb_y, pointb_z, vis, team, zonegroup, zonename) VALUES ('%s', '%i', '%i', '%i', '%f', '%f', '%f', '%f', '%f', '%f', '%i', '%i', '%i', '%s')"; Format(szQuery, 1024, sql_insertZones, g_szMapName, zoneid, zonetype, zonetypeid, pointax, pointay, pointaz, pointbx, pointby, pointbz, vis, team, zGrp, zName, hookname, targetname, ojl, prespeed); - SQL_TQuery(g_hDb, SQL_insertZonesCheapCallback, szQuery, query, DBPrio_Low); + g_hDb.Query(SQL_insertZonesCheapCallback, szQuery, query, DBPrio_Low); } public void SQL_insertZonesCheapCallback(Handle owner, Handle hndl, const char[] error, any query) @@ -4855,7 +4851,7 @@ public void db_insertZone(int zoneid, int zonetype, int zonetypeid, float pointa // char sql_insertZones[] = "INSERT INTO ck_zones (mapname, zoneid, zonetype, zonetypeid, pointa_x, pointa_y, pointa_z, pointb_x, pointb_y, pointb_z, vis, team, zonegroup, zonename, hookname, targetname, onejumplimit, prespeed) VALUES ('%s', '%i', '%i', '%i', '%f', '%f', '%f', '%f', '%f', '%f', '%i', '%i', '%i','%s','%s','%s',%i,%f)"; Format(szQuery, 1024, sql_insertZones, g_szMapName, zoneid, zonetype, zonetypeid, pointax, pointay, pointaz, pointbx, pointby, pointbz, vis, team, zonegroup, zName, "None", "player", 1, 250.0); - SQL_TQuery(g_hDb, SQL_insertZonesCallback, szQuery, 1, DBPrio_Low); + g_hDb.Query(SQL_insertZonesCallback, szQuery, 1, DBPrio_Low); } public void SQL_insertZonesCallback(Handle owner, Handle hndl, const char[] error, any data) @@ -4882,14 +4878,14 @@ public void db_insertZoneHook(int zoneid, int zonetype, int zonetypeid, int vis, // "INSERT INTO ck_zones (mapname, zoneid, zonetype, zonetypeid, pointa_x, pointa_y, pointa_z, pointb_x, pointb_y, pointb_z, vis, team, zonegroup, zonename) VALUES ('%s', '%i', '%i', '%i', '%f', '%f', '%f', '%f', '%f', '%f', '%i', '%i', '%i', '%s')"; Format(szQuery, 1024, "INSERT INTO ck_zones (mapname, zoneid, zonetype, zonetypeid, pointa_x, pointa_y, pointa_z, pointb_x, pointb_y, pointb_z, vis, team, zonegroup, zonename, hookname) VALUES ('%s', '%i', '%i', '%i', '%f', '%f', '%f', '%f', '%f', '%f', '%i', '%i', '%i','%s','%s')", g_szMapName, zoneid, zonetype, zonetypeid, point_a[0], point_a[1], point_a[2], point_b[0], point_b[1], point_b[2], vis, team, zonegroup, zName, szHookName); - SQL_TQuery(g_hDb, SQL_insertZonesCallback, szQuery, 1, DBPrio_Low); + g_hDb.Query(SQL_insertZonesCallback, szQuery, 1, DBPrio_Low); } public void db_saveZones() { char szQuery[258]; Format(szQuery, 258, sql_deleteMapZones, g_szMapName); - SQL_TQuery(g_hDb, SQL_saveZonesCallBack, szQuery, 1, DBPrio_Low); + g_hDb.Query(SQL_saveZonesCallBack, szQuery, 1, DBPrio_Low); } public void SQL_saveZonesCallBack(Handle owner, Handle hndl, const char[] error, any data) @@ -4918,7 +4914,7 @@ public void db_updateZone(int zoneid, int zonetype, int zonetypeid, float[] Poin { char szQuery[1024]; Format(szQuery, 1024, sql_updateZone, zonetype, zonetypeid, Point1[0], Point1[1], Point1[2], Point2[0], Point2[1], Point2[2], vis, team, onejumplimit, prespeed, hookname, targetname, zonegroup, zoneid, g_szMapName); - SQL_TQuery(g_hDb, SQL_updateZoneCallback, szQuery, 1, DBPrio_Low); + g_hDb.Query(SQL_updateZoneCallback, szQuery, 1, DBPrio_Low); } public void SQL_updateZoneCallback(Handle owner, Handle hndl, const char[] error, any data) @@ -4992,7 +4988,7 @@ public void db_selectzoneTypeIds(int zonetype, int client, int zonegrp) { char szQuery[258]; Format(szQuery, 258, sql_selectzoneTypeIds, g_szMapName, zonetype, zonegrp); - SQL_TQuery(g_hDb, SQL_selectzoneTypeIdsCallback, szQuery, client, DBPrio_Low); + g_hDb.Query(SQL_selectzoneTypeIdsCallback, szQuery, client, DBPrio_Low); } public void SQL_selectzoneTypeIdsCallback(Handle owner, Handle hndl, const char[] error, any data) @@ -5056,7 +5052,7 @@ InitZoneVariables(); char szQuery[258]; Format(szQuery, 258, "SELECT `zonegroup` ,`zonetype`, `zonetypeid` FROM `ck_zones` WHERE `mapname` = '%s';", g_szMapName); -SQL_TQuery(g_hDb, checkZoneTypeIdsCallback, szQuery, 1, DBPrio_High); +g_hDb.Query(checkZoneTypeIdsCallback, szQuery, 1, DBPrio_High); } public checkZoneTypeIdsCallback(Handle owner, Handle hndl, const char[] error, any:data) @@ -5098,7 +5094,7 @@ SQL_UnlockDatabase(g_hDb); } Format(szQuery, 258, "SELECT `zoneid` FROM `ck_zones` WHERE mapname = '%s' ORDER BY zoneid ASC;", g_szMapName); -SQL_TQuery(g_hDb, checkZoneIdsCallback, szQuery, 1, DBPrio_High); +g_hDb.Query(checkZoneIdsCallback, szQuery, 1, DBPrio_High); } } @@ -5134,7 +5130,7 @@ i++; char szQuery2[258]; Format(szQuery2, 258, "SELECT `zonegroup` FROM `ck_zones` WHERE `mapname` = '%s' ORDER BY `zonegroup` ASC;", g_szMapName); -SQL_TQuery(g_hDb, checkZoneGroupIds, szQuery2, 1, DBPrio_Low); +g_hDb.Query(checkZoneGroupIds, szQuery2, 1, DBPrio_Low); } } @@ -5175,7 +5171,7 @@ public void db_selectMapZones() { char szQuery[512]; Format(szQuery, sizeof(szQuery), sql_selectMapZones, g_szMapName); - SQL_TQuery(g_hDb, SQL_selectMapZonesCallback, szQuery, GetGameTime(), DBPrio_High); + g_hDb.Query(SQL_selectMapZonesCallback, szQuery, GetGameTime(), DBPrio_High); } public void SQL_selectMapZonesCallback(Handle owner, Handle hndl, const char[] error, float time) @@ -5403,7 +5399,7 @@ public void SQL_selectMapZonesCallback(Handle owner, Handle hndl, const char[] e PrintToServer("[SurfTimer] Found an error in zoneid : %i", i); Format(szQuery, 258, "UPDATE `ck_zones` SET zoneid = zoneid-1 WHERE mapname = '%s' AND zoneid > %i", g_szMapName, i); PrintToServer("Query: %s", szQuery); - SQL_TQuery(g_hDb, sql_zoneFixCallback, szQuery, -1, DBPrio_Low); + g_hDb.Query(sql_zoneFixCallback, szQuery, -1, DBPrio_Low); return; } @@ -5413,7 +5409,7 @@ public void SQL_selectMapZonesCallback(Handle owner, Handle hndl, const char[] e { PrintToServer("[SurfTimer] Found an error in zonegroup %i (ZoneGroups total: %i)", i, g_mapZoneGroupCount); Format(szQuery, 258, "UPDATE `ck_zones` SET `zonegroup` = zonegroup-1 WHERE `mapname` = '%s' AND `zonegroup` > %i", g_szMapName, i); - SQL_TQuery(g_hDb, sql_zoneFixCallback, szQuery, zoneGroupChecker[i], DBPrio_Low); + g_hDb.Query(sql_zoneFixCallback, szQuery, zoneGroupChecker[i], DBPrio_Low); return; } @@ -5427,7 +5423,7 @@ public void SQL_selectMapZonesCallback(Handle owner, Handle hndl, const char[] e { PrintToServer("[SurfTimer] ZoneTypeID missing! [ZoneGroup: %i ZoneType: %i, ZonetypeId: %i]", i, k, x); Format(szQuery, 258, "UPDATE `ck_zones` SET zonetypeid = zonetypeid-1 WHERE mapname = '%s' AND zonetype = %i AND zonetypeid > %i AND zonegroup = %i;", g_szMapName, k, x, i); - SQL_TQuery(g_hDb, sql_zoneFixCallback, szQuery, -1, DBPrio_Low); + g_hDb.Query(sql_zoneFixCallback, szQuery, -1, DBPrio_Low); return; } else if (zoneTypeIdChecker[i][k][x] > 1) @@ -5464,7 +5460,7 @@ public void sql_zoneFixCallback(Handle owner, Handle hndl, const char[] error, a { char szQuery[258]; Format(szQuery, 258, "DELETE FROM `ck_bonus` WHERE `mapname` = '%s' AND `zonegroup` = %i;", g_szMapName, zongeroup); - SQL_TQuery(g_hDb, sql_zoneFixCallback2, szQuery, zongeroup, DBPrio_Low); + g_hDb.Query(sql_zoneFixCallback2, szQuery, zongeroup, DBPrio_Low); } } @@ -5478,14 +5474,14 @@ public void sql_zoneFixCallback2(Handle owner, Handle hndl, const char[] error, char szQuery[258]; Format(szQuery, 258, "UPDATE ck_bonus SET zonegroup = zonegroup-1 WHERE `mapname` = '%s' AND `zonegroup` = %i;", g_szMapName, zongeroup); - SQL_TQuery(g_hDb, sql_zoneFixCallback, szQuery, -1, DBPrio_Low); + g_hDb.Query(sql_zoneFixCallback, szQuery, -1, DBPrio_Low); } public void db_deleteMapZones() { char szQuery[258]; Format(szQuery, 258, sql_deleteMapZones, g_szMapName); - SQL_TQuery(g_hDb, SQL_deleteMapZonesCallback, szQuery, 1, DBPrio_Low); + g_hDb.Query(SQL_deleteMapZonesCallback, szQuery, 1, DBPrio_Low); } public void SQL_deleteMapZonesCallback(Handle owner, Handle hndl, const char[] error, any data) @@ -5514,14 +5510,14 @@ public void db_deleteZone(int client, int zoneid) public void SQLTxn_ZoneRemovalSuccess(Handle db, any client, int numQueries, Handle[] results, any[] queryData) { if (IsValidClient(client)) - CPrintToChat(client, "%t", "SQL9", g_szChatPrefix); + CPrintToChat(client, "%t", "SQL9", g_szChatPrefix); PrintToServer("[SurfTimer] Zone Removed Succesfully"); } public void SQLTxn_ZoneRemovalFailed(Handle db, any client, int numQueries, const char[] error, int failIndex, any[] queryData) { if (IsValidClient(client)) - CPrintToChat(client, "%t", "SQL10", g_szChatPrefix, error); + CPrintToChat(client, "%t", "SQL10", g_szChatPrefix, error); PrintToServer("[SurfTimer] Zone Removal Failed. Error: %s", error); return; } @@ -5542,7 +5538,7 @@ public void db_insertLastPosition(int client, char szMapName[128], int stage, in WritePackCell(pack, zgroup); char szQuery[512]; Format(szQuery, 512, "SELECT * FROM ck_playertemp WHERE steamid = '%s'", g_szSteamID[client]); - SQL_TQuery(g_hDb, db_insertLastPositionCallback, szQuery, pack, DBPrio_Low); + g_hDb.Query(db_insertLastPositionCallback, szQuery, pack, DBPrio_Low); } } @@ -5574,12 +5570,12 @@ public void db_insertLastPositionCallback(Handle owner, Handle hndl, const char[ if (SQL_HasResultSet(hndl) && SQL_FetchRow(hndl)) { Format(szQuery, sizeof(szQuery), sql_updatePlayerTmp, g_fPlayerCordsLastPosition[client][0], g_fPlayerCordsLastPosition[client][1], g_fPlayerCordsLastPosition[client][2], g_fPlayerAnglesLastPosition[client][0], g_fPlayerAnglesLastPosition[client][1], g_fPlayerAnglesLastPosition[client][2], g_fPlayerLastTime[client], szMapName, tickrate, stage, zgroup, szSteamID); - SQL_TQuery(g_hDb, SQL_CheckCallback, szQuery, _, DBPrio_Low); + g_hDb.Query(SQL_CheckCallback, szQuery, __LINE__, DBPrio_Low); } else { Format(szQuery, sizeof(szQuery), sql_insertPlayerTmp, g_fPlayerCordsLastPosition[client][0], g_fPlayerCordsLastPosition[client][1], g_fPlayerCordsLastPosition[client][2], g_fPlayerAnglesLastPosition[client][0], g_fPlayerAnglesLastPosition[client][1], g_fPlayerAnglesLastPosition[client][2], g_fPlayerLastTime[client], szSteamID, szMapName, tickrate, stage, zgroup); - SQL_TQuery(g_hDb, SQL_CheckCallback, szQuery, _, DBPrio_Low); + g_hDb.Query(SQL_CheckCallback, szQuery, __LINE__, DBPrio_Low); } } } @@ -5588,12 +5584,12 @@ public void db_deletePlayerTmps() { char szQuery[64]; Format(szQuery, sizeof(szQuery), "delete FROM ck_playertemp"); - SQL_TQuery(g_hDb, SQL_CheckCallback, szQuery, _, DBPrio_Low); + g_hDb.Query(SQL_CheckCallback, szQuery, __LINE__, DBPrio_Low); } public void db_ViewLatestRecords(int client) { - SQL_TQuery(g_hDb, sql_selectLatestRecordsCallback, sql_selectLatestRecords, client, DBPrio_Low); + g_hDb.Query(sql_selectLatestRecordsCallback, sql_selectLatestRecords, client, DBPrio_Low); } public void sql_selectLatestRecordsCallback(Handle owner, Handle hndl, const char[] error, any data) @@ -5659,14 +5655,14 @@ public void db_InsertLatestRecords(char szSteamID[32], char szName[128], float F { char szQuery[512]; Format(szQuery, sizeof(szQuery), sql_insertLatestRecords, szSteamID, szName, FinalTime, g_szMapName); - SQL_TQuery(g_hDb, SQL_CheckCallback, szQuery, _, DBPrio_Low); + g_hDb.Query(SQL_CheckCallback, szQuery, __LINE__, DBPrio_Low); } public void db_CalcAvgRunTime() { char szQuery[256]; Format(szQuery, sizeof(szQuery), sql_selectAllMapTimesinMap, g_szMapName); - SQL_TQuery(g_hDb, SQL_db_CalcAvgRunTimeCallback, szQuery, GetGameTime(), DBPrio_Low); + g_hDb.Query(SQL_db_CalcAvgRunTimeCallback, szQuery, GetGameTime(), DBPrio_Low); } public void SQL_db_CalcAvgRunTimeCallback(Handle owner, Handle hndl, const char[] error, float time) @@ -5717,7 +5713,7 @@ public void db_CalcAvgRunTimeBonus() { char szQuery[256]; Format(szQuery, 256, sql_selectAllBonusTimesinMap, g_szMapName); - SQL_TQuery(g_hDb, SQL_db_CalcAvgRunBonusTimeCallback, szQuery, GetGameTime(), DBPrio_Low); + g_hDb.Query(SQL_db_CalcAvgRunBonusTimeCallback, szQuery, GetGameTime(), DBPrio_Low); } public void SQL_db_CalcAvgRunBonusTimeCallback(Handle owner, Handle hndl, const char[] error, float fTime) @@ -5770,7 +5766,7 @@ public void db_GetDynamicTimelimit() } char szQuery[256]; Format(szQuery, 256, sql_selectAllMapTimesinMap, g_szMapName); - SQL_TQuery(g_hDb, SQL_db_GetDynamicTimelimitCallback, szQuery, GetGameTime(), DBPrio_Low); + g_hDb.Query(SQL_db_GetDynamicTimelimitCallback, szQuery, GetGameTime(), DBPrio_Low); } public void SQL_db_GetDynamicTimelimitCallback(Handle owner, Handle hndl, const char[] error, float fTime) @@ -5847,7 +5843,7 @@ public void db_CalculatePlayerCount(int style) DataPack pack = new DataPack(); pack.WriteCell(style); pack.WriteFloat(GetGameTime()); - SQL_TQuery(g_hDb, sql_CountRankedPlayersCallback, szQuery, pack, DBPrio_Low); + g_hDb.Query(sql_CountRankedPlayersCallback, szQuery, pack, DBPrio_Low); } public void db_CalculatePlayersCountGreater0(int style) @@ -5857,7 +5853,7 @@ public void db_CalculatePlayersCountGreater0(int style) DataPack pack = new DataPack(); pack.WriteCell(style); pack.WriteFloat(GetGameTime()); - SQL_TQuery(g_hDb, sql_CountRankedPlayers2Callback, szQuery, pack, DBPrio_Low); + g_hDb.Query(sql_CountRankedPlayers2Callback, szQuery, pack, DBPrio_Low); } public void sql_CountRankedPlayersCallback(Handle owner, Handle hndl, const char[] error, DataPack pack) @@ -5929,7 +5925,7 @@ public void db_viewUnfinishedMaps(int client, char szSteamId[32]) char szQuery[720]; // Gets all players unfinished maps and bonuses from the database Format(szQuery, 720, "SELECT mapname, zonegroup, zonename, (SELECT tier FROM ck_maptier d WHERE d.mapname = a.mapname) AS tier FROM ck_zones a WHERE (zonetype = 1 OR zonetype = 5) AND (SELECT runtimepro FROM ck_playertimes b WHERE b.mapname = a.mapname AND a.zonegroup = 0 AND b.style = %d AND steamid = '%s' UNION SELECT runtime FROM ck_bonus c WHERE c.mapname = a.mapname AND c.zonegroup = a.zonegroup AND c.style = %d AND steamid = '%s') IS NULL GROUP BY mapname, zonegroup ORDER BY tier, mapname, zonegroup ASC", g_ProfileStyleSelect[client], szSteamId, g_ProfileStyleSelect[client], szSteamId); - SQL_TQuery(g_hDb, db_viewUnfinishedMapsCallback, szQuery, client, DBPrio_Low); + g_hDb.Query(db_viewUnfinishedMapsCallback, szQuery, client, DBPrio_Low); } public void db_viewUnfinishedMapsCallback(Handle owner, Handle hndl, const char[] error, any client) @@ -6104,7 +6100,7 @@ public void RefreshPlayerRankTable(int max) // SELECT steamid, name from ck_playerrank where points > 0 ORDER BY points DESC"; // SELECT steamid, name from ck_playerrank where points > 0 ORDER BY points DESC Format(szQuery, 255, sql_selectRankedPlayers); - SQL_TQuery(g_hDb, sql_selectRankedPlayersCallback, szQuery, max, DBPrio_Low); + g_hDb.Query(sql_selectRankedPlayersCallback, szQuery, max, DBPrio_Low); } public void sql_selectRankedPlayersCallback(Handle owner, Handle hndl, const char[] error, any data) @@ -6181,13 +6177,13 @@ public void db_Cleanup() // tmps Format(szQuery, sizeof(szQuery), "DELETE FROM ck_playertemp where mapname != '%s'", g_szMapName); - SQL_TQuery(g_hDb, SQL_CheckCallback, szQuery, _, DBPrio_Low); + g_hDb.Query(SQL_CheckCallback, szQuery, __LINE__, DBPrio_Low); // times - SQL_TQuery(g_hDb, SQL_CheckCallback, "DELETE FROM ck_playertimes where runtimepro = -1.0", _, DBPrio_Low); + g_hDb.Query(SQL_CheckCallback, "DELETE FROM ck_playertimes where runtimepro = -1.0", __LINE__, DBPrio_Low); // fluffys pointless players - SQL_TQuery(g_hDb, SQL_CheckCallback, "DELETE FROM ck_playerrank WHERE `points` <= 0", _, DBPrio_Low); + g_hDb.Query(SQL_CheckCallback, "DELETE FROM ck_playerrank WHERE `points` <= 0", __LINE__, DBPrio_Low); } @@ -6213,7 +6209,7 @@ public void db_UpdateLastSeen(int client) else if (g_DbType == SQLITE) Format(szQuery, sizeof(szQuery), sql_UpdateLastSeenSQLite, g_szSteamID[client]); - SQL_TQuery(g_hDb, SQL_CheckCallback, szQuery, _, DBPrio_Low); + g_hDb.Query(SQL_CheckCallback, szQuery, __LINE__, DBPrio_Low); } } @@ -6221,11 +6217,11 @@ public void db_UpdateLastSeen(int client) = DEFAULT CALLBACKS = ===================================*/ -public void SQL_CheckCallback(Handle owner, Handle hndl, const char[] error, any data) +public void SQL_CheckCallback(Handle owner, Handle hndl, const char[] error, int line) { if (hndl == null) { - LogStackTrace("[SurfTimer] SQL Error (SQL_CheckCallback): %s", error); + LogStackTrace("[SurfTimer] (SQL_CheckCallback) SQL Error from line %d: %s", line, error); return; } } @@ -6239,7 +6235,7 @@ public void db_viewPlayerOptions(int client, char szSteamId[32]) g_bLoadedModules[client] = false; char szQuery[2048]; Format(szQuery, 2048, sql_selectPlayerOptions, szSteamId); - SQL_TQuery(g_hDb, db_viewPlayerOptionsCallback, szQuery, client, DBPrio_Low); + g_hDb.Query(db_viewPlayerOptionsCallback, szQuery, client, DBPrio_Low); } public void db_viewPlayerOptionsCallback(Handle owner, Handle hndl, const char[] error, any client) @@ -6310,7 +6306,7 @@ public void db_viewPlayerOptionsCallback(Handle owner, Handle hndl, const char[] // "INSERT INTO ck_playeroptions2 (steamid, timer, hide, sounds, chat, viewmodel, autobhop, checkpoints, centrehud, module1c, module2c, module3c, module4c, module5c, module6c, sidehud, module1s, module2s, module3s, module4s, module5s) VALUES('%s', '%i', '%i', '%i', '%i', '%i', '%i', '%i', '%i', '%i', '%i', '%i', '%i', '%i', '%i', '%i', '%i', '%i', '%i', '%i', '%i');"; Format(szQuery, sizeof(szQuery), sql_insertPlayerOptions, g_szSteamID[client]); - SQL_TQuery(g_hDb, SQL_CheckCallback, szQuery, _, DBPrio_Low); + g_hDb.Query(SQL_CheckCallback, szQuery, __LINE__, DBPrio_Low); g_bTimerEnabled[client] = true; g_bHide[client] = false; @@ -6370,7 +6366,7 @@ public void db_updatePlayerOptions(int client) { Format(szQuery, sizeof(szQuery), sql_updatePlayerOptions, BooltoInt(g_bTimerEnabled[client]), BooltoInt(g_bHide[client]), BooltoInt(g_bEnableQuakeSounds[client]), BooltoInt(g_bHideChat[client]), BooltoInt(g_bViewModel[client]), BooltoInt(g_bAutoBhopClient[client]), BooltoInt(g_bCheckpointsEnabled[client]), g_SpeedGradient[client], g_SpeedMode[client], BooltoInt(g_bCenterSpeedDisplay[client]), BooltoInt(g_bCentreHud[client]), g_iTeleSide[client], g_iCentreHudModule[client][0], g_iCentreHudModule[client][1], g_iCentreHudModule[client][2], g_iCentreHudModule[client][3], g_iCentreHudModule[client][4], g_iCentreHudModule[client][5], BooltoInt(g_bSideHud[client]), g_iSideHudModule[client][0], g_iSideHudModule[client][1], g_iSideHudModule[client][2], g_iSideHudModule[client][3], g_iSideHudModule[client][4], BooltoInt(g_iPrespeedText[client]), BooltoInt(g_iCpMessages[client]), BooltoInt(g_iWrcpMessages[client]), BooltoInt(g_bAllowHints[client]), g_iCSDUpdateRate[client], g_fCSD_POS_X[client], g_fCSD_POS_Y[client], g_iCSD_R[client], g_iCSD_G[client], g_iCSD_B[client], g_PreSpeedMode[client], g_szSteamID[client]); //Format(szQuery, 1024, sql_updatePlayerOptions, BooltoInt(g_bTimerEnabled[client]), BooltoInt(g_bHide[client]), BooltoInt(g_bEnableQuakeSounds[client]), BooltoInt(g_bHideChat[client]), BooltoInt(g_bViewModel[client]), BooltoInt(g_bAutoBhopClient[client]), BooltoInt(g_bCheckpointsEnabled[client]), g_SpeedGradient[client], g_SpeedMode[client], BooltoInt(g_bCenterSpeedDisplay[client]), BooltoInt(g_bCentreHud[client]), g_iTeleSide[client], g_iCentreHudModule[client][0], g_iCentreHudModule[client][1], g_iCentreHudModule[client][2], g_iCentreHudModule[client][3], g_iCentreHudModule[client][4], g_iCentreHudModule[client][5], BooltoInt(g_bSideHud[client]), g_iSideHudModule[client][0], g_iSideHudModule[client][1], g_iSideHudModule[client][2], g_iSideHudModule[client][3], g_iSideHudModule[client][4], BooltoInt(g_iPrespeedText[client]), BooltoInt(g_iCpMessages[client]), BooltoInt(g_iWrcpMessages[client]), BooltoInt(g_bAllowHints[client]), BooltoInt(g_bTimeleftDisplay[client]), g_szSteamID[client]); - SQL_TQuery(g_hDb, SQL_CheckCallback, szQuery, _, DBPrio_Low); + g_hDb.Query(SQL_CheckCallback, szQuery, __LINE__, DBPrio_Low); } } @@ -6386,7 +6382,7 @@ public void db_selectTopPlayers(int client, int style) char szQuery[128]; Format(szQuery, 128, sql_selectTopPlayers, style); - SQL_TQuery(g_hDb, db_selectTop100PlayersCallback, szQuery, pack, DBPrio_Low); + g_hDb.Query(db_selectTop100PlayersCallback, szQuery, pack, DBPrio_Low); } public void db_selectTop100PlayersCallback(Handle owner, Handle hndl, const char[] error, any pack) @@ -6547,7 +6543,7 @@ public void db_selectTotalBonusCount() { char szQuery[512]; Format(szQuery, sizeof(szQuery), "SELECT COUNT(DISTINCT `a`.`mapname`, `a`.`zonegroup`) AS `count` FROM `ck_zones` `a` INNER JOIN `ck_maptier` `b` ON `b`.`mapname` = `a`.`mapname` WHERE `a`.`zonetype` = 1 AND `a`.`zonegroup` > 0"); - SQL_TQuery(g_hDb, sql_selectTotalBonusCountCallback, szQuery, GetGameTime(), DBPrio_Low); + g_hDb.Query(sql_selectTotalBonusCountCallback, szQuery, GetGameTime(), DBPrio_Low); } public void sql_selectTotalBonusCountCallback(Handle owner, Handle hndl, const char[] error, float time) @@ -6576,7 +6572,7 @@ public void db_selectTotalStageCount() { char szQuery[512]; Format(szQuery, sizeof(szQuery), "SELECT COUNT(DISTINCT `a`.`mapname`) + COUNT(1) AS `count` FROM `ck_zones` `a` INNER JOIN `ck_maptier` `b` ON `b`.`mapname` = `a`.`mapname` WHERE `a`.`zonetype` = 3 AND `a`.`zonegroup` = 0;"); - SQL_TQuery(g_hDb, sql_selectTotalStageCountCallback, szQuery, GetGameTime(), DBPrio_Low); + g_hDb.Query(sql_selectTotalStageCountCallback, szQuery, GetGameTime(), DBPrio_Low); } public void sql_selectTotalStageCountCallback(Handle owner, Handle hndl, const char[] error, float time) @@ -6620,7 +6616,7 @@ public void db_selectWrcpRecord(int client, int style, int stage) else if (style != 0) Format(szQuery, 255, "SELECT runtimepro FROM ck_wrcps WHERE steamid = '%s' AND mapname = '%s' AND stage = %i AND style = %i", g_szSteamID[client], g_szMapName, stage, style); - SQL_TQuery(g_hDb, sql_selectWrcpRecordCallback, szQuery, pack, DBPrio_Low); + g_hDb.Query(sql_selectWrcpRecordCallback, szQuery, pack, DBPrio_Low); } public void sql_selectWrcpRecordCallback(Handle owner, Handle hndl, const char[] error, any packx) @@ -6738,7 +6734,7 @@ public void sql_selectWrcpRecordCallback(Handle owner, Handle hndl, const char[] else if (style != 0) Format(szQuery, sizeof(szQuery), "INSERT INTO ck_wrcps (steamid, name, mapname, runtimepro, stage, style, velStartXY, velStartXYZ, velStartZ) VALUES ('%s', '%s', '%s', '%f', %i, %i, %i, %i, %i);", g_szSteamID[data], szName, g_szMapName, g_fFinalWrcpTime[data], stage, style, g_iPreStrafeStage[0][stage][style][data], g_iPreStrafeStage[1][stage][style][data], g_iPreStrafeStage[2][stage][style][data]); - SQL_TQuery(g_hDb, SQL_UpdateWrcpRecordCallback, szQuery, pack, DBPrio_Low); + g_hDb.Query(SQL_UpdateWrcpRecordCallback, szQuery, pack, DBPrio_Low); g_bStageSRVRecord[data][stage] = false; } @@ -6772,7 +6768,7 @@ public void db_updateWrcpRecord(int client, int style, int stage) Format(szQuery, sizeof(szQuery), "UPDATE ck_wrcps SET name = '%s', runtimepro = '%f', velStartXY = %i, velStartXYZ = %i, velStartZ = %i WHERE steamid = '%s' AND mapname = '%s' AND stage = %i AND style = 0;", szName, g_fFinalWrcpTime[client], g_iPreStrafeStage[0][stage][0][client], g_iPreStrafeStage[1][stage][0][client], g_iPreStrafeStage[2][stage][0][client], g_szSteamID[client], g_szMapName, stage); if (style > 0) Format(szQuery, sizeof(szQuery), "UPDATE ck_wrcps SET name = '%s', runtimepro = '%f', velStartXY = %i, velStartXYZ = %i, velStartZ = %i WHERE steamid = '%s' AND mapname = '%s' AND stage = %i AND style = %i;", szName, g_fFinalWrcpTime[client], g_iPreStrafeStage[0][stage][style][client], g_iPreStrafeStage[1][stage][style][client], g_iPreStrafeStage[2][stage][style][client], g_szSteamID[client], g_szMapName, stage, style); - SQL_TQuery(g_hDb, SQL_UpdateWrcpRecordCallback, szQuery, pack, DBPrio_Low); + g_hDb.Query(SQL_UpdateWrcpRecordCallback, szQuery, pack, DBPrio_Low); } @@ -6797,7 +6793,7 @@ public void SQL_UpdateWrcpRecordCallback(Handle owner, Handle hndl, const char[] else if (style != 0) Format(szQuery, 512, "SELECT count(runtimepro) FROM ck_wrcps WHERE mapname = '%s' AND runtimepro < %f AND stage = %i AND style = %i AND runtimepro > -1.0;", g_szMapName, stagetime, stage, style); - SQL_TQuery(g_hDb, SQL_UpdateWrcpRecordCallback2, szQuery, data, DBPrio_Low); + g_hDb.Query(SQL_UpdateWrcpRecordCallback2, szQuery, data, DBPrio_Low); } public void SQL_UpdateWrcpRecordCallback2(Handle owner, Handle hndl, const char[] error, any data) @@ -6867,12 +6863,12 @@ public void SQL_UpdateWrcpRecordCallback2(Handle owner, Handle hndl, const char[ Format(szDiff, 128, "%cPB: %c%s%c", WHITE, LIMEGREEN, g_szFinalWrcpTime[client], WHITE); } - if (g_fWrcpRecord[client][stage][style] != -1.0){ // Existing stage time - if (fDiff >= 0){ + if (g_fWrcpRecord[client][stage][style] != -1.0) { // Existing stage time + if (fDiff >= 0) { SetNewPersonalRecordPrestrafe(client, stage, style, false, false, true); } } - else{ + else { SetNewPersonalRecordPrestrafe(client, stage, style, false, false, true); } @@ -7053,7 +7049,7 @@ public void db_viewPersonalStageRecords(int client, char szSteamId[32]) char szQuery[1024]; Format(szQuery, 1024, "SELECT runtimepro, stage, style FROM ck_wrcps WHERE steamid = '%s' AND mapname = '%s' AND runtimepro > '0.0';", szSteamId, g_szMapName); - SQL_TQuery(g_hDb, SQL_selectPersonalStageRecordsCallback, szQuery, client, DBPrio_Low); + g_hDb.Query(SQL_selectPersonalStageRecordsCallback, szQuery, client, DBPrio_Low); } public void SQL_selectPersonalStageRecordsCallback(Handle owner, Handle hndl, const char[] error, any client) @@ -7124,7 +7120,7 @@ public void db_viewStageRanks(int client, int stage) // "SELECT name,mapname FROM ck_playertimes WHERE runtimepro <= (SELECT runtimepro FROM ck_playertimes WHERE steamid = '%s' AND mapname = '%s' AND runtimepro > -1.0) AND mapname = '%s' AND runtimepro > -1.0 ORDER BY runtimepro;"; // SELECT name FROM ck_bonus WHERE runtime <= (SELECT runtime FROM ck_bonus WHERE steamid = '%s' AND mapname= '%s' AND runtime > 0.0 AND zonegroup = %i) AND mapname = '%s' AND zonegroup = %i; Format(szQuery, 512, "SELECT COUNT(*) FROM ck_wrcps WHERE runtimepro <= (SELECT runtimepro FROM ck_wrcps WHERE steamid = '%s' AND mapname = '%s' AND runtimepro > -1.0 AND stage = %i AND style = 0) AND mapname = '%s' AND stage = %i AND style = 0 AND runtimepro > -1.0;", g_szSteamID[client], g_szMapName, stage, g_szMapName, stage); - SQL_TQuery(g_hDb, sql_viewStageRanksCallback, szQuery, pack, DBPrio_Low); + g_hDb.Query(sql_viewStageRanksCallback, szQuery, pack, DBPrio_Low); } public void sql_viewStageRanksCallback(Handle owner, Handle hndl, const char[] error, any pack) @@ -7146,17 +7142,17 @@ public void sql_viewStageRanksCallback(Handle owner, Handle hndl, const char[] e } } -public void db_viewPersonalPrestrafeSpeeds(int client, char szSteamId[32]){ +public void db_viewPersonalPrestrafeSpeeds(int client, char szSteamId[32]) { selectPersonalPrestrafeSpeeds_Map(client, szSteamId); } -public void selectPersonalPrestrafeSpeeds_Map(int client, char szSteamId[32]){ +public void selectPersonalPrestrafeSpeeds_Map(int client, char szSteamId[32]) { char szQuery[1024]; Format(szQuery, sizeof(szQuery), "SELECT style, velStartXY, velStartXYZ, velStartZ FROM ck_playertimes WHERE steamid = '%s' AND mapname = '%s' AND runtimepro > '0.0';", szSteamId, g_szMapName); - SQL_TQuery(g_hDb, SQL_selectPersonalPrestrafeSpeeds_MapCallback, szQuery, client, DBPrio_Low); + g_hDb.Query(SQL_selectPersonalPrestrafeSpeeds_MapCallback, szQuery, client, DBPrio_Low); } @@ -7226,11 +7222,11 @@ public void SQL_selectPersonalPrestrafeSpeeds_MapCallback(Handle owner, Handle h } -public void selectPersonalPrestrafeSpeeds_Stages(int client, char szSteamId[32]){ +public void selectPersonalPrestrafeSpeeds_Stages(int client, char szSteamId[32]) { char szQuery[1024]; Format(szQuery, sizeof(szQuery), "SELECT stage, style, velStartXY, velStartXYZ, velStartZ FROM ck_wrcps WHERE steamid = '%s' AND mapname = '%s' AND runtimepro > '0.0';", szSteamId, g_szMapName); - SQL_TQuery(g_hDb, SQL_selectPersonalPrestrafeSpeeds_StagesCallback, szQuery, client, DBPrio_Low); + g_hDb.Query(SQL_selectPersonalPrestrafeSpeeds_StagesCallback, szQuery, client, DBPrio_Low); } @@ -7239,7 +7235,7 @@ public void SQL_selectPersonalPrestrafeSpeeds_StagesCallback(Handle owner, Handl if (hndl == null) { LogError("[SurfTimer] SQL Error (SQL_selectPersonalPrestrafeSpeeds_StagesCallback): %s", error); - if(g_bhasBonus) + if (g_bhasBonus) selectPersonalPrestrafeSpeeds_Bonus(client, g_szSteamID[client]); else if (!g_bSettingsLoaded[client]) @@ -7280,9 +7276,9 @@ public void SQL_selectPersonalPrestrafeSpeeds_StagesCallback(Handle owner, Handl } } - if(g_bhasBonus) + if (g_bhasBonus) selectPersonalPrestrafeSpeeds_Bonus(client, g_szSteamID[client]); - else{ + else { if (!g_bSettingsLoaded[client]) { PrintToServer("[SurfTimer] : %s Finished db_viewPersonalPrestrafeSpeeds", g_szSteamID[client]); @@ -7291,11 +7287,11 @@ public void SQL_selectPersonalPrestrafeSpeeds_StagesCallback(Handle owner, Handl } } -public void selectPersonalPrestrafeSpeeds_Bonus(int client, char szSteamId[32]){ +public void selectPersonalPrestrafeSpeeds_Bonus(int client, char szSteamId[32]) { char szQuery[1024]; Format(szQuery, sizeof(szQuery), "SELECT zonegroup, style, velStartXY, velStartXYZ, velStartZ FROM ck_bonus WHERE steamid = '%s' AND mapname = '%s' AND runtime > '0.0';", szSteamId, g_szMapName); - SQL_TQuery(g_hDb, SQL_selectPersonalPrestrafeSpeeds_BonusCallback, szQuery, client, DBPrio_Low); + g_hDb.Query(SQL_selectPersonalPrestrafeSpeeds_BonusCallback, szQuery, client, DBPrio_Low); } @@ -7362,7 +7358,7 @@ public void db_GetTotalStages() char szQuery[512]; Format(szQuery, 512, "SELECT COUNT(`zonetype`) AS stages FROM `ck_zones` WHERE `zonetype` = '3' AND `mapname` = '%s'", g_szMapName); - SQL_TQuery(g_hDb, db_GetTotalStagesCallback, szQuery, GetGameTime(), DBPrio_Low); + g_hDb.Query(db_GetTotalStagesCallback, szQuery, GetGameTime(), DBPrio_Low); } public void db_GetTotalStagesCallback(Handle owner, Handle hndl, const char[] error, float time) @@ -7398,7 +7394,7 @@ public void db_viewWrcpMap(int client, char mapname[128]) Handle pack = CreateDataPack(); WritePackCell(pack, client); WritePackString(pack, mapname); - SQL_TQuery(g_hDb, sql_viewWrcpMapCallback, szQuery, pack, DBPrio_Low); + g_hDb.Query(sql_viewWrcpMapCallback, szQuery, pack, DBPrio_Low); } public void sql_viewWrcpMapCallback(Handle owner, Handle hndl, const char[] error, any pack) @@ -7449,7 +7445,7 @@ public void sql_viewWrcpMapCallback(Handle owner, Handle hndl, const char[] erro /*// Find out how many times are are faster than the players time char szQuery[512]; Format(szQuery, 512, "", g_szMapName, g_CurrentStage[data], stagetime); - SQL_TQuery(g_hDb, sql_viewWrcpMapCallback, szQuery, client, DBPrio_Low);*/ + g_hDb.Query(sql_viewWrcpMapCallback, szQuery, client, DBPrio_Low);*/ } } } @@ -7459,7 +7455,7 @@ public void db_viewWrcpMapRecord(int client) char szQuery[1024]; Format(szQuery, 512, "SELECT name, MIN(runtimepro) FROM ck_wrcps WHERE mapname = '%s' AND runtimepro > -1.0 AND stage = %s AND style = 0;", g_szMapName, g_szWrcpMapSelect[client]); - SQL_TQuery(g_hDb, sql_viewWrcpMapRecordCallback, szQuery, client, DBPrio_Low); + g_hDb.Query(sql_viewWrcpMapRecordCallback, szQuery, client, DBPrio_Low); } public void sql_viewWrcpMapRecordCallback(Handle owner, Handle hndl, const char[] error, any client) @@ -7504,7 +7500,7 @@ public void db_selectStageTopSurfers(int client, char info[32], char mapname[128 // WritePackCell(pack, stage); WritePackString(pack, info); WritePackString(pack, mapname); - SQL_TQuery(g_hDb, sql_selectStageTopSurfersCallback, szQuery, pack, DBPrio_Low); + g_hDb.Query(sql_selectStageTopSurfersCallback, szQuery, pack, DBPrio_Low); } public void sql_selectStageTopSurfersCallback(Handle owner, Handle hndl, const char[] error, any pack) @@ -7598,7 +7594,7 @@ public void db_viewStageRecords() { char szQuery[512]; Format(szQuery, 512, "SELECT cp1.name, cp1.runtimepro, cp1.stage, cp1.style, cp1.velStartXY, cp1.velStartXYZ, cp1.velstartZ FROM ck_wrcps cp1 JOIN ( SELECT MIN(runtimepro) AS min_runtime, stage, style, mapname FROM ck_wrcps GROUP BY stage, mapname, style ) AS cp2 ON cp1.stage = cp2.stage AND cp1.runtimepro = cp2.min_runtime AND cp1.mapname=cp2.mapname AND cp1.style=cp2.style WHERE cp1.mapname='%s'", g_szMapName); - SQL_TQuery(g_hDb, sql_viewStageRecordsCallback, szQuery, GetGameTime(), DBPrio_Low); + g_hDb.Query(sql_viewStageRecordsCallback, szQuery, GetGameTime(), DBPrio_Low); } public void sql_viewStageRecordsCallback(Handle owner, Handle hndl, const char[] error, float time) @@ -7694,7 +7690,7 @@ public void db_viewTotalStageRecords() { char szQuery[512]; Format(szQuery, 512, "SELECT stage, style, count(1) FROM ck_wrcps WHERE mapname = '%s' GROUP BY stage, style;", g_szMapName); - SQL_TQuery(g_hDb, sql_viewTotalStageRecordsCallback, szQuery, GetGameTime(), DBPrio_Low); + g_hDb.Query(sql_viewTotalStageRecordsCallback, szQuery, GetGameTime(), DBPrio_Low); } public void sql_viewTotalStageRecordsCallback(Handle owner, Handle hndl, const char[] error, float time) @@ -7778,7 +7774,7 @@ public void db_selectPersonalStyleRecord(int client, int style) char szQuery[255]; Format(szQuery, 255, "SELECT runtimepro FROM `ck_playertimes` WHERE `steamid` = '%s' AND `mapname` = '%s' AND `style` = %i AND `runtimepro` > -1.0", g_szSteamID[client], g_szMapName, style); - SQL_TQuery(g_hDb, sql_selectPersonalStyleRecordCallback, szQuery, stylepack, DBPrio_Low); + g_hDb.Query(sql_selectPersonalStyleRecordCallback, szQuery, stylepack, DBPrio_Low); } public void sql_selectPersonalStyleRecordCallback(Handle owner, Handle hndl, const char[] error, any stylepack) @@ -7827,7 +7823,7 @@ public void sql_selectPersonalStyleRecordCallback(Handle owner, Handle hndl, con g_StyleMapTimesCount[style]++; Format(szQuery, 512, "INSERT INTO ck_playertimes (steamid, mapname, name, runtimepro, style, velStartXY, velStartXYZ, velStartZ) VALUES ('%s', '%s', '%s', '%f', %i, %i, %i, %i)", g_szSteamID[data], g_szMapName, szName, g_fFinalTime[data], style, g_iPreStrafe[0][0][style], g_iPreStrafe[1][0][style], g_iPreStrafe[2][0][style]); - SQL_TQuery(g_hDb, SQL_UpdatePersonalStyleRecordCallback, szQuery, pack, DBPrio_Low); + g_hDb.Query(SQL_UpdatePersonalStyleRecordCallback, szQuery, pack, DBPrio_Low); } } @@ -7854,7 +7850,7 @@ public void db_updatePersonalStyleRecord(int client, int style) char szQuery[1024]; // "UPDATE ck_playertimes SET name = '%s', runtimepro = '%f' WHERE steamid = '%s' AND mapname = '%s';"; Format(szQuery, 1024, "UPDATE `ck_playertimes` SET `name` = '%s', runtimepro = '%f', `velStartXY` = %i, `velStartXYZ` = %i, `velStartZ` = %i WHERE `steamid` = '%s' AND `mapname` = '%s' AND `style` = %i;", szName, g_fFinalTime[client], g_iPreStrafe[0][0][style], g_iPreStrafe[1][0][style], g_iPreStrafe[2][0][style], g_szSteamID[client], g_szMapName, style); - SQL_TQuery(g_hDb, SQL_UpdatePersonalStyleRecordCallback, szQuery, pack, DBPrio_Low); + g_hDb.Query(SQL_UpdatePersonalStyleRecordCallback, szQuery, pack, DBPrio_Low); } public void SQL_UpdatePersonalStyleRecordCallback(Handle owner, Handle hndl, const char[] error, any pack) @@ -7878,7 +7874,7 @@ public void SQL_UpdatePersonalStyleRecordCallback(Handle owner, Handle hndl, con // Find out how many times are are faster than the players time char szQuery[512]; Format(szQuery, 512, "SELECT count(runtimepro) FROM `ck_playertimes` WHERE `mapname` = '%s' AND `style` = %i AND `runtimepro` < %f;", g_szMapName, style, time); - SQL_TQuery(g_hDb, SQL_UpdatePersonalStyleRecordCallback2, szQuery, data, DBPrio_Low); + g_hDb.Query(SQL_UpdatePersonalStyleRecordCallback2, szQuery, data, DBPrio_Low); } public void SQL_UpdatePersonalStyleRecordCallback2(Handle owner, Handle hndl, const char[] error, any pack) @@ -7909,7 +7905,7 @@ public void db_GetStyleMapRecord_Pro(int style) g_fRecordStyleMapTime[style] = 9999999.0; char szQuery[512]; Format(szQuery, 512, "SELECT MIN(runtimepro), name, steamid FROM ck_playertimes WHERE mapname = '%s' AND style = %i AND runtimepro > -1.0", g_szMapName, style); - SQL_TQuery(g_hDb, sql_selectStyleMapRecordCallback, szQuery, style, DBPrio_Low); + g_hDb.Query(sql_selectStyleMapRecordCallback, szQuery, style, DBPrio_Low); } public void sql_selectStyleMapRecordCallback(Handle owner, Handle hndl, const char[] error, int style) @@ -7949,7 +7945,7 @@ public void db_viewStyleMapRankCount(int style) g_StyleMapTimesCount[style] = 0; char szQuery[512]; Format(szQuery, 512, "SELECT name FROM ck_playertimes WHERE mapname = '%s' AND style = %i AND runtimepro > -1.0;", g_szMapName, style); - SQL_TQuery(g_hDb, sql_selectStylePlayerCountCallback, szQuery, style, DBPrio_Low); + g_hDb.Query(sql_selectStylePlayerCountCallback, szQuery, style, DBPrio_Low); } public void sql_selectStylePlayerCountCallback(Handle owner, Handle hndl, const char[] error, int style) @@ -7979,7 +7975,7 @@ public void db_viewStyleMapRank(int client, int style) WritePackCell(data, style); Format(szQuery, 512, "SELECT COUNT(*) FROM ck_playertimes WHERE runtimepro <= (SELECT runtimepro FROM ck_playertimes WHERE steamid = '%s' AND mapname = '%s' AND style = %i AND runtimepro > -1.0) AND mapname = '%s' AND style = %i AND runtimepro > -1.0;", g_szSteamID[client], g_szMapName, style, g_szMapName, style); - SQL_TQuery(g_hDb, db_viewStyleMapRankCallback, szQuery, data, DBPrio_Low); + g_hDb.Query(db_viewStyleMapRankCallback, szQuery, data, DBPrio_Low); } public void db_viewStyleMapRankCallback(Handle owner, Handle hndl, const char[] error, any data) @@ -8011,7 +8007,7 @@ public void db_selectStyleMapTopSurfers(int client, char mapname[128], int style WritePackCell(pack, client); WritePackString(pack, mapname); WritePackCell(pack, style); - SQL_TQuery(g_hDb, sql_selectTopSurfersCallback, szQuery, pack, DBPrio_Low); + g_hDb.Query(sql_selectTopSurfersCallback, szQuery, pack, DBPrio_Low); } // Styles for bonuses @@ -8028,7 +8024,7 @@ public void db_insertBonusStyle(int client, char szSteamId[32], char szUName[128 WritePackCell(pack, zoneGrp); WritePackCell(pack, style); Format(szQuery, 1024, "INSERT INTO ck_bonus (steamid, name, mapname, runtime, zonegroup, style, velStartXY, velStartXYZ, velStartZ) VALUES ('%s', '%s', '%s', '%f', '%i', '%i', '%i', '%i', '%i')", szSteamId, szName, g_szMapName, FinalTime, zoneGrp, style, g_iPreStrafeBonus[0][zoneGrp][style][client], g_iPreStrafeBonus[1][zoneGrp][style][client], g_iPreStrafeBonus[2][zoneGrp][style][client]); - SQL_TQuery(g_hDb, SQL_insertBonusStyleCallback, szQuery, pack, DBPrio_Low); + g_hDb.Query(SQL_insertBonusStyleCallback, szQuery, pack, DBPrio_Low); } public void SQL_insertBonusStyleCallback(Handle owner, Handle hndl, const char[] error, any data) @@ -8060,7 +8056,7 @@ public void db_viewMapRankBonusStyle(int client, int zgroup, int type, int style WritePackCell(pack, style); Format(szQuery, 1024, "SELECT name FROM ck_bonus WHERE runtime <= (SELECT runtime FROM ck_bonus WHERE steamid = '%s' AND mapname= '%s' AND style = %i AND runtime > 0.0 AND zonegroup = %i) AND mapname = '%s' AND style = %i AND zonegroup = %i;", g_szSteamID[client], g_szMapName, style, zgroup, g_szMapName, style, zgroup); - SQL_TQuery(g_hDb, db_viewMapRankBonusStyleCallback, szQuery, pack, DBPrio_Low); + g_hDb.Query(db_viewMapRankBonusStyleCallback, szQuery, pack, DBPrio_Low); } public void db_viewMapRankBonusStyleCallback(Handle owner, Handle hndl, const char[] error, any data) @@ -8114,7 +8110,7 @@ public void db_updateBonusStyle(int client, char szSteamId[32], char szUName[128 WritePackCell(datapack, style); SQL_EscapeString(g_hDb, szUName, szName, MAX_NAME_LENGTH * 2 + 1); Format(szQuery, 1024, "UPDATE ck_bonus SET runtime = '%f', name = '%s', velStartXY = %i, velStartXYZ = %i, velStartZ = %i WHERE steamid = '%s' AND mapname = '%s' AND zonegroup = %i AND style = %i;", FinalTime, szName, g_iPreStrafeBonus[0][zoneGrp][style][client], g_iPreStrafeBonus[1][zoneGrp][style][client], g_iPreStrafeBonus[2][zoneGrp][style][client], szSteamId, g_szMapName, zoneGrp, style); - SQL_TQuery(g_hDb, SQL_updateBonusStyleCallback, szQuery, datapack, DBPrio_Low); + g_hDb.Query(SQL_updateBonusStyleCallback, szQuery, datapack, DBPrio_Low); } @@ -8143,7 +8139,7 @@ public void db_currentBonusStyleRunRank(int client, int zGroup, int style) WritePackCell(pack, zGroup); WritePackCell(pack, style); Format(szQuery, 512, "SELECT count(runtime)+1 FROM ck_bonus WHERE mapname = '%s' AND zonegroup = '%i' AND style = '%i' AND runtime < %f", g_szMapName, zGroup, style, g_fFinalTime[client]); - SQL_TQuery(g_hDb, db_viewBonusStyleRunRank, szQuery, pack, DBPrio_Low); + g_hDb.Query(db_viewBonusStyleRunRank, szQuery, pack, DBPrio_Low); } public void db_viewBonusStyleRunRank(Handle owner, Handle hndl, const char[] error, any pack) @@ -8178,7 +8174,7 @@ public void db_viewPersonalBonusStylesRecords(int client, char szSteamId[32], in char szQuery[1024]; // "SELECT runtime, zonegroup FROM ck_bonus WHERE steamid = '%s' AND mapname = '%s' AND runtime > '0.0'"; Format(szQuery, 1024, "SELECT runtime, zonegroup FROM ck_bonus WHERE steamid = '%s' AND mapname = '%s' AND style = '%i' AND runtime > '0.0'", szSteamId, g_szMapName, style); - SQL_TQuery(g_hDb, SQL_selectPersonalBonusStylesRecordsCallback, szQuery, pack, DBPrio_Low); + g_hDb.Query(SQL_selectPersonalBonusStylesRecordsCallback, szQuery, pack, DBPrio_Low); } public void SQL_selectPersonalBonusStylesRecordsCallback(Handle owner, Handle hndl, const char[] error, any pack) @@ -8256,7 +8252,7 @@ public void db_viewStyleStageRanks(int client, int stage, int style) WritePackCell(pack, style); Format(szQuery, 512, "SELECT COUNT(*) FROM ck_wrcps WHERE runtimepro <= (SELECT runtimepro FROM ck_wrcps WHERE steamid = '%s' AND mapname = '%s' AND stage = %i AND style = %i AND runtimepro > -1.0) AND mapname = '%s' AND stage = %i AND style = %i AND runtimepro > -1.0;", g_szSteamID[client], g_szMapName, stage, style, g_szMapName, stage, style); - SQL_TQuery(g_hDb, sql_viewStyleStageRanksCallback, szQuery, pack, DBPrio_Low); + g_hDb.Query(sql_viewStyleStageRanksCallback, szQuery, pack, DBPrio_Low); } public void sql_viewStyleStageRanksCallback(Handle owner, Handle hndl, const char[] error, any pack) @@ -8288,7 +8284,7 @@ public void db_viewWrcpStyleMapRecord(int client, int style) WritePackCell(pack, client); WritePackCell(pack, style); - SQL_TQuery(g_hDb, sql_viewWrcpStyleMapRecordCallback, szQuery, pack, DBPrio_Low); + g_hDb.Query(sql_viewWrcpStyleMapRecordCallback, szQuery, pack, DBPrio_Low); } public void sql_viewWrcpStyleMapRecordCallback(Handle owner, Handle hndl, const char[] error, any pack) @@ -8331,7 +8327,7 @@ public void db_viewStyleWrcpMap(int client, char mapname[128], int style) WritePackCell(pack, client); WritePackCell(pack, style); WritePackString(pack, mapname); - SQL_TQuery(g_hDb, sql_viewStyleWrcpMapCallback, szQuery, pack, DBPrio_Low); + g_hDb.Query(sql_viewStyleWrcpMapCallback, szQuery, pack, DBPrio_Low); } public void sql_viewStyleWrcpMapCallback(Handle owner, Handle hndl, const char[] error, any pack) @@ -8396,7 +8392,7 @@ public void db_selectStageStyleTopSurfers(int client, char info[32], char mapnam // WritePackCell(pack, stage); WritePackString(pack, info); WritePackString(pack, mapname); - SQL_TQuery(g_hDb, sql_selectStageStyleTopSurfersCallback, szQuery, pack, DBPrio_Low); + g_hDb.Query(sql_selectStageStyleTopSurfersCallback, szQuery, pack, DBPrio_Low); } public void sql_selectStageStyleTopSurfersCallback(Handle owner, Handle hndl, const char[] error, any pack) @@ -8493,7 +8489,7 @@ public void db_selectMapRank(int client, char szSteamId[32], char szMapName[128] Format(szQuery, 1024, "SELECT `steamid`, `name`, `mapname`, `runtimepro` FROM `ck_playertimes` WHERE `steamid` = '%s' AND `mapname` = '%s' AND style = 0 LIMIT 1;", szSteamId, szMapName); else Format(szQuery, 1024, "SELECT `steamid`, `name`, `mapname`, `runtimepro` FROM `ck_playertimes` WHERE `steamid` = '%s' AND `mapname` LIKE '%c%s%c' AND style = 0 LIMIT 1;", szSteamId, PERCENT, szMapName, PERCENT); - SQL_TQuery(g_hDb, db_selectMapRankCallback, szQuery, client, DBPrio_Low); + g_hDb.Query(db_selectMapRankCallback, szQuery, client, DBPrio_Low); } public void db_selectMapRankCallback(Handle owner, Handle hndl, const char[] error, any client) @@ -8527,7 +8523,7 @@ public void db_selectMapRankCallback(Handle owner, Handle hndl, const char[] err char szQuery[1024]; Format(szQuery, 1024, "SELECT count(name) FROM `ck_playertimes` WHERE `mapname` = '%s' AND style = 0;", mapname); - SQL_TQuery(g_hDb, db_SelectTotalMapCompletesCallback, szQuery, pack, DBPrio_Low); + g_hDb.Query(db_SelectTotalMapCompletesCallback, szQuery, pack, DBPrio_Low); } else { @@ -8560,7 +8556,7 @@ public void db_SelectTotalMapCompletesCallback(Handle owner, Handle hndl, const char szQuery[1024]; Format(szQuery, 1024, "SELECT name,mapname FROM ck_playertimes WHERE runtimepro <= (SELECT runtimepro FROM ck_playertimes WHERE steamid = '%s' AND mapname = '%s' AND runtimepro > -1.0 AND style = 0) AND mapname = '%s' AND style = 0 AND runtimepro > -1.0 ORDER BY runtimepro;", szSteamId, mapname, mapname); - SQL_TQuery(g_hDb, db_SelectPlayersMapRankCallback, szQuery, pack, DBPrio_Low); + g_hDb.Query(db_SelectPlayersMapRankCallback, szQuery, pack, DBPrio_Low); } else { @@ -8633,7 +8629,7 @@ public void db_selectMapRankUnknown(int client, char szMapName[128], int rank) rank = rank - 1; Format(szQuery, 1024, "SELECT `steamid`, `name`, `mapname`, `runtimepro` FROM `ck_playertimes` WHERE `mapname` LIKE '%c%s%c' AND style = 0 ORDER BY `runtimepro` ASC LIMIT %i, 1;", PERCENT, szMapName, PERCENT, rank); - SQL_TQuery(g_hDb, db_selectMapRankUnknownCallback, szQuery, pack, DBPrio_Low); + g_hDb.Query(db_selectMapRankUnknownCallback, szQuery, pack, DBPrio_Low); } // sm_mrank @x command without map parameter (current mapname being used) @@ -8646,7 +8642,7 @@ public void db_selectMapRankUnknownWithMap(int client, char szMapName[128], int rank = Math_Min(rank - 1, 0); Format(szQuery, 1024, sql_selectMapRankUnknownWithMap, szMapName, rank); - SQL_TQuery(g_hDb, db_selectMapRankUnknownCallback, szQuery, pack, DBPrio_Low); + g_hDb.Query(db_selectMapRankUnknownCallback, szQuery, pack, DBPrio_Low); } public void db_selectMapRankUnknownCallback(Handle owner, Handle hndl, const char[] error, any data) @@ -8686,7 +8682,7 @@ public void db_selectMapRankUnknownCallback(Handle owner, Handle hndl, const cha char szQuery[1024]; Format(szQuery, 1024, "SELECT count(name) FROM `ck_playertimes` WHERE `mapname` = '%s' AND style = 0;", mapname); - SQL_TQuery(g_hDb, db_SelectTotalMapCompletesUnknownCallback, szQuery, pack, DBPrio_Low); + g_hDb.Query(db_SelectTotalMapCompletesUnknownCallback, szQuery, pack, DBPrio_Low); } else { @@ -8753,7 +8749,7 @@ public void db_selectBonusRank(int client, char szSteamId[32], char szMapName[12 { char szQuery[1024]; Format(szQuery, 1024, "SELECT `steamid`, `name`, `mapname`, `runtime`, zonegroup FROM `ck_bonus` WHERE `steamid` = '%s' AND `mapname` LIKE '%c%s%c' AND zonegroup = %i AND style = 0 LIMIT 1;", szSteamId, PERCENT, szMapName, PERCENT, bonus); - SQL_TQuery(g_hDb, db_selectBonusRankCallback, szQuery, client, DBPrio_Low); + g_hDb.Query(db_selectBonusRankCallback, szQuery, client, DBPrio_Low); } public void db_selectBonusRankCallback(Handle owner, Handle hndl, const char[] error, any client) @@ -8790,7 +8786,7 @@ public void db_selectBonusRankCallback(Handle owner, Handle hndl, const char[] e char szQuery[1024]; Format(szQuery, 1024, "SELECT count(name) FROM `ck_bonus` WHERE `mapname` = '%s' AND zonegroup = %i AND style = 0 AND runtime > 0.0;", mapname, bonus); - SQL_TQuery(g_hDb, db_SelectTotalBonusCompletesCallback, szQuery, pack, DBPrio_Low); + g_hDb.Query(db_SelectTotalBonusCompletesCallback, szQuery, pack, DBPrio_Low); } else { @@ -8824,7 +8820,7 @@ public void db_SelectTotalBonusCompletesCallback(Handle owner, Handle hndl, cons char szQuery[1024]; Format(szQuery, 1024, "SELECT name,mapname FROM ck_bonus WHERE runtime <= (SELECT runtime FROM ck_bonus WHERE steamid = '%s' AND mapname = '%s' AND zonegroup = %i AND style = 0 AND runtime > -1.0) AND mapname = '%s' AND zonegroup = %i AND runtime > -1.0 ORDER BY runtime;", szSteamId, mapname, bonus, mapname, bonus); - SQL_TQuery(g_hDb, db_SelectPlayersBonusRankCallback, szQuery, pack, DBPrio_Low); + g_hDb.Query(db_SelectPlayersBonusRankCallback, szQuery, pack, DBPrio_Low); } else { @@ -8869,7 +8865,7 @@ public void db_selectMapRecordTime(int client, char szMapName[128]) WritePackString(pack, szMapName); Format(szQuery, 1024, "SELECT db1.runtimepro, IFNULL(db1.mapname, 'NULL'), db2.name, db1.steamid FROM ck_playertimes db1 INNER JOIN ck_playerrank db2 ON db1.steamid = db2.steamid WHERE mapname LIKE '%c%s%c' AND runtimepro > -1.0 AND db1.style = 0 AND db2.style = 0 ORDER BY runtimepro ASC LIMIT 1", PERCENT, szMapName, PERCENT); - SQL_TQuery(g_hDb, db_selectMapRecordTimeCallback, szQuery, pack, DBPrio_Low); + g_hDb.Query(db_selectMapRecordTimeCallback, szQuery, pack, DBPrio_Low); } public void db_selectMapRecordTimeCallback(Handle owner, Handle hndl, const char[] error, any pack) @@ -8929,7 +8925,7 @@ public void db_selectPlayerRank(int client, int rank, char szSteamId[32]) Format(szQuery, 1024, "SELECT `name`, `points` FROM `ck_playerrank` WHERE `steamid` = '%s' AND `style` = 0;", szSteamId); } - SQL_TQuery(g_hDb, db_selectPlayerRankCallback, szQuery, client, DBPrio_Low); + g_hDb.Query(db_selectPlayerRankCallback, szQuery, client, DBPrio_Low); } public void db_selectPlayerRankCallback(Handle owner, Handle hndl, const char[] error, any client) @@ -8970,7 +8966,7 @@ public void db_selectPlayerRankUnknown(int client, char szName[128]) SQL_EscapeString(g_hDb, szName, szNameE, MAX_NAME_LENGTH * 2 + 1); Format(szQuery, 1024, "SELECT `steamid`, `name`, `points` FROM `ck_playerrank` WHERE `name` LIKE '%c%s%c' ORDER BY `points` DESC LIMIT 0, 1;", PERCENT, szNameE, PERCENT); - SQL_TQuery(g_hDb, db_selectPlayerRankUnknownCallback, szQuery, client, DBPrio_Low); + g_hDb.Query(db_selectPlayerRankUnknownCallback, szQuery, client, DBPrio_Low); } public void db_selectPlayerRankUnknownCallback(Handle owner, Handle hndl, const char[] error, any client) @@ -9000,7 +8996,7 @@ public void db_selectPlayerRankUnknownCallback(Handle owner, Handle hndl, const char szQuery[1024]; // "SELECT name FROM ck_playerrank WHERE points >= (SELECT points FROM ck_playerrank WHERE steamid = '%s') ORDER BY points"; Format(szQuery, 512, sql_selectRankedPlayersRank, 0, szSteamId, 0); - SQL_TQuery(g_hDb, db_getPlayerRankUnknownCallback, szQuery, pack, DBPrio_Low); + g_hDb.Query(db_getPlayerRankUnknownCallback, szQuery, pack, DBPrio_Low); } else CPrintToChat(client, "%t", "SQLTwo7", g_szChatPrefix); @@ -9038,7 +9034,7 @@ public void db_selectMapImprovement(int client, char szMapName[128]) char szQuery[1024]; Format(szQuery, 1024, "SELECT mapname, (SELECT count(1) FROM ck_playertimes b WHERE a.mapname = b.mapname AND b.style = 0) as total, (SELECT tier FROM ck_maptier b WHERE a.mapname = b.mapname) as tier FROM ck_playertimes a where mapname LIKE '%c%s%c' AND style = 0 LIMIT 1;", PERCENT, szMapName, PERCENT); - SQL_TQuery(g_hDb, db_selectMapImprovementCallback, szQuery, client, DBPrio_Low); + g_hDb.Query(db_selectMapImprovementCallback, szQuery, client, DBPrio_Low); } public void db_selectMapImprovementCallback(Handle owner, Handle hndl, const char[] error, any client) @@ -9333,7 +9329,7 @@ public void db_selectCurrentMapImprovement() { char szQuery[1024]; Format(szQuery, 1024, "SELECT mapname, (SELECT count(1) FROM ck_playertimes b WHERE a.mapname = b.mapname AND b.style = 0) as total FROM ck_playertimes a where mapname = '%s' AND style = 0 LIMIT 0, 1;", g_szMapName); - SQL_TQuery(g_hDb, db_selectMapCurrentImprovementCallback, szQuery, GetGameTime(), DBPrio_Low); + g_hDb.Query(db_selectMapCurrentImprovementCallback, szQuery, GetGameTime(), DBPrio_Low); } public void db_selectMapCurrentImprovementCallback(Handle owner, Handle hndl, const char[] error, float time) @@ -9452,7 +9448,7 @@ public void db_selectMapNameEquals(int client, char[] szMapName, int style) WritePackCell(pack, style); WritePackString(pack, szMapName); - SQL_TQuery(g_hDb, sql_selectMapNameEqualsCallback, szQuery, pack, DBPrio_Low); + g_hDb.Query(sql_selectMapNameEqualsCallback, szQuery, pack, DBPrio_Low); } public void sql_selectMapNameEqualsCallback(Handle owner, Handle hndl, const char[] error, any pack) @@ -9489,7 +9485,7 @@ public void sql_selectMapNameEqualsCallback(Handle owner, Handle hndl, const cha Format(g_szMapNameFromDatabase[client], sizeof(g_szMapNameFromDatabase), "invalid"); char szQuery[256]; Format(szQuery, sizeof(szQuery), "SELECT DISTINCT mapname FROM ck_zones WHERE mapname LIKE '%c%s%c';", PERCENT, szMapName, PERCENT); - SQL_TQuery(g_hDb, sql_selectMapNameLikeCallback, szQuery, pack, DBPrio_Low); + g_hDb.Query(sql_selectMapNameLikeCallback, szQuery, pack, DBPrio_Low); } } @@ -9595,12 +9591,12 @@ public void db_viewPlayerPr(int client, char szSteamId[32], char szMapName[128]) WritePackCell(pack, g_mapZoneGroupCount); // first select map time Format(szQuery, 1024, "SELECT steamid, name, mapname, runtimepro, (select count(name) FROM ck_playertimes WHERE mapname = '%s' AND style = 0) as total FROM ck_playertimes WHERE runtimepro <= (SELECT runtimepro FROM ck_playertimes WHERE steamid = '%s' AND mapname = '%s' AND runtimepro > -1.0 AND style = 0) AND mapname = '%s' AND runtimepro > -1.0 AND style = 0 ORDER BY runtimepro;", szMapName, szSteamId, szMapName, szMapName); - SQL_TQuery(g_hDb, SQL_ViewPlayerPrMaptimeCallback, szQuery, pack, DBPrio_Low); + g_hDb.Query(SQL_ViewPlayerPrMaptimeCallback, szQuery, pack, DBPrio_Low); } else { Format(szQuery, 1024, "SELECT mapname FROM ck_maptier WHERE mapname LIKE '%c%s%c' LIMIT 1;", PERCENT, szMapName, PERCENT); - SQL_TQuery(g_hDb, SQL_ViewMapNamePrCallback, szQuery, pack, DBPrio_Low); + g_hDb.Query(SQL_ViewMapNamePrCallback, szQuery, pack, DBPrio_Low); } } @@ -9627,7 +9623,7 @@ public void SQL_ViewMapNamePrCallback(Handle owner, Handle hndl, const char[] er char szQuery[1024]; Format(szQuery, 1024, "SELECT mapname, (SELECT COUNT(1) FROM ck_zones WHERE zonetype = '3' AND mapname = '%s') AS stages, (SELECT COUNT(DISTINCT zonegroup) FROM ck_zones WHERE mapname = '%s' AND zonegroup > 0) AS bonuses FROM ck_maptier WHERE mapname = '%s';", szMapName, szMapName, szMapName); - SQL_TQuery(g_hDb, SQL_ViewPlayerPrMapInfoCallback, szQuery, pack, DBPrio_Low); + g_hDb.Query(SQL_ViewPlayerPrMapInfoCallback, szQuery, pack, DBPrio_Low); } } @@ -9660,7 +9656,7 @@ public void SQL_ViewPlayerPrMapInfoCallback(Handle owner, Handle hndl, const cha char szQuery[1024]; Format(szQuery, 1024, "SELECT steamid, name, mapname, runtimepro, (select count(name) FROM ck_playertimes WHERE mapname = '%s' AND style = 0) as total FROM ck_playertimes WHERE runtimepro <= (SELECT runtimepro FROM ck_playertimes WHERE steamid = '%s' AND mapname = '%s' AND runtimepro > -1.0 AND style = 0) AND mapname = '%s' AND runtimepro > -1.0 AND style = 0 ORDER BY runtimepro;", szMapName, szSteamId, szMapName, szMapName); - SQL_TQuery(g_hDb, SQL_ViewPlayerPrMaptimeCallback, szQuery, pack, DBPrio_Low); + g_hDb.Query(SQL_ViewPlayerPrMaptimeCallback, szQuery, pack, DBPrio_Low); } } @@ -9718,7 +9714,7 @@ public void SQL_ViewPlayerPrMaptimeCallback(Handle owner, Handle hndl, const cha char szQuery[1024]; Format(szQuery, 1024, "SELECT db1.steamid, db1.name, db1.mapname, db1.runtimepro, db1.stage, (SELECT count(name) FROM ck_wrcps WHERE style = 0 AND mapname = db1.mapname AND stage = db1.stage AND runtimepro > -1.0 AND runtimepro <= db1.runtimepro) AS `rank`, (SELECT count(name) FROM ck_wrcps WHERE style = 0 AND mapname = db1.mapname AND stage = db1.stage AND runtimepro > -1.0) AS total FROM ck_wrcps db1 WHERE db1.mapname = '%s' AND db1.steamid = '%s' AND db1.runtimepro > -1.0 AND db1.style = 0 ORDER BY stage ASC", szMapName, szSteamId); - SQL_TQuery(g_hDb, SQL_ViewPlayerPrMaptimeCallback2, szQuery, pack, DBPrio_Low); + g_hDb.Query(SQL_ViewPlayerPrMaptimeCallback2, szQuery, pack, DBPrio_Low); } public void SQL_ViewPlayerPrMaptimeCallback2(Handle owner, Handle hndl, const char[] error, any pack) @@ -9854,7 +9850,7 @@ public void db_CheckVIPAdmin(int client, char[] szSteamID) { char szQuery[1024]; Format(szQuery, 1024, "SELECT vip, admin, zoner FROM ck_vipadmins WHERE steamid = '%s';", szSteamID); - SQL_TQuery(g_hDb, SQL_CheckVIPAdminCallback, szQuery, client, DBPrio_Low); + g_hDb.Query(SQL_CheckVIPAdminCallback, szQuery, client, DBPrio_Low); } public void SQL_CheckVIPAdminCallback(Handle owner, Handle hndl, const char[] error, any client) @@ -9926,7 +9922,7 @@ public void db_checkCustomPlayerTitle(int client, char[] arg) char szQuery[512]; Format(szQuery, 512, "SELECT `steamid` FROM `ck_vipadmins` WHERE `steamid` = '%s';", g_szSteamID[client]); - SQL_TQuery(g_hDb, SQL_checkCustomPlayerTitleCallback, szQuery, pack, DBPrio_Low); + g_hDb.Query(SQL_checkCustomPlayerTitleCallback, szQuery, pack, DBPrio_Low); } @@ -9961,7 +9957,7 @@ public void db_checkCustomPlayerNameColour(int client, char[] arg) char szQuery[512]; Format(szQuery, 512, "SELECT `steamid` FROM `ck_vipadmins` WHERE `steamid` = '%s';", g_szSteamID[client]); - SQL_TQuery(g_hDb, SQL_checkCustomPlayerNameColourCallback, szQuery, pack, DBPrio_Low); + g_hDb.Query(SQL_checkCustomPlayerNameColourCallback, szQuery, pack, DBPrio_Low); } @@ -9994,7 +9990,7 @@ public void db_checkCustomPlayerTextColour(int client, char[] arg) char szQuery[512]; Format(szQuery, 512, "SELECT `steamid` FROM `ck_vipadmins` WHERE `steamid` = '%s';", g_szSteamID[client]); - SQL_TQuery(g_hDb, SQL_checkCustomPlayerTextColourCallback, szQuery, pack, DBPrio_Low); + g_hDb.Query(SQL_checkCustomPlayerTextColourCallback, szQuery, pack, DBPrio_Low); } @@ -10029,7 +10025,7 @@ public void db_insertCustomPlayerTitle(int client, char[] arg) char szQuery[512]; Format(szQuery, 512, "INSERT INTO `ck_vipadmins` (steamid, title, inuse) VALUES ('%s', '%s', 1);", g_szSteamID[client], new_arg); - SQL_TQuery(g_hDb, SQL_insertCustomPlayerTitleCallback, szQuery, GetClientUserId(client), DBPrio_Low); + g_hDb.Query(SQL_insertCustomPlayerTitleCallback, szQuery, GetClientUserId(client), DBPrio_Low); } public void SQL_insertCustomPlayerTitleCallback(Handle owner, Handle hndl, const char[] error, int userid) @@ -10048,7 +10044,7 @@ public void db_updateCustomPlayerTitle(int client, char[] arg) { char szQuery[512]; Format(szQuery, 512, "UPDATE `ck_vipadmins` SET `title` = '%s' WHERE `steamid` = '%s';", arg, g_szSteamID[client]); - SQL_TQuery(g_hDb, SQL_updateCustomPlayerTitleCallback, szQuery, GetClientUserId(client), DBPrio_Low); + g_hDb.Query(SQL_updateCustomPlayerTitleCallback, szQuery, GetClientUserId(client), DBPrio_Low); } public void SQL_updateCustomPlayerTitleCallback(Handle owner, Handle hndl, const char[] error, int userid) @@ -10067,7 +10063,7 @@ public void db_updateCustomPlayerNameColour(int client, char[] arg) { char szQuery[512]; Format(szQuery, 512, "UPDATE `ck_vipadmins` SET `namecolour` = '%s' WHERE `steamid` = '%s';", arg, g_szSteamID[client]); - SQL_TQuery(g_hDb, SQL_updateCustomPlayerNameColourCallback, szQuery, GetClientUserId(client), DBPrio_Low); + g_hDb.Query(SQL_updateCustomPlayerNameColourCallback, szQuery, GetClientUserId(client), DBPrio_Low); } public void SQL_updateCustomPlayerNameColourCallback(Handle owner, Handle hndl, const char[] error, int userid) @@ -10086,7 +10082,7 @@ public void db_updateCustomPlayerTextColour(int client, char[] arg) { char szQuery[512]; Format(szQuery, 512, "UPDATE `ck_vipadmins` SET `textcolour` = '%s' WHERE `steamid` = '%s';", arg, g_szSteamID[client]); - SQL_TQuery(g_hDb, SQL_updateCustomPlayerTextColourCallback, szQuery, GetClientUserId(client), DBPrio_Low); + g_hDb.Query(SQL_updateCustomPlayerTextColourCallback, szQuery, GetClientUserId(client), DBPrio_Low); } public void SQL_updateCustomPlayerTextColourCallback(Handle owner, Handle hndl, const char[] error, int userid) @@ -10113,7 +10109,7 @@ public void db_toggleCustomPlayerTitle(int client) Format(szQuery, 512, "UPDATE `ck_vipadmins` SET `inuse` = '1' WHERE `steamid` = '%s';", g_szSteamID[client]); } - SQL_TQuery(g_hDb, SQL_insertCustomPlayerTitleCallback, szQuery, GetClientUserId(client), DBPrio_Low); + g_hDb.Query(SQL_insertCustomPlayerTitleCallback, szQuery, GetClientUserId(client), DBPrio_Low); } public void SQL_toggleCustomPlayerTitleCallback(Handle owner, Handle hndl, const char[] error, int userid) @@ -10130,7 +10126,7 @@ public void db_viewCustomTitles(int client) { char szQuery[728]; Format(szQuery, 728, "SELECT `title`, `namecolour`, `textcolour`, `inuse`, `vip`, `zoner`, `joinmsg` FROM `ck_vipadmins` WHERE `steamid` = '%s'", g_szSteamID[client]); - SQL_TQuery(g_hDb, SQL_viewCustomTitlesCallback, szQuery, GetClientUserId(client), DBPrio_Low); + g_hDb.Query(SQL_viewCustomTitlesCallback, szQuery, GetClientUserId(client), DBPrio_Low); } public void SQL_viewCustomTitlesCallback(Handle owner, Handle hndl, const char[] error, int userid) @@ -10231,7 +10227,7 @@ public void db_viewPlayerColours(int client, char szSteamId[32], int type) char szQuery[512]; Format(szQuery, 512, "SELECT steamid, namecolour, textcolour FROM ck_vipadmins WHERE `steamid` = '%s';", szSteamId); - SQL_TQuery(g_hDb, SQL_ViewPlayerColoursCallback, szQuery, data, DBPrio_Low); + g_hDb.Query(SQL_ViewPlayerColoursCallback, szQuery, data, DBPrio_Low); } public void SQL_ViewPlayerColoursCallback(Handle owner, Handle hndl, const char[] error, any data) @@ -10314,7 +10310,7 @@ public int changeColoursMenuHandler(Handle menu, MenuAction action, int client, type = 0; else if (StrEqual(szType, "text")) type = 1; - if(item >= 0 && item <= 15) + if (item >= 0 && item <= 15) db_updateColours(client, g_szSteamID[client], item, type); } else if (action == MenuAction_Cancel) @@ -10338,7 +10334,7 @@ public void db_updateColours(int client, char szSteamId[32], int newColour, int case 1: Format(szQuery, 512, "UPDATE ck_vipadmins SET textcolour = %i WHERE steamid = '%s';", newColour, szSteamId); } - SQL_TQuery(g_hDb, SQL_UpdatePlayerColoursCallback, szQuery, client, DBPrio_Low); + g_hDb.Query(SQL_UpdatePlayerColoursCallback, szQuery, client, DBPrio_Low); } public void SQL_UpdatePlayerColoursCallback(Handle owner, Handle hndl, const char[] error, any client) @@ -10362,7 +10358,7 @@ public void db_selectAnnouncements() char szEscServerName[128]; SQL_EscapeString(g_hDb, g_sServerName, szEscServerName, sizeof(szEscServerName)); Format(szQuery, 1024, "SELECT `id` FROM `ck_announcements` WHERE `server` != '%s' AND `id` > %d", szEscServerName, g_iLastID); - SQL_TQuery(g_hDb, SQL_SelectAnnouncementsCallback, szQuery, GetGameTime(), DBPrio_Low); + g_hDb.Query(SQL_SelectAnnouncementsCallback, szQuery, GetGameTime(), DBPrio_Low); } public void SQL_SelectAnnouncementsCallback(Handle owner, Handle hndl, const char[] error, float time) @@ -10401,7 +10397,7 @@ public void db_insertAnnouncement(char szName[128], char szMapName[128], int szM char szEscServerName[128]; SQL_EscapeString(g_hDb, g_sServerName, szEscServerName, sizeof(szEscServerName)); Format(szQuery, 512, "INSERT INTO `ck_announcements` (`server`, `name`, `mapname`, `mode`, `time`, `group`) VALUES ('%s', '%s', '%s', '%i', '%s', '%i');", szEscServerName, szName, szMapName, szMode, szTime, szGroup); - SQL_TQuery(g_hDb, SQL_CheckCallback, szQuery, _, DBPrio_Low); + g_hDb.Query(SQL_CheckCallback, szQuery, __LINE__, DBPrio_Low); } public void db_checkAnnouncements() @@ -10410,7 +10406,7 @@ public void db_checkAnnouncements() char szEscServerName[128]; SQL_EscapeString(g_hDb, g_sServerName, szEscServerName, sizeof(szEscServerName)); Format(szQuery, 512, "SELECT `id`, `server`, `name`, `mapname`, `mode`, `time`, `group` FROM `ck_announcements` WHERE `server` != '%s' AND `id` > %d;", szEscServerName, g_iLastID); - SQL_TQuery(g_hDb, SQL_CheckAnnouncementsCallback, szQuery, 1, DBPrio_Low); + g_hDb.Query(SQL_CheckAnnouncementsCallback, szQuery, 1, DBPrio_Low); } public void SQL_CheckAnnouncementsCallback(Handle owner, Handle hndl, const char[] error, any data) @@ -10453,7 +10449,7 @@ public void db_selectMapCycle() { char szQuery[128]; Format(szQuery, sizeof(szQuery), "SELECT mapname, tier FROM ck_maptier ORDER BY mapname ASC"); - SQL_TQuery(g_hDb, SQL_SelectMapCycleCallback, szQuery, 1, DBPrio_Low); + g_hDb.Query(SQL_SelectMapCycleCallback, szQuery, 1, DBPrio_Low); } public void SQL_SelectMapCycleCallback(Handle owner, Handle hndl, const char[] error, any data) @@ -10494,7 +10490,7 @@ public void db_setJoinMsg(int client, char[] szArg) char szQuery[512]; Format(szQuery, sizeof(szQuery), "UPDATE ck_vipadmins SET joinmsg = '%s' WHERE steamid = '%s';", szArg, g_szSteamID[client]); Format(g_szCustomJoinMsg[client], sizeof(g_szCustomJoinMsg), "%s", szArg); - SQL_TQuery(g_hDb, SQL_SetJoinMsgCallback, szQuery, client, DBPrio_Low); + g_hDb.Query(SQL_SetJoinMsgCallback, szQuery, client, DBPrio_Low); } public void SQL_SetJoinMsgCallback(Handle owner, Handle hndl, const char[] error, any client) @@ -10675,7 +10671,7 @@ public void db_selectCPRTargetCPs(const char[] szSteamId, any pack) char szQuery[512]; Format(szQuery, sizeof(szQuery), "SELECT cp, time FROM ck_checkpoints WHERE steamid = '%s' AND mapname = '%s' AND zonegroup = 0;", szSteamId, g_szCPRMapName[client]); - SQL_TQuery(g_hDb, SQL_SelectCPRTargetCPsCallback, szQuery, pack, DBPrio_Low); + g_hDb.Query(SQL_SelectCPRTargetCPsCallback, szQuery, pack, DBPrio_Low); } public void SQL_SelectCPRTargetCPsCallback(Handle owner, Handle hndl, const char[] error, any pack) @@ -10711,7 +10707,7 @@ public void SQL_SelectCPRTargetCPsCallback(Handle owner, Handle hndl, const char char szCPR[32], szCompared[32], szItem[256]; int cp_count; - if(!g_bhasStages) + if (!g_bhasStages) cp_count = g_iTotalCheckpoints; else cp_count = g_TotalStages - 1; @@ -10721,7 +10717,7 @@ public void SQL_SelectCPRTargetCPsCallback(Handle owner, Handle hndl, const char { int cp = SQL_FetchInt(hndl, 0); targetCPs = SQL_FetchFloat(hndl, 1); - if(cp <= cp_count) + if (cp <= cp_count) comparedCPs = (g_fClientCPs[client][cp] - targetCPs); else continue; @@ -10764,7 +10760,7 @@ public void db_selectPRinfoUnknown(int client, int rank, int zonegroup, char szS Handle pack = CreateDataPack(); WritePackCell(pack, client); - if(rank == 99999 || rank == 9999999) + if (rank == 99999 || rank == 9999999) rank = -1; rank = Math_Min((rank - 1), 0); @@ -10775,7 +10771,7 @@ public void db_selectPRinfoUnknown(int client, int rank, int zonegroup, char szS Format(szQuery, 1024, "SELECT steamid, name, mapname, runtime, PRtimeinzone, PRcomplete, PRattempts, PRstcomplete FROM ck_prinfo WHERE mapname LIKE '%c%s%c' AND zonegroup = '%i' AND steamid = '%s';", PERCENT, g_szMapName, PERCENT, zonegroup, szSteamID); //PrintToConsole(client, "QUERY %s", szQuery); - SQL_TQuery(g_hDb, db_selectPRinfoUnknownCallback, szQuery, pack, DBPrio_Low); + g_hDb.Query(db_selectPRinfoUnknownCallback, szQuery, pack, DBPrio_Low); } // sm_prinfo @x command without map parameter (current mapname being used) @@ -10789,7 +10785,7 @@ public void db_selectPRinfoUnknownWithMap(int client, int rank, char szMapName[1 Handle pack = CreateDataPack(); WritePackCell(pack, client); - if(rank == 99999 || rank == 9999999){ + if (rank == 99999 || rank == 9999999) { CPrintToChat(client, "%t", "SQL28", g_szChatPrefix); return; } @@ -10802,7 +10798,7 @@ public void db_selectPRinfoUnknownWithMap(int client, int rank, char szMapName[1 Format(szQuery, 1024, "SELECT steamid, name, mapname, runtime, PRtimeinzone, PRcomplete, PRattempts, PRstcomplete FROM ck_prinfo WHERE mapname = '%s' AND zonegroup = '%i' AND steamid = '%s';", szMapName, zonegroup, szSteamID); //PrintToConsole(client, "QUERY %s", szQuery); - SQL_TQuery(g_hDb, db_selectPRinfoUnknownCallback, szQuery, pack, DBPrio_Low); + g_hDb.Query(db_selectPRinfoUnknownCallback, szQuery, pack, DBPrio_Low); } public void db_selectPRinfoUnknownCallback(Handle owner, Handle hndl, const char[] error, any pack) @@ -10839,7 +10835,7 @@ public void db_selectPRinfoUnknownCallback(Handle owner, Handle hndl, const char /* //DISPLAY CHAT ERROR MESSAGE WHEN PLAYER HASNT COMPLETED THE MAP - if(runtime == 0.0 && rank == 0){ + if (runtime == 0.0 && rank == 0) { CPrintToChat(client, "%t", "SQL28", g_szChatPrefix); return; } @@ -10886,7 +10882,7 @@ public void db_viewPRinfoMapRank(int client, char szSteamID[32], char szMapName[ Format(szQuery, 1024, "SELECT COUNT(*),steamid FROM ck_playertimes WHERE runtimepro <= (SELECT runtimepro FROM ck_playertimes WHERE steamid = '%s' AND mapname LIKE '%c%s%c' AND style = 0 AND runtimepro > -1.0) AND mapname LIKE '%c%s%c' AND style = 0 AND runtimepro > -1.0;", szSteamID, PERCENT, szMapName, PERCENT, PERCENT, szMapName, PERCENT); //PrintToConsole(client, "QUERY %s", szQuery); - SQL_TQuery(g_hDb, db_viewPRinfoMapRankCallback, szQuery, pack, DBPrio_Low); + g_hDb.Query(db_viewPRinfoMapRankCallback, szQuery, pack, DBPrio_Low); } public void db_viewPRinfoMapRankCallback(Handle owner, Handle hndl, const char[] error, any pack) @@ -10914,7 +10910,7 @@ public void db_viewPRinfoMapRankCallback(Handle owner, Handle hndl, const char[] db_selectPRinfoUnknownWithMap(client, g_iPRinfoMapRank[client], szMapName, 0, szSteamID); } - else{ + else { CPrintToChat(client, "%t", "SQL28", g_szChatPrefix); } @@ -10934,7 +10930,7 @@ public void db_viewPRinfoMapRankBonus(int client, char szSteamID[32], char szMap Format(szQuery, 1024, "SELECT COUNT(*), steamid FROM ck_bonus WHERE runtime <= (SELECT runtime FROM ck_bonus WHERE steamid = '%s' AND mapname LIKE '%c%s%c' AND runtime > -1.0 AND zonegroup = %i AND style = 0) AND mapname = '%s' AND zonegroup = %i AND style = 0;", szSteamID, PERCENT, szMapName, PERCENT, zonegroup, szMapName, zonegroup); //PrintToConsole(client, "QUERY %s", szQuery); - SQL_TQuery(g_hDb, db_viewPRinfoMapRankBonusCallback, szQuery, pack, DBPrio_Low); + g_hDb.Query(db_viewPRinfoMapRankBonusCallback, szQuery, pack, DBPrio_Low); } public void db_viewPRinfoMapRankBonusCallback(Handle owner, Handle hndl, const char[] error, any pack) @@ -10964,7 +10960,7 @@ public void db_viewPRinfoMapRankBonusCallback(Handle owner, Handle hndl, const c db_selectPRinfoUnknownWithMap(client, g_iPRinfoMapRankBonus[client], szMapName, bonus_number, szSteamID); } - else{ + else { CPrintToChat(client, "%t", "SQL28", g_szChatPrefix); } } @@ -10983,15 +10979,15 @@ public void db_GetRankSteamID(int client, char szMapName[128], int rank, int zon WritePackCell(pack, rank); WritePackCell(pack, zonegroup); - if(zonegroup == 0){ + if (zonegroup == 0) { Format(szQuery, 1024, "SELECT steamid FROM ck_playertimes WHERE mapname = '%s' AND style = 0 AND runtimepro > -1.0 ORDER BY runtimepro ASC LIMIT %i, 1;", szMapName, rank - 1); //PrintToConsole(client, "QUERY %s", szQuery); - SQL_TQuery(g_hDb, SQL_GetRankSteamIDCallback, szQuery, pack, DBPrio_Low); + g_hDb.Query(SQL_GetRankSteamIDCallback, szQuery, pack, DBPrio_Low); } - else{ + else { Format(szQuery, 1024, "SELECT steamid FROM ck_bonus WHERE mapname = '%s' AND style = 0 AND runtime > -1.0 AND zonegroup = '%i' ORDER BY runtime ASC LIMIT %i, 1;", szMapName, zonegroup, rank - 1); //PrintToConsole(client, "QUERY %s", szQuery); - SQL_TQuery(g_hDb, SQL_GetRankSteamIDCallback, szQuery, pack, DBPrio_Low); + g_hDb.Query(SQL_GetRankSteamIDCallback, szQuery, pack, DBPrio_Low); } } @@ -11021,13 +11017,13 @@ public void SQL_GetRankSteamIDCallback(Handle owner, Handle hndl, const char[] e db_selectPRinfoUnknownWithMap(client, rank, szMapName, zonegroup, szSteamID); } - else{ + else { CPrintToChat(client, "%t", "SQL28", g_szChatPrefix); } } -public void db_PRinfoDoneCallback(any pack){ +public void db_PRinfoDoneCallback(any pack) { if (pack == 0) { @@ -11078,16 +11074,16 @@ public void db_PRinfoDoneCallback(any pack){ FormatTimeFloat(client, runtime, 3, szruntimeFormatted, 32); SetMenuOptionFlags(menu, MENUFLAG_BUTTON_EXIT); - if(zonegroup == 0) + if (zonegroup == 0) SetMenuTitle(menu, "PR info for %s on %s\n\n", playername, mapname); else SetMenuTitle(menu, "PR info for %s on %s | Bonus %i\n\n", playername, mapname, zonegroup); - if(rank == 0 || runtime == 0.0){ + if (rank == 0 || runtime == 0.0) { Format(szItem, sizeof(szItem), "Rank: N/A", rank); AddMenuItem(menu, "", szItem, ITEMDRAW_DISABLED); } - else if(rank != 99999 && rank != 9999999 ){ + else if (rank != 99999 && rank != 9999999 ) { Format(szItem, sizeof(szItem), "Rank: %i\n", rank); AddMenuItem(menu, "", szItem, ITEMDRAW_DISABLED); @@ -11098,20 +11094,20 @@ public void db_PRinfoDoneCallback(any pack){ Format(szItem, sizeof(szItem), "Total Time: %s\n", szTimeinZoneformatted); AddMenuItem(menu, "", szItem, ITEMDRAW_DISABLED); - if(attempts != 0.0){ + if (attempts != 0.0) { Format(szItem, sizeof(szItem), "Completes : (%i / %i) (%.2f %%)\n\n", RoundToFloor(completes), RoundToFloor(attempts), (completes / attempts) * 100.0 ); AddMenuItem(menu, "", szItem, ITEMDRAW_DISABLED); } - else{ + else { Format(szItem, sizeof(szItem), "Completes : N/A\n\n"); AddMenuItem(menu, "", szItem, ITEMDRAW_DISABLED); } - if(stcomplete != 0.0){ + if (stcomplete != 0.0) { Format(szItem, sizeof(szItem), "First Complete: %s\n", szstCompleteFormatted); AddMenuItem(menu, "", szItem, ITEMDRAW_DISABLED); } - else{ + else { Format(szItem, sizeof(szItem), "First Complete: N/A\n\n"); AddMenuItem(menu, "", szItem, ITEMDRAW_DISABLED); } @@ -11141,7 +11137,7 @@ public void db_updateMapRankedStatus() g_bRankedMap = true; } - SQL_TQuery(g_hDb, SQL_CheckCallback, szQuery, _, DBPrio_Low); + g_hDb.Query(SQL_CheckCallback, szQuery, __LINE__, DBPrio_Low); } public void db_selectPracWrcpRecord(int client, int style, int stage) @@ -11171,7 +11167,7 @@ public void db_selectPracWrcpRecord(int client, int style, int stage) Format(szQuery, 255, "SELECT runtimepro FROM ck_wrcps WHERE steamid = '%s' AND mapname = '%s' AND stage = %i AND style = %i", g_szSteamID[client], g_szMapName, stage, style); } - SQL_TQuery(g_hDb, sql_selectPracWrcpRecordCallback, szQuery, pack, DBPrio_Low); + g_hDb.Query(sql_selectPracWrcpRecordCallback, szQuery, pack, DBPrio_Low); } public void sql_selectPracWrcpRecordCallback(Handle owner, Handle hndl, const char[] error, DataPack packx) @@ -11226,7 +11222,7 @@ public void db_SelectCountryRank(int client, char szPlayerName[MAX_NAME_LENGTH], //GET TOTAL AMOUNT OF PLAYERS char szQuery[512]; Format(szQuery, sizeof szQuery, "SELECT COUNT(steamid), country FROM ck_playerrank WHERE country = '%s' AND style = '%i';", szCountry, style); - SQL_TQuery(g_hDb, db_SelectCountryRankCallback, szQuery, pack, DBPrio_Low); + g_hDb.Query(db_SelectCountryRankCallback, szQuery, pack, DBPrio_Low); } public void db_SelectCountryRankCallback(Handle owner, Handle hndl, const char[] error, any pack) @@ -11268,7 +11264,7 @@ public void db_GetPlayerPoints(int client, int CountryPlayerTotal, char szPlayer //GET PLAYER POINTS char szQuery[512]; Format(szQuery, sizeof szQuery, "SELECT points FROM ck_playerrank WHERE name = '%s' AND style = '%i';", szPlayerName, style); - SQL_TQuery(g_hDb, db_GetPlayerPointsCallback, szQuery, pack, DBPrio_Low); + g_hDb.Query(db_GetPlayerPointsCallback, szQuery, pack, DBPrio_Low); } public void db_GetPlayerPointsCallback(Handle owner, Handle hndl, const char[] error, any pack) @@ -11310,7 +11306,7 @@ public void db_GetPlayerCountryRank(int PlayerPoints, int CountryPlayerTotal, ch //GET CLIENT COUNTRY RANK char szQuery[512]; Format(szQuery, sizeof szQuery, "SELECT COUNT(steamid) + 1 FROM ck_playerrank WHERE country = '%s' AND style = '%i' AND points > '%i';", szCountry, style, PlayerPoints); - SQL_TQuery(g_hDb, db_GetPlayerCountryRankCallback, szQuery, pack, DBPrio_Low); + g_hDb.Query(db_GetPlayerCountryRankCallback, szQuery, pack, DBPrio_Low); } public void db_GetPlayerCountryRankCallback(Handle owner, Handle hndl, const char[] error, any pack) @@ -11354,7 +11350,7 @@ public void db_SelectCustomPlayerCountryRank(int client, char szPlayerName[MAX_N //CHECK IF PLAYER EXISTS char szQuery[512]; Format(szQuery, sizeof szQuery, "SELECT * FROM ck_playerrank WHERE name = '%s';", szName); - SQL_TQuery(g_hDb, db_SelectCustomPlayerCountryRankCallback, szQuery, pack, DBPrio_Low); + g_hDb.Query(db_SelectCustomPlayerCountryRankCallback, szQuery, pack, DBPrio_Low); } public void db_SelectCustomPlayerCountryRankCallback(Handle owner, Handle hndl, const char[] error, any pack) @@ -11395,7 +11391,7 @@ public void db_SelectCustomPlayerCountryRank_GetCountry(int client, char szPlaye //GET SELECT PLAYER COUNTRY char szQuery[512]; Format(szQuery, sizeof szQuery, "SELECT country FROM ck_playerrank WHERE name = '%s' AND style = '%i';", szName, style); - SQL_TQuery(g_hDb, db_SelectCustomPlayerCountryRank_GetCountryCallback, szQuery, pack, DBPrio_Low); + g_hDb.Query(db_SelectCustomPlayerCountryRank_GetCountryCallback, szQuery, pack, DBPrio_Low); } public void db_SelectCustomPlayerCountryRank_GetCountryCallback(Handle owner, Handle hndl, const char[] error, any pack) @@ -11440,7 +11436,7 @@ public void db_SelectCountryTOP(int client, char szCountryName[256], int style) char szQuery[512]; Format(szQuery, sizeof szQuery, "SELECT name, country, points, style FROM ck_playerrank WHERE country = '%s' AND style = '%i' ORDER BY points DESC LIMIT 100;", szCountryName, style); - SQL_TQuery(g_hDb, db_SelectCountryTOPCallback, szQuery, pack, DBPrio_Low); + g_hDb.Query(db_SelectCountryTOPCallback, szQuery, pack, DBPrio_Low); } public void db_SelectCountryTOPCallback(Handle owner, Handle hndl, const char[] error, any pack) @@ -11552,7 +11548,7 @@ public void db_GetCountriesNames(int client, int style) char szQuery[512]; Format(szQuery, sizeof szQuery, "SELECT DISTINCT(country) FROM ck_playerrank WHERE style = '%i' ORDER BY country;", style); - SQL_TQuery(g_hDb, db_GetCountriesNamesCallback, szQuery, pack, DBPrio_Low); + g_hDb.Query(db_GetCountriesNamesCallback, szQuery, pack, DBPrio_Low); } public void db_GetCountriesNamesCallback(Handle owner, Handle hndl, const char[] error, any pack) @@ -11645,7 +11641,7 @@ public void db_SelectContinentRank(int client, char szPlayerName[MAX_NAME_LENGTH //GET TOTAL AMOUNT OF PLAYERS char szQuery[512]; Format(szQuery, sizeof szQuery, "SELECT COUNT(steamid) FROM ck_playerrank WHERE continentCode = '%s' AND style = '%i';", szContinentCode, style); - SQL_TQuery(g_hDb, db_SelectContinentRankCallback, szQuery, pack, DBPrio_Low); + g_hDb.Query(db_SelectContinentRankCallback, szQuery, pack, DBPrio_Low); } public void db_SelectContinentRankCallback(Handle owner, Handle hndl, const char[] error, any pack) @@ -11687,7 +11683,7 @@ public void db_GetPlayerPointsContinent(int client, int ContinentPlayerTotal, ch //GET PLAYER POINTS char szQuery[512]; Format(szQuery, sizeof szQuery, "SELECT points FROM ck_playerrank WHERE name = '%s' AND style = '%i';", szPlayerName, style); - SQL_TQuery(g_hDb, db_GetPlayerPointsContinentCallback, szQuery, pack, DBPrio_Low); + g_hDb.Query(db_GetPlayerPointsContinentCallback, szQuery, pack, DBPrio_Low); } public void db_GetPlayerPointsContinentCallback(Handle owner, Handle hndl, const char[] error, any pack) @@ -11729,7 +11725,7 @@ public void db_GetPlayerContinentRank(int PlayerPoints, int ContinentPlayerTotal //GET CLIENT CONTINENT RANK char szQuery[512]; Format(szQuery, sizeof szQuery, "SELECT COUNT(steamid) + 1 FROM ck_playerrank WHERE continentCode = '%s' AND style = '%i' AND points > '%i';", szContinentCode, style, PlayerPoints); - SQL_TQuery(g_hDb, db_GetPlayerContinentRankCallback, szQuery, pack, DBPrio_Low); + g_hDb.Query(db_GetPlayerContinentRankCallback, szQuery, pack, DBPrio_Low); } public void db_GetPlayerContinentRankCallback(Handle owner, Handle hndl, const char[] error, any pack) @@ -11776,7 +11772,7 @@ public void db_SelectCustomPlayerContinentRank(int client, char szPlayerName[MAX //CHECK IF PLAYER EXISTS char szQuery[512]; Format(szQuery, sizeof szQuery, "SELECT * FROM ck_playerrank WHERE name = '%s';", szName); - SQL_TQuery(g_hDb, db_SelectCustomPlayerContinentRankCallback, szQuery, pack, DBPrio_Low); + g_hDb.Query(db_SelectCustomPlayerContinentRankCallback, szQuery, pack, DBPrio_Low); } public void db_SelectCustomPlayerContinentRankCallback(Handle owner, Handle hndl, const char[] error, any pack) @@ -11817,7 +11813,7 @@ public void db_SelectCustomPlayerContinentRank_GetContinent(int client, char szP //GET SELECT PLAYER CONTINENT char szQuery[512]; Format(szQuery, sizeof szQuery, "SELECT continentCode FROM ck_playerrank WHERE name = '%s' AND style = '%i';", szName, style); - SQL_TQuery(g_hDb, db_SelectCustomPlayerContinentRank_GetContinentCallback, szQuery, pack, DBPrio_Low); + g_hDb.Query(db_SelectCustomPlayerContinentRank_GetContinentCallback, szQuery, pack, DBPrio_Low); } public void db_SelectCustomPlayerContinentRank_GetContinentCallback(Handle owner, Handle hndl, const char[] error, any pack) @@ -11862,7 +11858,7 @@ public void db_SelectContinentTOP(int client, char szContinentCode[3], int style char szQuery[512]; Format(szQuery, sizeof szQuery, "SELECT name, points, style FROM ck_playerrank WHERE continentCode = '%s' AND style = '%i' ORDER BY points DESC LIMIT 100;", szContinentCode, style); - SQL_TQuery(g_hDb, db_SelectContinentTOPCallback, szQuery, pack, DBPrio_Low); + g_hDb.Query(db_SelectContinentTOPCallback, szQuery, pack, DBPrio_Low); } public void db_SelectContinentTOPCallback(Handle owner, Handle hndl, const char[] error, any pack) @@ -11976,7 +11972,7 @@ public void db_GetContinentNames(int client, int style) char szQuery[512]; Format(szQuery, sizeof szQuery, "SELECT DISTINCT(continentCode) FROM ck_playerrank WHERE style = '%i' AND continentCode IS NOT NULL ORDER BY continentCode;", style); - SQL_TQuery(g_hDb, db_GetContinentNamesCallback, szQuery, pack, DBPrio_Low); + g_hDb.Query(db_GetContinentNamesCallback, szQuery, pack, DBPrio_Low); } public void db_GetContinentNamesCallback(Handle owner, Handle hndl, const char[] error, any pack) @@ -12067,7 +12063,7 @@ public void db_ViewPlayerRank(int client) { char szQuery[512]; Format(szQuery, sizeof szQuery, "SELECT name, points, style FROM ck_playerrank WHERE style = %i AND points >= (SELECT points FROM ck_playerrank WHERE steamid = '%s' AND style = %i) ORDER BY points;", g_iCurrentStyle[client], g_szSteamID[client], g_iCurrentStyle[client]); - SQL_TQuery(g_hDb, db_ViewPlayerRankCallback, szQuery, client, DBPrio_Low); + g_hDb.Query(db_ViewPlayerRankCallback, szQuery, client, DBPrio_Low); } public void db_ViewPlayerRankCallback(Handle owner, Handle hndl, const char[] error, any client) @@ -12164,7 +12160,7 @@ public void db_GetNextRankPoints(int client, int style, int points, int next_ran char szQuery[512]; Format(szQuery, sizeof szQuery, "SELECT points FROM ck_playerrank WHERE style = %d ORDER BY points DESC LIMIT %d,1;", style, next_rank - 1); - SQL_TQuery(g_hDb, db_GetNextRankPointsCallback, szQuery, pack, DBPrio_Low); + g_hDb.Query(db_GetNextRankPointsCallback, szQuery, pack, DBPrio_Low); } public void db_GetNextRankPointsCallback(Handle owner, Handle hndl, const char[] error, DataPack pack) @@ -12204,7 +12200,7 @@ public void db_viewCCP_WithMapRank(int client, char szSteamID[32], char szMapNam WritePackCell(pack, map_rank); Format(szQuery, 2048, "SELECT -1, runtimepro, steamid FROM ck_playertimes WHERE mapname = '%s' AND style = '0' ORDER BY runtimepro ASC LIMIT %i, 1;", szMapName, map_rank-1); - SQL_TQuery(g_hDb, SQL_viewCCP_GetMapRankCallback, szQuery, pack, DBPrio_Low); + g_hDb.Query(SQL_viewCCP_GetMapRankCallback, szQuery, pack, DBPrio_Low); } //GET PLAYER'S CCP MAP RANK @@ -12221,7 +12217,7 @@ public void db_viewCCP_GetMapRank(int client, char szSteamID[32], char szMapName WritePackString(pack, szMapName); Format(szQuery, sizeof(szQuery), "SELECT COUNT(*), runtimepro, steamid FROM ck_playertimes WHERE runtimepro <= (SELECT runtimepro FROM ck_playertimes WHERE steamid = '%s' AND mapname = '%s' AND style = 0 AND runtimepro > -1.0) AND mapname = '%s' AND style = 0 AND runtimepro > -1.0;", szSteamID, szMapName, szMapName); - SQL_TQuery(g_hDb, SQL_viewCCP_GetMapRankCallback, szQuery, pack, DBPrio_Low); + g_hDb.Query(SQL_viewCCP_GetMapRankCallback, szQuery, pack, DBPrio_Low); } public void SQL_viewCCP_GetMapRankCallback(Handle owner, Handle hndl, const char[] error, any pack) @@ -12257,11 +12253,11 @@ public void SQL_viewCCP_GetMapRankCallback(Handle owner, Handle hndl, const char //IF THE DIDNT PLAYER PROVIDED THE RANK BEFORE //THIS -1 IS A COLUMN FROM THE SQL QUERY //WHEN IT HAS A -1 IN IT , IT MEANS THE PLAYER PROVIDED THE RANK - if(map_rank != -1) { + if (map_rank != -1) { db_GetTotalMapCompletions(client, szSteamID, szMapName, map_time, map_rank); } //IF THE PLAYER PROVIDED THE RANK BEFORE - else{ + else { //SINCE THE PLAYER PROVIDED THE RANK WE READ FROM THE PACK GENERATED WITH THE RANK map_rank = ReadPackCell(pack); db_GetTotalMapCompletions(client, szPlayerSteamID, szMapName, map_time, map_rank); @@ -12275,7 +12271,7 @@ public void SQL_viewCCP_GetMapRankCallback(Handle owner, Handle hndl, const char } //GET TOTAL MAP COMPLETIONS -public void db_GetTotalMapCompletions(int client, char szSteamID[32], char szMapName[128], float map_time, int map_rank){ +public void db_GetTotalMapCompletions(int client, char szSteamID[32], char szMapName[128], float map_time, int map_rank) { char szQuery[2048]; @@ -12287,11 +12283,11 @@ public void db_GetTotalMapCompletions(int client, char szSteamID[32], char szMap WritePackString(pack, szMapName); Format(szQuery, 1024, "SELECT count(runtimepro) FROM ck_playertimes WHERE mapname = '%s' AND style = '0';", szMapName); - SQL_TQuery(g_hDb, SQL_GetTotalMapCompletionsCallback, szQuery, pack, DBPrio_Low); + g_hDb.Query(SQL_GetTotalMapCompletionsCallback, szQuery, pack, DBPrio_Low); } -public void SQL_GetTotalMapCompletionsCallback(Handle owner, Handle hndl, const char[] error, any pack){ +public void SQL_GetTotalMapCompletionsCallback(Handle owner, Handle hndl, const char[] error, any pack) { if (hndl == null) { @@ -12318,7 +12314,7 @@ public void SQL_GetTotalMapCompletionsCallback(Handle owner, Handle hndl, const { int total_map_completions = SQL_FetchInt(hndl, 0); - if(total_map_completions > 0) + if (total_map_completions > 0) db_getRecordTime(client, szSteamID, szMapName, map_time, map_rank, total_map_completions); else CPrintToChat(client, "%t", "CCP_03", g_szChatPrefix); @@ -12326,7 +12322,7 @@ public void SQL_GetTotalMapCompletionsCallback(Handle owner, Handle hndl, const } //GET RECORD TIME (200IQ EXPLANATION) -public void db_getRecordTime(int client, char szSteamID[32], char szMapName[128], float map_time, int map_rank, int total_map_completions){ +public void db_getRecordTime(int client, char szSteamID[32], char szMapName[128], float map_time, int map_rank, int total_map_completions) { char szQuery[2048]; @@ -12339,11 +12335,11 @@ public void db_getRecordTime(int client, char szSteamID[32], char szMapName[128] WritePackString(pack, szMapName); Format(szQuery, 1024, "SELECT steamid, runtimepro FROM ck_playertimes WHERE mapname = '%s' AND style = 0 ORDER BY runtimepro ASC LIMIT 1;", szMapName); - SQL_TQuery(g_hDb, SQL_getRecordTimeCallback, szQuery, pack, DBPrio_Low); + g_hDb.Query(SQL_getRecordTimeCallback, szQuery, pack, DBPrio_Low); } -public void SQL_getRecordTimeCallback(Handle owner, Handle hndl, const char[] error, any pack){ +public void SQL_getRecordTimeCallback(Handle owner, Handle hndl, const char[] error, any pack) { if (hndl == null) { @@ -12397,7 +12393,7 @@ public void db_viewCCP_GetMapStageTimes_Record(int client, char szSteamID[32], c char szQuery[2048]; Format(szQuery, 2048, sql_selectStageTimes, szMapName, Record_SteamID); - SQL_TQuery(g_hDb, SQL_viewCCP_GetMapStageTimes_RecordCallback, szQuery, pack, DBPrio_Low); + g_hDb.Query(SQL_viewCCP_GetMapStageTimes_RecordCallback, szQuery, pack, DBPrio_Low); } @@ -12437,7 +12433,7 @@ public void SQL_viewCCP_GetMapStageTimes_RecordCallback(Handle owner, Handle hnd } //IF RECORD HAS CCP ENTRIES - if(g_fCCP_StageTimes_ServerRecord[client][0] > 0.0) + if (g_fCCP_StageTimes_ServerRecord[client][0] > 0.0) db_viewCCP_GetPlayerPR(client, szSteamID, szMapName, map_time, map_rank, record_time, total_map_completions); else CPrintToChat(client, "%t", "CCP_06", g_szChatPrefix); @@ -12452,7 +12448,7 @@ public void SQL_viewCCP_GetMapStageTimes_RecordCallback(Handle owner, Handle hnd //STAGE ATTEMPTS OF CCP //STAGE RANK OF CCP //STAGE TOTAL OF CCP -public void db_viewCCP_GetPlayerPR(int client, char szSteamID[32], char szMapName[128], float map_time, int map_rank, float record_time, int total_map_completions){ +public void db_viewCCP_GetPlayerPR(int client, char szSteamID[32], char szMapName[128], float map_time, int map_rank, float record_time, int total_map_completions) { Handle pack = CreateDataPack(); WritePackCell(pack, client); //CLIENT WHO DID SM_CCP @@ -12465,7 +12461,7 @@ public void db_viewCCP_GetPlayerPR(int client, char szSteamID[32], char szMapNam char szQuery[2048]; Format(szQuery, sizeof szQuery, "SELECT db1.steamid, db1.mapname, db1.cp, db1.stage_time, db1.stage_attempts, (SELECT count(name)+1 FROM ck_wrcps WHERE style = 0 AND mapname = db1.mapname AND stage = db1.cp AND stage_time > -1.0 AND runtimepro <= db1.stage_time) AS `rank`, (SELECT count(name) FROM ck_wrcps WHERE style = 0 AND mapname = db1.mapname AND stage = db1.cp AND runtimepro > -1.0) AS total FROM ck_checkpoints db1 WHERE db1.mapname = '%s' AND db1.steamid = '%s' AND db1.stage_time > -1.0 ORDER BY cp ASC;", szMapName, szSteamID); - SQL_TQuery(g_hDb, SQL_db_viewCCP_GetPlayerPRCallback, szQuery, pack, DBPrio_Low); + g_hDb.Query(SQL_db_viewCCP_GetPlayerPRCallback, szQuery, pack, DBPrio_Low); } public void SQL_db_viewCCP_GetPlayerPRCallback(Handle owner, Handle hndl, const char[] error, any pack) @@ -12532,14 +12528,14 @@ public void DisplayCCPMenu(int client, float map_time, float record_time, int ma //FORMAT WRCP DIFF char szStageTimeDifferenceFormatted[32]; FormatTimeFloat(client, g_fCCP_StageTimes_ServerRecord[client][i] - g_fCCP_StageTimes_Player[client][i], 3, szStageTimeDifferenceFormatted, sizeof szStageTimeDifferenceFormatted); - if(g_fCCP_StageTimes_ServerRecord[client][i] - g_fCCP_StageTimes_Player[client][i] >= 0.0) + if (g_fCCP_StageTimes_ServerRecord[client][i] - g_fCCP_StageTimes_Player[client][i] >= 0.0) Format(szStageTimeDifferenceFormatted, sizeof szStageTimeDifferenceFormatted, "-%s", szStageTimeDifferenceFormatted); else Format(szStageTimeDifferenceFormatted, sizeof szStageTimeDifferenceFormatted, "+%s", szStageTimeDifferenceFormatted); //FORMAT STAGE DISPLAY //IF THE STAGE RANK THE PLAYER GETS IS THE SLOWEST JUST INCREASE THE RANKS BY 1 - if(g_iCCP_StageRank_Player[client][i] < g_iCCP_StageTotal_Player[client][i]) + if (g_iCCP_StageRank_Player[client][i] < g_iCCP_StageTotal_Player[client][i]) Format(szItem, sizeof(szItem), "Stage %i\nRank %i/%i\nAttempts : %i\nTime: %s (%s)\n \n", i+1, g_iCCP_StageRank_Player[client][i], g_iCCP_StageTotal_Player[client][i], g_iCCP_StageAttempts_Player[client][i], szStageTimeFormatted, szStageTimeDifferenceFormatted); else Format(szItem, sizeof(szItem), "Stage %i\nRank %i/%i\nAttempts : %i\nTime: %s (%s)\n \n", i+1, g_iCCP_StageRank_Player[client][i], g_iCCP_StageTotal_Player[client][i] + 1, g_iCCP_StageAttempts_Player[client][i], szStageTimeFormatted, szStageTimeDifferenceFormatted); @@ -12569,10 +12565,26 @@ public void DisplayCCPMenu(int client, float map_time, float record_time, int ma public int CCPMenuHandler(Menu menu, MenuAction action, int param1, int param2) { - if(action == MenuAction_Select) + if (action == MenuAction_Select) return 0; - else if(action == MenuAction_End) + else if (action == MenuAction_End) delete menu; return 0; } + +void db_InsertUpdatePlayersTable(int client) +{ + char sSteamId2[32]; + GetClientAuthId(client, AuthId_Steam2, sSteamId2, sizeof(sSteamId2)); + + char sSteamId64[64]; + GetClientAuthId(client, AuthId_SteamID64, sSteamId64, sizeof(sSteamId64)); + + char sName[MAX_NAME_LENGTH]; + GetClientName(client, sName, sizeof(sName)); + + char sQuery[1024]; + g_hDb.Format(sQuery, sizeof(sQuery), sql_insertUpdatePlayersAll, GetSteamAccountID(client), sSteamId2, sSteamId64, sName, sSteamId2, sSteamId64, sName); + g_hDb.Query(SQL_CheckCallback, sQuery, __LINE__, DBPrio_Low); +} diff --git a/addons/sourcemod/scripting/surftimer/sqltime.sp b/addons/sourcemod/scripting/surftimer/sqltime.sp index 5c572ab3..6ae61274 100644 --- a/addons/sourcemod/scripting/surftimer/sqltime.sp +++ b/addons/sourcemod/scripting/surftimer/sqltime.sp @@ -2,7 +2,7 @@ public void db_viewPlayerInfo(int client, char szSteamId[32]) { char szQuery[512]; Format(szQuery, 512, "SELECT steamid, steamid64, name, country, lastseen, joined, connections, timealive, timespec FROM ck_playerrank WHERE steamid = '%s';", szSteamId); - SQL_TQuery(g_hDb, SQL_ViewPlayerInfoCallback, szQuery, client, DBPrio_Low); + g_hDb.Query(SQL_ViewPlayerInfoCallback, szQuery, client, DBPrio_Low); } @@ -82,7 +82,7 @@ public void db_savePlayTime(int client) { char szQuery[512]; Format(szQuery, 512, "UPDATE ck_playerrank SET timealive = timealive + %i, timespec = timespec + %i WHERE steamid = '%s';", g_iPlayTimeAliveSession[client], g_iPlayTimeSpecSession[client], g_szSteamID[client]); - SQL_TQuery(g_hDb, SQL_SavePlayTimeCallback, szQuery, client, DBPrio_Low); + g_hDb.Query(SQL_SavePlayTimeCallback, szQuery, client, DBPrio_Low); } public void SQL_SavePlayTimeCallback(Handle owner, Handle hndl, const char[] error, any client) diff --git a/addons/sourcemod/scripting/surftimer/surfzones.sp b/addons/sourcemod/scripting/surftimer/surfzones.sp index 96b2b421..5f2ae620 100644 --- a/addons/sourcemod/scripting/surftimer/surfzones.sp +++ b/addons/sourcemod/scripting/surftimer/surfzones.sp @@ -112,14 +112,14 @@ public void CreateZoneEntity(int zoneIndex) TeleportEntity(iEnt, fMiddle, NULL_VECTOR, NULL_VECTOR); // Have the mins always be negative - for(int i = 0; i < 3; i++){ + for(int i = 0; i < 3; i++) { fMins[i] = fMins[i] - fMiddle[i]; if (fMins[i] > 0.0) fMins[i] *= -1.0; } // And the maxs always be positive - for(int i = 0; i < 3; i++){ + for(int i = 0; i < 3; i++) { fMaxs[i] = fMaxs[i] - fMiddle[i]; if (fMaxs[i] < 0.0) fMaxs[i] *= -1.0; @@ -307,7 +307,7 @@ public Action EndTouchTrigger(int caller, int activator) public void StartTouch(int client, int action[3]) { - /* if (g_iClientInZone[client][0] > 0){ + /* if (g_iClientInZone[client][0] > 0) { g_TeleInTriggerMultiple[client] = false; } */ @@ -323,24 +323,24 @@ public void StartTouch(int client, int action[3]) //PRINFO int zGroup = g_iClientInZone[client][2]; //ease of use - if ((action[0] == 1 || action[0] == 2 || action[0] == 3) && (!g_bPracticeMode[client] && !IsFakeClient(client) && g_iCurrentStyle[client] == 0)){ + if ((action[0] == 1 || action[0] == 2 || action[0] == 3) && (!g_bPracticeMode[client] && !IsFakeClient(client) && g_iCurrentStyle[client] == 0)) { //PLAYER ON A RUN - if(action[0] == 2 && g_bTimerRunning[client]){ + if (action[0] == 2 && g_bTimerRunning[client]) { g_fCompletes[client][zGroup]++; g_fTimeinZone[client][zGroup] += fCurrentRunTime; g_fTimeIncrement[client][zGroup] = 0.0; - if(g_fstComplete[client][zGroup] == 0.0) + if (g_fstComplete[client][zGroup] == 0.0) g_fstComplete[client][zGroup] = g_fTimeinZone[client][zGroup]; //END ZONE OF MAP - if(zGroup == 0) + if (zGroup == 0) //PLAYER ALREADY HAS A COMPLETION - if( g_fPersonalRecord[client] > 0.0 ) + if ( g_fPersonalRecord[client] > 0.0 ) //IMPROVES COMPLETION - if(g_fCurrentRunTime[client] < g_fPersonalRecord[client]) + if (g_fCurrentRunTime[client] < g_fPersonalRecord[client]) db_UpdatePRinfo_WithRuntime(client, g_szSteamID[client], zGroup, g_fCurrentRunTime[client]); //UPDATE THE PLAYERS PRINFO WITH THEIR RUNTIME IF THEY IMPROVED else db_UpdatePRinfo(client, g_szSteamID[client], zGroup); //UPDATE THE PLAYERS PRINFO EXECPT FOR THE RUNTIME @@ -350,7 +350,7 @@ public void StartTouch(int client, int action[3]) //ENDZONE OF BONUS else //PLAYER ALREADY HAS A COMPLETION - if(g_fPersonalRecordBonus[zGroup][client] > 0) + if (g_fPersonalRecordBonus[zGroup][client] > 0) //IMPROVES COMPLETION if (g_fCurrentRunTime[client] < g_fPersonalRecordBonus[zGroup][client]) db_UpdatePRinfo_WithRuntime(client, g_szSteamID[client], zGroup, g_fCurrentRunTime[client]); //UPDATE THE PLAYERS PRINFO WITH THEIR RUNTIME IF THEY IMPROVED @@ -361,9 +361,9 @@ public void StartTouch(int client, int action[3]) db_UpdatePRinfo_WithRuntime(client, g_szSteamID[client], zGroup, g_fCurrentRunTime[client]); } //PLAYER JUST DOING STAGES - else if(action[0] == 3 && g_bWrcpTimeractivated[client] && !g_bTimerRunning[client]){ + else if (action[0] == 3 && g_bWrcpTimeractivated[client] && !g_bTimerRunning[client]) { //CHECK IF THERE IS TIME NOT ADDED TO TIMEINZONE - if(g_fTimeIncrement[client][zGroup] != 0.0){ + if (g_fTimeIncrement[client][zGroup] != 0.0) { g_fTimeinZone[client][zGroup] += g_fTimeIncrement[client][zGroup]; g_fTimeIncrement[client][zGroup] = 0.0; } @@ -371,9 +371,9 @@ public void StartTouch(int client, int action[3]) //CASE WHERE PLAYER IS RUNNING THE MAP BUT MID RUN SWAP TO LETS SAY /B 1, THE VALUE CONTINUES STORES IN THE g_fTimeIncrement[ZONEGROUP 0], WHEN PLAYER GOES BACK //TO MAP STARTZONE THE PREVIOUSLY INCREMENTED VALUE IS NOW ADDED TO THE TIMEINZONE //MAP OR BONUS STARTZONE - else if(action[0] == 1){ + else if (action[0] == 1) { //CHECK IF THERE IS TIME NOT ADDED TO TIMEINZONE - if(g_fTimeIncrement[client][zGroup] != 0.0){ + if (g_fTimeIncrement[client][zGroup] != 0.0) { g_fTimeinZone[client][zGroup] += g_fTimeIncrement[client][zGroup]; g_fTimeIncrement[client][zGroup] = 0.0; } @@ -553,7 +553,7 @@ public void StartTouch(int client, int action[3]) { Checkpoint(client, action[1], g_iClientInZone[client][2], fCurrentRunTime); } - else{ + else { //PrintToChatAll("style %d | cp %i | %d tick count", g_iCurrentStyle[client], action[1], g_iRecordedTicks[client]); g_iCPStartFrame_CurrentRun[g_iCurrentStyle[client]][action[1]][client] = g_iRecordedTicks[client]; } @@ -577,7 +577,7 @@ public void StartTouch(int client, int action[3]) g_bWrcpTimeractivated[client] = false; } - if(g_bPracSrcpTimerActivated[client]) + if (g_bPracSrcpTimerActivated[client]) { g_bPracSrcpTimerActivated[client] = false; } @@ -627,7 +627,7 @@ public void StartTouch(int client, int action[3]) lastCheckpoint[g_iClientInZone[client][2]][client] = g_iPlayerPracLocationSnap[client][g_iLastSaveLocIdClient[client]] - 1; } } - else{ + else { //PrintToChatAll("style %d | cp %i | %d tick count", g_iCurrentStyle[client], action[1], g_iRecordedTicks[client]); g_iCPStartFrame_CurrentRun[g_iCurrentStyle[client]][action[1]][client] = g_iRecordedTicks[client]; } @@ -666,12 +666,12 @@ public void StartTouch(int client, int action[3]) //THIS WAY WHEN THE DATABASE HAS NO VALUES //THE PLAYERS CAN SELECT THE CHECKPOINTS OPTION IN THE REPLAY MENU WITH THE CORRECT VALUES //ONLY PERFOM ACTIONS IF THE CLIENT INDEX IS THE MAP RECORD BOT'S INDEX AND IF THERE ARE NOT REPLAY TICKS FOUND - if(IsPlayerAlive(client) && IsFakeClient(client) && !g_bReplayTickFound[g_iCurrentStyle[client]] && client == g_RecordBot){ + if (IsPlayerAlive(client) && IsFakeClient(client) && !g_bReplayTickFound[g_iCurrentStyle[client]] && client == g_RecordBot) { //MAKE BOTS REGISTER TICKS - if(action[0] == 3 || action[0] == 4) + if (action[0] == 3 || action[0] == 4) g_iCPStartFrame[g_iCurrentStyle[client]][action[1]] = g_iReplayTick[client]; - if(action[0] == 2) + if (action[0] == 2) db_UpdateReplaysTick(client, g_iCurrentStyle[client]); } diff --git a/addons/sourcemod/scripting/surftimer/timer.sp b/addons/sourcemod/scripting/surftimer/timer.sp index a4dd6d47..df56b1f1 100644 --- a/addons/sourcemod/scripting/surftimer/timer.sp +++ b/addons/sourcemod/scripting/surftimer/timer.sp @@ -647,9 +647,9 @@ public Action RestartPlayer(Handle timer, any client) public Action DatabaseUpgrading(Handle timer) { - if(!g_tables_converted) + if (!g_tables_converted) for(int client = 1; client <= MaxClients; client++) - if(IsValidClient(client)) + if (IsValidClient(client)) CPrintToChat(client, "Server is still updating database tables, pls wait..."); return Plugin_Handled; diff --git a/addons/sourcemod/scripting/surftimer/vip.sp b/addons/sourcemod/scripting/surftimer/vip.sp index 9a0a2c20..8f6f1c30 100644 --- a/addons/sourcemod/scripting/surftimer/vip.sp +++ b/addons/sourcemod/scripting/surftimer/vip.sp @@ -85,7 +85,7 @@ public void db_selectVipStatus(char szSteamId[128], int iVip, int type) WritePackCell(pack, iVip); Format(szQuery, 256, "SELECT steamid, vip, active FROM ck_vipadmins WHERE steamid = '%s';", szSteamId); - SQL_TQuery(g_hDb, db_selectVipStatusCallback, szQuery, pack, DBPrio_Low); + g_hDb.Query(db_selectVipStatusCallback, szQuery, pack, DBPrio_Low); } else { @@ -103,7 +103,7 @@ public void db_selectVipStatus(char szSteamId[128], int iVip, int type) } } Format(szQuery, 256, "UPDATE ck_vipadmins SET inuse = 0, active = 0 WHERE steamid = '%s';", szSteamId); - SQL_TQuery(g_hDb, db_removeVipCallback, szQuery, client, DBPrio_Low); + g_hDb.Query(db_removeVipCallback, szQuery, client, DBPrio_Low); } } @@ -191,7 +191,7 @@ public void db_insertVip(char szSteamId[128], int iVip) WritePackCell(pack, iVip); Format(szQuery, 256, "INSERT INTO ck_vipadmins (steamid, title, namecolour, textcolour, inuse, vip, admin, zoner) VALUES ('%s', '%s', %i, 0, 1 , %i, 0, 0);", szSteamId, szTitle, colour, iVip); - SQL_TQuery(g_hDb, db_insertVipCallback, szQuery, pack, DBPrio_Low); + g_hDb.Query(db_insertVipCallback, szQuery, pack, DBPrio_Low); } public void db_insertVipCallback(Handle owner, Handle hndl, const char[] error, DataPack pack) @@ -258,5 +258,5 @@ public void db_updateVip(char szSteamId[128], int iVip) WritePackCell(pack, iVip); Format(szQuery, 256, "UPDATE ck_vipadmins SET title = '%s', namecolour = %i, textcolour = 0, inuse = 1, vip = %i WHERE steamid = '%s';", szTitle, colour, iVip, szSteamId); - SQL_TQuery(g_hDb, db_insertVipCallback, szQuery, pack, DBPrio_Low); + g_hDb.Query(db_insertVipCallback, szQuery, pack, DBPrio_Low); } diff --git a/addons/sourcemod/scripting/test.sp b/addons/sourcemod/scripting/test.sp deleted file mode 100644 index 7594c199..00000000 --- a/addons/sourcemod/scripting/test.sp +++ /dev/null @@ -1,23 +0,0 @@ -#include - -char g_sSteamIdTablesCleanup[][] = { - "ck_bonus", - "ck_checkpoints", - "ck_latestrecords", - "ck_playeroptions2", - "ck_playerrank", - "ck_playertemp", - "ck_playertimes", - "ck_prinfo", - "ck_vipadmins" -}; - -public void OnPluginStart() -{ - char sQuery[256]; - for (int i = 0; i < sizeof(g_sSteamIdTablesCleanup); i++) - { - FormatEx(sQuery, sizeof(sQuery), "DELETE FROM \"%s\" WHERE steamid = \"STEAM_ID_STOP_IGNORING_RETVALS\";", g_sSteamIdTablesCleanup[i]); - LogMessage(sQuery); - } -} \ No newline at end of file diff --git a/scripts/mysql-files/fresh_install.sql b/scripts/mysql-files/fresh_install.sql index bc438345..0520ab52 100644 --- a/scripts/mysql-files/fresh_install.sql +++ b/scripts/mysql-files/fresh_install.sql @@ -257,3 +257,11 @@ CREATE TABLE IF NOT EXISTS ck_replays ( `style` INT(12) NOT NULL DEFAULT '0', PRIMARY KEY(`mapname`, `cp`, `style`)) DEFAULT CHARSET=utf8mb4; + +CREATE TABLE IF NOT EXISTS ck_players ( + accountid INT NOT NULL, + steamid2 VARCHAR(32) NULL, + steamid64 VARCHAR(64) NULL, + name VARCHAR(64) NULL, + PRIMARY KEY(accountid)) + EFAULT CHARSET=utf8mb4;