Maximum deposit in bank
#1

Fixed!
Reply
#2

Pure common sense.

pawn Код:
if(maxamount >= 1000000000) return SendClientMessage(playerid,COLOR_RED,"[ ERROR: You can only store $1,000,000,000 in your bank account. ]");
Reply
#3

Код:
CMD:deposit(playerid, params[])
{
    new amount, maxamount;
    maxamount = 1000000000;
    new name[MAX_PLAYER_NAME]; GetPlayerName(playerid, name, sizeof(name)); format(file,sizeof(file),PlayerFile,name);
    if(!IsPlayerInRangeOfPoint(playerid, 1.0, 2316.2041,-4.6539,26.7422)) return SendClientMessage(playerid, COLOR_RED, "[ ERROR: You are not inside a bank, or on a counter checkpoint! ]");
    if(sscanf(params, "i", amount)) return SendClientMessage(playerid, COLOR_LIGHTBLUE, "[ USAGE: /deposit (amount) ]");
    if(amount > GetPlayerMoney(playerid)) return SendClientMessage(playerid,COLOR_RED,"[ ERROR: You dont have that much cash! ]");
    if(amount <= 0) return SendClientMessage(playerid,COLOR_RED,"[ ERROR: You have to deposit atleast $1 into the bank! ]");
    if(100000000 < amount) return SendClientMessage(playerid,COLOR_RED,"[ ERROR: You can only deposit $100,000,000 at a time. ]");
    if(pInfo[playerid][BankCash] >= maxamount) return SendClientMessage(playerid,COLOR_RED,"[ ERROR: You can only store $1,000,000,000 in your bank account. ]");
    GivePlayerMoney(playerid,-amount);
    pInfo[playerid][BankCash] += amount;
    new string[256];
    format(string,sizeof(string),"[ NOTIFICATION: You have successfully deposited: $%s. ]",comma(amount));
    SendClientMessage(playerid,COLOR_BANK,string);
}
Reply
#4

Fixed!
Reply
#5

Quote:
Originally Posted by Sc0pion
Посмотреть сообщение
Both of the above codes don't work properly.

Lets just say you have $999,999,500 in your bank account, the player can deposit any amount up to $100,000,000, so its gonna be more than $1,000,000,000 deposited in bank, but I want only $1,000,000,000 to be able to deposit.


Код:
[23:26:41] [ Your current balance is, Cash: $999. Bank: $999,999,500. Total: $1,000,000,499. ]//My balance was this.

[23:26:50] [ NOTIFICATION: You have successfully deposited: $5,000,000. ]//I deposited this.

[23:26:50] [ NOTIFICATION: And your new bank balance is: $1,004,999,500. ]//Second balance was this after I deposited.

[23:27:04] [ ERROR: You can only store $1,000,000,000 in your bank account. ]//Now I can't deposit more, its pointless if you can deposit more than 1,000,000,000 using that abuse.
It's not that it doesn't work, it's that you didn't allot/initialize a variable properly (using a value without retrieving it first => sscanf).

pawn Код:
CMD:deposit(playerid, params[])
{
    if(!IsPlayerInRangeOfPoint(playerid, 1.0, 2316.2041, -4.6539, 26.7422)) return SendClientMessage(playerid, COLOR_RED, "[ ERROR: You are not inside a bank, or on a counter checkpoint! ]");

    new amount;
    if(sscanf(params, "i", amount)) return SendClientMessage(playerid, COLOR_LIGHTBLUE, "[ USAGE: /deposit (amount) ]");
    if(amount <= 0) return SendClientMessage(playerid, COLOR_RED, "[ ERROR: You have to deposit atleast $1 into the bank! ]");
    if(GetPlayerMoney(playerid) < amount) return SendClientMessage(playerid, COLOR_RED, "[ ERROR: You dont have that much cash! ]");
    if(amount > 100000000) return SendClientMessage(playerid, COLOR_RED, "[ ERROR: You can only deposit $100,000,000 at a time. ]");
    if((pInfo[playerid][BankCash] + amount) >= 1000000000) return SendClientMessage(playerid, COLOR_RED, "[ ERROR: You can only store $1,000,000,000 in your bank account. ]");

    new string[144];
    GivePlayerMoney(playerid, -amount);
    pInfo[playerid][BankCash] += amount;

    format(string, sizeof(string), "[ NOTIFICATION: You have successfully deposited: $%s. ]", comma(amount));
    SendClientMessage(playerid, COLOR_BANK, string);
    return 1;
}
Reply
#6

Fixed!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)