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

[Need help] Check if connecting client's steamid is in database


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
Mooni
SourceMod Donor
Join Date: Dec 2012
Location: Sweden
Old 01-30-2013 , 06:56   [Need help] Check if connecting client's steamid is in database
Reply With Quote #1

Okey, lets jump right in to it.

Im kinda new to coding overall. (made some minecraft bukkit plugins(java) and also some kind of 2d java game about 6-8 moths ago.)

And i started trying with sourcepawn about 1 month ago and after searching the forum, api and wiki, and whatching some youtube tuts I desided to ask for help.

I think it is pretty simple,
when client connect it checks if his steamid is in the database and if it is he gets the 2 admin flags, if not it checks if he got the 2 flags and if he do it removes them.

(It's for Counter-Strike: Source)

Here is what i currently got:
PHP Code:
#include <sourcemod>

#define PLUGIN_VERSION    "1.0"

new Handle:DB INVALID_HANDLE;

public 
Plugin:myinfo = {
    
name "VipReload",
    
author "Mooni",
    
description "Vip Reload Plugin",
    
version PLUGIN_VERSION,
    
url "www.ggaming.se"
};

public 
OnPluginStart()
{
    new 
String:Error[70];
    
DB SQL_Connect("VipPlugin"trueErrorsizeof(Error));
    if(
DB == INVALID_HANDLE)
    {
        
PrintToServer("[ERROR] Cannot connect to MySQL Server: %s"Error);
        
CloseHandle(DB);
    }
    else
    {
        
PrintToServer("Connection Successful");
    }
}

public 
OnClientConnect(client)
{
//I think something like: if(steamid == DBsteamid)
    /**
    new String:steamid[32];
    GetClientAuthString(client, steamid, 32);
    
    if(steamid == hQuery)
    {
        SetAdminFlag(steamid, ADMFLAG_CUSTOM6);
        SetAdminFlag(steamid, ADMFLAG_RESERVATION);
    }
    **/
}

GetSomeInfo(Handle:DB, const String:name[], client)
{
    new 
Handle:hQuery
    
new String:query[200]
    
    
/* Create enough space to make sure our string is quoted properly  */
    
new buffer_len strlen(name) * 1
    
new String:new_name[buffer_len]
    
    
/* Ask the SQL driver to make sure our string is safely quoted */
    
SQL_QuoteString(DBnamenew_namebuffer_len);
    
    
/* Build the query */
    
Format(querysizeof(query), "SELECT steamid FROM viplist");
    
    
/* Execute the query */
    
if ((hQuery SQL_Query(query)) == INVALID_HANDLE)
    {
        return 
0
    
}
    
/* Get some info here */
    
DBsteamid SQL_FetchRow(hQuery)
    
    
CloseHandle(hQuery)

And im pretty sure i got the databases.cfg setup right but here it is anyway:
Code:
	"VipPlugin"
	{
		"driver"			"default"
		"host"				"my host ip"
		"database"			"my db"
		"user"				"my db user"
		"pass"				"my db user pw"
		//"timeout"			"0"
		"port"			"3306"
	}

Last edited by Mooni; 01-30-2013 at 07:04. Reason: (It's for Counter-Strike: Source)
Mooni 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 03:58.


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