Define.
#1

Is there any possible way to use this on displaying stuffs such as "Enable" if true and "Disable" false (print)

pawn Код:
#define TEST true
Is there anyway to do it without using the functions manually but this.

pawn Код:
new yes[4] = "Yes", no[3] = "No";
printf("Test: %s", TEST ? yes : no);
Reply
#2

What do you mean ?
If TEST defined as true, server print Yes and if TEST defined False server print No ?
Reply
#3

Yep, that's what i am trying to point here.
Reply
#4

I'm not sure but i think if you use printf to print Test, it will be print Test defined
For example
pawn Код:
#define Test True
printf("Test: %s",Test);
It will be print true

You have to use if and strcmp, so if Test defined as true, print Yes variable value

Sorry i'm on my cellphone and i can't test code

I think only way is use "if"
If someone knows other way please help me and jake :P
Reply
#5

As i said, i am trying to optimized my script that's why i am not using any strcmp, and the method you have given to me didn't work.
Reply
#6

Quote:
Originally Posted by _Jake_
Посмотреть сообщение
Is there any possible way to use this on displaying stuffs such as "Enable" if true and "Disable" false (print)
Is there anyway to do it without using the functions manually but this.

pawn Код:
new yes[4] = "Yes", no[3] = "No";
printf("Test: %s", TEST ? yes : no);
According to the above code, you can use simple macros to define :
pawn Код:
#define retTrueFalse(%0) (%0 == true ? ("Yes") : ("No"))

//Can be used as
new
    bool:test;

printf("%s", retTrueFalse(test));
Will print "Yes" if "test" is set to true, else "No".
Reply
#7

Is it working with the defines, i really need 'em.
Reply
#8

The one I did will, you can even shorten it if you want.
Reply
#9

It works however it gives me a warning

pawn Код:
redundant test: constant expression is non-zero
I don't want to make my script dirty just because of these warnings.

Any solutions for the fix of the warning?
Reply
#10

Quote:
Originally Posted by _Jake_
Посмотреть сообщение
It works however it gives me a warning

pawn Код:
redundant test: constant expression is non-zero
I don't want to make my script dirty just because of these warnings.

Any solutions for the fix of the warning?
Show that line where it occurs.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)