How to check - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: How to check (
/showthread.php?tid=132155)
How to check -
Torran - 06.03.2010
How to check to see if a player enters numbers on DIALOG_STYLE_INPUT,
And how to make sure that he enters 4 numbers, And if he dosent, Returns msg
Re: How to check -
Torran - 06.03.2010
I know that but how do i check if he entered numbers, And 4 numbers,
It can be anything, But it has to be numbers and it has to be 4 digits
Re: How to check -
¤Adas¤ - 06.03.2010
pawn Код:
if(strlen(inputtext) == 4 && IsNumeric(inputtext))
Re: How to check -
Torran - 06.03.2010
Wouldnt that check if the player entered 4?
Let me try explain better:
Im making a bit on my server where you need to enter the year you were born,
So i need to know if they entered numbers ( Got that, Thanks for the code )
And that its 4 digits
So
****
Example: 1990
Re: How to check -
¤Adas¤ - 06.03.2010
That is what i said. Here is my function to check, if birth date is valid. I hope, it will help you a lot.
pawn Код:
stock bool:IsValidDate(day, month, year)
{
new actual_day, actual_month, actual_year;
getdate(actual_year, actual_month, actual_day);
if(day < 1 || month < 1 || year < 1 || day > 31 || month > 12 || year > actual_year) return false;
if(year == actual_year)
{
if(month > actual_month) return false;
if(month == actual_month && day > actual_day) return false;
}
switch(month)
{
case 2: if((year % 4 && day > 28) || day > 29) return false;
case 4: if(day == 31) return false;
case 6: if(day == 31) return false;
case 9: if(day == 31) return false;
case 11: if(day == 31) return false;
}
return true;
}
Re: How to check -
smeti - 06.03.2010
pawn Код:
if(!IsNumeric(inputtext) || strlen(inputtext) < 0 || strlen(inputtext) > 4 || strval(inputtext) < 1960 || strval(inputtext) > 2010) return printf("No inputtext 4 char and numeric and no value 1960 - 2010");
else printf("perfect %d", strval(inputtext));
Simplifield:
pawn Код:
if(!IsNumeric(inputtext) || strval(inputtext) < 1960 || strval(inputtext) > 2010) return print("inputtext no value 1960 - 2010");
else printf("perfect %d", strval(inputtext));
pawn Код:
stock IsNumeric(string[])
{
for (new i = 0, j = strlen(string); i < j; i++)
{
if (string[i] > '9' || string[i] < '0') return false;
}
return true;
}
Final:
pawn Код:
if(strval(inputtext) < 1960 || strval(inputtext) > 2010) return print("inputtext no value 1960 - 2010");
else printf("perfect %d", strval(inputtext));