Author
|
Message
|
New Member
|
08-22-2023
, 00:33
SQL plugin help
|
#1
|
Hi I need help with this plugin I read SQL documentation. How do I make this plugin from SQL documentation run the CheckSteamID? and I'm wondering how do I link CheckSteamID with OnClientAuthorized so its checked when someone joins?
public void OnPluginStart()
{
//Database Connection
StartSQL();
}
Database hDatabase = null;
void StartSQL()
{
Database.Connect(GotDatabase, "databasename");
}
public void GotDatabase(Database db, const char[] error, any data)
{
if (db == null)
{
LogError("Database failure: %s", error);
}
else
{
hDatabase = db;
}
}
public void CheckSteamID(int userid, const char[] auth)
{
char query[255];
FormatEx(query, sizeof(query), "SELECT userid FROM users WHERE steamid = '%s'", auth);
hdatabase.Query(T_CheckSteamID, query, userid);
}
public void T_CheckSteamID(Database db, DBResultSet results, const char[] error, any data)
{
int client = 0;
/* Make sure the client didn't disconnect while the thread was running */
if ((client = GetClientOfUserId(data)) == 0)
{
return;
}
if (db == null || results == null || error[0] != '\0')
{
LogError("Query failed! %s", error);
KickClient(client, "Authorization failed");
}
else if (results.RowCount == 0)
{
KickClient(client, "You are not a member");
}
}
|
|
|
|