Hi, I'm relatively new to GS2 and have been trying to get this player-sorting script to work...I'm getting closer, and I -think- I have an idea what the problem is, but I can't quite figure it out.
Basically, what is supposed to happen is the first 6 players are warped on a top level, 8 tiles apart from eachother, and the next 4 are warped below them...However, it only seems to sort the first 10. (I haven't had a chance to test it with 20+, so I don't know if it's only sorting the first 10, or in sets of 10)
I included a picture in this post..the red squares are where people are being warped...just not everyone.
PHP Code:
function onCreated()
{
//starting x,y for top and bottom rows
this.conStartTopx = 8.5;
this.conStartBottomx = 23.5;
this.conStartTopy = 10;
this.conStartBottomy = 20;
}
function onPlayerChats()
{
if ( player.guild == "Events Team" )
{
if ( player.chat == ":start" )
{
temp.countCons = 0;
for ( temp.c = 0; temp.c < players.size(); temp.c++ )
{
if ( players[temp.c].guild == "Convict" )
temp.countCons++;
}
serverr.numStartCons = temp.countCons;
if ( !(serverr.pbmapsize = null) )
{
for ( temp.pl = 0; temp.pl < players.size(); temp.pl++ )
{
if ( players[temp.pl].guild == "Guard" )
{
players[temp.pl].setlevel2("era_prison-entrance_" @ serverr.pbmapsize @ ".nw", 30, 40);
}
}
//This is supposed to determine the number of times
//the while loop should execute
if (serverr.numStartCons%10 != 0)
{
temp.numloop = int(serverr.numStartCons/10) + 1;
}
else
{
temp.numloop = serverr.numStartCons/10;
}
while ( temp.numloop > 0 )
{
temp.counter = 0;
temp.conxwarp = this.conStartTopx;
temp.conywarp = this.conStartTopy;
for ( temp.p = 0; temp.p < players.size(); temp.p++ )
{
if ( players[temp.p].guild == "Convict" )
{
if ( temp.counter < 6 )
{
players[temp.p].setlevel2("era_prison-cellroom_" @ serverr.pbmapsize @ ".nw", temp.conxwarp, temp.conywarp);
temp.conxwarp+=8;
if ( temp.counter == 5 )
temp.conxwarp = this.conStartBottomx;
}
else if ( temp.counter < 10 )
{
temp.conywarp = this.conStartBottomy;
players[temp.p].setlevel2("era_prison-cellroom_" @ serverr.pbmapsize @ ".nw", temp.conxwarp, temp.conywarp);
temp.conxwarp+=8;
}
temp.counter++;
}
}
temp.numloop--;
}
}
else
{
player.chat = "I need to set the map!";
}
}
}
}