[TUT/INFO] Condition operator aka ? and :
Ok. I saw few scripters using this function so I decide to make this little tutorial.
Intro ? and : can be a very usefull function...i'll explain a bit: Code:
condition ? expresion1 : expresion2 2. if condition is false, the function will asses expresion2 Example: PHP Code:
How to use this function in code 1. An example for printing a kill/kills: PHP Code:
2. Depending on admins activity cvar: PHP Code:
3. I saw script posted about a week ago wich won't let a player to use 'say' command: PHP Code:
PHP Code:
|
Re: [TUT/INFO] ? and : function
nice :D..i have learn something new , 10x anakin :*!
+karma |
Re: [TUT/INFO] ? and : function
Don't forget you should be very careful while using this expression. It has strange precedence orders, and can lead to unexpected behavior. To avoid this, enclose it in () where you have more complex expressions.
PS: +karma, good tut. |
Re: [TUT/INFO] ? and : function
Exelent tuto :D +Karma
|
Re: [TUT/INFO] ? and : function
You can put only 2 lines in this function: one at first expresion at one at last expresion....otherwise you'll get an error.
|
Re: [TUT/INFO] ? and : function
I can use a task like this or how i cant?
PHP Code:
|
Re: [TUT/INFO] ? and : function
I don't understand what do you want to do...
|
Re: [TUT/INFO] ? and : function
You can use it anywhere...
I've even used it in menus: Code:
|
Re: [TUT/INFO] ? and : function
Yea...you can use it several times on one line..is codeless:)
|
Re: [TUT/INFO] ? and : function
aka "condition operator"...
|
All times are GMT -4. The time now is 12:30. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.