17.06.2013, 23:56
I have this code, but It doesn't work. I'm trying to still learn these new functions before I convert my gamemode. Anyone tell me if I'm doing something wrong, thanks in advance.
It always says: Bank account numberhere has 1 dollars in it. It always say 1 dollar, so not sure what i'm doing wrong.
pawn Код:
public BankAccBal(account) {
new bal, bals[64];
format(myquery, sizeof(myquery), "SELECT balance FROM saes_bank_accounts WHERE number='%i'", account);
mysql_function_query(1, myquery, true, "OnBankBal", "d", account);
return 1;
}
forward OnBankBal(account);
public OnBankBal(account)
{
new rows, fields;
cache_get_data(rows, fields);
new temp[64];
new bal;
cache_get_field_content(1, "balance", temp);
bal = strval(temp);
return bal;
}
CMD:getbalance(playerid, params[])
{
new num, balance;
if(sscanf(params, "d", num)) return SendClientMessage(playerid, -1, "> /getbalance accountnumber");
balance = BankAccBal(num);
format(msgstring, sizeof(msgstring), "Bank account %d has %d dollars in it.", num, balance);
SendClientMessage(playerid, -1, msgstring);
return 1;
}