Raised This Month: $ Target: $400
 0% 

Truncating Variables?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Migs Davis
Junior Member
Join Date: Mar 2006
Location: Wilton, CT
Old 04-07-2006 , 12:39   Truncating Variables?
Reply With Quote #1

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.)
__________________
www.kdoubt.net - CS Syndicate website
------
(they need website hits \/\/\/)
www.awesomejon.com - friend's site (check galleries)
www.jednet.com - Friends website (check galleries)
www.djpeak.net - DJ website
Migs Davis is offline
Send a message via AIM to Migs Davis
Migs Davis
Junior Member
Join Date: Mar 2006
Location: Wilton, CT
Old 04-07-2006 , 13:44  
Reply With Quote #2

Hey guys I still can't figure it out...I've tried using different mysql querries and using a different code order... still no luck. Actually, for a while, "name" appeared as 91 and steam id showed up perfectly.
__________________
www.kdoubt.net - CS Syndicate website
------
(they need website hits \/\/\/)
www.awesomejon.com - friend's site (check galleries)
www.jednet.com - Friends website (check galleries)
www.djpeak.net - DJ website
Migs Davis is offline
Send a message via AIM to Migs Davis
Xanimos
Veteran Member
Join Date: Apr 2005
Location: Florida
Old 04-07-2006 , 14:11  
Reply With Quote #3

where do you get
Code:
<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>
from
Xanimos is offline
Send a message via AIM to Xanimos Send a message via MSN to Xanimos
Migs Davis
Junior Member
Join Date: Mar 2006
Location: Wilton, CT
Old 04-07-2006 , 14:15  
Reply With Quote #4

Thats an xml export from phpmyadmin to see content excel-style or w/e... its that about 8 times after connecting 8 times.
__________________
www.kdoubt.net - CS Syndicate website
------
(they need website hits \/\/\/)
www.awesomejon.com - friend's site (check galleries)
www.jednet.com - Friends website (check galleries)
www.djpeak.net - DJ website
Migs Davis is offline
Send a message via AIM to Migs Davis
Xanimos
Veteran Member
Join Date: Apr 2005
Location: Florida
Old 04-07-2006 , 14:19  
Reply With Quote #5

Code:
if (checkExist <= RESULT_NONE)
--->
Code:
if (checkExist >= RESULT_NONE)
Xanimos is offline
Send a message via AIM to Xanimos Send a message via MSN to Xanimos
Migs Davis
Junior Member
Join Date: Mar 2006
Location: Wilton, CT
Old 04-07-2006 , 14:22  
Reply With Quote #6

Alright lets see what happens, I copied the code straight off an official tutorial (more or less)
>>>>>>>>>5 MINS LATER>>>>>>

nope... its still truncating the steamid variable sometimes between displaying and sending the query to MySQL from my steamid STEAM_0:1:9834747 to just 83
Also,
In English, for that conditional, i intended it to be If Record Doesn't Exist Then:... so is switching the operand there appropriate?
__________________
www.kdoubt.net - CS Syndicate website
------
(they need website hits \/\/\/)
www.awesomejon.com - friend's site (check galleries)
www.jednet.com - Friends website (check galleries)
www.djpeak.net - DJ website
Migs Davis is offline
Send a message via AIM to Migs Davis
Migs Davis
Junior Member
Join Date: Mar 2006
Location: Wilton, CT
Old 04-07-2006 , 14:36  
Reply With Quote #7

I was thinking something might be wrong in

Code:
"INSERT INTO list (name, steamid) values ('%s', '%d')"
because if I just do one variable it works., either name or steam.
But I can't tell :-( <-- me a nub
__________________
www.kdoubt.net - CS Syndicate website
------
(they need website hits \/\/\/)
www.awesomejon.com - friend's site (check galleries)
www.jednet.com - Friends website (check galleries)
www.djpeak.net - DJ website
Migs Davis is offline
Send a message via AIM to Migs Davis
Migs Davis
Junior Member
Join Date: Mar 2006
Location: Wilton, CT
Old 04-07-2006 , 15:46  
Reply With Quote #8

Alright. Contest. First person to help me fix this: 5 bucks via paypal.
__________________
www.kdoubt.net - CS Syndicate website
------
(they need website hits \/\/\/)
www.awesomejon.com - friend's site (check galleries)
www.jednet.com - Friends website (check galleries)
www.djpeak.net - DJ website
Migs Davis is offline
Send a message via AIM to Migs Davis
slurpycof
Senior Member
Join Date: Nov 2004
Old 04-07-2006 , 15:47  
Reply With Quote #9

Try this. if it works, keep your 5 bucks for your server costs. I just modified a different plugin I had made for someone.

Code:
 #include <amxmodx>  #include <amxmisc>  #include <dbi>  new Sql:dbc  new Result:result  public plugin_init(){     register_plugin("SteamId Manager","1.0","Migs Davis ")     set_task(0.1,"sql_init")  }  public sql_init() {     new host[64], username[32], password[32], dbname[32], error[32]     get_cvar_string("amx_sql_host",host,64)     get_cvar_string("amx_sql_user",username,32)     get_cvar_string("amx_sql_pass",password,32)     get_cvar_string("amx_sql_db",dbname,32)     dbc = dbi_connect(host,username,password,dbname,error,32)     if (dbc == SQL_FAILED)     {         new err[255]         new errNum = dbi_error(dbc, err, 254)         server_print("error1: %s|%d", err, errNum)     }     else     {         dbi_query(dbc,"CREATE TABLE IF NOT EXISTS `steamidmanager` (`steamid` VARCHAR(32) NOT NULL,`player` VARCHAR(32) NOT NULL, PRIMARY KEY(`steamid`))")     }  } public client_authorized(id){     if ( is_user_bot(id) ) {  //Do not add to database         return PLUGIN_CONTINUE     }     if (is_user_hltv(id) ) {  //Do not add to database         return PLUGIN_CONTINUE     }     new name[32]     get_user_name(id,name,31)     new authid[32]     get_user_authid(id,authid,31)     result = dbi_query(dbc,"SELECT * FROM steamidmanager WHERE steamid = '%s'",authid)     if (result == RESULT_FAILED){ //Problem with mysql         log_amx("[steamidmanager] MySQL Query failed")         return PLUGIN_CONTINUE     }     else if (result == RESULT_NONE)     { //not in db, add them         server_print("Not in our database yet, %s", authid)         result = dbi_query(dbc,"INSERT INTO steamidmanager (steamid, player) values ('%s','%s')", authid, name)         return PLUGIN_CONTINUE     }     else     {         server_print("%s is in our database under %s", authid, name)         result = dbi_query(dbc,"UPDATE steamidmanager SET player=%s WHERE steamid='%s'", name, authid)     }     dbi_free_result(result)     return PLUGIN_CONTINUE }
slurpycof is offline
Xanimos
Veteran Member
Join Date: Apr 2005
Location: Florida
Old 04-07-2006 , 16:12  
Reply With Quote #10

Quote:
Originally Posted by Migs Davis
...
In English, for that conditional, i intended it to be If Record Doesn't Exist Then:... so is switching the operand there appropriate?
Code:
if (checkExist == RESULT_NONE)
Xanimos is offline
Send a message via AIM to Xanimos Send a message via MSN to Xanimos
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 16:48.


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