Doesn't work Y_Ini atm withdraw - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Doesn't work Y_Ini atm withdraw (
/showthread.php?tid=655636)
Doesn't work Y_Ini atm withdraw -
bujase1337 - 25.06.2018
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];
}
}
}
}
Re: Doesn't work Y_Ini atm withdraw -
bujase1337 - 26.06.2018
bump
Re: Doesn't work Y_Ini atm withdraw -
Sasino97 - 26.06.2018
Hello, by doing this:
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(playerid, inputvalue);
PlayerInfo[playerid][pBankMoney] -= inputvalue;
}
}
Re: Doesn't work Y_Ini atm withdraw -
GTLS - 26.06.2018
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.
Re: Doesn't work Y_Ini atm withdraw -
bujase1337 - 26.06.2018
Quote:
Originally Posted by Sasino97
Hello, by doing this:
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(playerid, inputvalue);
PlayerInfo[playerid][pBankMoney] -= inputvalue;
}
}
|
Appreciate Your help.