Bank Errors
#1

So if a player has 0 money in the bank he can still withdraw unlimited money..same with deposit..

Code:
Код:
CMD:deposit(playerid, params[])
{
	if(IsPlayerInRangeOfPoint(playerid, 2, -2455.4519, 503.9336, 30.0781))
	{
	    if(GetPlayerMoney(playerid) < 0) return SendClientMessage(playerid, COLOR_RED, "ERROR:You don't have any money on you!");
	    new amount;
	    if(sscanf(params,"nd", amount)) return SendClientMessage(playerid, -1,"USAGE: /deposit [amount]");
	    GivePlayerMoney(playerid, -amount);
	    pInfo[playerid][Bank]++;
	}
	return 1;
}
CMD:withdraw(playerid, params[])
{
	if(IsPlayerInRangeOfPoint(playerid, 2, -2455.4519, 503.9336, 30.0781))
	{
	    if(pInfo[playerid][Bank] < 0) return SendClientMessage(playerid, COLOR_RED, "ERROR:You Don't Have Money In Your Bank Account!");
     	new amount;
    	if(sscanf(params,"nd", amount)) return SendClientMessage(playerid, -1,"USAGE: /withdraw [amount]");
    	GivePlayerMoney(playerid, amount);
    	pInfo[playerid][Bank]--;
	}
	return 1;
}
Reply
#2

Try this, you have this in plus if(sscanf(params,"nd", amount))

PHP код:
CMD:deposit(playerid, params[])
{
    if(
IsPlayerInRangeOfPoint(playerid, 2, -2455.4519, 503.9336, 30.0781))
    {
        if(
GetPlayerMoney(playerid) < 0) return SendClientMessage(playerid, COLOR_RED, "ERROR:You don't have any money on you!");
        new 
amount;
        if(
sscanf(params,"d", amount)) return SendClientMessage(playerid, -1,"USAGE: /deposit [amount]");
            if(
amount < 0 ) return SendClientMessage(playerid,-1,"You can not withdraw money with minus");
    
GivePlayerMoney(playerid, -amount);
        
pInfo[playerid][Bank]++;
    }
    return 
1;
}
CMD:withdraw(playerid, params[])
{
    if(
IsPlayerInRangeOfPoint(playerid, 2, -2455.4519, 503.9336, 30.0781))
    {
        if(
pInfo[playerid][Bank] < 0) return SendClientMessage(playerid, COLOR_RED, "ERROR:You Don't Have Money In Your Bank Account!");
         new 
amount;
        if(
sscanf(params,"d", amount)) return SendClientMessage(playerid, -1,"USAGE: /withdraw [amount]");
            if(
amount < 0 ) return SendClientMessage(playerid,-1,"You can not withdraw money with minus");
        
GivePlayerMoney(playerid, amount);
        
pInfo[playerid][Bank]--;
    }
    return 
1;
} 
Reply
#3

And
PHP код:
 if(GetPlayerMoney(playerid) <= 0) 
Reply
#4

EDIT:Only deposit works..Withdraw doesn't.. am i doing something wrong in the code?

Код:
ON :OnPlayerDisconnetct:
INI_WriteInt(file,"Bank",pInfo[playerid][Bank]);//As explained above

ON: public laodaccount_user

INI_Int("Bank",pInfo[playerid][Bank]);//As explained above
Is there something wrong there?
Reply
#5

PHP код:
CMD:deposit(playerid, params[])
{
    if(
IsPlayerInRangeOfPoint(playerid, 2, -2455.4519, 503.9336, 30.0781))
    {
        if(
GetPlayerMoney(playerid) <= 0) return SendClientMessage(playerid, COLOR_RED, "ERROR:You don't have any money on you!");
        new 
amount;
        if(
sscanf(params,"d", amount)) return SendClientMessage(playerid, -1,"USAGE: /deposit [amount]");
            if(
amount < 0 ) return SendClientMessage(playerid,-1,"You can not withdraw money with minus");
    
GivePlayerMoney(playerid, -amount);
        
pInfo[playerid][Bank]++;
    }
    return 
1;
}
CMD:withdraw(playerid, params[])
{
    if(
IsPlayerInRangeOfPoint(playerid, 2, -2455.4519, 503.9336, 30.0781))
    {
        if(
pInfo[playerid][Bank] <= 0) return SendClientMessage(playerid, COLOR_RED, "ERROR:You Don't Have Money In Your Bank Account!");
         new 
amount;
        if(
sscanf(params,"d", amount)) return SendClientMessage(playerid, -1,"USAGE: /withdraw [amount]");
            if(
amount < 0 ) return SendClientMessage(playerid,-1,"You can not withdraw money with minus");
        
GivePlayerMoney(playerid, amount);
        
pInfo[playerid][Bank]--;
    }
    return 
1;
} 
Reply
#6

PHP код:
CMD:withdraw(playerid, params[]) 
{ 
    if(!
IsPlayerInRangeOfPoint(playerid, 2, -2455.4519, 503.9336, 30.0781))  return SendClientMessage(playerid, -1,"You are not at the Bank"); 
     new 
amount; 
     if(
sscanf(params,"d", amount)) return SendClientMessage(playerid, -1,"USAGE: /withdraw [amount]"); 
     if (
amount> pInfo[playerid][Bank] || amount< 1) return SendClientMessage(playerid, COLOR_GRAD2, "  INVALID TRANZACTION!");
     
GivePlayerMoney(playerid, amount); 
     
pInfo[playerid][Bank]--; 
     return 
1; 
} 
Reply
#7

Umm it still does the same...
Reply
#8

What about this one?:

PHP код:
CMD:deposit(playerid, params[])
{
    if(
IsPlayerInRangeOfPoint(playerid, 2, -2455.4519, 503.9336, 30.0781))
    {
        new 
amount;
        if(
sscanf(params, "d", amount)) return SendClientMessage(playerid, -1, "USAGE: /deposit [amount]");
        if(
GetPlayerMoney(playerid) < amount || amount < 1) return SendClientMessage(playerid, -1, "Error: You haven't that much money or invalid amount.");
        
GivePlayerMoney(playerid, -amount);
        
pInfo[playerid][Bank] += amount;
    }
    return 
1;
}
CMD:withdraw(playerid, params[])
{
    if(
IsPlayerInRangeOfPoint(playerid, 2, -2455.4519, 503.9336, 30.0781))
    {
         new 
amount;
        if(
sscanf(params, "d", amount)) return SendClientMessage(playerid, -1, "USAGE: /withdraw [amount]");
        if(
pInfo[playerid][Bank] < amount || amount < 1) return SendClientMessage(playerid, -1, "Error: You haven't that much money or invalid amount.");
        
GivePlayerMoney(playerid, amount);
        
pInfo[playerid][Bank] -= amount;
    }
    return 
1;
} 
Reply
#9

Nope..
Reply
#10

What's your trouble with this? what do you want?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)