ondialogresponse inputtext
#1

Hi,

If player in dialog which is input type write anything it will be null? i can check

Код:
if( isnull( inputtext ) )
{

}
??
Reply
#2

pawn Код:
if(strlen(inputtext) < 1) Do Something..
https://sampwiki.blast.hk/wiki/Strlen
Reply
#3

this is not good he will get tag mistakes warrning
Reply
#4

This is what I normally use:
pawn Код:
if(!inputtext)
{
 // your code here
}
Reply
#5

You can use Strlen, but i suggest to you to use what Alvord said.
Reply
#6

Quote:
Originally Posted by UltraScripter
Посмотреть сообщение
this is not good he will get tag mistakes warrning
why?
a tag mismatch occurs when...
Quote:
Originally Posted by PAWNlang
-assigning to a tagged variable a value that is untagged or that has
a different tag

-the expressions on either side of a binary operator have different
tags

- in a function call, passing an argument that is untagged or that
has a different tag than what the function argument was defined with

- indexing an array which requires a tagged index with no tag or a
wrong tag name
i dont see how the strlen solution would trigger that... enlighten me please


Quote:
Originally Posted by TheSnaKe
Посмотреть сообщение
You can use Strlen, but i suggest to you to use what Alvord said.
totally wrong, just wrong.

this will throw error 33

Quote:

error 033: array must be indexed...

Quote:
Originally Posted by PAWNlang
An array as a whole cannot be used in a expression; you must
indicate an element of the array between square brackets
the solution with strlen is also not the best (it works though)

what you should do is check if the 1st real element is already the end of the string (EOS)

pawn Код:
if(inputtext[0] == EOS) //some code here
np
Reply
#7

Thanks.
Reply
#8

If player write a space and then text? " hello"

if(inputtext[0] == EOS) //some code here

This mean that this check is == EOS or != EOS?
Reply
#9

Quote:
Originally Posted by Banditukas
Посмотреть сообщение
If player write a space and then text? " hello"

if(inputtext[0] == EOS) //some code here

This mean that this check is == EOS or != EOS?
a space is a space (32, to be exact) and no EOS
EOS is basically the "null-char"
this: '\0'
(its still only 1 char even though its '\' and '0')

so if inputtext is: " hello"
the control structure would look like
if(32 == EOS)

but 32 is not EOS so it'll result in false
Reply
#10

Or just use isnull, correctly demonstrated in the first post. Why must everything be so difficult?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)