Raised This Month: $ Target: $400
 0% 

Whats wrong with this [DBI]


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Styles
Veteran Member
Join Date: Jul 2004
Location: California
Old 04-05-2007 , 23:04   Whats wrong with this [DBI]
Reply With Quote #1

Code:
public client_putinserver(id)
{
	if(dbc == SQL_FAILED)
	{
		return PLUGIN_HANDLED
	}
	new authid[33], query[256];
	get_user_authid(id, authid, 32)
	format(query,255,"SELECT steamid FROM bmjailmod")
	result = dbi_query(dbc,"%s",query)
	if(result <= RESULT_NONE && equali(authid, "STEAM_ID_PENDING"))
	{
		client_print(0, print_chat, "[Jail Mod Debug] Trying to add %s", authid);
		format(query,255,"INSERT INTO bmjailmod (steamid,flag) VALUES('%s', '0')",authid)
		dbi_query(dbc,"%s",query)
		client_print(id,print_console,"%s",query)
		server_print("%s",query)
	}
	dbi_free_result(result)
	return PLUGIN_CONTINUE;
}
I tryed Returning it handled it doesn't work eathier.

This only adds the FIRST person in the server. whY?
Styles is offline
Send a message via AIM to Styles
Nican
Veteran Member
Join Date: Jan 2006
Location: NY
Old 04-05-2007 , 23:33   Re: Whats wrong with this [DBI]
Reply With Quote #2

i like sqlx better

PHP Code:
new errnumerror[128]
mysql SQL_Connect(dbtupleerrnumerror128)
if (!
mysql)
    return 
PLUGIN_HANDLED
    
new authid[33], error[256]
get_user_authid(idauthid32)
new 
Handle:que SQL_PrepareQuery(mysql,"SELECT steamid FROM bmjailmod WHERE steamid = '%s'",authid)


//If it could not execute query
if(!SQL_Execute(que)){
    
SQL_QueryError(que,error,256)
    
log_amx("Error: %s",error)
    return 
PLUGIN_HANDLED
}

//If could find anyone, insert it
if(SQL_AffectedRows(que) == && !equali(authid"STEAM_ID_PENDING")){
    new 
Handle:query SQL_PrepareQuery(mysql,"INSERT INTO bmjailmod (steamid,flag) VALUES('%s', '0')",authid)

    if(!
SQL_Execute(que)){
        
SQL_QueryError(query,error,256)
        
log_amx("Error: Could not insert user: %s",error)
    } else { 
        
log_amx("%s succefuly inserted",authid)
        
SQL_FreeHandle(query)
    }
}
//Free handle query
SQL_FreeHandle(que)
//free mysql handle
SQL_FreeHandle(que
__________________
http://www.nican132.com
I require reputation!
Nican is offline
Send a message via ICQ to Nican Send a message via MSN to Nican
Styles
Veteran Member
Join Date: Jul 2004
Location: California
Old 04-06-2007 , 00:15   Re: Whats wrong with this [DBI]
Reply With Quote #3

Please use DBI because TS uses that.
Styles is offline
Send a message via AIM to Styles
Drak
Veteran Member
Join Date: Jul 2005
Old 04-06-2007 , 00:37   Re: Whats wrong with this [DBI]
Reply With Quote #4

TS doesn't 'use' anything. He just switched to a different module, for whatever reason.
Also, am I reading this wrong?
Code:
if(result <= RESULT_NONE && equali(authid, "STEAM_ID_PENDING"))

Doesn't this mean if you're SteamID is pending, let's continue on.. Which doesn't make much sence

Try changing it with
Code:
if(result <= RESULT_NONE && !equali(authid, "STEAM_ID_PENDING"))

(Not Equal) ...
__________________
Oh yeah
Drak is offline
Send a message via MSN to Drak
Styles
Veteran Member
Join Date: Jul 2004
Location: California
Old 04-06-2007 , 01:52   Re: Whats wrong with this [DBI]
Reply With Quote #5

o hahaha nice catch, wasnt paying attention i guess
Thanks.
Styles is offline
Send a message via AIM to Styles
Styles
Veteran Member
Join Date: Jul 2004
Location: California
Old 04-06-2007 , 02:19   Re: Whats wrong with this [DBI]
Reply With Quote #6

Still not working shit It doesn't allways add people.

Last edited by Styles; 04-06-2007 at 02:26.
Styles is offline
Send a message via AIM to Styles
Drak
Veteran Member
Join Date: Jul 2005
Old 04-06-2007 , 02:29   Re: Whats wrong with this [DBI]
Reply With Quote #7

Uhh, errors? Is it returning anything?
Code:
public client_putinserver(id) {     if(dbc == SQL_OK) return PLUGIN_HANDLED             new authid[35],query[256];     get_user_authid(id, authid, 34)     format(query,255,"SELECT steamid FROM bmjailmod WHERE steamid = '%s'",authid)     result = dbi_query(dbc,"%s",query)     if(!result == RESULT_NONE && !equali(authid, "STEAM_ID_PENDING"))     {         client_print(0, print_chat, "[Jail Mod Debug] Trying to add %s", authid);         format(query,255,"INSERT INTO bmjailmod (steamid,flag) VALUES('%s', '0')",authid)         dbi_query(dbc,"%s",query)         client_print(id,print_console,"%s",query)         server_print("%s",query)     }     dbi_free_result(result)     return PLUGIN_CONTINUE; }

You should also look what Nican did, I basically did just that. And like I said, you're returning stuff:
"client_print(0, print_chat, "[Jail Mod Debug] Trying to add %s", authid);"
Is it printing out everyones steamid that joins?
__________________
Oh yeah

Last edited by Drak; 04-06-2007 at 02:39.
Drak is offline
Send a message via MSN to Drak
teame06
i have a hat
Join Date: Feb 2005
Location: Hat City
Old 04-06-2007 , 02:31   Re: Whats wrong with this [DBI]
Reply With Quote #8

Code:
if(result <= RESULT_NONE && equali(authid, "STEAM_ID_PENDING"))

You should not be checking the results like that.

Code:
    /* Error checking correctly so you can log stuff */     if(result == RESULT_FAILED)     {         /* Log saying your query failed */         return PLUGIN_CONTINUE;     } else if(result == RESULT_NONE) {         /* No data return from query */         return PLUGIN_CONTINUE;     }     /* Then retrieve the data */     /* or         If you do not care for logging then do */     if(result <= RESULT_NONE)     {         /* The query failed or no data from query */         return PLUGIN_CONTINUE     }     /* Do rest of the code to retrieve data from query*/
__________________
No private support via Instant Message
GunGame:SM Released

Last edited by teame06; 04-06-2007 at 02:33.
teame06 is offline
Send a message via AIM to teame06
Styles
Veteran Member
Join Date: Jul 2004
Location: California
Old 04-06-2007 , 03:10   Re: Whats wrong with this [DBI]
Reply With Quote #9

Okay well I have a:
Code:
set_task(1.0,"check_int",0,"",0,"b")
in Plugin_init

Then that runs:
Code:
public check_int()
{
	new players[32], num;
	get_players(players,num);
	
	for( new i = 0;  i < 32; i++ )
	{
		check_jail(players[i]);
		//set_user_maxspeed(i, Float:320);
	}
	return PLUGIN_HANDLED
}
Then that runs:
Code:
if(flagNum == 1) {
		get_user_aiming(id,entid,entbody,200)
		if(get_distance(origin,jailone) <= 100.0)
			set_user_origin(entid,jailone)
	} else if (flagNum == 2) {
I don't know if thats even working right. Its not teleporting them back in every time.
Styles is offline
Send a message via AIM to Styles
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 06:45.


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