inputtext problem
#1

pawn Код:
if(dialogid == 4){
    if(inputtext > DOF2_GetInt(pFile(playerid),"Money")){SendClientMessage(playerid,COLOR_DENIED,"[ERROR] {FF6969}You don't have this ammount of money"); return 1;}
    DOF2_SetString(pFile(playerid),"Bank",inputtext); DOF2_SetString(pFile(playerid),"Money",-inputtext);}
    return 1;}
problem: array must be indexed (variable "inputtext")

the error line:
pawn Код:
if(inputtext > DOF2_GetInt(pFile(playerid),"Money")){SendClientMessage(playerid,COLOR_DENIED,"[ERROR] {FF6969}You don't have this ammount of money"); return 1;}
Reply
#2

inputtext is a string.
Use isnumeric(string) to check if it's a number.
If it was, use strval(inputtext) > ... instead of inputtext.
Reply
#3

Quote:
Originally Posted by Stinged
Посмотреть сообщение
inputtext is a string.
Use isnumeric(string) to check if it's a number.
If it was, use strval(inputtext) > ... instead of inputtext.
Example please?
Reply
#4

pawn Код:
if(IsNumeric(inputtext) > DOF2_GetInt(pFile(playerid),"Money")) return SendClientMessage(playerid,COLOR_DENIED,"[ERROR] {FF6969}You don't have this ammount of money");

stock IsNumeric(string[])
{
    for (new i = 0, j = strlen(string); i < j; i++)
    {
        if (string[i] > '9' || string[i] < '0') return 0;
    }
    return 1;
}
Reply
#5

Use strval to convert a string into a integer.

for example
pawn Код:
if(strval(inputtext) > DOF2_GetInt(pFile(playerid),"Money")) return SendClientMessage(playerid,COLOR_DENIED,"[ERROR] {FF6969}You don't have this ammount of money");
Reply
#6

Yes just like I said.
I just added that you should use IsNumeric to make sure the player entered an integer.
Get the IsNumeric stock from awesomedude's post and do this:
pawn Код:
if(IsNumeric(inputtext)
{
    if(strval(inputtext) > DOF2_GetInt(pFile(playerid),"Money")) return SendClientMessage(playerid,COLOR_DENIED,"[ERROR] {FF6969}You don't have this ammount of money");
}
else
{
    SendClientMessage(playerid, YOURCOLOR, MESSAGE THAT HE HAS TO ENTER A NUMBER);
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)