Code:
format(query,255,"SELECT balance FROM money WHERE steamid='%s'",authid);
if(mysql_query(mysql,query) == 0)
{
server_print("Query failed!");
return PLUGIN_HANDLED;
}
new strBalance[32],strIncome[32];
if(mysql_nextrow(mysql) > 0)
{
client_print(i,3,"Test:4");
mysql_getfield(mysql,1,strBalance,31);
mysql_getfield(mysql,3,strIncome,31);
SELECT balance FROM money WHERE steamid='%s'"
<< you are only selecting balance. So you only get one field.
You can do like this:
Code:
format(query,255,"SELECT balance FROM money WHERE steamid='%s'",authid);
const FIELD_BALANCE = 1
// then later when you want to get the field:
mysql_getfield(mysql,FIELD_BALANCE,strBalance,31);
So it's a nice thing to only use defined constants when referring to a field.
If you wanted to get the income field also (which I think you really wanted to do?), you would have to change the select query to something like this:
Code:
format(query,255,"SELECT balance, income FROM money WHERE steamid='%s'",authid);
const FIELD_BALANCE = 1
const FIELD_INCOME = 2
// then later when you want to get the fields:
mysql_getfield(mysql,FIELD_BALANCE,strBalance,31);
mysql_getfield(mysql,FIELD_INCOME,strIncome,31);
I hope you get the picture, you can only get the fields which you select. and they come in the order, 1, 2 and so on... defining constants right after the select has helped me keep the fields in order nice and straight.
Might wanna take a look at syntax for SELECT:
http://dev.mysql.com/doc/mysql/en/SELECT.html