Checking if inputtext is text
#1

I'm making a deposit to house using dialogs..
I need to make the inputtext numbers only, it's a simple question I guess

I'd appreciate help
Reply
#2

Use IsNumeric(); to check if the "inputtext" is a number or not.

https://sampwiki.blast.hk/wiki/Useful_Functions#IsNumeric
Reply
#3

put it into code please, give me an example.
Reply
#4

Add this anywhere in your script:

PHP код:
stock IsNumeric(const string[])
{
    for (new 
0strlen(string); ji++)
    {
        if (
string[i] > '9' || string[i] < '0') return 0;
    }
    return 
1;

That's the "IsNumeric" function.

Now you can use it like this:

PHP код:
if(IsNumeric(inputtext)) return 1
That means if "inputtext" is numeric. If it is.
Reply
#5

pawn Код:
if(dialogid == 3003)
    {
        if(!response)
        {
           return 1;
        }
        if(response)
        {
            if(!strlen(inputtext)) return ShowPlayerDialog(playerid, 3003, DIALOG_STYLE_INPUT,"{FF0000}House Information","{FFFFFF} Type how much cash you'd like to deposit in your house.","Deposit","Cancel");
            if(strlen(inputtext) > GetPlayerMoney(playerid))
            {
                SendClientMessage(playerid, COLOR_RED,"[ERROR] You don't have enough cash in hand to deposit.");
                return 1;
            }
            if(HInfo[InsideHouse[playerid]][hCash] > 25000000 && PlayerInfo[playerid][pDonator] == 0)
            {
                SendClientMessage(playerid, COLOR_RED,"[ERROR] Your maximum house deposit is 25 million.");
                return 1;
            }
            if(HInfo[InsideHouse[playerid]][hCash] > 50000000 && PlayerInfo[playerid][pDonator] == 1)
            {
                SendClientMessage(playerid, COLOR_RED,"[ERROR] Your maximum house deposit is 50 million.");
                return 1;
            }
            HInfo[InsideHouse[playerid]][hCash] +=strlen(inputtext);
            GivePlayerMoney(playerid, -strlen(inputtext));
            format(string,sizeof(string),"[HOUSE] You've successfully deposited $%d in your house",strlen(inputtext));
            SendClientMessage(playerid, COLOR_GREEN,string);
            return 1;
        }
    }
Nothing is written in the Y_INI, and the client message sent is fucked up
Код:
[22:07:36] [HOUSE] You've successfully deposited $3 in your house
any help?
Reply
#6

You're only reply was "ssacnf2!" this isn't helping.
and IsNumeric() gave ma alot of errors, so I decided to make it work now then add numbers only later, don't judge on a "we", talk only about yourself.
Reply
#7

Quote:
Originally Posted by Vanter
Посмотреть сообщение
You're only reply was "ssacnf2!" this isn't helping.
and IsNumeric() gave ma alot of errors, so I decided to make it work now then add numbers only later, don't judge on a "we", talk only about yourself.
Do you not use sscanf in your CMD's?
Is it that hard to go to the sscanf topic and read a bit?
Reply
#8

Edix, if you're just copying ******'s opinion because he's more experienced or whatever you call, then I have no respect to your comment..

and if that's your own opinion then I'd respect it, I'm sure if ****** didn't post that reply you wouldn't post that comment either
Reply
#9

Well, problem fixed because of someone's help
thanks for your replies guys
appreciated
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)