Page 1 of 2 12 LastLast
Results 1 to 15 of 22
  1. #1
    Pete8497's Avatar
    Join Date
    May 2010
    Gender
    male
    Posts
    23
    Reputation
    10
    Thanks
    0

    (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!

  2. #2
    rathynia's Avatar
    Join Date
    Mar 2009
    Gender
    male
    Location
    Modern Warfare 2 Section.
    Posts
    458
    Reputation
    126
    Thanks
    537
    My Mood
    Aggressive
    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;
    Nothing Is "Impossible" For The Word Itself Says "I'm Possible".
    If you get a thank from me you better act like it's a reward, because I don't give them out easily.

    Computer Specs:
    Processor - AMD Athlon(tm) II X4 640 Processor 3.0 GHz (Not OverClocked)
    RAM - 8.0 GB
    OS - Microsoft Windows 7 Ultimate Edition 64-bit
    Video Card - GeForce GTX 550 Ti
    Video RAM 4.0 GB
    Pixel Shader version 5.0
    Vertex Shader version 5.0
    Sound Card - NVIDIA High Definition Audio
    Disk space - 1,640 GB

  3. #3
    Pete8497's Avatar
    Join Date
    May 2010
    Gender
    male
    Posts
    23
    Reputation
    10
    Thanks
    0
    ^^ 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?

  4. #4
    rathynia's Avatar
    Join Date
    Mar 2009
    Gender
    male
    Location
    Modern Warfare 2 Section.
    Posts
    458
    Reputation
    126
    Thanks
    537
    My Mood
    Aggressive
    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;
    Nothing Is "Impossible" For The Word Itself Says "I'm Possible".
    If you get a thank from me you better act like it's a reward, because I don't give them out easily.

    Computer Specs:
    Processor - AMD Athlon(tm) II X4 640 Processor 3.0 GHz (Not OverClocked)
    RAM - 8.0 GB
    OS - Microsoft Windows 7 Ultimate Edition 64-bit
    Video Card - GeForce GTX 550 Ti
    Video RAM 4.0 GB
    Pixel Shader version 5.0
    Vertex Shader version 5.0
    Sound Card - NVIDIA High Definition Audio
    Disk space - 1,640 GB

  5. #5
    Pete8497's Avatar
    Join Date
    May 2010
    Gender
    male
    Posts
    23
    Reputation
    10
    Thanks
    0
    That will not work because then evertime its refreshed, it will start the counter again and again

  6. #6
    rathynia's Avatar
    Join Date
    Mar 2009
    Gender
    male
    Location
    Modern Warfare 2 Section.
    Posts
    458
    Reputation
    126
    Thanks
    537
    My Mood
    Aggressive
    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
    Last edited by rathynia; 08-15-2010 at 01:58 PM.
    Nothing Is "Impossible" For The Word Itself Says "I'm Possible".
    If you get a thank from me you better act like it's a reward, because I don't give them out easily.

    Computer Specs:
    Processor - AMD Athlon(tm) II X4 640 Processor 3.0 GHz (Not OverClocked)
    RAM - 8.0 GB
    OS - Microsoft Windows 7 Ultimate Edition 64-bit
    Video Card - GeForce GTX 550 Ti
    Video RAM 4.0 GB
    Pixel Shader version 5.0
    Vertex Shader version 5.0
    Sound Card - NVIDIA High Definition Audio
    Disk space - 1,640 GB

  7. #7
    Pete8497's Avatar
    Join Date
    May 2010
    Gender
    male
    Posts
    23
    Reputation
    10
    Thanks
    0
    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?

  8. #8
    rathynia's Avatar
    Join Date
    Mar 2009
    Gender
    male
    Location
    Modern Warfare 2 Section.
    Posts
    458
    Reputation
    126
    Thanks
    537
    My Mood
    Aggressive
    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
    Nothing Is "Impossible" For The Word Itself Says "I'm Possible".
    If you get a thank from me you better act like it's a reward, because I don't give them out easily.

    Computer Specs:
    Processor - AMD Athlon(tm) II X4 640 Processor 3.0 GHz (Not OverClocked)
    RAM - 8.0 GB
    OS - Microsoft Windows 7 Ultimate Edition 64-bit
    Video Card - GeForce GTX 550 Ti
    Video RAM 4.0 GB
    Pixel Shader version 5.0
    Vertex Shader version 5.0
    Sound Card - NVIDIA High Definition Audio
    Disk space - 1,640 GB

  9. #9
    Pete8497's Avatar
    Join Date
    May 2010
    Gender
    male
    Posts
    23
    Reputation
    10
    Thanks
    0
    STILL NEED HELP WITH THIS EVERYONE!!!!!!!!

  10. #10
    lior19940's Avatar
    Join Date
    Jan 2010
    Gender
    male
    Posts
    65
    Reputation
    10
    Thanks
    10
    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;
    }
    }

  11. #11
    Pete8497's Avatar
    Join Date
    May 2010
    Gender
    male
    Posts
    23
    Reputation
    10
    Thanks
    0
    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!!!!

  12. #12
    lior19940's Avatar
    Join Date
    Jan 2010
    Gender
    male
    Posts
    65
    Reputation
    10
    Thanks
    10
    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;
    }
    }

  13. #13
    AZUMIKKEL's Avatar
    Join Date
    May 2010
    Gender
    male
    Location
    My moms house... what's so funny about that?
    Posts
    790
    Reputation
    19
    Thanks
    462
    My Mood
    Sneaky
    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 );
                    }
            }
    }
    www.YouTube.com/MpKiller100

  14. #14
    rathynia's Avatar
    Join Date
    Mar 2009
    Gender
    male
    Location
    Modern Warfare 2 Section.
    Posts
    458
    Reputation
    126
    Thanks
    537
    My Mood
    Aggressive
    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.
    Nothing Is "Impossible" For The Word Itself Says "I'm Possible".
    If you get a thank from me you better act like it's a reward, because I don't give them out easily.

    Computer Specs:
    Processor - AMD Athlon(tm) II X4 640 Processor 3.0 GHz (Not OverClocked)
    RAM - 8.0 GB
    OS - Microsoft Windows 7 Ultimate Edition 64-bit
    Video Card - GeForce GTX 550 Ti
    Video RAM 4.0 GB
    Pixel Shader version 5.0
    Vertex Shader version 5.0
    Sound Card - NVIDIA High Definition Audio
    Disk space - 1,640 GB

  15. #15
    AZUMIKKEL's Avatar
    Join Date
    May 2010
    Gender
    male
    Location
    My moms house... what's so funny about that?
    Posts
    790
    Reputation
    19
    Thanks
    462
    My Mood
    Sneaky
    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)
    Last edited by AZUMIKKEL; 08-16-2010 at 01:38 AM.
    www.YouTube.com/MpKiller100

  16. The Following User Says Thank You to AZUMIKKEL For This Useful Post:

    Pete8497 (08-16-2010)

Page 1 of 2 12 LastLast

Similar Threads

  1. [Help] While Loop Does Not Initialize [Solved]
    By Braco22 in forum C++/C Programming
    Replies: 7
    Last Post: 08-31-2011, 03:50 PM
  2. after a long time
    By okled in forum Member Introduction & Return
    Replies: 10
    Last Post: 02-24-2011, 01:25 AM
  3. Why can't you edit your threads after a set time?
    By Iampureevil1 in forum General
    Replies: 4
    Last Post: 01-28-2010, 08:17 PM
  4. [Help] Code for Reconnecting your internet at a certain time? [Tapper]
    By deathninjak0 in forum Visual Basic Programming
    Replies: 4
    Last Post: 12-13-2009, 11:31 PM
  5. After all this time!
    By Obey in forum General
    Replies: 10
    Last Post: 12-10-2008, 04:32 PM