Raised This Month: $51 Target: $400
 12% 

Donation System for you, but needs a small fix.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
casvdry
Member
Join Date: Mar 2008
Old 09-09-2010 , 15:08   Donation System for you, but needs a small fix.
Reply With Quote #1

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"trueerrorsizeof(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(clientsteamidsizeof(steamid));
    
    
Format(querysizeof(query), "SELECT id_member FROM smf_themes WHERE variable = 'cust_steami' AND value = '%s'"steamid);
    
SQL_TQuery(dbSQLQueryIDqueryGetClientUserId(client));
}

public 
SQLQueryID(Handle:ownerHandle: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(querysizeof(query), "SELECT end_time FROM smf_log_subscribed WHERE id_member = %i AND status = 1"SQL_FetchInt(hndl0));
        
SQL_TQuery(dbSQLQuerySubscriptionqueryGetClientUserId(client));
    }
}

public 
SQLQuerySubscription(Handle:ownerHandle: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(hndl0) - GetTime();
        if(
remain 0) {
            return;
        }
    
        
SetUserFlagBits(clientGetUserFlagBits(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
Attached Files
File Type: sp Get Plugin or Get Source (SMFDonation.sp - 285 views - 1.6 KB)

Last edited by casvdry; 09-09-2010 at 15:29.
casvdry is offline
Gippo
AlliedModders Donor
Join Date: Oct 2008
Old 09-09-2010 , 23:48   Re: Donation System for you, but needs a small fix.
Reply With Quote #2

can you make it work for vbulletin?
Gippo is offline
thetwistedpanda
Good Little Panda
Join Date: Sep 2008
Old 09-10-2010 , 00:03   Re: Donation System for you, but needs a small fix.
Reply With Quote #3

or phpbb :-o
__________________
thetwistedpanda is offline
Xp3r7
SourceMod Donor
Join Date: Jul 2006
Old 09-10-2010 , 09:12   Re: Donation System for you, but needs a small fix.
Reply With Quote #4

Quote:
Originally Posted by Gippo View Post
can you make it work for vbulletin?
I 2nd this.
__________________
Xp3r7 is offline
Send a message via MSN to Xp3r7
Bloodlvst
Senior Member
Join Date: Jul 2007
Old 09-10-2010 , 09:27   Re: Donation System for you, but needs a small fix.
Reply With Quote #5

Why would he do that. Just switch to SMF, it's the best forum out there anyway. ;)
__________________
Quote:
skywalker: I have cs source client 5 how to upgrade to client 7
BAILOPAN: oh
Bloodlvst is offline
Groger
Veteran Member
Join Date: Oct 2009
Location: Belgium
Old 09-10-2010 , 10:21   Re: Donation System for you, but needs a small fix.
Reply With Quote #6

Quote:
Originally Posted by thetwistedpanda View Post
or phpbb :-o
Haha that indeed would be awsome..
Groger is offline
Inflikted
SourceMod Donor
Join Date: Jan 2009
Old 09-10-2010 , 10:47   Re: Donation System for you, but needs a small fix.
Reply With Quote #7

this 'should' work for vbulletin. i haven't checked but the columns should be right you still have to setup the subscription and custom steam profile field.

the only thing you may have to change in the plugin is.. when you manually add in the vbulletin custom profile field. you must pay attention to the field #.. by default I have it setup to field5 in the plugin


but just so you guys understand this plugin from the looks of it will only add in donators, it won't remove them.
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"trueerrorsizeof(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(clientsteamidsizeof(steamid));
    
    
Format(querysizeof(query), "SELECT userid FROM userfield WHERE field5 = '%s'"steamid);
    
SQL_TQuery(dbSQLQueryIDqueryGetClientUserId(client));
}

public 
SQLQueryID(Handle:ownerHandle: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(querysizeof(query), "SELECT expirydate FROM subscriptionlog WHERE userid = %i AND status = 1"SQL_FetchInt(hndl0));
        
SQL_TQuery(dbSQLQuerySubscriptionqueryGetClientUserId(client));
    }
}

public 
SQLQuerySubscription(Handle:ownerHandle: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(hndl0) - GetTime();
        if(
remain 0) {
            return;
        }
    
        
SetUserFlagBits(clientGetUserFlagBits(client) | ADMFLAG_RESERVATION);
    }


Last edited by Inflikted; 09-10-2010 at 10:50.
Inflikted is offline
casvdry
Member
Join Date: Mar 2008
Old 09-10-2010 , 12:00   Re: Donation System for you, but needs a small fix.
Reply With Quote #8

Quote:
Originally Posted by Inflikted View Post
this 'should' work for vbulletin. i haven't checked but the columns should be right you still have to setup the subscription and custom steam profile field.

the only thing you may have to change in the plugin is.. when you manually add in the vbulletin custom profile field. you must pay attention to the field #.. by default I have it setup to field5 in the plugin


but just so you guys understand this plugin from the looks of it will only add in donators, it won't remove them.
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"trueerrorsizeof(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(clientsteamidsizeof(steamid));
    
    
Format(querysizeof(query), "SELECT userid FROM userfield WHERE field5 = '%s'"steamid);
    
SQL_TQuery(dbSQLQueryIDqueryGetClientUserId(client));
}

public 
SQLQueryID(Handle:ownerHandle: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(querysizeof(query), "SELECT expirydate FROM subscriptionlog WHERE userid = %i AND status = 1"SQL_FetchInt(hndl0));
        
SQL_TQuery(dbSQLQuerySubscriptionqueryGetClientUserId(client));
    }
}

public 
SQLQuerySubscription(Handle:ownerHandle: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(hndl0) - GetTime();
        if(
remain 0) {
            return;
        }
    
        
SetUserFlagBits(clientGetUserFlagBits(client) | ADMFLAG_RESERVATION);
    }

That looks like it may work. It'd be nice for someone to try it and confirm here. It will remove donators, because they won't get the flag if their sub isn't active.
casvdry is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 04:48.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode