I'm making a custom plugin, needs to store steam ids and usernames to mysql database (when I get these two things down everythign else will be cake) but it truncates their steamid somewhere along the code...
Code:
#include <amxmodx>
#include <amxmisc>
#include <dbi>
#define PLUGIN "SteamId Manager"
#define VERSION "1.0"
#define AUTHOR "Migs Davis"
public plugin_init() {
register_plugin(PLUGIN, VERSION, AUTHOR)
}
public client_connect(id)
{
new user[20], len
new Sql:idList
new steamId[20]
new Result:checkExist
new Result:addId
new Result:addName
idList = dbi_connect ( "host", "username", "password", "table")
if (idList < SQL_OK)
{
new err[255]
new errNum = dbi_error(idList, err, 254)
server_print("error1: %s|%d", err, errNum)
}
get_user_authid(id, steamId, 20)
server_print("Their steam ID is: %s", steamId)
//while (steamId[9]=='P')
//get_user_authid(id, steamId[], 20)
checkExist = dbi_query ( idList, "SELECT * FROM list WHERE (steamid) = ('%s')", steamId)
if (checkExist <= RESULT_NONE) {
len = get_user_name(id,user[0],30)
server_print("Not in our database yet, %s", steamId)
addId = dbi_query(idList, "INSERT INTO list (name, steamid) values ('%s', '%d')", steamId, user)
//These are reversed but whats strange is that it doesn't reverse them in the database
//addName = dbi_query(idList, "UPDATE list SET name='%d' WHERE steamid='%s'", user, steamId)
console_print(id, "You should be succesfully added")
dbi_free_result(addId)
}
server_print("%s is in our database under %d", user, steamId)
dbi_free_result(addName)
dbi_free_result(checkExist)
dbi_close ( idList )
}
(sorry for the somewhat messed up indents I've been up for a day or 3)
This is the server output:
Quote:
Their steam ID is: STEAM_0:1:9834747
Not in our database yet, STEAM_0:1:9834747
[ css:um ] Migs Davis is in our database under 83
|
This is the created fields in the table:
(^^i actually think thats correct grammar, one example, many fields?)
<list>
<name>[ css:um ] Migs Davis</name>
<id>29</id>
<steamid>83</steamid>
<roundsplayed>0</roundsplayed>
<posts>0</posts>
<css>0</css>
<blazed>0</blazed>
<zero>0</zero>
<admin>not</admin>
</list>
(of course everytime I connect it copies.)
__________________