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

Whats wrong in this mysql?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
jonatat
Senior Member
Join Date: Dec 2017
Old 04-17-2021 , 05:44   Whats wrong in this mysql?
Reply With Quote #1

I need to kick player if they STEAMID are not in database.

PHP Code:
public client_authorized(id

new 
auth[32]; 
get_user_authid(idauthsizeof (auth));

new 
Handle:query SQL_PrepareQuery(g_sql"SELECT `steam_id` FROM `users` WHERE (`steam_id` = '%s')"auth); 
SQL_Execute(query); 

new 
res[32]; 

if (
SQL_MoreResults(query)) 

SQL_ReadResult(query0ressizeof (res)); 
SQL_FreeHandle(query); 


if (!
strlen(res)) 

server_cmd("kick #%i %s"get_user_userid(id), restrict_msg); 


But i'm allways getting kick. Any suggestions what im doing wrong?
jonatat is offline
jonatat
Senior Member
Join Date: Dec 2017
Old 04-17-2021 , 06:48   Re: Whats wrong in this mysql?
Reply With Quote #2

Any help?
jonatat is offline
Shadows Adi
AlliedModders Donor
Join Date: Aug 2019
Location: Romania
Old 04-17-2021 , 09:55   Re: Whats wrong in this mysql?
Reply With Quote #3

Try this:
PHP Code:
public client_putinserver(id// In this phase the user can be affected by the commands
{
    new 
auth[32]; 
    
get_user_authid(idauthsizeof (auth));

    new 
Handle:query SQL_PrepareQuery(g_sql"SELECT * FROM `users` WHERE (`steam_id` = '%s')"auth); 
    
SQL_Execute(query); 

    if (!
SQL_NumResultsquery)) // If no results found, kick the player
    

        
server_cmd("kick #%i ^"%s^""get_user_userid(id), restrict_msg); 
    }
    
SQL_FreeHandle(query); // Free the query

__________________


Accepting Paid Requests, contact PM.

MVP Of The Round View project on GITHUB / AlliedModders
CSGO REMAKE ~ CSGO MOD [STABLE + SOURCE CODE]
Shadows Adi is offline
jonatat
Senior Member
Join Date: Dec 2017
Old 04-17-2021 , 13:08   Re: Whats wrong in this mysql?
Reply With Quote #4

Quote:
Originally Posted by Shadows Adi View Post
Try this:
PHP Code:
public client_putinserver(id// In this phase the user can be affected by the commands
{
    new 
auth[32]; 
    
get_user_authid(idauthsizeof (auth));

    new 
Handle:query SQL_PrepareQuery(g_sql"SELECT * FROM `users` WHERE (`steam_id` = '%s')"auth); 
    
SQL_Execute(query); 

    if (!
SQL_NumResultsquery)) // If no results found, kick the player
    

        
server_cmd("kick #%i ^"%s^""get_user_userid(id), restrict_msg); 
    }
    
SQL_FreeHandle(query); // Free the query

Same problem... I dont get it why...
jonatat is offline
Shadows Adi
AlliedModders Donor
Join Date: Aug 2019
Location: Romania
Old 04-17-2021 , 15:20   Re: Whats wrong in this mysql?
Reply With Quote #5

Show full code.
__________________


Accepting Paid Requests, contact PM.

MVP Of The Round View project on GITHUB / AlliedModders
CSGO REMAKE ~ CSGO MOD [STABLE + SOURCE CODE]
Shadows Adi is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 04-17-2021 , 15:23   Re: Whats wrong in this mysql?
Reply With Quote #6

Try this:
PHP Code:
new szError64 ];
if ( !
SQL_Executequery ) )
{
    
SQL_QueryErrorquery szError charsmaxszError ) );
    
set_fail_stateszError );

__________________
Bugsy is offline
LondoN
Senior Member
Join Date: Dec 2015
Location: Roman, Romania.
Old 04-19-2021 , 03:54   Re: Whats wrong in this mysql?
Reply With Quote #7

Code:
public client_connect(id)
{
	new g_szAuthID[32];
	get_user_authid(id, g_szAuthID, charsmax(g_szAuthID));

	new g_szQuery[256];
	formatex(g_szQuery, charsmax(g_szQuery), "SELECT * FROM tablename WHERE player_auth = '%s'", g_szAuthID);

	new g_szData[1];
	g_szData[0] = id;

	SQL_ThreadQuery(g_SQLTuple, "SQL_Check", g_szQuery, g_szData, sizeof g_szData);
}

public SQL_Check(FailState, Handle: Query, szError[], iErrorCode, szData[], iDataSize)
{
	if(!FailState && !iErrorCode)
	{
		new id = szData[0];

		if(!SQL_NumResults(Query))
			server_cmd("kick #%d", get_user_userid(id));
	}

	SQL_FreeHandle(Query);
}
This type of 'doing sql' always worked fine for me, you can try.
__________________
LondoN 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 07:46.


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