Raised This Month: $ Target: $400
 0% 

Little help on this?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
TheNewt
Donor
Join Date: Jun 2006
Location: Where I live.
Old 07-02-2006 , 18:57   Little help on this?
Reply With Quote #1

Did I do this correctly? Its for a plugin to create a mysql entry and retrieve it later.
Code:
public client_disconnect(id) {     new player_name[33]     new authid[32]     new playtime = get_user_time (id)     get_user_authid(id,authid,31)     get_user_name(id,player_name,31)     if (g_ConnectTime[id]== 0) {         result = dbi_query(dbc,"INSERT INTO MySQLTest (player, steamid, connecttime, playerlevel, playerxp, date) values ('%s','%s',%i,%i,%i,NOW())",player_name,authid,playtime,g_PlayerLevel[id],g_PlayerXP[id])     }     else {         new store_time = (playtime + g_ConnectTime[id])         result = dbi_query(dbc,"UPDATE MySQLTest SET player='%s', connecttime=%i, playerlevel=%i, playerxp=%i, date=NOW() WHERE steamid='%s'",player_name,store_time, g_PlayerLevel[id],g_PlayerXP[id],authid)     } } /*------------------------------------------------------------------------------------------------*/ public client_authorized(id) {     new authid[32]     get_user_authid(id,authid,31)         result = dbi_query(dbc,"SELECT * FROM MySQLTest WHERE steamid = '%s'",authid)     if (result == RESULT_FAILED) {         log_amx("[MySQL Test] MySQL Query Failed!!")         return PLUGIN_CONTINUE     }     else if (result == RESULT_NONE) {         g_ConnectTime[id] = 0         g_PlayerLevel[id] = 0         g_PlayerXP[id] = 0     }     else {         dbi_nextrow(result)         g_ConnectTime[id] = dbi_result(result,"connecttime")         g_PlayerLevel[id] = dbi_result(result, "playerlevel")         g_PlayerXP[id]= dbi_result(result, "playerxp")     }     dbi_free_result(result)     return PLUGIN_HANDLED; }

JUST tried it out on my plugin, IT WORKS!!!!!!!!!!! Saves to MySQL and Loads from it too!!

Last edited by TheNewt; 07-02-2006 at 20:15.
TheNewt is offline
Hawk552
AMX Mod X Moderator
Join Date: Aug 2005
Old 07-02-2006 , 20:45   Re: Little help on this?
Reply With Quote #2

Why didn't you try it before you posted? Sorry but I think this is just a waste of forum space.

You should probably use SQLx rather than DBI.
__________________
Hawk552 is offline
Send a message via AIM to Hawk552
TheNewt
Donor
Join Date: Jun 2006
Location: Where I live.
Old 07-02-2006 , 22:08   Re: Little help on this?
Reply With Quote #3

I didn't try it before posting it becuase I was getting a BadLoad error when I loaded... I solved the bad load about 10 minutes after posting.
TheNewt 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:56.


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