Checking if inputtext is text -
Vanter - 17.08.2013
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
Re: Checking if inputtext is text -
gtakillerIV - 17.08.2013
Use IsNumeric(); to check if the "inputtext" is a number or not.
https://sampwiki.blast.hk/wiki/Useful_Functions#IsNumeric
Re: Checking if inputtext is text -
Vanter - 17.08.2013
put it into code please, give me an example.
Re: Checking if inputtext is text -
gtakillerIV - 17.08.2013
Add this anywhere in your script:
PHP код:
stock IsNumeric(const string[])
{
for (new i = 0, j = strlen(string); i < j; i++)
{
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.
Re: Checking if inputtext is text -
Vanter - 17.08.2013
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?
Re: Checking if inputtext is text -
Vanter - 17.08.2013
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.
Re: Checking if inputtext is text -
Edix - 17.08.2013
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?
Re: Checking if inputtext is text -
Vanter - 17.08.2013
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
Re: Checking if inputtext is text -
Vanter - 17.08.2013
Well, problem fixed because of someone's help
thanks for your replies guys
appreciated