Author Topic: Arrays  (Read 519 times)

I work with arrays from time to time, but I'm not 100% on them. Would this work as an array?
Code: [Select]
    GameModeStorerSO.team[%team].member[%i] = %client;
    GameModeStorerSO.team[%team].memberNum++;
    echo(GameModeStorerSO.team[%team].member[%i].getName());
    echo(GameModeStorerSO.team[%team].memberNum);
This is for a gamemode I'm working on, and no, it's not Survival Rp.

Whats %i got to do with anything?

It's part of a for loop above. I didn't bother posting that since I just want to know if a bracket in the middle of an array is valid, and if the rest of them are valid.

Oh and shoulda use getPlayerName...

-codesnip-

It's a problem with the array, I'll try to find an alternate way of storing them, but please people, suggest!
« Last Edit: July 13, 2009, 09:47:53 PM by AGlass0fMilk »


GameModeStorerSO.team[%team].member[%i] = %client;

If %team and %i are numbers...

GameModeStorerSO.RedTeam.1 = %client;

Imagine that. Except that's a visual representation

Oh, and..
In an array, a piece of data is found by a key. A key is literally the "key" to find the string.
$array[%key] = %string;

So...

$name[0] = "Badspot";
$name[1] = "Kompressor";

Which would be GameModeStorerSO.teamRedTeam. member1.

And $name0 = "Badspot" and so on.
$var[Bob,Clan] would be $varBob_Clan.

The difference is that you can do $var[%arg,%arg2] and you cannot do $var%arg_%arg2. Second one would cause a syntax error.

Which would be GameModeStorerSO.teamRedTeam. member1.

And $name0 = "Badspot" and so on.
$var[Bob,Clan] would be $varBob_Clan.

The difference is that you can do $var[%arg,%arg2] and you cannot do $var%arg_%arg2. Second one would cause a syntax error.
Hahaha, I didn't even know you can do that with just a regular variable, nor does it help me.

It doesn't help, but it gives a better understanding.