Raised This Month: $ Target: $400
 0% 

[CS:GO] sql help


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
TomeR917
Junior Member
Join Date: Jul 2014
Old 07-26-2014 , 04:10   [CS:GO] sql help
Reply With Quote #1

i made callback to check if active is 1 or 0.
this is the code:

PHP Code:
public Action:Command_VipMenu(client,args)
{
    
    
decl String:auth[255];
    
GetClientAuthString(client,auth,sizeof(auth));
    
decl String:Query[255];
    
Format(Querysizeof(Query), "SELECT active FROM donators WHERE steamid = '%s'"auth);
    
//SQL_TQuery(dData, T_CheckDonator, Query, client);
    
    
    
if(SQL_TQuery(dDataT_CheckDonatorQueryclient)==1)
    {
        
TopMenu(client);
    }
    
    else 
PrintToChat(client,"[\x02Donator\x01] You are not a donator");

the callback is:

PHP Code:
public T_CheckDonator(Handle:ownerHandle:hndl, const String:error[], any:theuser)
{
    
    if (!
IsClientConnected(theuser)) return 0;
    if (
hndl == INVALID_HANDLE)
    {
        
LogError("Query failed! %s"error);
        
PrintToChatAll("a0");
        return 
0;
    } 
    else
    {
        
decl String:Clientsteamid[255];
        
GetClientAuthString(theuserClientsteamidsizeof(Clientsteamid));
        
PrintToChatAll("%s",Clientsteamid);
        if(
SQL_FetchRow(hndl)) 
        {
            if(
SQL_FetchInt(hndl,0)==0)
            {
                
PrintToChatAll("b0");
                return 
0;
            }
            
            if(
SQL_FetchInt(hndl,0)==1)
            {
                
PrintToChatAll("1");
                return 
1;
            }
            
            else 
            {
                
PrintToChatAll("c0");
                return 
0;
            }
        }
        
        else 
        {
            
PrintToChatAll("d0");
            return 
0;
        }
    }
    

i made the printtochat all in the callback to check where it goes.
if active=1 it goes into the return 1;
if active=0 it goes into PrintToChat("b0") and then return 0;
but in the command vipmenu it always opens the menu even if active is 0.
i need help pls.
TomeR917 is offline
splewis
Veteran Member
Join Date: Feb 2014
Location: United States
Old 07-26-2014 , 14:20   Re: [CS:GO] sql help
Reply With Quote #2

SQL_TQuery doesn't return the result of the query - in fact, it returns nothing. You could fix this by moving the menu open/"you are not a donator!" logic into the callback.

However, that means there might be latency between the command and the reply, so I'd suggest making an array for each client that stores if they are a donator, then in the command you'll just check that array. Then you should set the value when a client connects.

Something like:
Code:
new bool:g_IsVIP[MAXPLAYERS+1];
Then when a player connects you do that SQL_TQuery call that takes care of setting the value for the client.
__________________

Last edited by splewis; 07-26-2014 at 17:31.
splewis is offline
TomeR917
Junior Member
Join Date: Jul 2014
Old 07-26-2014 , 17:02   Re: [CS:GO] sql help
Reply With Quote #3

thank you so much i will use the way you suggest it is so much easier
TomeR917 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 22:27.


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