![]() |
if (this.something1 in player.chat) {}
This is something I'd like to know for vulgar language kind of stuff.
If I were to do the below script and if someone said "You fuken stupid a$$!" would the player chatting say "Don't be mean"? PHP Code:
Note: I had to evade the curse filter for people to see this correctly, sorry. :frown: |
PHP Code:
|
PHP Code:
You could probably do that. |
PHP Code:
|
people. you do know that it only finds an individual string in an array right? you can't do array in array...
|
PHP Code:
|
Quote:
|
Quote:
|
Quote:
Quote:
|
NPC Code: Known as a for-each statement. NPC Code:condition?true-case:false-case Known as the tertiary operator. |
Quote:
|
PHP Code:
PHP Code:
|
I Saids Explain >_<
|
It evaluates a condition and depending on whether it is true or false, it will execute the true-case or the false-case.
I say 'execute', but in practice, using this as flow-control is bad. |
That's basically "if () { } else {}" :\
|
Quote:
PHP Code:
|
So explain, what does the ? do EXACTLY, what does the : do EXACTLY?
|
Quote:
condition?statements; Quote:
statement1:statement2 All they do is tell the computer where one piece ends and another starts. Both the ? and the : need to be present for the operator to function correctly. They can also be nested: a?b?c:d:e is "translated" into a?(b?c:d):e You will always have # statements = # conditions + 1. |
Quote:
*It would be more accurate to say that the code/content either before or after the : replaces the entire statement, but the way it's phrased above makes it easier to understand. |
Quote:
Quote:
But sometimes I see someone's script and it doesnt have a ? in it, so clearly you don't ALWAYS have to use a ?. What are examples like that and what happens in them? |
lol the swear filter i have makes you say funny stuff and logs you. like i said oh sh!t, and it made me say, "i eat tampons"
|
Quote:
|
i used i not ! tho
|
back on topic please? :\
|
Quote:
In this case, you have to put an array on the right side of the colon. The for loop is then executed a number of times equal to the length of the array, and this.var is set to the corresponding value in the array each time. So if this.array = {8, 20, 1, 6}, then the loop will be executed 4 times, and this.var will be set to 8 the first time, 20 the second time, 1 the third time and 6 the fourth time. Of course, this.var can be any type of variable (you could just name it "i" as is standard in for loops), it doesn't have to be a this. variable. |
That helpd a bunch, thanks :D
|
The colon in a for loop and the colon in a conditional assignment are completely different.
|
I know, Googi said that. I asked how they were different.
|
| All times are GMT +2. The time now is 07:35 AM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.