Inputtext empty condition
#1

how to make if inputtext are blank server return that..

I try in my ways but doesn't work fine..

Код:
if(strlen(inputtext) < 1)
		{
 		   	SCM(playerid, COLOR_GREY,"Eror");
			return 1;
		}
Код:
if(strfind(inputtext, "", true) != -1)return  SCM(playerid, COLOR_GREY, "Eror");
Код:
if(!response)
{
    SCM(playerid, COLOR_GREY,"Eror");
    return 1;
}
Also i try with sscanf but if are emty server say him eror, but if i type something again server say eror..

All of these not work i need if the imputtext emty server return that and send him message with eror.
Reply
#2

pawn Код:
#define isnull(%1) \
((!(%1[0])) || (((%1[0]) == '\1') && (!(%1[1]))))
Example:
pawn Код:
if(isnull(inputtext)) return SendClientMessage(playerid, -1, "Inputted text is null.")
else return SendClientMessage(playerid, -1, "Inputted text isn't null.")
Reply
#3

Quote:
Originally Posted by SickAttack
Посмотреть сообщение
pawn Код:
#define isnull(%1) \
((!(%1[0])) || (((%1[0]) == '\1') && (!(%1[1]))))
Example:
pawn Код:
if(isnull(inputtext)) return SendClientMessage(playerid, -1, "Inputted text is null.")
else return SendClientMessage(playerid, -1, "Inputted text isn't null.")
I have defined isnull already..
I try with
Код:
if(isnull(inputtext)) return SendClientMessage(playerid, -1, "Inputted text is null.")
not work
Reply
#4

It must work, the code shows, shows how you do it.
Reply
#5

Quote:
Originally Posted by JuanStone
Посмотреть сообщение
It must work, the code shows, shows how you do it.
If i define isnull it tells me that it is already defined, like
Код:
warning 201: redefinition of constant/macro
But if i put
Код:
if(isnull(inputtext))
I can continue and I have not typed anything
I will try in my other methods
Reply
#6

Just change the name of the macro.

PHP код:
#define lenull(%1) \
    
((%1[0] == 0) || (%1[0] == && %1[1] == 0))


if(
lenull(inputtext))
{
    
SendClientMessage(playerid, -1"text is null, insert correct text.");
}
else if(!
lenull(inputtext))
{
    if(
strlen(inputtext) >= && strlen(inputtext) < 145// 1 - 144 characters in inpittext
    
{
    
/// bla bla text not is null, and range correct 1-144 characters.
    
}
    else 
SendClientMessage(playerid, -1"Text incorrect min 1 character, max 144.");

Reply
#7

Oh, I forgot to tell you to undefine it first.

Just add this before you define "isnull", obviously:
pawn Код:
#undef isnull
Reply
#8

Код:
if(response) return SCM(playerid, COLOR_GREY,"Inputtext is empty");
But i can't type anything, its say Inputtext is empty
Reply
#9

Quote:
Originally Posted by bigboy81
Посмотреть сообщение
Код:
if(response) return SCM(playerid, COLOR_GREY,"Inputtext is empty");
But i can't type anything, its say Inputtext is empty
That gives you the message if you click button 1 or press enter..
Reply
#10

Quote:
Originally Posted by CalvinC
Посмотреть сообщение
That gives you the message if you click button 1 or press enter..
Yes,but i want if player type something in inputtext continue,but if player not type in inputtext retrun
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)