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

need help


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
n0way0out
Junior Member
Join Date: Mar 2013
Old 04-04-2013 , 05:17   need help
Reply With Quote #1

hello all

i need help ,

i need a code that update table field name when user logged in . when player logged in to the server then that table colume field name automtic update and when player logged out then again update .



thanks ....
n0way0out is offline
Backstabnoob
Veteran Member
Join Date: Feb 2009
Location: Iwotadai Dorm
Old 04-04-2013 , 06:11   Re: need help
Reply With Quote #2

You really cannot figure it out yourself? You might as well post in requests next time.

Code:
/* Plugin generated by AMXX-Studio */ #include <amxmodx> #include <amxmisc> #include < sqlx > #define PLUGIN "New Plugin" #define VERSION "1.0" #define AUTHOR "Author" new Handle: g_SqlHandle new g_QueryCache[ 256 ] public plugin_init( ) {     g_SqlHandle = SQL_MakeStdTuple( ) } public client_connect( id ) {     new szAuthid[ 34 ]     get_user_authid( id, szAuthid, charsmax( szAuthid ) )         formatex( g_QueryCache, charsmax( g_QueryCache ), "INSERT INTO table VALUES ('%s', 1) ON DUPLICATE KEY online=1", szAuthid )         SQL_ThreadQuery( g_SqlHandle, "SQL__HANDLE_DROP", g_QueryCache ) } public client_disconnect( id ) {     new szAuthid[ 34 ]     get_user_authid( id, szAuthid, charsmax( szAuthid ) )         formatex( g_QueryCache, charsmax( g_QueryCache ), "INSERT INTO table VALUES ('%s', 0) ON DUPLICATE KEY online=0", szAuthid )         SQL_ThreadQuery( g_SqlHandle, "SQL__HANDLE_DROP", g_QueryCache ) } public SQL__HANDLE_DROP( ) { }
__________________
Currently busy working on a very large scale anime database project.

Last edited by Backstabnoob; 04-04-2013 at 06:13.
Backstabnoob is offline
n0way0out
Junior Member
Join Date: Mar 2013
Old 04-04-2013 , 06:32   Re: need help
Reply With Quote #3

thanks for reply bro . my table name is "register" and there is 5 field name . user,status,confirmcode,userid, and password . so if user connected then first check that user name and update his status "logged_in" and if user logged out then again update "logged_out".


thanks
n0way0out is offline
n0way0out
Junior Member
Join Date: Mar 2013
Old 04-04-2013 , 06:57   Re: need help
Reply With Quote #4

public client_connect( id )
{
new szAuthid[ 34 ]
get_user_authid( id, szAuthid, charsmax( szAuthid ) )
formatex(query, charsmax(query), "UPDATE register SET Status = ^"%s^" WHERE Name = ^"%s^";", enabled ? "LOGGED_IN" : "LOGGED_OUT", name)
SQL_ThreadQuery(g_sqltuple, "QuerySetData", query)
}

???

Last edited by n0way0out; 04-04-2013 at 06:58.
n0way0out is offline
Backstabnoob
Veteran Member
Join Date: Feb 2009
Location: Iwotadai Dorm
Old 04-04-2013 , 17:06   Re: need help
Reply With Quote #5

Something like that, replace double quotes by single ones, therefore you don't need to escape them with ^ and I don't even know how MySQL handles double quotes.

Only thing I don't understand is your enabled ? "LOGGED_IN" : "LOGGED_OUT" nonsense. Why do you even use it? Of course they will be logged in since you're calling the query from client_connect. Simply use SET Status = 'LOGGED_IN' in client_connect and LOGGED_OUT in client_disconnect.

Also, you're using "name" variable which doesn't even exist. You should check some basic pawn tutorials before trying to use more complex things such as MySQL.
__________________
Currently busy working on a very large scale anime database project.

Last edited by Backstabnoob; 04-04-2013 at 17:07.
Backstabnoob is offline
n0way0out
Junior Member
Join Date: Mar 2013
Old 04-05-2013 , 01:47   Re: need help
Reply With Quote #6

Quote:
Originally Posted by Backstabnoob View Post
Something like that, replace double quotes by single ones, therefore you don't need to escape them with ^ and I don't even know how MySQL handles double quotes.

Only thing I don't understand is your enabled ? "LOGGED_IN" : "LOGGED_OUT" nonsense. Why do you even use it? Of course they will be logged in since you're calling the query from client_connect. Simply use SET Status = 'LOGGED_IN' in client_connect and LOGGED_OUT in client_disconnect.

Also, you're using "name" variable which doesn't even exist. You should check some basic pawn tutorials before trying to use more complex things such as MySQL.
thanx for helping me .. now everything is ok except one thing.

how i block user to connect my server if his status is LOGGED_IN . ?
n0way0out is offline
Backstabnoob
Veteran Member
Join Date: Feb 2009
Location: Iwotadai Dorm
Old 04-05-2013 , 09:13   Re: need help
Reply With Quote #7

I have no idea why would you want this, but it would be a bit more complicated. You'd have to call a SELECT query from within the client_connect handler, however NOT as a threaded query. If you choose to use a threaded query, the next query that sets their status to LOGGED_IN would rewrite the value before the SELECT query is finished, therefore you would always get LOGGED_IN.
__________________
Currently busy working on a very large scale anime database project.

Last edited by Backstabnoob; 04-05-2013 at 09:13.
Backstabnoob 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 07:43.


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