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

Sourcemod member authorisation


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Corrosive
Junior Member
Join Date: Aug 2008
Old 08-08-2008 , 19:03   Sourcemod member authorisation
Reply With Quote #1

Hi there,

I have a database with a member table which contains the fields: playername, steamid and ipadress.

Is there a script which authorizes joining players by these fields? When they are not authorized they should be kicked out with a kickmessage something like "you're not a member, please register!"

Thanks in advance,

Joost.
Corrosive is offline
Corrosive
Junior Member
Join Date: Aug 2008
Old 08-08-2008 , 22:06   Re: Sourcemod member authorisation
Reply With Quote #2

We're trying it with the following code, but it isn't really responding

PHP Code:
#include <sourcemod>
 
public Plugin:myinfo =
{
 
name "Authentication",
 
author " ",
 
description "Client Authentication",
 
version "1.0.0.0",
 
url " "
};
 
public 
OnPluginStart()
{
}
 
new 
Handle:hDatabase INVALID_HANDLE;
StartSQL()
{
 
SQL_TConnect(GotDatabase);
}
 
public 
GotDatabase(Handle:ownerHandle:hndl, const String:error[], any:data)
{
 if (
hndl == INVALID_HANDLE)
 {
  
LogError("Database failure: %s"error);
 } else {
  
hDatabase hndl;
 }
}

CheckSteamID(userid, const String:auth[], maxstrlen)
{
 
decl String:query[255];
 
Format(querysizeof(query), "SELECT steamid FROM cpay_users WHERE steamid = '%s'"auth);
 
SQL_TQuery(hdatabaseT_CheckSteamIDqueryuserid)
}
 
public 
T_CheckSteamID(Handle:ownerHandle:hndl, const String:error[], any:data)
{
 new 
client;
 
 
/* Make sure the client didn't disconnect while the thread was running */
 
if ((client GetClientOfUserId(data)) == 0)
 {
  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");
 }

Pleeeaase help us out here!!
Corrosive is offline
Nican
Veteran Member
Join Date: Jan 2006
Location: NY
Old 08-09-2008 , 00:20   Re: Sourcemod member authorisation
Reply With Quote #3

You defined the function "StartSQL", but you never called it...
The plugin never gets connected to the database.

Put it like this:
PHP Code:
public OnPluginStart()
{
   
StartSQL();

__________________
http://www.nican132.com
I require reputation!
Nican is offline
Send a message via ICQ to Nican Send a message via MSN to Nican
Corrosive
Junior Member
Join Date: Aug 2008
Old 08-09-2008 , 07:11   Re: Sourcemod member authorisation
Reply With Quote #4

Nice, that resolved one problem with compiling! Thnx man!


Still having 2 errors now..

/home/groups/sourcemod/upload_tmp/phpJaSUZW.sp(69) : warning 203: symbol is never used: "CheckSteamID"

/home/groups/sourcemod/upload_tmp/phpJaSUZW.sp(36) : warning 204: symbol is assigned a value that is never used: "hDatabase"

What seams to be te problem here? Am i doing something really stupid, or should this work fine in-game?
Corrosive is offline
bl4nk
SourceMod Developer
Join Date: Jul 2007
Old 08-09-2008 , 07:49   Re: Sourcemod member authorisation
Reply With Quote #5

You need to use your CheckSteamID function somewhere. I suggest putting it inside of OnClientAuthorized(client), just like you did with the StartSQL function for OnPluginStart.
bl4nk is offline
Corrosive
Junior Member
Join Date: Aug 2008
Old 08-09-2008 , 09:49   Re: Sourcemod member authorisation
Reply With Quote #6

Quote:
Originally Posted by bl4nk View Post
You need to use your CheckSteamID function somewhere. I suggest putting it inside of OnClientAuthorized(client), just like you did with the StartSQL function for OnPluginStart.

Hmmm, could you give me an example? I'm not sure how to do this exactly..

The following code is used at the moment:

PHP Code:
#include <sourcemod>
 
public Plugin:myinfo =
{
 
name "Authentication",
 
author " ",
 
description "Client Authentication",
 
version "1.0.0.0",
 
url " "
};
 
public 
OnPluginStart()
{
 
StartSQL()
}

public 
OnClientAuthorized(client)
{
 
CheckSteamID()
}
 

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

CheckSteamID(userid, const String:auth[], maxstrlen)
{
 
decl String:query[255];
 
Format(querysizeof(query), "SELECT steamid FROM cpay_users WHERE steamid = '%s'"auth);
 
SQL_TQuery(hdatabaseT_CheckSteamIDqueryuserid)
}
 
public 
T_CheckSteamID(Handle:ownerHandle:hndl, const String:error[], any:data)
{
 new 
client;
 
 
/* Make sure the client didn't disconnect while the thread was running */
 
if ((client GetClientOfUserId(data)) == 0)
 {
  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");
 }

Am i doing this the right way? It is giving the following errors:

/home/groups/sourcemod/upload_tmp/phpxA2sKr.sp(24) : error 092: number of arguments does not match definition
/home/groups/sourcemod/upload_tmp/phpxA2sKr.sp(53) : error 017: undefined symbol "hdatabase"
/home/groups/sourcemod/upload_tmp/phpxA2sKr.sp(44) : warning 204: symbol is assigned a value that is never used: "hDatabase"

2 Errors.



Any suggestions on how to get this script working?

Thnx in advance!

Last edited by Corrosive; 08-09-2008 at 10:01.
Corrosive is offline
Lebson506th
Veteran Member
Join Date: Jul 2008
Old 08-09-2008 , 10:57   Re: Sourcemod member authorisation
Reply With Quote #7

Code:
forward OnClientAuthorized(client, const String:auth[]);
Use the Sourcemod API to see proper use of functions.

http://docs.sourcemod.net/api/

Also, rename "hdatabase" to "hDatabase"

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

Lebson506th is offline
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
Corrosive
Junior Member
Join Date: Aug 2008
Old 08-10-2008 , 18:59   Re: Sourcemod member authorisation
Reply With Quote #9

SWEET! it's working!!

Big up for mr. bl4nk
Corrosive is offline
Lebson506th
Veteran Member
Join Date: Jul 2008
Old 07-12-2011 , 16:01   Re: Sourcemod member authorisation
Reply With Quote #10

The one that bl4nk posted 2 above you is only for Steam ID
__________________
My Plugins
Spray Tracer by Nican, maintained by me
Simple TK Manager
DoD:S Admin Weapons

Links
Resistance and Liberation (A HL2 Multiplayer Modification)
Lebson506th 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 08:32.


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