/deposit command Problem + mysql
#1

hi guys...

im trying to make a /deposit command

the problem is that i want to make it working that you enter /deposit amount for example 1255 it will remove the amount from your current money and update into your bank. The problem is that nothing happens. Not even errors / warnings.

pawn Код:
CMD:deposit(playerid,params[])
{
    new money,pname[24],string[128],bankcash;
    if(sscanf(params,"d",money)) return SendClientMessage(playerid,COLOR_ERROR,"USAGE: /deposit amount");
        if(InBank[playerid])
        {
            if(IsPlayerInDynamicCP(playerid,sfschalter))
            {
                format(Query,sizeof(Query),"SELECT * FROM `users` WHERE username='%s'",pname);
                mysql_query(Query);
                mysql_store_result();
                if(mysql_num_rows() != 0)
                {
                    new line[512];
                    if(mysql_fetch_row(line)) //Fetches the line
                    {
                        new data[13];//The data strings
                        new data2[10]; //The data variables
                        sscanf(line, "p|ds[24]s[60]dddddd",data2[1], data[1],data[2],data2[2],data2[3],data2[4],data2[5],data2[6],data2[7]); //Splits the line with sscanf
                        bankcash = data2[5];
                        money += bankcash ; // here should the money ( amount) be aggregated with the bank money which comes from the database
                        mysql_free_result(); // dont know if its needed in here or not
                        format(Query,sizeof(Query),"UPDATE `users` SET `bankcash` = '%d' WHERE username='%s'",bankcash,pname);
                        mysql_query(Query);
                        SendClientMessage(playerid,0x8F8F8FAA,"_|San Fierro - Bank|_");
                        format(string,sizeof(string),"You deposited $%d into your account",money);
                        SendClientMessage(playerid,0x333333AA,string);
                        SendClientMessage(playerid,0x8F8F8FAA,"Transfer done");
                        GivePlayerMoney(playerid,-money);

                    }
                }

            }
            else
            {
                SendClientMessage(playerid,COLOR_ERROR,"You are not in the Checkpoint");
                return 1;
            }
        }
        else
        {
            SendClientMessage(playerid,COLOR_ERROR,"You are not at the Bank");
            return 1;
        }
    return 1;
}
Reply
#2

/bump
Reply
#3

Try using a strcmp command instead its more easier and quicker

pawn Код:
if(strcmp(cmd, "/bank", true) == 0 || strcmp(cmd, "/deposit", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            if(!IsPlayerInRangeOfPoint(playerid, 5.0, 2308.8071,-13.2485,26.7422))
            {
                SendClientMessage(playerid, COLOR_GREY, "   You are not at the bank !");
                return 1;
            }
            tmp = strtok(cmdtext, idx);
            if(!strlen(tmp))
            {
                SendClientMessage(playerid, COLOR_WHITE, "USAGE: /bank [amount]");
                format(string, sizeof(string), "  You have $%d in your bank account.", PlayerInfo[playerid][pAccount]);
                SendClientMessage(playerid, COLOR_GRAD3, string);
                return 1;
            }
            new cashdeposit = strvalEx(tmp);
            if(!strlen(tmp))
            {
                SendClientMessage(playerid, COLOR_WHITE, "USAGE: /bank [amount]");
                format(string, sizeof(string), "  You have $%d in your bank account.", PlayerInfo[playerid][pAccount]);
                SendClientMessage(playerid, COLOR_GRAD3, string);
                return 1;
            }
            if(cashdeposit > PlayerInfo[playerid][pCash] || cashdeposit < 1)
            {
                SendClientMessage(playerid, COLOR_GRAD2, "   You don't have that much !");
                return 1;
            }
            PlayerInfo[playerid][pCash] = PlayerInfo[playerid][pCash]-cashdeposit;
            GivePlayerMoney(playerid,-cashdeposit);
            new curfunds = PlayerInfo[playerid][pAccount];
            PlayerInfo[playerid][pAccount] = cashdeposit+PlayerInfo[playerid][pAccount];
            SendClientMessage(playerid, COLOR_WHITE, "|___ BANK STATEMENT ___|");
            format(string, sizeof(string), "  Old Balance: $%d", curfunds);
            SendClientMessage(playerid, COLOR_GRAD2, string);
            format(string, sizeof(string), "  Deposit: $%d",cashdeposit);
            SendClientMessage(playerid, COLOR_GRAD4, string);
            SendClientMessage(playerid, COLOR_GRAD6, "|------------------------------------------|");
            format(string, sizeof(string), "  New Balance: $%d", PlayerInfo[playerid][pAccount]);
            SendClientMessage(playerid, COLOR_WHITE, string);
            return 1;
        }
        return 1;
    }
Reply
#4

F*ck no.
ZCMD is faster and better.
Make sure if it's a filterscript,
pawn Код:
#define FILTERSCRIPT
and
pawn Код:
#include <zcmd>
is there, and your command is not in
pawn Код:
OnPlayerCommandText
.
Reply
#5

Quote:
Originally Posted by Seven_of_Nine
Посмотреть сообщение
F*ck no.
ZCMD is faster and better.
Make sure if it's a filterscript,
pawn Код:
#define FILTERSCRIPT
and
pawn Код:
#include <zcmd>
is there, and your command is not in
pawn Код:
OnPlayerCommandText
.
its inside of a gamemode

and the include is included as well..and nothing on OnPlayerCommandText
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)