AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Little help on this? (https://forums.alliedmods.net/showthread.php?t=40734)

TheNewt 07-02-2006 18:57

Little help on this?
 
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!!

Hawk552 07-02-2006 20:45

Re: Little help on this?
 
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.

TheNewt 07-02-2006 22:08

Re: Little help on this?
 
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.


All times are GMT -4. The time now is 07:56.

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