SA-MP Forums Archive
Inputtext empty condition - 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)
+--- Thread: Inputtext empty condition (/showthread.php?tid=566428)



Inputtext empty condition - bigboy81 - 05.03.2015

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.


Re: Inputtext empty condition - SickAttack - 06.03.2015

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.")



Re: Inputtext empty condition - bigboy81 - 06.03.2015

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


Respuesta: Inputtext empty condition - JuanStone - 06.03.2015

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


Re: Respuesta: Inputtext empty condition - bigboy81 - 06.03.2015

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


Respuesta: Inputtext empty condition - JuanStone - 06.03.2015

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.");




Re: Inputtext empty condition - SickAttack - 06.03.2015

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

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



Re: Respuesta: Inputtext empty condition - bigboy81 - 06.03.2015

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


Re: Respuesta: Inputtext empty condition - CalvinC - 06.03.2015

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..


Re: Respuesta: Inputtext empty condition - bigboy81 - 06.03.2015

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