Quote:
Originally Posted by bl4nk
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:owner, Handle: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(query, sizeof(query), "SELECT steamid FROM cpay_users WHERE steamid = '%s'", auth);
SQL_TQuery(hdatabase, T_CheckSteamID, query, userid)
}
public T_CheckSteamID(Handle:owner, Handle: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!