14.04.2016, 13:37
Hey guys, I've ran through a small problem. Since it's been a long time I scripted - I'm not able to solve this simple shit easily. I've made a function to fetch a value from a database (MySQL).
and this is where I'm using it:
Help me finish this piece of code, guys.
Thanks!
pawn Код:
function FetchBankAccountByName(name[24])
{
mysql_format(MySQL, gQuery, 256, "SELECT * FROM `"Banks_Table"` WHERE `Holder` = '%e'", name);
mysql_tquery(MySQL, gQuery, "Safe_FetchBankAccountByName", "i");
}
function Safe_FetchBankAccountByName(Balance)
{
new rows, fields;
cache_get_data(rows, fields);
if(rows)
{
Balance = cache_get_field_content_int(0, "Balance", MySQL);
}
return Balance;
}
pawn Код:
if(!IsPlayerConnected(GetPlayerID(Bank_Transfer_To[playerid])))
mysql_format(MySQL, str, sizeof str, "UPDATE `"Banks_Table"` SET `Balance` = '%i' WHERE `Holder` = '%e'", FetchBankAccountByName(Bank_Transfer_To[playerid]) + value, Bank_Transfer_To[playerid]);
mysql_tquery(MySQL, str, "", "");
}
Thanks!