PDA

View Full Version : Array problems


HolySheepy
07-15-2007, 11:10 PM
Hi,

so i did


function onCreated()
{
this.includelevels = { "test.nw" };
player.chat = this.includelevels.index( player.level );
}


it says -1


function onCreated()
{
this.includelevels = { "test.nw" };
player.chat = this.includelevels[ 0 ];
}


it says test.nw


function onCreated()
{
this.includelevels = { "test.nw" };
player.chat = this.includelevels[ 0 ] == player.level;
}


it says 1


function onCreated()
{
this.includelevels = { "test.nw", };
player.chat = this.includelevels.index( player.level );
}


it says -1


function onCreated()
{
this.includelevels = { "test.nw", "blub.nw" };
player.chat = this.includelevels.index( player.level );
}


it says -1


function onCreated()
{
this.includelevels = { };
this.includelevels.add( "test.nw" );
player.chat = this.includelevels.index( player.level );
}


it says 0

so why? i dont wanna add every single level with add() Oo
and the { } worked fine like a week ago

Tolnaftate2004
07-15-2007, 11:27 PM
Tack on .name to 'player.level'.

Inverness
07-15-2007, 11:35 PM
player.level is an object.

killerogue
07-16-2007, 12:24 AM
Out of observation, I don't mean to be rude....but, your styling is completely retarded. O.o At first glance I hardly understood what it was doing.

xXziroXx
07-16-2007, 02:47 AM
As the other's already stated, try using player.level.name instead of player.level. Should do the trick! :)

Gambet
07-16-2007, 04:07 AM
Out of observation, I don't mean to be rude....but, your styling is completely retarded. O.o At first glance I hardly understood what it was doing.



Yeah, I told him I disliked his styling as well for it didn't make much sense but that's his own personal preference. The problem comes when other people have to edit his work, for they're forced to deal with his styling. :frown:

HolySheepy
07-16-2007, 09:55 AM
Yeah, I told him I disliked his styling as well for it didn't make much sense but that's his own personal preference. The problem comes when other people have to edit his work, for they're forced to deal with his styling. :frown:

well dunno, but for me my styling makes more sense than yours :P
but thanks for helping

a year ago i had styling like

function meh() {
blubcommands
}

or

function meh()
{
blubcommands;
}


then i started working for a serv, the previous scripter quit and he styled it like im doing it now, i first found it hard to read, but after editing some scripts i liked that style and now i think its easier to read than the other styles i posted above :o
oh yeah thats a feature request, brb