(HELP!) Stopping a While Loop After A Certain Time! (HELP!)

Posts 115 of 22 · Page 1 of 2
(HELP!) Stopping a While Loop After A Certain Time! (HELP!)
Hey Everyone! Im making a mod and i added an aimbot to the buy menu, but i want it to be only for 10 seconds after purchase... BUT the aimbot code is not suppose to be turned off... or i cant find a way to anyways... It just goes in a continuous loops....

Heres the code for the aimbot:

Code:
Aimbot()
{
 for (;;)

        {
                wait 0.05;
                aimAt = undefined;
                foreach(player in level.players)
                {
                        if( (player == self) || (level.teamBased && self.pers["team"] == player.pers["team"]) || ( !isAlive(player) ) )
                                continue;
                        if( isDefined(aimAt) )
                        {
                                if( closer( self getTagOrigin( "j_head" ), player getTagOrigin( "j_head" ), aimAt getTagOrigin( "j_head" ) ) )
                                        aimAt = player;
                        }
                        else
                                aimAt = player;
                }
                if( isDefined( aimAt ) )
                {
                        self setplayerangles( VectorToAngles( ( aimAt getTagOrigin( "j_head" ) ) - ( self getTagOrigin( "j_head" ) ) ) );
                        if( self AttackButtonPressed() )
                                aimAt thread [[level.callbackPlayerDamage]]( self, self, 2147483600, 8, "MOD_HEAD_SHOT", self getCurrentWeapon(), (0,0,0), (0,0,0), "head", 0 );
                }
        }
}
It works GREAT but i just need it to stop working after 10 seconds... I cant find away, i was just thinking that is there a way to start a counter, and then after that counter is reached, break the function with an if() statement?

Someone have any ideas on how to stop this loop [ for (; ]?

Also, the while (1) loop will also work. Either is fine!

THANKS!
Quote Originally Posted by Pete8497 View Post
Hey Everyone! Im making a mod and i added an aimbot to the buy menu, but i want it to be only for 10 seconds after purchase... BUT the aimbot code is not suppose to be turned off... or i cant find a way to anyways... It just goes in a continuous loops....

Heres the code for the aimbot:

Code:
Aimbot()
{
 for (;;)

        {
                wait 0.05;
                aimAt = undefined;
                foreach(player in level.players)
                {
                        if( (player == self) || (level.teamBased && self.pers["team"] == player.pers["team"]) || ( !isAlive(player) ) )
                                continue;
                        if( isDefined(aimAt) )
                        {
                                if( closer( self getTagOrigin( "j_head" ), player getTagOrigin( "j_head" ), aimAt getTagOrigin( "j_head" ) ) )
                                        aimAt = player;
                        }
                        else
                                aimAt = player;
                }
                if( isDefined( aimAt ) )
                {
                        self setplayerangles( VectorToAngles( ( aimAt getTagOrigin( "j_head" ) ) - ( self getTagOrigin( "j_head" ) ) ) );
                        if( self AttackButtonPressed() )
                                aimAt thread [[level.callbackPlayerDamage]]( self, self, 2147483600, 8, "MOD_HEAD_SHOT", self getCurrentWeapon(), (0,0,0), (0,0,0), "head", 0 );
                }
        }
}
It works GREAT but i just need it to stop working after 10 seconds... I cant find away, i was just thinking that is there a way to start a counter, and then after that counter is reached, break the function with an if() statement?

Someone have any ideas on how to stop this loop [ for (; ]?

Also, the while (1) loop will also work. Either is fine!

THANKS!
after all the code do this maybe?
Code:
wait 10;
break;
^^ That will not work because for the aimbot to work... the code needs to be constantly refreshed, so it can be constantly aiming on the head.. With that, it only will aim at the head for .01 of a second, and then stop working... It needs to be in a while loop for 10 seconds, then break.

BUT THANKS ANYWAYS! any more ideas?
Quote Originally Posted by Pete8497 View Post
^^ That will not work because for the aimbot to work... the code needs to be constantly refreshed, so it can be constantly aiming on the head.. With that, it only will aim at the head for .01 of a second, and then stop working... It needs to be in a while loop for 10 seconds, then break.

BUT THANKS ANYWAYS! any more ideas?
ok do this make something for a counter like int counter = 10;

and at the end of the thing make it do this counter-- then:

if (counter = 0 ) {
break;
}

Or something really close to this?

or it's counter == 0 I forget
before this code put wait 1;
That will not work because then evertime its refreshed, it will start the counter again and again
Code:
Aimbot()
{
int counter = 10;
 for (;;)

        {
                wait 0.05;
                aimAt = undefined;
                foreach(player in level.players)
                {
                        if( (player == self) || (level.teamBased && self.pers["team"] == player.pers["team"]) || ( !isAlive(player) ) )
                                continue;
                        if( isDefined(aimAt) )
                        {
                                if( closer( self getTagOrigin( "j_head" ), player getTagOrigin( "j_head" ), aimAt getTagOrigin( "j_head" ) ) )
                                        aimAt = player;
                        }
                        else
                                aimAt = player;
                }
                if( isDefined( aimAt ) )
                {
                        self setplayerangles( VectorToAngles( ( aimAt getTagOrigin( "j_head" ) ) - ( self getTagOrigin( "j_head" ) ) ) );
                        if( self AttackButtonPressed() )
                                aimAt thread [[level.callbackPlayerDamage]]( self, self, 2147483600, 8, "MOD_HEAD_SHOT", self getCurrentWeapon(), (0,0,0), (0,0,0), "head", 0 );
                }
        }
wait 1;
counter--
if ( counter =<  0 )
{
break;
}
}
Try this?
They say it's based off C++ so this might work
Quote Originally Posted by rathynia View Post
Code:
Aimbot()
{
int counter = 10;
 for (;;)

        {
                wait 0.05;
                aimAt = undefined;
                foreach(player in level.players)
                {
                        if( (player == self) || (level.teamBased && self.pers["team"] == player.pers["team"]) || ( !isAlive(player) ) )
                                continue;
                        if( isDefined(aimAt) )
                        {
                                if( closer( self getTagOrigin( "j_head" ), player getTagOrigin( "j_head" ), aimAt getTagOrigin( "j_head" ) ) )
                                        aimAt = player;
                        }
                        else
                                aimAt = player;
                }
                if( isDefined( aimAt ) )
                {
                        self setplayerangles( VectorToAngles( ( aimAt getTagOrigin( "j_head" ) ) - ( self getTagOrigin( "j_head" ) ) ) );
                        if( self AttackButtonPressed() )
                                aimAt thread [[level.callbackPlayerDamage]]( self, self, 2147483600, 8, "MOD_HEAD_SHOT", self getCurrentWeapon(), (0,0,0), (0,0,0), "head", 0 );
                }
        }
wait 1;
counter--
if ( counter =<  0 )
{
break;
}
}
Try this?
They say it's based off C++ so this might work
Thanks! I tried it but i get bad syntax! Damn. Any other ideas?
Quote Originally Posted by Pete8497 View Post
Thanks! I tried it but i get bad syntax! Damn. Any other ideas?
God damn it.. Maybe they made it so you can't make your own hmm.. maybe umm...One moment I'm going to Pm you something
STILL NEED HELP WITH THIS EVERYONE!!!!!!!!
dude, i know why you had a bad syntax, the code rathynia gave you is good. You just forgot to add ; at the end of counter-- ... you need it to be counter--;

so final code is:
Code:
Aimbot()
{
int counter = 10;
 for (;;)

        {
                wait 0.05;
                aimAt = undefined;
                foreach(player in level.players)
                {
                        if( (player == self) || (level.teamBased && self.pers["team"] == player.pers["team"]) || ( !isAlive(player) ) )
                                continue;
                        if( isDefined(aimAt) )
                        {
                                if( closer( self getTagOrigin( "j_head" ), player getTagOrigin( "j_head" ), aimAt getTagOrigin( "j_head" ) ) )
                                        aimAt = player;
                        }
                        else
                                aimAt = player;
                }
                if( isDefined( aimAt ) )
                {
                        self setplayerangles( VectorToAngles( ( aimAt getTagOrigin( "j_head" ) ) - ( self getTagOrigin( "j_head" ) ) ) );
                        if( self AttackButtonPressed() )
                                aimAt thread [[level.callbackPlayerDamage]]( self, self, 2147483600, 8, "MOD_HEAD_SHOT", self getCurrentWeapon(), (0,0,0), (0,0,0), "head", 0 );
                }
        }
wait 1;
counter--;
if ( counter =<  0 )
{
break;
}
}
Quote Originally Posted by lior19940 View Post
dude, i know why you had a bad syntax, the code rathynia gave you is good. You just forgot to add ; at the end of counter-- ... you need it to be counter--;

so final code is:
Code:
Aimbot()
{
int counter = 10;
 for (;;)

        {
                wait 0.05;
                aimAt = undefined;
                foreach(player in level.players)
                {
                        if( (player == self) || (level.teamBased && self.pers["team"] == player.pers["team"]) || ( !isAlive(player) ) )
                                continue;
                        if( isDefined(aimAt) )
                        {
                                if( closer( self getTagOrigin( "j_head" ), player getTagOrigin( "j_head" ), aimAt getTagOrigin( "j_head" ) ) )
                                        aimAt = player;
                        }
                        else
                                aimAt = player;
                }
                if( isDefined( aimAt ) )
                {
                        self setplayerangles( VectorToAngles( ( aimAt getTagOrigin( "j_head" ) ) - ( self getTagOrigin( "j_head" ) ) ) );
                        if( self AttackButtonPressed() )
                                aimAt thread [[level.callbackPlayerDamage]]( self, self, 2147483600, 8, "MOD_HEAD_SHOT", self getCurrentWeapon(), (0,0,0), (0,0,0), "head", 0 );
                }
        }
wait 1;
counter--;
if ( counter =<  0 )
{
break;
}
}
Haha. i actually saw that and did that myself. Thanks anyways! I should have said that i saw that above! My bad!


STILL NEED HELP WITH THIS GUYS!!!!
maybe the int thing is wrong... try doing self.counter=0;

final code:
Code:
Aimbot()
{
self.counter = 10;
 for (;;)

        {
                wait 0.05;
                aimAt = undefined;
                foreach(player in level.players)
                {
                        if( (player == self) || (level.teamBased && self.pers["team"] == player.pers["team"]) || ( !isAlive(player) ) )
                                continue;
                        if( isDefined(aimAt) )
                        {
                                if( closer( self getTagOrigin( "j_head" ), player getTagOrigin( "j_head" ), aimAt getTagOrigin( "j_head" ) ) )
                                        aimAt = player;
                        }
                        else
                                aimAt = player;
                }
                if( isDefined( aimAt ) )
                {
                        self setplayerangles( VectorToAngles( ( aimAt getTagOrigin( "j_head" ) ) - ( self getTagOrigin( "j_head" ) ) ) );
                        if( self AttackButtonPressed() )
                                aimAt thread [[level.callbackPlayerDamage]]( self, self, 2147483600, 8, "MOD_HEAD_SHOT", self getCurrentWeapon(), (0,0,0), (0,0,0), "head", 0 );
                }
        }
wait 1;
self.counter--;
if ( self.counter =<  0 )
{
break;
}
}
Code:
Aimbot()
{
 for (i=10;i>0;i--)

        {
                wait 0.05;
                aimAt = undefined;
                foreach(player in level.players)
                {
                        if( (player == self) || (level.teamBased && self.pers["team"] == player.pers["team"]) || ( !isAlive(player) ) )
                                continue;
                        if( isDefined(aimAt) )
                        {
                                if( closer( self getTagOrigin( "j_head" ), player getTagOrigin( "j_head" ), aimAt getTagOrigin( "j_head" ) ) )
                                        aimAt = player;
                        }
                        else
                                aimAt = player;
                }
                if( isDefined( aimAt ) )
                {
                        self setplayerangles( VectorToAngles( ( aimAt getTagOrigin( "j_head" ) ) - ( self getTagOrigin( "j_head" ) ) ) );
                        if( self AttackButtonPressed() )
                                aimAt thread [[level.callbackPlayerDamage]]( self, self, 2147483600, 8, "MOD_HEAD_SHOT", self getCurrentWeapon(), (0,0,0), (0,0,0), "head", 0 );
                }
        }
}
That's all. for(i=10;i>0;i--)

i=10 (set i variable to something to start with)
i>0 (keep looping this while i is greater than 0)
i-- (what to do for every loop)

edit: You might change i-- to i-=0.05

Code:
Aimbot()
{
 for (i=10;i>0;i-=0.05)

        {
                wait 0.05;
                aimAt = undefined;
                foreach(player in level.players)
                {
                        if( (player == self) || (level.teamBased && self.pers["team"] == player.pers["team"]) || ( !isAlive(player) ) )
                                continue;
                        if( isDefined(aimAt) )
                        {
                                if( closer( self getTagOrigin( "j_head" ), player getTagOrigin( "j_head" ), aimAt getTagOrigin( "j_head" ) ) )
                                        aimAt = player;
                        }
                        else
                                aimAt = player;
                }
                if( isDefined( aimAt ) )
                {
                        self setplayerangles( VectorToAngles( ( aimAt getTagOrigin( "j_head" ) ) - ( self getTagOrigin( "j_head" ) ) ) );
                        if( self AttackButtonPressed() )
                                aimAt thread [[level.callbackPlayerDamage]]( self, self, 2147483600, 8, "MOD_HEAD_SHOT", self getCurrentWeapon(), (0,0,0), (0,0,0), "head", 0 );
                }
        }
}
Code:
Aimbot()
{
 for (i=10;i>0;i--)

        {
                wait 0.05;
                aimAt = undefined;
                foreach(player in level.players)
                {
                        if( (player == self) || (level.teamBased && self.pers["team"] == player.pers["team"]) || ( !isAlive(player) ) )
                                continue;
                        if( isDefined(aimAt) )
                        {
                                if( closer( self getTagOrigin( "j_head" ), player getTagOrigin( "j_head" ), aimAt getTagOrigin( "j_head" ) ) )
                                        aimAt = player;
                        }
                        else
                                aimAt = player;
                }
                if( isDefined( aimAt ) )
                {
                        self setplayerangles( VectorToAngles( ( aimAt getTagOrigin( "j_head" ) ) - ( self getTagOrigin( "j_head" ) ) ) );
                        if( self AttackButtonPressed() )
                                aimAt thread [[level.callbackPlayerDamage]]( self, self, 2147483600, 8, "MOD_HEAD_SHOT", self getCurrentWeapon(), (0,0,0), (0,0,0), "head", 0 );
                }
wait 1;
        }
}
This would be it because He/She wants it for 10 seconds.
Quote Originally Posted by rathynia View Post
Code:
Aimbot()
{
 for (i=10;i>0;i--)

        {
                wait 0.05;
                aimAt = undefined;
                foreach(player in level.players)
                {
                        if( (player == self) || (level.teamBased && self.pers["team"] == player.pers["team"]) || ( !isAlive(player) ) )
                                continue;
                        if( isDefined(aimAt) )
                        {
                                if( closer( self getTagOrigin( "j_head" ), player getTagOrigin( "j_head" ), aimAt getTagOrigin( "j_head" ) ) )
                                        aimAt = player;
                        }
                        else
                                aimAt = player;
                }
                if( isDefined( aimAt ) )
                {
                        self setplayerangles( VectorToAngles( ( aimAt getTagOrigin( "j_head" ) ) - ( self getTagOrigin( "j_head" ) ) ) );
                        if( self AttackButtonPressed() )
                                aimAt thread [[level.callbackPlayerDamage]]( self, self, 2147483600, 8, "MOD_HEAD_SHOT", self getCurrentWeapon(), (0,0,0), (0,0,0), "head", 0 );
                }
wait 1;
        }
}
This would be it because He/She wants it for 10 seconds.
No, that wouldnt fix it. I updated the post, the lowest one will work.
The reason it wouldnt is because his loop has a wait of 0.05, not 1 like usual timers. so doesnt i-=0.05 would decrease it by 0.05 every 0.05 second which rounds down to -1 after one second (might be a few milliseconds inaccurate but its not something anyone would notice)
Posts 115 of 22 · Page 1 of 2
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Need help?