View Single Post
  #10  
Old 08-10-2010, 08:34 AM
khortez khortez is offline
PrototypeX
khortez's Avatar
Join Date: Dec 2008
Posts: 91
khortez will become famous soon enough
Quote:
Originally Posted by Switch View Post
In that case, this.origins is a multi-dimensional array, sort of like matrices.

Arrays store multiple variables.
PHP Code:
temp.array = {"Hello""World""!"};
echo(array[
0SPC array[1] @ array[2]); 
The first line defines the array, containing the strings "Hello", "World", and "!".
The second line outputs "Hello World!" on RC. To get a specific variable from an array, you need [#], where the number inside braces ([]) relates to the position in the array starting at the lowest integer 0, so "Hello" is 0, "World" is 1, and "!" is 2.

Now for multi-dimensional arrays.
PHP Code:
temp.array = {{"Hello""World""!"}, {"Nice""day""we're""having""!"}};
echo(array[
0][0SPC array[0][1] @ array[0][1]);
echo(array[
1][0SPC array[1][1SPC array[1][2SPC array[1][3] @ array[1][4]); 
The first line defines the array, with as the first variable and another array as the second.
The second line outputs "Hello World!" on RC. It gets the first array's variables with array[0][#].
The third line outputs "Nice day we're having!" on RC. It gets the second array's variables with array[1][#].

Also, please stop with all the enters.





For Loops
PHP Code:
for (ABC) {
  
D

Use A as a number to do D (or just to do D the amount of times between A with a C increase/decrease and B)

For-Each Loops
PHP Code:
for (B) {
  
C

Use A as each of the variables in B (array) in order to do C.

For-each loops are simplified from this.
PHP Code:
for (temp.i=0temp.i<array.size(); temp.i++) {
  
temp.= array[i];
  
//do things with v



Too much explaining...


Nothing wrong with that, helps people that don't know how to use 'for' and the uses of it understand it better. Also saves possible future questions. Thanks guys, all this helped a lot. Now I got one last thing fustrating me,

Now for me this is pretty pathetic on my part if I really did this wrong. Such a simple script. But not working for me.

I was trying to test my knowledge on arrays by making a list, and then having a specific variable be output in F2 in-game. That failed, so I went even simpler. Just to see if I was doing something wrong

This is what I did....

PHP Code:
//#CLIENTSIDE
function onPlayerChats(){
if(
player.chat == "/test")

echo(
"test");

I tried sendRPGMessage(); too like someone suggested, but that was a no-go.

I Also tried this server-side, and it worked, once? Out of the 5x i tried calling on it.

What did I mess up on?
Reply With Quote