General Scripting Question
#1

I have no idea what this particular code is called, but I found it very useful when making commands that had optional strings.

https://sampwiki.blast.hk/wiki/Fast_Comm...tional_strings

Код:
...
format(reason, sizeof (reason), "You have been banned%s%s.", reason[0] ? (" for: ") : (""), reason);
...
Could someone tell me what this is called and where I can learn more about how to use it?

Thanks,
ledzep
Reply
#2

Quote:
Originally Posted by ledzep
I have no idea what this particular code is called, but I found it very useful when making commands that had optional strings.

https://sampwiki.blast.hk/wiki/Fast_Comm...tional_strings

Код:
...
format(reason, sizeof (reason), "You have been banned%s%s.", reason[0] ? (" for: ") : (""), reason);
...
Could someone tell me what this is called and where I can learn more about how to use it?

Thanks,
ledzep
Post the whole code
Reply
#3

There's a link to the whole code above the code I posted.
I always give sauce.
Reply
#4

It's called a conditional expression, and you can learn about it by reading the pawn manual.

a ? b : c is like "if a is true then do b, else do c"
Reply
#5

you mean at this ?
pawn Код:
? (" for: ") : (""),

Reply
#6

Quote:
Originally Posted by MJφ
you mean at this ?
pawn Код:
? (" for: ") : (""),
Yes that is what I meant.

Quote:
Originally Posted by 0rb
It's called a conditional expression, and you can learn about it by reading the pawn manual.

a ? b : c is like "if a is true then do b, else do c"
Thanks a lot. Just needed to know what it was called so I could actually search for it lol.
Reply
#7

Here you ca understand it better http://en.wikipedia.org/wiki/%3F:
Reply
#8

Quote:
Originally Posted by 0rb
Here you ca understand it better http://en.wikipedia.org/wiki/%3F:
Awesome.
That's definitely easier to understand than the Pawn_Language_Guide.pdf.

Thanks again.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)