MySQL query question. -
oliverrud - 08.06.2010
Hey, is it possible to like instead of:
pawn Код:
format(string,300,"UPDATE `SQL_FACTION` SET `Bank`='%s' WHERE `ID`='2'",inputtext);
then do some mysql query that would plus the inputtext with the current numbers in the bank?
Re: MySQL query question. -
Ignas1337 - 08.06.2010
by plus i assume you mean add up, or sum. well i haven't heard of an mysql function that does that, so you should :
1. Extract data
2. Alter it (in your case, sum, add up, plus, what is needed)
3. Update data
Re: MySQL query question. -
Aleksandar_Zivanovci - 08.06.2010
Код:
format(string,300,"UPDATE `SQL_FACTION` SET `Bank`=Bank + %d WHERE `ID`='2'",strval(inputtext));
if you wanted this
Re: MySQL query question. -
oliverrud - 08.06.2010
Aleksandar you made my day ^^
Thanks Izanagi for telling me the information.
Re: MySQL query question. -
oliverrud - 08.06.2010
Oh yea I got one problem left I hope one of you can help me solve:
pawn Код:
if(IsNumeric(inputtext))
{
new moneycheck[128];
format(moneycheck,128,"%s",inputtext);
if(GetPlayerMoney(playerid) < moneycheck)
{
SendClientMessage(playerid, 0xFFFFFF, "You don't have enough cash.");
}
else
{
GivePlayerMoney(playerid, -moneycheck);
new string2[128];
format(string,300,"UPDATE "SQL_FACTION" SET `FactionBank`=FactionBank + %d WHERE `ID`='2'",strval(inputtext));
mysql_query(string);
format(string,128,"You have just deposit %s into HR313SR Faction Bank",inputtext);
SendClientMessage(playerid,COLOR_YELLOW,string2);
}
}
I'm having error at the:
pawn Код:
if(GetPlayerMoney(playerid) < moneycheck)
pawn Код:
GivePlayerMoney(playerid, -moneycheck);
Errors is following:
Код:
error 035: argument type mismatch (argument 2)
error 033: array must be indexed (variable "moneycheck")
Re: MySQL query question. -
Sascha - 08.06.2010
use:
instead of "moneycheck" at the error lines (but leave the
at its' definition)
Re: MySQL query question. -
Aleksandar_Zivanovci - 08.06.2010
if(IsNumeric(inputtext))
{
if(GetPlayerMoney(playerid) < strval(inputtext))
{
SendClientMessage(playerid, 0xFFFFFF, "You don't have enough cash.");
}
else
{
GivePlayerMoney(playerid, -moneycheck);
new string2[128];
format(string,300,"UPDATE "SQL_FACTION" SET `FactionBank`=FactionBank + %d WHERE `ID`='2'",strval(inputtext));
mysql_query(string);
format(string,128,"You have just deposit %s into HR313SR Faction Bank",inputtext);
SendClientMessage(playerid,COLOR_YELLOW,string2);
}
}
Re: MySQL query question. -
oliverrud - 08.06.2010
Aleksander can I ask you one last question? (Thanks Sascha).
Re: MySQL query question. -
Aleksandar_Zivanovci - 08.06.2010
of course
Re: MySQL query question. -
oliverrud - 08.06.2010
My first question/problem is,
pawn Код:
if(IsNumeric(inputtext))
{
GivePlayerMoney(playerid, strval(inputtext));
new string2[128];
format(string,300,"UPDATE "SQL_FACTION" SET `FactionBank`=FactionBank - %d WHERE `ID`='2'",strval(inputtext));
mysql_query(string);
format(string2,128,"You have just deposit %s$ into HR313SR Faction Bank",inputtext);
SendClientMessage(playerid,COLOR_YELLOW,string2);
}
Let's say theres 500 in the FactionBank.
Right now people can withdraw as much they want so they can actually withdraw 50000 without they loosing anything but the FactionBank money going down.
I want to do so it makes sure the FactionBank money wont go under 0 and that they can't withdraw more then till 0.
Anybody got a solution for this?