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

Save User Information after SQL_TQuery


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
BFBombi
Junior Member
Join Date: Jul 2011
Old 07-13-2011 , 18:30   Save User Information after SQL_TQuery
Reply With Quote #1

Hey, i have a problem. I need to save user information after that when plugin do database connection and get from there steam id.

Piece of my code
PHP Code:
// Include
#include <sourcemod>
#include <dbi>

// Database
new Handle:Database;

// Privileges
new privileges;

// Version
#define _V "1.0.0"

public Plugin:myinfo =
{
    
name        "Name",
    
author    "author",
    
description    "description",
    
version        _V,
    
url            "url"
}

public 
OnPluginStart()
{    
    
// Set log file
    
BuildPath(Path_SMlogFilesizeof(logFile), "logs/premium.log");
    
    
// Connect to database
    
SQL_TConnect(GotDatabase"premium");
}

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)
    {
        
LogToFile(logFile"%s."error);
    }
    else 
    {
        
Database hndl;
    }    
}

CheckSteamID(userid, const String:auth[])
{
    
decl String:query[255];
    
Format(querysizeof(query), "SELECT steam_id FROM premium_users WHERE steam_id = '%s'"auth);
    
SQL_TQuery(DatabaseT_CheckSteamIDqueryuserid);
}  

public 
T_CheckSteamID(Handle:ownerHandle:hndl, const String:error[], any:client)
{    
    if (
hndl == INVALID_HANDLE)
    {
        
LogToFile(logFile"%s."error);
        
privileges 0;
    }
    else if (!
SQL_GetRowCount(hndl))
    {
        
privileges 0;
    }
    else
    {
        
privileges 1;
    }

This is not all my code, only piece wich connected with database

Problem:
When i connected i have privileges = 1, when someone connectec and happend restart round, privileges = 1 set to privileges = 0. But i need that i have privileges = 1 all map.

P.S - Sorry for my bad english.
Please help me.
BFBombi is offline
databomb
Veteran Member
Join Date: Jun 2009
Location: california
Old 07-13-2011 , 19:56   Re: Save User Information after SQL_TQuery
Reply With Quote #2

consider using ClientPrefs for this instead..

but mainly, instead of

PHP Code:
new privileges
you should have

PHP Code:
new g_bIsPremium[MAXPLAYERS+1]; 
__________________
databomb is offline
BFBombi
Junior Member
Join Date: Jul 2011
Old 07-14-2011 , 04:19   Re: Save User Information after SQL_TQuery
Reply With Quote #3

Big thanks ! It's work !
BFBombi 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 20:59.


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