Ok that was quite helpful but I am now stuck elsewhere. I am including my entire script for you to see it and I would like to know how to stop the tetris pieces. I am in a triple for loop and need to break them all at once... It is indicated by a comment but the script is still quite big.
Code:
main()
{
thread letsplaysometetris();
}
letsplaysometetris()
{
tetris = [];
tetris[11] = getent ("tetris1_1", "targetname");
tetris[12] = getent ("tetris1_2", "targetname");
tetris[13] = getent ("tetris1_3", "targetname");
tetris[14] = getent ("tetris1_4", "targetname");
tetris[21] = getent ("tetris2_1", "targetname");
tetris[22] = getent ("tetris2_2", "targetname");
tetris[23] = getent ("tetris2_3", "targetname");
tetris[24] = getent ("tetris2_4", "targetname");
tetris[31] = getent ("tetris3_1", "targetname");
tetris[32] = getent ("tetris3_2", "targetname");
tetris[33] = getent ("tetris3_3", "targetname");
tetris[34] = getent ("tetris3_4", "targetname");
tetris[41] = getent ("tetris4_1", "targetname");
tetris[42] = getent ("tetris4_2", "targetname");
tetris[43] = getent ("tetris4_3", "targetname");
tetris[44] = getent ("tetris4_4", "targetname");
tetris[51] = getent ("tetris5_1", "targetname");
tetris[52] = getent ("tetris5_2", "targetname");
tetris[53] = getent ("tetris5_3", "targetname");
tetris[54] = getent ("tetris5_4", "targetname");
tetris[61] = getent ("tetris6_1", "targetname");
tetris[62] = getent ("tetris6_2", "targetname");
tetris[63] = getent ("tetris6_3", "targetname");
tetris[64] = getent ("tetris6_4", "targetname");
tetris[71] = getent ("tetris7_1", "targetname");
tetris[72] = getent ("tetris7_2", "targetname");
tetris[73] = getent ("tetris7_3", "targetname");
tetris[74] = getent ("tetris7_4", "targetname");
tetris[81] = getent ("tetris8_1", "targetname");
tetris[82] = getent ("tetris8_2", "targetname");
tetris[83] = getent ("tetris8_3", "targetname");
tetris[84] = getent ("tetris8_4", "targetname");
tetris[91] = getent ("tetris9_1", "targetname");
tetris[92] = getent ("tetris9_2", "targetname");
tetris[93] = getent ("tetris9_3", "targetname");
tetris[94] = getent ("tetris9_4", "targetname");
tetris[101] = getent ("tetris10_1", "targetname");
tetris[102] = getent ("tetris10_2", "targetname");
tetris[103] = getent ("tetris10_3", "targetname");
tetris[104] = getent ("tetris10_4", "targetname");
tetris[111] = getent ("tetris12_1", "targetname");
tetris[112] = getent ("tetris12_2", "targetname");
tetris[113] = getent ("tetris12_3", "targetname");
tetris[114] = getent ("tetris12_4", "targetname");
tetris[121] = getent ("tetris13_1", "targetname");
tetris[122] = getent ("tetris13_2", "targetname");
tetris[123] = getent ("tetris13_3", "targetname");
tetris[124] = getent ("tetris13_4", "targetname");
rotatebutton = getent ("rotate","targetname");
leftbutton = getent ("left","targetname");
rightbutton = getent ("right","targetname");
controllerspawn = getent ("spawn","targetname");
spawnorigin = controllerspawn.origin;
level.rotatepressed = false;
level.rightpressed = false;
level.leftpressed = false;
megaorigin = tetris[11].origin;
for (p=0; p<12; p++)
{
for (s=0; s<4; s++)
{
tetris[(p+1) * 10 + s + 1].inplay = 0;
tetris[(p+1) * 10 + s + 1].rotation = 0;
}
}
wait 60;
for(;;)
{
players = getentarray ("player","classname");
num = randomInt(players.size);
if(getcvar("g_gametype") == "zom")
{
if(players[num].sessionstate == "playing" && players[num].pers["team"] == "axis" && maps\mp\gametypes\_zombie_util::numofplayers("axis") >= 2)
{
iPrintlnBold ("^7Let's play some ^2TETRIS^7!");
iPrintlnBold ("^7" + players[num].name + "^7 was chosen to play!");
players[num] setorigin(spawnorigin,1);
break;
}
}
else
{
if(players[num].sessionstate == "playing" && players.size >= 1)
{
iPrintlnBold ("^7Let's play some ^2TETRIS^7!");
iPrintlnBold ("^7" + players[num].name + "^7 was chosen to play!");
players[num] setorigin(spawnorigin,1);
break;
}
}
}
thread checkrotate();
thread checkleft();
thread checkright();
while (1)
{
for(;;)
{
piece = randomInt(12);
if (tetris[piece * 10 + 1].inplay = 0 && tetris[piece * 10 + 2].inplay = 0 && tetris[piece * 10 + 3].inplay = 0 && tetris[piece * 10 + 4].inplay = 0)
break;
}
raisepiece(tetris,piece);
movepiece(tetris,piece,3);
for(;;)
{
for(p=0; p<12; p++)
{
for(q=0; q<4; q++)
{
if (tetris[piece * 10 + 1].origin == tetris[(p+1)*10 + q].origin || tetris[piece * 10 + 2].origin == tetris[(p+1)*10 + q].origin || tetris[piece * 10 + 3].origin == tetris[(p+1)*10 + q].origin || tetris[piece * 10 + 4].origin == tetris[(p+1)*10 + q].origin)
//stop the tetris, but how?
}
}
if (level.rotatepressed == 1)
rotatepiece(tetris,piece);
if (level.leftpressed == 1)
pieceleft(tetris,piece,1);
if (level.rightpressed == 1)
pieceright(tetris,piece,1);
if (level.rotatepressed == 0 && level.leftpressed == 0 && level.rightpressed == 0)
movepiece(tetris,piece,1);
}
}
}
checkrotate()
{
while(1)
{
rotatetrig = getent ("rotatetrig","targetname");
rotatetrig waittill ("trigger");
level.rotatepressed = true;
wait 0.1;
}
}
checkleft()
{
while(1)
{
lefttrig = getent ("lefttrig","targetname");
lefttrig waittill ("trigger");
level.leftpressed = true;
wait 0.1;
}
}
checkright()
{
while(1)
{
righttrig = getent ("righttrig","targetname");
righttrig waittill ("trigger");
level.rightpressed = true;
wait 0.1;
}
}
rotatepiece(tetris,piece)
{
tetris[10 * piece + 1] rotateyaw (90,0.5);
tetris[10 * piece + 1].rotation++;
tetris[10 * piece + 2] rotateyaw (90,0.5);
tetris[10 * piece + 2].rotation++;
tetris[10 * piece + 3] rotateyaw (90,0.5);
tetris[10 * piece + 3].rotation++;
tetris[10 * piece + 4] rotateyaw (90,0.5);
tetris[10 * piece + 4].rotation++;
tetris[10 * piece + 4] waittill ("rotatedone");
tetris[10 * piece + 1] movex(128,0.1);
tetris[10 * piece + 2] movex(128,0.1);
tetris[10 * piece + 3] movex(128,0.1);
tetris[10 * piece + 4] movex(128,0.1);
tetris[10 * piece + 4] waittill("movedone");
wait 0.5;
}
raisepiece(tetris,piece)
{
tetris[10 * piece + 1] movez(256,1);
tetris[10 * piece + 2] movez(256,1);
tetris[10 * piece + 3] movez(256,1);
tetris[10 * piece + 4] movez(256,1);
tetris[10 * piece + 4] waittill("movedone");
tetris[10 * piece +1].inplay = 1;
tetris[10 * piece +2].inplay = 1;
tetris[10 * piece +3].inplay = 1;
tetris[10 * piece +4].inplay = 1;
}
movepiece(tetris,piece,times)
{
for (i=0; i<times; i++)
{
tetris[10 * piece + 1] movex(128,0.1);
tetris[10 * piece + 2] movex(128,0.1);
tetris[10 * piece + 3] movex(128,0.1);
tetris[10 * piece + 4] movex(128,0.1);
tetris[10 * piece + 4] waittill("movedone");
wait 0.5;
}
}
pieceright(tetris,piece,times)
{
for (i=0; i<times; i++)
{
tetris[10 * piece + 1] movey(128,0.1);
tetris[10 * piece + 2] movey(128,0.1);
tetris[10 * piece + 3] movey(128,0.1);
tetris[10 * piece + 4] movey(128,0.1);
tetris[10 * piece + 4] waittill("movedone");
wait 0.5;
tetris[10 * piece + 1] movex(128,0.1);
tetris[10 * piece + 2] movex(128,0.1);
tetris[10 * piece + 3] movex(128,0.1);
tetris[10 * piece + 4] movex(128,0.1);
tetris[10 * piece + 4] waittill("movedone");
wait 0.5;
}
}
pieceleft(tetris,piece,times)
{
for (i=0; i<times; i++)
{
tetris[10 * piece + 1] movey(-128,0.1);
tetris[10 * piece + 2] movey(-128,0.1);
tetris[10 * piece + 3] movey(-128,0.1);
tetris[10 * piece + 4] movey(-128,0.1);
tetris[10 * piece + 4] waittill("movedone");
wait 0.5;
tetris[10 * piece + 1] movex(128,0.1);
tetris[10 * piece + 2] movex(128,0.1);
tetris[10 * piece + 3] movex(128,0.1);
tetris[10 * piece + 4] movex(128,0.1);
tetris[10 * piece + 4] waittill("movedone");
wait 0.5;
}
}
killline(piece1,piece2,piece3,piece4,piece5,piece6,piece7,piece8,piece9,origin,tetris)
{
piece1 movez(-256,0.1);
piece2 movez(-256,0.1);
piece3 movez(-256,0.1);
piece4 movez(-256,0.1);
piece5 movez(-256,0.1);
piece6 movez(-256,0.1);
piece7 movez(-256,0.1);
piece8 movez(-256,0.1);
piece9 movez(-256,0.1);
piece9 waittill("movedone");
wait 0.5;
piece1 moveto((origin),0.1);
piece2 moveto((origin),0.1);
piece3 moveto((origin),0.1);
piece4 moveto((origin),0.1);
piece5 moveto((origin),0.1);
piece6 moveto((origin),0.1);
piece7 moveto((origin),0.1);
piece8 moveto((origin),0.1);
piece9 moveto((origin),0.1);
piece9 waittill("movedone");
wait 0.5;
for (y=0; y<3; y++)
{
if (piece1.rotation >= 1)
{
piece1.rotation--;
piece1 rotateyaw(-90,0.01);
piece1 waittill("rotatedone");
}
if (piece2.rotation >= 1)
{
piece2.rotation--;
piece2 rotateyaw(-90,0.01);
piece2 waittill("rotatedone");
}
if (piece3.rotation >= 1)
{
piece3.rotation--;
piece3 rotateyaw(-90,0.01);
piece3 waittill("rotatedone");
}
if (piece4.rotation >= 1)
{
piece4.rotation--;
piece4 rotateyaw(-90,0.01);
piece4 waittill("rotatedone");
}
if (piece5.rotation >= 1)
{
piece5.rotation--;
piece5 rotateyaw(-90,0.01);
piece5 waittill("rotatedone");
}
if (piece6.rotation >= 1)
{
piece6.rotation--;
piece6 rotateyaw(-90,0.01);
piece6 waittill("rotatedone");
}
if (piece7.rotation >= 1)
{
piece7.rotation--;
piece7 rotateyaw(-90,0.01);
piece7 waittill("rotatedone");
}
if (piece8.rotation >= 1)
{
piece8.rotation--;
piece8 rotateyaw(-90,0.01);
piece8 waittill("rotatedone");
}
if (piece9.rotation >= 1)
{
piece9.rotation--;
piece9 rotateyaw(-90,0.01);
piece9 waittill("rotatedone");
}
}
piece1.inplay = 0;
piece2.inplay = 0;
piece3.inplay = 0;
piece4.inplay = 0;
piece5.inplay = 0;
piece6.inplay = 0;
piece7.inplay = 0;
piece8.inplay = 0;
piece9.inplay = 0;
for (p=0; p<12; p++)
{
for (s=0; s<4; s++)
{
if (tetris[(p+1) * 10 + s + 1].inplay == 1)
{
tetris[(p+1) * 10 + s + 1] movex(128,0.01);
tetris[(p+1) * 10 + s + 1] waittill("movedone");
}
}
}
}