PHP Code:
#pragma semicolon 1
#include <sourcemod>
new Handle:db = INVALID_HANDLE;
public OnPluginStart() {
decl String:error[256];
if(SQL_CheckConfig("reg")) {
db = SQL_Connect("reg", true, error, sizeof(error));
} else {
SetFailState("Didn't find database.");
}
if(db == INVALID_HANDLE) {
SetFailState("Could not connect to database: %s", error);
}
}
public OnClientPostAdminCheck(client) {
decl String:query[256], String:steamid[32];
GetClientAuthString(client, steamid, sizeof(steamid));
Format(query, sizeof(query), "SELECT id_member FROM smf_themes WHERE variable = 'cust_steami' AND value = '%s'", steamid);
SQL_TQuery(db, SQLQueryID, query, GetClientUserId(client));
}
public SQLQueryID(Handle:owner, Handle:hndl, const String:error[], any:data) {
if(!StrEqual("", error)) {
LogError("Query failed: %s", error);
}
new client = GetClientOfUserId(data);
if(client == 0) {
return;
}
if(SQL_FetchRow(hndl)) {
decl String:query[256];
Format(query, sizeof(query), "SELECT end_time FROM smf_log_subscribed WHERE id_member = %i AND status = 1", SQL_FetchInt(hndl, 0));
SQL_TQuery(db, SQLQuerySubscription, query, GetClientUserId(client));
}
}
public SQLQuerySubscription(Handle:owner, Handle:hndl, const String:error[], any:data) {
if(!StrEqual("", error)) {
LogError("Query failed: %s", error);
}
new client = GetClientOfUserId(data);
if(client == 0) {
return;
}
if(SQL_FetchRow(hndl)) {
new remain = SQL_FetchInt(hndl, 0) - GetTime();
if(remain < 0) {
return;
}
SetUserFlagBits(client, GetUserFlagBits(client) | ADMFLAG_RESERVATION);
}
}
The problem is that I get the error in logs:
Native "SQL_FetchInt" reported: Current result set has no fetched rows.
Here is how the 2 tables look. (See Attachments).
Here is how the plugin functions:
A user enters his steamid into a custom profile field I've added to the SMF 2.0 forum software. Once he does this, he can purchase a subscription that you've added to your forums. The plugin is supposed to check the DB and look for the user and make sure his sub is active and then grant reserved flag for him until it no longer shows as active.
This is free for anyone to use on their own server/forum but in its current condition it doesn't appear to be working.
EDIT: Okay the original author fixed it. It's free to use here, when I can get the time to format a decent looking post I may submit it as a plugin. The code above should work. It's only for SMF 2.0, not 1.x