Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help Make this code shorter!
#1
heyho, can you help me to make this code shorter? Same function but shorter!

PHP Code:
customrecoil()
{    
    while( 
true )
    {    
        
self waittill "begin_firing" );
        
        
curWeapon self GetCurrentWeapon();
        
        {
        
self setClientDvar("perk_weapSpreadMultiplier"0.20);
        
self endon "end_firing" );
        
self thread    customrecoil();
        
wait 0.5;
        
self setClientDvar("perk_weapSpreadMultiplier"0.21);
        
self endon "end_firing" );
        
self thread    customrecoil();
        
wait 0.01;
        
self setClientDvar("perk_weapSpreadMultiplier"0.22);
        
self endon "end_firing" );
        
self thread    customrecoil();
        
wait 0.01;
        
self setClientDvar("perk_weapSpreadMultiplier"0.23);
        
self endon "end_firing" );
        
self thread    customrecoil();
        
wait 0.01;
        
self setClientDvar("perk_weapSpreadMultiplier"0.24);
        
self endon "end_firing" );
        
self thread    customrecoil();
        
wait 0.01;
        
self setClientDvar("perk_weapSpreadMultiplier"0.25);
        
self endon "end_firing" );
        
self thread    customrecoil();
        
wait 0.01;
        
self setClientDvar("perk_weapSpreadMultiplier"0.26);
        
self endon "end_firing" );
        
self thread    customrecoil();
        
wait 0.01;
        
self setClientDvar("perk_weapSpreadMultiplier"0.27);
        
self endon "end_firing" );
        
self thread    customrecoil();
        
wait 0.01;
        
self setClientDvar("perk_weapSpreadMultiplier"0.28);
        
self endon "end_firing" );
        
self thread    customrecoil();
        
wait 0.01;
        
self setClientDvar("perk_weapSpreadMultiplier"0.29);
        
self endon "end_firing" );
        
self thread    customrecoil();
        
wait 0.01;
        
self setClientDvar("perk_weapSpreadMultiplier"0.30);
        
self endon "end_firing" );
        
self thread    customrecoil();
        
wait 0.01;
        
self setClientDvar("perk_weapSpreadMultiplier"0.31);
        
self endon "end_firing" );
        
self thread    customrecoil();
        
wait 0.01;
        
self setClientDvar("perk_weapSpreadMultiplier"0.32);
        
self endon "end_firing" );
        
self thread    customrecoil();
        
wait 0.01;
        
self setClientDvar("perk_weapSpreadMultiplier"0.33);
        
self endon "end_firing" );
        
self thread    customrecoil();
        
wait 0.01;
        
self setClientDvar("perk_weapSpreadMultiplier"0.34);
        
self endon "end_firing" );
        
self thread    customrecoil();
        
wait 0.01;
        
self setClientDvar("perk_weapSpreadMultiplier"0.35);
        
self endon "end_firing" );
        
self thread    customrecoil();
        
wait 0.01;
        
self setClientDvar("perk_weapSpreadMultiplier"0.36);
        
self endon "end_firing" );
        
self thread    customrecoil();
        
wait 0.01;
        
self setClientDvar("perk_weapSpreadMultiplier"0.37);
        
self endon "end_firing" );
        
self thread    customrecoil();
        
wait 0.01;
        
self setClientDvar("perk_weapSpreadMultiplier"0.38);
        
self endon "end_firing" );
        
self thread    customrecoil();
        
wait 0.01;
        
self setClientDvar("perk_weapSpreadMultiplier"0.40);
        
self endon "end_firing" );
        
self thread    customrecoil();
        
wait 0.01;
        
self setClientDvar("perk_weapSpreadMultiplier"0.41);
        
self endon "end_firing" );
        
self thread    customrecoil();
        
wait 0.01;
        
self setClientDvar("perk_weapSpreadMultiplier"0.42);
        
self endon "end_firing" );
        
self thread    customrecoil();
        
wait 0.01;
        
self endon "end_firing" );
        
self thread    customrecoil();
        }
    }

Reply

#2
i've shorted it by myself Smile
ok maybe not shorted but fixed the script overload error
PHP Code:
customrecoil()
{    
        
self endon "end_firing" );


    while( 
true )
    {    
        
self waittill "begin_firing" );
        
self endon "end_firing" );

        
        
curWeapon self GetCurrentWeapon();
        
        {
        
self setClientDvar("perk_weapSpreadMultiplier"0.20);
        
wait 0.5;
        
self setClientDvar("perk_weapSpreadMultiplier"0.21);
        
wait 0.1;
        
self setClientDvar("perk_weapSpreadMultiplier"0.22);
        
wait 0.1;
        
self setClientDvar("perk_weapSpreadMultiplier"0.23);
        
wait 0.1;
        
self setClientDvar("perk_weapSpreadMultiplier"0.24);
        
wait 0.1;
        
self setClientDvar("perk_weapSpreadMultiplier"0.25);
        
wait 0.1;
        
self setClientDvar("perk_weapSpreadMultiplier"0.26);
        
wait 0.1;
        
self setClientDvar("perk_weapSpreadMultiplier"0.27);
        
wait 0.1;
        
self setClientDvar("perk_weapSpreadMultiplier"0.28);
        
wait 0.1;
        
self setClientDvar("perk_weapSpreadMultiplier"0.29);
        
wait 0.1;
        
self setClientDvar("perk_weapSpreadMultiplier"0.30);
        
wait 0.1;
        
self setClientDvar("perk_weapSpreadMultiplier"0.31);
        
wait 0.1;
        
self setClientDvar("perk_weapSpreadMultiplier"0.32);
        
wait 0.1;
        
self setClientDvar("perk_weapSpreadMultiplier"0.33);
        
wait 0.1;
        
self setClientDvar("perk_weapSpreadMultiplier"0.34);
        
wait 0.1;
        
self setClientDvar("perk_weapSpreadMultiplier"0.35);
        
wait 0.1;
        
self setClientDvar("perk_weapSpreadMultiplier"0.36);
        
wait 0.1;
        
self setClientDvar("perk_weapSpreadMultiplier"0.37);
        
wait 0.1;
        
self setClientDvar("perk_weapSpreadMultiplier"0.38);
        
wait 0.1;
        
self setClientDvar("perk_weapSpreadMultiplier"0.40);
        
wait 0.1;
        
self setClientDvar("perk_weapSpreadMultiplier"0.41);
        
wait 0.1;
        
self setClientDvar("perk_weapSpreadMultiplier"0.43);
        
wait 0.1;
        
self setClientDvar("perk_weapSpreadMultiplier"0.44);
        
wait 0.1;
        
self setClientDvar("perk_weapSpreadMultiplier"0.45);
        
wait 0.1;    
        
self thread    customrecoil();
        
wait 0.1;
        }
    }
}

recoilfix()
{
    while(
1)
    {
        
self waittill "end_firing" );
        {
                
self thread    customrecoil();
                
wait 0.5;
        }
    }

Reply

#3
I never made GSC's myself but maybe this works:

C++ Code
  1. customrecoil()
  2. {
  3. self endon ( "end_firing" );
  4.  
  5.  
  6. while( true )
  7. {
  8. self waittill ( "begin_firing" );
  9. self endon ( "end_firing" );
  10.  
  11.  
  12. curWeapon = self GetCurrentWeapon();
  13.  
  14. self setClientDvar("perk_weapSpreadMultiplier", 0.20);
  15. wait 0.5;
  16. self.recoil = 0.21;
  17. while (recoil <= 0.45) {
  18. self setClientDvar("perk_weapSpreadMultiplier", self.recoil);
  19. self.recoil += 0.01;
  20. wait 0.1;
  21. }
  22. }
  23. }
  24.  
  25. recoilfix()
  26. {
  27. while(1)
  28. {
  29. self waittill ( "end_firing" );
  30. {
  31. self thread customrecoil();
  32. wait 0.5;
  33. }
  34. }
  35. }
Reply

#4
looks ok xD
Reply

#5
(06-02-2011, 02:04)SuperNovaAO Wrote: I never made GSC's myself but maybe this works:

C++ Code
  1. customrecoil()
  2. {
  3. self endon ( "end_firing" );
  4.  
  5.  
  6. while( true )
  7. {
  8. self waittill ( "begin_firing" );
  9. self endon ( "end_firing" );
  10.  
  11.  
  12. curWeapon = self GetCurrentWeapon();
  13.  
  14. self setClientDvar("perk_weapSpreadMultiplier", 0.20);
  15. wait 0.5;
  16. self.recoil = 0.21;
  17. while (recoil <= 0.45) {
  18. self setClientDvar("perk_weapSpreadMultiplier", self.recoil);
  19. self.recoil += 0.01;
  20. wait 0.1;
  21. }
  22. }
  23. }
  24.  
  25. recoilfix()
  26. {
  27. while(1)
  28. {
  29. self waittill ( "end_firing" );
  30. {
  31. self thread customrecoil();
  32. wait 0.5;
  33. }
  34. }
  35. }
yeah it works pretty well, but i want that it stay at 0.55 till end_firing
btw you forgot the self.@ while (recoil <= 0.45) { Smile
mehh with this script i get a script runtime error again and the game is crashing :S
Reply



Possibly Related Threads…
Thread Author Replies Views Last Post
  Make area detect. flag Teleport lewisbibo 4 4,994 10-12-2013, 18:10
Last Post: EnVi Sweden Rocks
Wink Make Platforme lewisbibo 5 4,992 10-08-2013, 14:35
Last Post: 8q4s8
  Make obj MW3.by lewisbibo lewisbibo 3 3,702 10-05-2013, 20:16
Last Post: Nekochan
  Make obj MW3.by lewisbibo lewisbibo 0 2,333 10-03-2013, 20:19
Last Post: lewisbibo
  Help Code color crosshairs koren30 3 4,017 10-02-2013, 19:26
Last Post: koren30
  Help need help?how to make plugins code hXnarutoXone 12 8,552 09-01-2013, 18:30
Last Post: Bandarigoda123
  Help Need Help with C# code tubwux 2 3,315 08-27-2013, 18:18
Last Post: tubwux
  [Request] Compile this code please dozsa0 4 4,135 08-10-2013, 21:02
Last Post: Nukem
  Compile this code please First_Semyon 12 9,687 08-08-2013, 14:53
Last Post: Bandarigoda123
  Compile please this code First_Semyon 8 5,640 07-28-2013, 01:52
Last Post: First_Semyon

Forum Jump:


Users browsing this thread:
1 Guest(s)

Forum Powered By MyBB, Theme by © 2002-2024 Melroy van den Berg.