Raised This Month: $32 Target: $400
 8% 

OnClientAuthorized


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
boynedmaster
Member
Join Date: Jun 2012
Old 04-30-2014 , 18:31   OnClientAuthorized
Reply With Quote #1

Here's my code.
Code:
public OnClientAuthorized(client, const String:auth[]){
	PrintToServer("error 1");
	
	if(!IsFakeClient(client)){
		PrintToServer("error 2");
		GetClientAuthString(client, clientauth, sizeof(clientauth));
		
		Format(query, sizeof(query), "SELECT * FROM accounts WHERE `steamid`='%s'", clientauth);
		
		new Handle:q = SQL_Query(db, query);
		
		if(q == INVALID_HANDLE){
			SQL_GetError(db, error, sizeof(error));
			PrintToServer("Query fail: %s", error);
			PrintToServer("error 2.5");
		}
		
		PrintToServer("error 3");
		
		if(SQL_GetRowCount(q) == 0){
			PrintToServer("error 4");
			Format(query, sizeof(query), "INSERT INTO accounts(`steamid`) VALUES('%s')", clientauth);
			PrintToChat(client, "Thanks for joining! You've been put in our database.");
		}
	}
}
I only get "error 1" and "error 2".
I don't get any errors in the server. What's happening?
__________________
I mean Venusaur...with a question mark
boynedmaster is offline
boynedmaster
Member
Join Date: Jun 2012
Old 04-30-2014 , 20:09   Re: OnClientAuthorized
Reply With Quote #2

do we have some top notch programmers here or what
__________________
I mean Venusaur...with a question mark
boynedmaster is offline
Dr. Greg House
Professional Troll,
Part-Time Asshole
Join Date: Jun 2010
Old 04-30-2014 , 20:12   Re: OnClientAuthorized
Reply With Quote #3

Sorry we don't even have Notch.
__________________
Santa or Satan?

Watch out when you're paying people for private requests! Most stuff already exists and you can hardly assess the quality of what you'll get, and if it's worth the money.
Dr. Greg House is offline
blaacky
Senior Member
Join Date: Oct 2012
Old 04-30-2014 , 23:03   Re: OnClientAuthorized
Reply With Quote #4

If error 3 doesn't show up and you have no errors then it probably means your server is freezing from that query.
blaacky is offline
friagram
Veteran Member
Join Date: Sep 2012
Location: Silicon Valley
Old 05-01-2014 , 05:02   Re: OnClientAuthorized
Reply With Quote #5

You should use threaded queries, and your print message will probably fail, since authorize can happen before they are in game.
__________________
Profile - Plugins
Add me on steam if you are seeking sp/map/model commissions.
friagram is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 05-01-2014 , 05:16   Re: OnClientAuthorized
Reply With Quote #6

...don't add `these` in your sql query
you get only confused, even MySQL or else show output like that way.
When parameter is string, then use 'these'
PHP Code:
Format(querysizeof(query), "SELECT * FROM accounts WHERE `steamid`='%s'"clientauth); 
PHP Code:
Format(querysizeof(query), "SELECT * FROM accounts WHERE steamid='%s'"clientauth); 
Try first that.

*edit
Maybe problem is your connection to database.

Last edited by Bacardi; 05-01-2014 at 05:17.
Bacardi is offline
boynedmaster
Member
Join Date: Jun 2012
Old 05-01-2014 , 16:08   Re: OnClientAuthorized
Reply With Quote #7

Quote:
Originally Posted by Bacardi View Post
...don't add `these` in your sql query
you get only confused, even MySQL or else show output like that way.
When parameter is string, then use 'these'
PHP Code:
Format(querysizeof(query), "SELECT * FROM accounts WHERE `steamid`='%s'"clientauth); 
PHP Code:
Format(querysizeof(query), "SELECT * FROM accounts WHERE steamid='%s'"clientauth); 
Try first that.

*edit
Maybe problem is your connection to database.
Sourcemod doesn't say any connection error. Also, I've been using `` in MySQL forever. It's fixed so many errors for me.
__________________
I mean Venusaur...with a question mark
boynedmaster is offline
Doodil
Senior Member
Join Date: Mar 2012
Old 05-02-2014 , 08:33   Re: OnClientAuthorized
Reply With Quote #8

Have you checked if you actually recieve a auth string? I remember having problems with OnClientAuthorized (years ago) and had to use OnClientPostAdminCheck() to retrieve the steam-id.

My guess is your clientauth is empty and breaks your query (btw, is that a single global variable for every client?).

Check if GetClientAuthString() returns true and report back
Doodil is offline
xf117
Senior Member
Join Date: Mar 2010
Location: Russia
Old 05-04-2014 , 09:35   Re: OnClientAuthorized
Reply With Quote #9

Why do you even GetClientAuthString in OnClientAuthorized? You already have auth in that callback available for you.
xf117 is offline
Send a message via ICQ to xf117
Bittersweet
Veteran Member
Join Date: May 2012
Old 05-05-2014 , 18:03   Re: OnClientAuthorized
Reply With Quote #10

That can't be the complete code. db is not defined, nor the error string. You should use threaded queries. I have a plugin that does the same thing, I use threaded queries, don't use `` around fields in the query, and I do the check after a 1 second timer in OnClientPostAdminCheck.

You said you don't get any errors in the server, what about the error logs?
__________________
Thank you in advance for your help

My plugins:
[CS:S] BOT Swat | [ANY] CVAR Randomizer | [CS:S] SM CS:S Tag Beta | [CS:S] Bot2Player
Awesome & Crucial plugins by other people:
[CS:S/CS:GO] GunGame | [UMC3] Ultimate Mapchooser | [ANY] Server Crontab | [ANY] SM ForceCamera
Bittersweet is offline
Reply


Thread Tools
Display Modes

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 05:47.


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