updated table names to actual DB, vip works with select queries now

This commit is contained in:
christian 2021-06-29 15:55:07 +02:00
parent 280dc0ca67
commit 397bc99bb3

View File

@ -56,16 +56,19 @@ public Plugin myinfo =
public void OnPluginStart()
{
EstablishConnection();
}
public void EstablishConnection()
{
if (SQL_CheckConfig("xenforo"))
{
Database.Connect(ConnectionCallback, "xenforo");
}
else
{
SetFailState("'xenforo' not found in 'sourcemod/configs/databases.cfg'");
}
}
public void ConnectionCallback(Database db, const char[] error, any data)
{
@ -83,17 +86,20 @@ public void ConnectionCallback(Database db, const char[] error, any data)
for(int client = 1; client <= MaxClients; client++)
{
if(IsClientConnected(client))
{
OnClientConnected(client);
}
if(IsClientAuthorized(client) && !IsFakeClient(client))
{
char sSteamID32[32];
if(GetClientAuthId(client, AuthId_Steam2, sSteamID32, sizeof(sSteamID32)))
{
OnClientAuthorized(client, sSteamID32);
}
}
}
}
}
@ -104,7 +110,9 @@ public void ConnectionCallback(Database db, const char[] error, any data)
public void OnRebuildAdminCache(AdminCachePart part)
{
if (part != AdminCache_Admins)
{
return;
}
CreateTimer(1.0, OnRebuildAdminCachePost, INVALID_HANDLE, TIMER_FLAG_NO_MAPCHANGE);
}
@ -117,9 +125,11 @@ public Action OnRebuildAdminCachePost(Handle hTimer)
for (int client = 1; client <= MaxClients; client++)
{
if(G_bResponsePassed[client] && G_bPreAdminChecked[client])
{
ApplyGroupFlags(client);
}
}
}
//----------------------------------------------------------------------------------------------------
// Purpose:
@ -151,26 +161,17 @@ public void OnClientDisconnect(int client)
public void OnClientAuthorized(int client, const char[] sSteamID32)
{
if (IsFakeClient(client))
{
return;
}
char sSteamID64[32];
SteamID32toSteamID64(sSteamID32, sSteamID64, sizeof(sSteamID64));
char sRequest[256];
Format(sRequest, sizeof(sRequest), "select * from unloze_forum.xf_user_external_auth ka inner JOIN unloze_forum.xf_user_upgrade_active kak on ka.user_id = kak.user_id where provider_key = '%s'", sSteamID64);
Format(sRequest, sizeof(sRequest), "select * from unloze_forum_2.xf_user_connected_account ka inner JOIN unloze_forum_2.xf_user_upgrade_active kak on ka.user_id = kak.user_id where provider_key = '%s'", sSteamID64);
//PrintToChatAll("OnClientAuthorized plugin start sRequest: %s", sRequest);
g_hDatabase.Query(SQL_FUCKYOU, sRequest, GetClientSerial(client));
/*FormatEx(sRequest, sizeof(sRequest), "https://unloze.com/api/private_api.php?api_key=%s&steam_id=%s", UNLOZE_APIKEY, sSteamID64);
int iSerial = GetClientSerial(client);
Handle hRequest = SteamWorks_CreateHTTPRequest(k_EHTTPMethodGET, sRequest);
if (!hRequest ||
!SteamWorks_SetHTTPCallbacks(hRequest, OnClientAuthorized_OnTransferComplete) ||
!SteamWorks_SetHTTPRequestContextValue(hRequest, iSerial) ||
!SteamWorks_SendHTTPRequest(hRequest))
{
delete hRequest;
}*/
}
//----------------------------------------------------------------------------------------------------
@ -179,9 +180,11 @@ public void OnClientAuthorized(int client, const char[] sSteamID32)
public void SQL_FUCKYOU(Database db, DBResultSet results, const char[] error, int data)
{
int client;
if ((client = GetClientFromSerial(data)) == 0)
if ((client = GetClientFromSerial(data)) == 0 || db == null || results == null)
{
return;
}
//PrintToChatAll("SQL fuck you");
if (results.RowCount && results.FetchRow())
{
OnClientAuthorized_OnTransferResponse("Game-Donator", data);
@ -193,7 +196,7 @@ public void SQL_FUCKYOU(Database db, DBResultSet results, const char[] error, in
char sSteamID64[32];
SteamID32toSteamID64(sSID, sSteamID64, sizeof(sSteamID64));
char sRequest[256];
Format(sRequest, sizeof(sRequest), "select * from unloze_forum.xf_user xfu inner join unloze_forum.xf_user_external_auth xuea ON xfu.user_id = xuea.user_id where find_in_set('6',secondary_group_ids) <> 0 and provider_key = '%s'", sSteamID64);
Format(sRequest, sizeof(sRequest), "select * from unloze_forum_2.xf_user xfu inner join unloze_forum_2.xf_user_connected_account xuea ON xfu.user_id = xuea.user_id where find_in_set('6',secondary_group_ids) <> 0 and provider_key = '%s'", sSteamID64);
g_hDatabase.Query(SQL_FUCKYOU_mapper, sRequest, GetClientSerial(client));
}
}
@ -204,9 +207,10 @@ public void SQL_FUCKYOU(Database db, DBResultSet results, const char[] error, in
public void SQL_FUCKYOU_mapper(Database db, DBResultSet results, const char[] error, int data)
{
int client;
if ((client = GetClientFromSerial(data)) == 0)
if ((client = GetClientFromSerial(data)) == 0 || db == null || results == null)
{
return;
}
if (results.RowCount && results.FetchRow())
{
OnClientAuthorized_OnTransferResponse("Game-Donator", data);
@ -218,7 +222,7 @@ public void SQL_FUCKYOU_mapper(Database db, DBResultSet results, const char[] er
char sSteamID64[32];
SteamID32toSteamID64(sSID, sSteamID64, sizeof(sSteamID64));
char sRequest[256];
Format(sRequest, sizeof(sRequest), "select * from unloze_forum.xf_user xfu inner join unloze_forum.xf_user_external_auth xuea ON xfu.user_id = xuea.user_id where find_in_set('21',secondary_group_ids) <> 0 and provider_key = '%s'", sSteamID64);
Format(sRequest, sizeof(sRequest), "select * from unloze_forum_2.xf_user xfu inner join unloze_forum_2.xf_user_connected_account xuea ON xfu.user_id = xuea.user_id where find_in_set('21',secondary_group_ids) <> 0 and provider_key = '%s'", sSteamID64);
g_hDatabase.Query(SQL_FUCKYOU_retired, sRequest, GetClientSerial(client));
}
}
@ -228,6 +232,10 @@ public void SQL_FUCKYOU_mapper(Database db, DBResultSet results, const char[] er
//----------------------------------------------------------------------------------------------------
public void SQL_FUCKYOU_retired(Database db, DBResultSet results, const char[] error, int data)
{
if ( db == null || results == null)
{
return;
}
if (results.RowCount && results.FetchRow())
{
OnClientAuthorized_OnTransferResponse("Game-Donator", data);
@ -246,19 +254,23 @@ public int OnClientAuthorized_OnTransferResponse(char[] sData, int iSerial)
int client = GetClientFromSerial(iSerial);
if (!client) //Player disconnected.
{
return;
}
TrimString(sData);
StripQuotes(sData);
//PrintToChatAll("reached sData with status 200");
//LogMessage("reached sData with status 200: %s", sData);
strcopy(G_sGroup[client], sizeof(G_sGroup[]), sData);
G_bResponsePassed[client] = true;
if (G_bPreAdminChecked[client])
{
NotifyPostAdminCheck(client);
}
}
//----------------------------------------------------------------------------------------------------
// Purpose:
@ -268,7 +280,9 @@ public Action OnClientPreAdminCheck(int client)
G_bPreAdminChecked[client] = true;
if (G_bResponsePassed[client] || G_bResponseFailed[client])
{
return Plugin_Continue;
}
RunAdminCacheChecks(client);
return Plugin_Handled;
@ -288,8 +302,9 @@ public void OnClientPostAdminFilter(int client)
stock void ApplyGroupFlags(int client)
{
if (!G_bResponsePassed[client])
{
return;
}
AdminId AdmID;
GroupId GrpID;
@ -332,7 +347,7 @@ public int Native_AsyncHasSteamIDReservedSlot(Handle plugin, int numParams)
SteamID32toSteamID64(sSteamID32, sSteamID64, sizeof(sSteamID64));
char sRequest[256];
Format(sRequest, sizeof(sRequest), "select * from unloze_forum.xf_user_external_auth ka inner JOIN unloze_forum.xf_user_upgrade_active kak on ka.user_id = kak.user_id where provider_key = '%s'", sSteamID64);
Format(sRequest, sizeof(sRequest), "select * from unloze_forum_2.xf_user_connected_account ka inner JOIN unloze_forum_2.xf_user_upgrade_active kak on ka.user_id = kak.user_id where provider_key = '%s'", sSteamID64);
DataPack hDataPack = new DataPack();
hDataPack.WriteString(sSteamID32);
@ -345,6 +360,10 @@ public int Native_AsyncHasSteamIDReservedSlot(Handle plugin, int numParams)
public void SQL_FUCKYOU2(Database db, DBResultSet results, const char[] error, DataPack fuck)
{
if (db == null || results == null)
{
return;
}
if (results.RowCount && results.FetchRow())
{
Native_AsyncHasSteamIDReservedSlot_OnTransferResponse("Game-Donator", fuck);
@ -357,13 +376,17 @@ public void SQL_FUCKYOU2(Database db, DBResultSet results, const char[] error, D
char sSteamID64[32];
SteamID32toSteamID64(sSID, sSteamID64, sizeof(sSteamID64));
char sRequest[256];
Format(sRequest, sizeof(sRequest), "select * from unloze_forum.xf_user xfu inner join unloze_forum.xf_user_external_auth xuea ON xfu.user_id = xuea.user_id where find_in_set('6',secondary_group_ids) <> 0 and provider_key = '%s'", sSteamID64);
Format(sRequest, sizeof(sRequest), "select * from unloze_forum_2.xf_user xfu inner join unloze_forum_2.xf_user_connected_account xuea ON xfu.user_id = xuea.user_id where find_in_set('6',secondary_group_ids) <> 0 and provider_key = '%s'", sSteamID64);
g_hDatabase.Query(SQL_FUCKYOU_mapper2, sRequest, fuck);
}
}
public void SQL_FUCKYOU_mapper2(Database db, DBResultSet results, const char[] error, DataPack fuck)
{
if (db == null || results == null)
{
return;
}
if (results.RowCount && results.FetchRow())
{
Native_AsyncHasSteamIDReservedSlot_OnTransferResponse("Game-Donator", fuck);
@ -376,13 +399,18 @@ public void SQL_FUCKYOU_mapper2(Database db, DBResultSet results, const char[] e
char sSteamID64[32];
SteamID32toSteamID64(sSID, sSteamID64, sizeof(sSteamID64));
char sRequest[256];
Format(sRequest, sizeof(sRequest), "select * from unloze_forum.xf_user xfu inner join unloze_forum.xf_user_external_auth xuea ON xfu.user_id = xuea.user_id where find_in_set('21',secondary_group_ids) <> 0 and provider_key = '%s'", sSteamID64);
Format(sRequest, sizeof(sRequest), "select * from unloze_forum_2.xf_user xfu inner join unloze_forum_2.xf_user_connected_account xuea ON xfu.user_id = xuea.user_id where find_in_set('21',secondary_group_ids) <> 0 and provider_key = '%s'", sSteamID64);
//LogMessage("sRequest: %s", sRequest);
g_hDatabase.Query(SQL_FUCKYOU_retired2, sRequest, fuck);
}
}
public void SQL_FUCKYOU_retired2(Database db, DBResultSet results, const char[] error, DataPack fuck)
{
if (db == null || results == null)
{
return;
}
if (results.RowCount && results.FetchRow())
{
Native_AsyncHasSteamIDReservedSlot_OnTransferResponse("Game-Donator", fuck);
@ -393,22 +421,6 @@ public void SQL_FUCKYOU_retired2(Database db, DBResultSet results, const char[]
}
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
/*public int Native_AsyncHasSteamIDReservedSlot_OnTransferComplete(Handle hRequest, bool bFailure, bool bSuccessful, EHTTPStatusCode eStatusCode, DataPack hDataPack)
{
if (bFailure || !bSuccessful || eStatusCode != k_EHTTPStatusCode200OK)
{
char sData[32] = "NOGROUP";
Native_AsyncHasSteamIDReservedSlot_OnTransferResponse(sData, hDataPack);
delete hRequest;
return;
}
SteamWorks_GetHTTPResponseBodyCallback(hRequest, Native_AsyncHasSteamIDReservedSlot_OnTransferResponse, hDataPack);
}*/
//----------------------------------------------------------------------------------------------------
// Purpose:
@ -434,9 +446,13 @@ public int Native_AsyncHasSteamIDReservedSlot_OnTransferResponse(char[] sData, D
int result;
if (StrEqual(sData, "Game-Donator", false))
{
result = 1;
}
else
{
result = 0;
}
Call_StartFunction(plugin, callback);
Call_PushString(sSteamID32);
@ -477,18 +493,3 @@ stock bool SteamID32toSteamID64(const char[] sSteamID32, char[] sSteamID64, int
}
stock void PrintToMe(char[] sText, any:...)
{
char steamid[64];
for (int i = 1; i < MaxClients; i++)
{
if(IsClientConnected(i) && IsClientInGame(client) && GetUserFlagBits(i) & ADMFLAG_RCON)
{
GetClientAuthId(i, AuthId_SteamID64, steamid, sizeof steamid);
if(StrEqual(steamid, "76561198018661517"))
{
PrintToChat(i, sText);
}
}
}
}