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

One thing with SQLx


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Rixorster
Senior Member
Join Date: Jul 2005
Old 01-05-2007 , 14:33   One thing with SQLx
Reply With Quote #1

So i'm trying out SQLx at the moment, so i used Hawk552's example of that 'Core' thingy (His last example on the topic).
So, i got an function like this:
Code:
public hrp_is_job(id,authid) {     SQL_ThreadQuery(sql_get_handle(),"QueryHandle","SELECT job FROM users WHERE steamid='%s'",authid) } public QueryHandle(FailState,Handle:Query,Error[],Errcode,Data[],DataSize) {     //Thanks Hawk552 <3     if(FailState == TQUERY_CONNECT_FAILED)         return set_fail_state("[HRPi]SQL Connection Failed.")     else if(FailState == TQUERY_QUERY_FAILED)         return set_fail_state("[HRPi]Query failed.")         if(Errcode)         return log_amx("[HRPi]Error on query: %s",Error)         server_print("[HRPi] SQL Connection Successfull!")     return Handle:Query }
And, i'm calling that function with this:
Code:
    if(!hrp_is_job(id,authid) >= 2 && !hrp_is_job(id,authid) <= 11)     {         client_print(id,print_chat,"You must be an Police for the Tazer to work!")         return PLUGIN_HANDLED     }
SQL_ThreadQuery gives an error of the authid thing, but isn't that how it's supposed to be so it would work?

Also, I think i should have an 'return (something)' in 'public hrp_is_job' to return the value of the job, but what should i return?

Any help would be nice :/
__________________
You never know, what will happen the day after tomorrow...

+karma if i helped you!
Rixorster is offline
teame06
i have a hat
Join Date: Feb 2005
Location: Hat City
Old 01-05-2007 , 14:38   Re: One thing with SQLx
Reply With Quote #2

Your usage of SQL_ThreadQuery is wrong. You can't format string in SQL_ThreadQuery. You have to do it before.

Code:
SQL_ThreadQuery ( Handle:cn_tuple, const handler[], const query[], const data[]=0 )

Code:
static query[256]; format(query, 255, "SELECT job FROM users WHERE steamid='%s'", authid); SQL_ThreadQuery(sql_get_handle(),"QueryHandle", query)
__________________
No private support via Instant Message
GunGame:SM Released
teame06 is offline
Send a message via AIM to teame06
Rixorster
Senior Member
Join Date: Jul 2005
Old 01-05-2007 , 14:44   Re: One thing with SQLx
Reply With Quote #3

Quote:
Originally Posted by teame06 View Post
Your usage of SQL_ThreadQuery is wrong. You can't format string in SQL_ThreadQuery. You have to do it before.

Code:
SQL_ThreadQuery ( Handle:cn_tuple, const handler[], const query[], const data[]=0 )

Code:
static query[256]; format(query, 255, "SELECT job FROM users WHERE steamid='%s'", authid); SQL_ThreadQuery(sql_get_handle(),"QueryHandle", query)
Thanks
Though still, the 'if(!hrp_is_job(id,authid) >= 2 && !hrp_is_job(id,authid) <= 11)' doesn't work, but how should i be doing it then?
__________________
You never know, what will happen the day after tomorrow...

+karma if i helped you!
Rixorster is offline
teame06
i have a hat
Join Date: Feb 2005
Location: Hat City
Old 01-05-2007 , 15:53   Re: One thing with SQLx
Reply With Quote #4

SQL_ThreadQuery works in asynchronous. So you should be storing the players job into an array or something.

Also your not retrieving the data from the column.

Code:
if(SQL_NumResults(Query)) {     StoreSomeWhere = SQL_ReadResult(Query, 0); }

I don't know what plugin this is for but it look like it a TS plugin. You need to recode this plugin around to work in Asynchronous if you are going to SQL_ThreadQuery.
__________________
No private support via Instant Message
GunGame:SM Released
teame06 is offline
Send a message via AIM to teame06
Rixorster
Senior Member
Join Date: Jul 2005
Old 01-05-2007 , 16:31   Re: One thing with SQLx
Reply With Quote #5

Hmm...
Code:
public hrp_is_job_higher(id,authid[],jobid[]) {     static query[256];     format(query, 255, "SELECT job>%s FROM users WHERE steamid='%s'",jobid,authid);     SQL_ThreadQuery(sql_get_handle(),"QueryHandle", query) } public hrp_is_job_smaller(id,authid[],jobid[]) {     static query[256];     format(query, 255, "SELECT job<%s FROM users WHERE steamid='%s'",jobid,authid);     SQL_ThreadQuery(sql_get_handle(),"QueryHandle", query) } public QueryHandle(FailState,Handle:Query,Error[],Errcode,Data[],DataSize) {     //Thanks Hawk552 <3     if(FailState == TQUERY_CONNECT_FAILED)         return set_fail_state("[HRPi]SQL Connection Failed.")     else if(FailState == TQUERY_QUERY_FAILED)         return set_fail_state("[HRPi]Query failed.")         if(Errcode)         return log_amx("[HRPi]Error on query: %s",Error)         server_print("[HRPi] SQL Query Executed Successfully!")     if(SQL_NumResults(Query)) {         StoreSomeWhere = SQL_ReadResult(Query, 0);     }     return Handle:Query }
And this gives an error:
Code:
if(!hrp_is_job_higher(id,pid,2) && !hrp_is_job_smaller(id,<,pid,11))
Argument type mismatch (argument 3) on line 129
So i guess that means something wrong with the (id,pid,2) ?
__________________
You never know, what will happen the day after tomorrow...

+karma if i helped you!
Rixorster is offline
lunarwolfx
Member
Join Date: Feb 2005
Old 01-05-2007 , 17:46   Re: One thing with SQLx
Reply With Quote #6

Code:
public hrp_is_job_higher(id,authid[],jobid[]) {     new data[2]; format(data,1,"%d",id); static query[256];     format(query, 255, "SELECT job>%s FROM users WHERE steamid='%s'",jobid,authid);     SQL_ThreadQuery(sql_get_handle(),"QueryHandle", query,data,1) } public hrp_is_job_smaller(id,authid[],jobid[]) { new data[2]; format(data,1,"%d",id);     static query[256]; format(query, 255, "SELECT job<%s FROM users WHERE steamid='%s'",jobid,authid);   SQL_ThreadQuery(sql_get_handle(),"QueryHandle", query,data,1) } public QueryHandle(FailState,Handle:Query,Error[],Errcode,Data[],DataSize) {     //Thanks Hawk552 <3     if(FailState == TQUERY_CONNECT_FAILED)          return set_fail_state("[HRPi]SQL Connection Failed.")     else if(FailState == TQUERY_QUERY_FAILED)          return set_fail_state("[HRPi]Query failed.")         if(Errcode)          return log_amx("[HRPi]Error on query: %s",Error)         server_print("[HRPi] SQL Query Executed Successfully!")      if(SQL_NumResults(Query)) {         new id = str_to_num(data)        StoreSomeWhere[id] = SQL_ReadResult(Query, 0);     }      return Handle:Query }

Sorry for the lack of indenting.

Try to pass your id through data, and make StoreSomeWhere an array.


change this:

Code:
if(!hrp_is_job_higher(id,pid,2) && !hrp_is_job_smaller(id,<,pid,11))

to this:


Code:
if(!StoreSomeWhere[id] > 2 && !StooreSomeWhere[id] <11))

Last edited by lunarwolfx; 01-05-2007 at 17:48.
lunarwolfx is offline
Rixorster
Senior Member
Join Date: Jul 2005
Old 01-05-2007 , 20:12   Re: One thing with SQLx
Reply With Quote #7

Fixed it already on my own, thanks anyways
__________________
You never know, what will happen the day after tomorrow...

+karma if i helped you!
Rixorster 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 13:24.


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