I have no idea...
#1

I have no idea what the hell is wrong with this command, it SHOULD work. It's a multiple sscanf-using command, and uses MANY parameters. If anyone would help me out, that'd be really great. Basically, the create function works fine, the login doesn't, causing nothing else to work. It doesn't even say anything, when it should, and it works perfectly other than that.

pawn Код:
COMMAND:bank(playerid, params[]) {

    new
        BankAccountNum,
        BankAccountPIN,
        BankWithdrawAmount,
        BankDepositAmount,
        string[128];

    if(IsPlayerInRangeOfPoint(playerid, 3, 2447.6873,2376.2104,12.1635)) {
        if(strcmp(params, "login", true, 7) == 0) {
            strdel(params, 0, 5);

            if(sscanf(params, "ii", BankAccountNum, BankAccountPIN)) {
                UsageMessage(playerid, "Bank Login", "[Bank Account Number] [Bank Account PIN]", "Logs you into the specified bank account.");
                return 1;
            }

            for(new i = 0; i < global_ConnectedPlayers; i++) {
                if(PVar[i][BankAccount] == BankAccountNum) {
                    if(PVar[i][BankPIN] == BankAccountPIN) {
                        SetPVarInt(playerid, "LoggedIntoBankAccount", BankAccountNum);
                        format(string, sizeof(string), "You have logged into Bank Account #%d, PIN: %d", BankAccountNum, BankAccountPIN);
                        SuccessMessage(playerid, string);
                    }
                    else return ErrorMessage(playerid, "Invalid Bank Account PIN!");
                }
                else return ErrorMessage(playerid, "Invalid Bank Account Number!");
            }
            return 1;
        }
        else if(strcmp(params, "withdraw", true, 8) == 0) {
            strdel(params, 0, 8);

            if(sscanf(params, "i", BankWithdrawAmount)) {
                UsageMessage(playerid, "Bank Withdraw", "[Amount]", "Withdraws the specified amount out of the bank account.");
                return 1;
            }
           
            if(GetPVarInt(playerid, "LoggedIntoBankAccount") != -1) {
                for(new i = 0; i < global_ConnectedPlayers; i++) {
                    if(PVar[i][BankAccount] == BankAccountNum) {
                        if(PVar[i][BankPIN] == BankAccountPIN) {
                            PVar[i][BankMoney] -= BankWithdrawAmount;
                            PVar[playerid][Cash] += BankWithdrawAmount;
                            if(i != playerid) {
                                SendClientMessage(i, -1, "{FFFFFF}An unknown amount has been withdrawn out of your bank account.");
                            }
                        }
                        else return ErrorMessage(playerid, "Invalid Bank Account PIN!");
                    }
                    else return ErrorMessage(playerid, "Invalid Bank Account Number!");
                }
            }
            else return 1;
        }
        else if(strcmp(params, "deposit", true, 7) == 0) {
            strdel(params, 0, 7);

            if(sscanf(params, "i", BankDepositAmount)) {
                UsageMessage(playerid, "Bank Deposit", "[Amount]", "Deposits the specified amount into the bank account.");
                return 1;
            }

            if(GetPVarInt(playerid, "LoggedIntoBankAccount") != -1) {
                for(new i = 0; i < global_ConnectedPlayers; i++) {
                    if(PVar[i][BankAccount] == BankAccountNum) {
                        if(PVar[i][BankPIN] == BankAccountPIN) {
                            PVar[i][BankMoney] += BankDepositAmount;
                            PVar[playerid][Cash] -= BankDepositAmount;
                            if(i != playerid) {
                                SendClientMessage(i, -1, "{FFFFFF}An unknown amount has been deposited into your bank account.");
                            }
                        }
                        else return ErrorMessage(playerid, "Invalid Bank Account PIN!");
                    }
                    else return ErrorMessage(playerid, "Invalid Bank Account Number!");
                }
            }
            else return 1;
        }
        else if(strcmp(params, "create", true, 6) == 0) {
            strdel(params, 0, 6);
           
            if(PVar[playerid][BankAccount] == 0) {
                PVar[playerid][BankAccount] = random(9999999);
                if(PVar[playerid][BankAccount] == 0) { //Prevent them from getting a zero bank ID.
                    random(9999999);
                }
                PVar[playerid][BankPIN] = random(9999);
                PVar[playerid][BankMoney] = 100;
                SuccessMessage(playerid, "You have successfully registered your account. You have been given $100 as a gift!");
                format(string, sizeof(string), "{FFFFFF}Bank Account Number: %d", PVar[playerid][BankAccount]);
                SendClientMessage(playerid, -1, string);
                format(string, sizeof(string), "{FFFFFF}Bank Account PIN: %d", PVar[playerid][BankPIN]);
                SendClientMessage(playerid, -1, string);
                format(string, sizeof(string), "{FFFFFF}You may now access your account using /Bank Login %d %d", PVar[playerid][BankAccount], PVar[playerid][BankPIN]);
                SendClientMessage(playerid, -1, string);
            }
            else return ErrorMessage(playerid, "You already have a Bank Account!");
        }
    }
    else return ErrorMessage(playerid, "You are not at the Bank of Las Venturas!");
    return 1;
}
Reply
#2

You haven't set proper string lengths for strcmp, "login" is 5 characters and not 7.
Reply
#3

Quote:
Originally Posted by __
Посмотреть сообщение
You haven't set proper string lengths for strcmp, "login" is 5 characters and not 7.
Always a stupid mistake, thank you very much.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)