MySQL query question.
#1

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?
Reply
#2

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
Reply
#3

Код:
format(string,300,"UPDATE `SQL_FACTION` SET `Bank`=Bank + %d WHERE `ID`='2'",strval(inputtext));
if you wanted this
Reply
#4

Aleksandar you made my day ^^

Thanks Izanagi for telling me the information.
Reply
#5

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")
Reply
#6

use:
Код:
strval(moneycheck)
instead of "moneycheck" at the error lines (but leave the
Код:
new moneycheck[128]
at its' definition)
Reply
#7

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);
}
}
Reply
#8

Aleksander can I ask you one last question? (Thanks Sascha).
Reply
#9

of course
Reply
#10

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?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)