SA-MP Forums Archive
Updating value from input box - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Updating value from input box (/showthread.php?tid=284040)



Updating value from input box - DJGama101 - 17.09.2011

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?


Re: Updating value from input box - =WoR=Varth - 17.09.2011

Quote:

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

Remove ";"?


Re: Updating value from input box - [MWR]Blood - 17.09.2011

Код:
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;
}



Re: Updating value from input box - DJGama101 - 18.09.2011

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;