Raised This Month: $ Target: $400
 0% 

Function Help


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
IchWill
Junior Member
Join Date: Sep 2010
Old 10-18-2010 , 16:22   Function Help
Reply With Quote #1

Hi.
I've done a plugin that logs nick, authid,ip to a database ...
But when the player join again, the ip etc is inserted again, then i have duplicate results...
Can you help with a function that checks before doing the query if the nickname is in the database?
Here is partial code:
Code:
public client_putinserver(id){


new Error[512], Handle: SqlTuple;
new host[64], user[64], password[64], database[64], prefix[64];
new configsDir[64]
get_configsdir(configsDir, 63)
server_cmd("exec %s/amxx.cfg", configsDir)	// Execute main configuration file
server_cmd("exec %s/sql.cfg", configsDir)
get_cvar_string("mpstats_sql_host", host, charsmax(host));
get_cvar_string("mpstats_sql_user", user, charsmax(user));
get_cvar_string("mpstats_sql_pass", password, charsmax(password));
get_cvar_string("mpstats_sql_db", database, charsmax(database));
get_cvar_string("mpstats_sql_prefix", prefix, charsmax(prefix));
SqlTuple = SQL_MakeDbTuple(host, user, password, database);


new Handle: SqlConnection, Handle: Query, ErrorCode;
SqlConnection = SQL_Connect(SqlTuple, ErrorCode, Error, charsmax(Error));
new name[32],protocol[32],userip[32];
get_user_name(id,name,31);
get_user_ip(id, userip, 31, 1); 
get_user_authid(id, protocol,31); 
if(SqlConnection != Empty_Handle)
Query = SQL_PrepareQuery(SqlConnection, "INSERT INTO `mostplay_players`(`nick`,`protocol`,`ip`,`active`) VALUES ('%s','%s','%s','1')", name,protocol, userip);  
SQL_Execute(Query);
SQL_FreeHandle(Query);
SQL_FreeHandle(SqlConnection);
server_cmd("echo Player %s with ip %s connected!",name, userip) 
return PLUGIN_CONTINUE;
}
Cheers.(and sorry for my bad english)
IchWill is offline
 


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 10:22.


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