Updating value from input box
#1

Hello. I want to update a cash on player's bank account - this value is in mysql. I have already make dialogs but my value doesn't update.

Code:

Код:
ShowPlayerDialog(playerid,706,DIALOG_STYLE_INPUT,"{ADCAB6}Truck Drive {F2E088}Toll","Wybierz kwotę doładowania","Doładuj","Anuluj");
tolladded[playerid] = strval(inputtext);
tollcash[playerid] = GetValue(playerid, "tollcash")+tolladded[playerid];
GivePlayerMoney(playerid,-tolladded[playerid]);
UpdateValue(playerid, "tollcash", tollcash[playerid]);
UpdateValue code

Код:
public UpdateValue(playerid, field[], value)
{
	new query[256];
	format(query, 256, "UPDATE `users` SET %s = %d WHERE `uid` = '%d';", field, value, uID[playerid]);
    mysql_query(query);
    mysql_free_result();
	return 1;
}
And how to make it's working?
Reply
#2

Quote:

"UPDATE `users` SET %s = %d WHERE `uid` = '%d';"

Remove ";"?
Reply
#3

Код:
public UpdateValue(playerid, field[], value)
{
	new query[256];
	format(query, 256, "UPDATE `users` SET `%s` = %d WHERE `uid` = %d", field, value, uID[playerid]);
        mysql_query(query);
        mysql_free_result();
	return 1;
}
Reply
#4

It doesn't work... I think the problem is here:

Код:
ShowPlayerDialog(playerid,706,DIALOG_STYLE_INPUT,"{ADCAB6}Truck Drive {F2E088}Toll","Wybierz kwotę doładowania","Doładuj","Anuluj");
tolladded[playerid] = strval(inputtext);
tollcash[playerid] = GetValue(playerid, "tollcash")+tolladded[playerid];
GivePlayerMoney(playerid,-tolladded[playerid]);
UpdateValue(playerid, "tollcash", tollcash[playerid]);
because the money is still the same, and a tollcash is still same too. So i think the main problem is this:

Код:
tolladded[playerid] = strval(inputtext);
I check tollcash by

Код:
new string[512];
format(string, sizeof(string), "{ADCAB6}Stan Twojego konta TDToll wynosi {595a90}%d.",tollcash[playerid]);
ShowPlayerDialog(playerid,707,DIALOG_STYLE_MSGBOX,"{ADCAB6}Truck Drive {F2E088}Toll",string,"Ok","");
return 1;
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)