Raised This Month: $ Target: $400
 0% 

Sourcemod member authorisation


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
bl4nk
SourceMod Developer
Join Date: Jul 2007
Old 08-09-2008 , 12:48   Re: Sourcemod member authorisation
Reply With Quote #8

PHP Code:
#include <sourcemod>

new Handle:hDatabase INVALID_HANDLE;

public 
Plugin:myinfo =
{
 
name "Authentication",
 
author " ",
 
description "Client Authentication",
 
version "1.0.0.0",
 
url " "
};

public 
OnPluginStart()
{
    
StartSQL()
}

public 
OnClientAuthorized(client)
{
    
decl String:auth[32];
    
GetClientAuthString(clientauthsizeof(auth));

    
CheckSteamID(clientauth)
}

public 
GotDatabase(Handle:ownerHandle:hndl, const String:error[], any:data)
{
    if (
hndl == INVALID_HANDLE)
    {
        
LogError("Database failure: %s"error);
    }
    else
    {
        
hDatabase hndl;
    }
}

public 
T_CheckSteamID(Handle:ownerHandle:hndl, const String:error[], any:client)
{
    
/* Make sure the client didn't disconnect while the thread was running */
    
if (!IsClientConnected(client))
    {
        return;
    }

    if (
hndl == INVALID_HANDLE)
    {
        
LogError("Query failed! %s"error);
        
KickClient(client"Authorization failed");
    }
    else if (!
SQL_GetRowCount(hndl))
    {
        
KickClient(client"You are not a member");
    }
}

StartSQL()
{
    
SQL_TConnect(GotDatabase);
}

CheckSteamID(userid, const String:auth[])
{
    
decl String:query[255];
    
Format(querysizeof(query), "SELECT steamid FROM cpay_users WHERE steamid = '%s'"auth);
    
SQL_TQuery(hDatabaseT_CheckSteamIDqueryuserid)

bl4nk is offline
 



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 21:31.


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