Doesn't work Y_Ini atm withdraw
#1

Script itself has no errors, but it doesn't work.

Script:
Код:
		case atm_withdraw:
		{
			if (!response) return 1;
            if(response)
            {
				if (inputtext[256] == 0)
				if (inputtext[256] < 0)
				if (PlayerInfo[playerid][pBankMoney] >= inputtext[256])
				{
					GivePlayerMoney(playerid, inputtext[256]);
					PlayerInfo[playerid][pBankMoney] -= inputtext[256];
				}
				else
				{
					return 1;
				}
			}
		}
Another tryied script that has no errors, but doesn't function:
Код:
		case atm_withdraw:
		{
			if (!response) return 1;
            if(response)
            {
				if (inputtext[256] == 0)
				{
					return 1;
				}
				else if (inputtext[256] < 0)
				{
					return 1;
				}
				else
				{
					if (PlayerInfo[playerid][pBankMoney] >= inputtext[256])
					{
						GivePlayerMoney(playerid, inputtext[256]);
						PlayerInfo[playerid][pBankMoney] -= inputtext[256];
					}
				}
			}
		}
Reply
#2

bump
Reply
#3

Hello, by doing this:

PHP код:
inputtext[256
You are getting the 257th character in the input string, not the numerical value of the string.
Please see Strval.

In your case:

PHP код:
case atm_withdraw:
{
    if (!
response)
        return 
1;
    
// no need to check also if(response) because if(!response) already stopped the code returning 1.
    
    
new inputvalue// we create an integer variable
    
inputvalue strval(inputtext); // we set its value to the integer value of the string "inputtext"
    
    // inputtext[256] is wrong, we will now use inputvalue
    
    
if (inputvalue <= 0// <= means less than or equal to (similarly you can use >=)
        
return 1;
        
    
// again, no need for an else {} block here, because if inputvalue <= 0 then the code stops there
    
    
if (PlayerInfo[playerid][pBankMoney] >= inputvalue)
    {
        
GivePlayerMoney(playeridinputvalue);
        
PlayerInfo[playerid][pBankMoney] -= inputvalue;
    }

Reply
#4

PHP код:
 if (inputvalue <= 0// <= means less than or equal to (similarly you can use >=) 
        
return 1
No, He can not use >= here. he has to check if its less than 0 or not. using >= will revert the function. Rest will work.
Reply
#5

Quote:
Originally Posted by Sasino97
Посмотреть сообщение
Hello, by doing this:

PHP код:
inputtext[256
You are getting the 257th character in the input string, not the numerical value of the string.
Please see Strval.

In your case:

PHP код:
case atm_withdraw:
{
    if (!
response)
        return 
1;
    
// no need to check also if(response) because if(!response) already stopped the code returning 1.
    
    
new inputvalue// we create an integer variable
    
inputvalue strval(inputtext); // we set its value to the integer value of the string "inputtext"
    
    // inputtext[256] is wrong, we will now use inputvalue
    
    
if (inputvalue <= 0// <= means less than or equal to (similarly you can use >=)
        
return 1;
        
    
// again, no need for an else {} block here, because if inputvalue <= 0 then the code stops there
    
    
if (PlayerInfo[playerid][pBankMoney] >= inputvalue)
    {
        
GivePlayerMoney(playeridinputvalue);
        
PlayerInfo[playerid][pBankMoney] -= inputvalue;
    }

Appreciate Your help.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)