Advertisement
LostProphet

NanoSuit

Aug 6th, 2011
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 15.25 KB | None | 0 0
  1. using System;
  2. using GTA;
  3.  
  4. bool Armor, Stealth, Power, Speed, lEnergy, NightVision, know, kold;;
  5. int aArmor;
  6. double aEnergy;
  7. double a, b;
  8. int armorkey, stealthkey, speedkey, strengthkey;
  9. float x, y, z;
  10. float sx, sy, sz;
  11. float ovx, ovy, ovz;
  12. float cx, cy, cz;
  13. //f32 camx, camy, camz;
  14. float vehx, vehy, vehz;
  15. float powx, powy, powz;
  16. float dpowx, dpowy, dpowz;
  17. float chead, vhead;
  18. int at, qTimer, ktimer, doubletap;
  19. int health, pArmor;
  20. int armor1, armor2, armor;
  21. int ahealth1, ahealth2, newhealth;
  22.  
  23. namespace MOD
  24. {
  25.     public class NanoSuit
  26.     {
  27.         public NanoSuit()
  28.         {
  29.             // Give your own name here!
  30.             //SetName("Nanosuit");
  31.             this.Tick += new EventHandler(this.NanoSuit_Tick);
  32.         }
  33.  
  34.         private void NanoSuit_Tick(object sender, EventArgs e)
  35.         {
  36.             int doubletap = GetPrivateProfileInt("Options", "DoubletapSpeed", 112, "./Nanosuit.ini");
  37.             bool SoundEffect = GetPrivateProfileInt("Options", "EnableVoice", 112, "./Nanosuit.ini");
  38.  
  39.             Player PlayerIndex = ConvertIntToPlayerIndex(GetPlayerId()); //getting PlayerIndex and PlayerChar for usage in script
  40.             Ped PlayerChar;
  41.             GetPlayerChar(PlayerIndex, &PlayerChar);
  42.             GetCharCoordinates(PlayerChar, &x, &y, &z); //coordinates for easy access
  43.    
  44.             if (IsHUDPreferenceSwitchedOn() == true)
  45.             {
  46.                 SetTextDropshadow(false, 0, 0, 0, 0);
  47.                 SetTextFont(5);
  48.                 SetTextColour(0, 180, 240, 200); //RGBA
  49.                 DisplayTextWithNumber(0.95f, 0.89f, "NUMBER", aEnergy);
  50.                 f32 tempn1 = 0.05f + (0.000625 * aEnergy);
  51.                 f32 tempn2 = (0.00125 * aEnergy);
  52.                 DrawRect(tempn1, 0.96f, tempn2, 0.015f, 0, 180, 240, 200);
  53.             }
  54.            
  55.             if (aEnergy < 100)
  56.             {
  57.                 a = 0.25;
  58.                 aEnergy = aEnergy + b;
  59.             }
  60.  
  61.             if (aEnergy > 100)
  62.             {
  63.                 a = 0;
  64.                 b = 0;
  65.             }
  66.  
  67.             if (aEnergy > 10)
  68.             {
  69.                 lEnergy = false;
  70.             }
  71.             else
  72.             {
  73.                 lEnergy = true;
  74.                 Stealth = false;
  75.                 Speed = false;
  76.                 Power = false;
  77.             }
  78.  
  79.             /*if ((GetKeyState(VK_MBUTTON)& 1) != 0) //Suit menu
  80.             {
  81.                 PrintStringWithLiteralStringNow("STRING", "ACCESSING SUIT MENU", 1000, true);
  82.                 SetTextFont(1);
  83.                 SetTextColour(90, 250, 90, 100);
  84.                 DisplayTextWithLiteralString(0.5f, 0.5f, "STRING", "MENU");
  85.                 SetTextFont(1);
  86.                 SetTextColour(90, 250, 90, 100);
  87.                 DisplayTextWithLiteralString(0.5f, 0.7f, "STRING", "Armor");
  88.                 SetTextFont(1);
  89.                 SetTextColour(90, 250, 90, 100);
  90.                 DisplayTextWithLiteralString(0.5f, 0.3f, "STRING", "Strength");
  91.                 SetTextFont(1);
  92.                 SetTextColour(90, 250, 90, 100);
  93.                 DisplayTextWithLiteralString(0.3f, 0.5f, "STRING", "Cloak");
  94.                 SetTextFont(1);
  95.                 SetTextColour(90, 250, 90, 100);
  96.                 DisplayTextWithLiteralString(0.7f, 0.5f, "STRING", "Speed");
  97.                 SetCameraControlsDisabledWithPlayerControls(true);
  98.                 SetPlayerControl(PlayerIndex, false);
  99.                 //xPos = GET_X_LPARAM(lParam);
  100.                 //yPos = GET_Y_LPARAM(lParam);
  101.             }
  102.             else
  103.             {
  104.                 SetCameraControlsDisabledWithPlayerControls(false);
  105.                 SetPlayerControl(PlayerIndex, true);
  106.             }*/
  107.  
  108.             int kNv = GetPrivateProfileInt("Keys", "NightVision", 112, "./Nanosuit.ini");
  109.            
  110.             if (IsGameKeyboardKeyJustPressed(kNv))
  111.             {
  112.                 this.NightVision = !this.NightVision;
  113.             }
  114.  
  115.             //cube = MODEL_CJ_GAME_CUBE_4;
  116.             //Object box;
  117.             if (NightVision)// && ((DoesObjectExist(box)&1) == false))
  118.             {
  119.                 DrawRect(0.5f, 0.5f, 1.0f, 1.0f, 128, 255, 128, 60);
  120.                 /*Camera cam;
  121.                 GetGameCam(&cam);
  122.                 GetCamPos(cam, &camx, &camy, &camz);
  123.                 RequestModel(cube);
  124.                 CreateObject(cube, camx, camy, camz, &box, true);*/
  125.             }
  126.            
  127.             /*if (NightVision != true)
  128.             {
  129.                 if (DoesObjectExist(box))
  130.                 {
  131.                     DeleteObject(&box);
  132.                 }
  133.             }*/
  134.  
  135.             int kArmor = GetPrivateProfileInt("Keys", "ArmorKey", 112, "./Nanosuit.ini");
  136.            
  137.             if (IsGameKeyboardKeyJustPressed(kArmor))
  138.             {
  139.                 armorkey++;
  140.             }
  141.            
  142.             if (armorkey == 1)
  143.             {
  144.                 ktimer++;
  145.                 //DisplayTextWithNumber(0.8f, 0.2f, "NUMBER", ktimer);
  146.                
  147.                 if (ktimer >= doubletap)
  148.                 {
  149.                     armorkey = 0;
  150.                     ktimer = 0;
  151.                 }
  152.             }
  153.            
  154.             if (armorkey == 2)
  155.             {
  156.                 Armor = !Armor;
  157.                
  158.                 if (Armor)
  159.                 {
  160.                     if (SoundEffect)
  161.                     {
  162.                         PlaySound("armor.wav", NULL, SND_FILENAME | SND_ASYNC);
  163.                     }
  164.                    
  165.                     PrintStringWithLiteralStringNow("STRING", "MAXIMUM ARMOR", 1500, true);
  166.                     Stealth = false;
  167.                     Power = false;
  168.                     Speed = false;
  169.                     at = 0;
  170.                     qTimer = 0;
  171.                 }
  172.                
  173.                 armorkey = 0;
  174.             }
  175.  
  176.             if (!Stealth && !Power && !Speed && !Armor)
  177.             {
  178.                 Armor = true;
  179.                 PrintStringWithLiteralStringNow("STRING", "MAXIMUM ARMOR", 1500, true);
  180.                
  181.                 if(SoundEffect == true)
  182.                 {
  183.                     PlaySound(TEXT("armor.wav"), NULL, SND_FILENAME | SND_ASYNC);
  184.                 }
  185.             }
  186.            
  187.             if (Armor == true)
  188.             {
  189.                 SetCharProofs(PlayerChar, false, true, false, true, true);
  190.                 qTimer = qTimer + 1;
  191.                
  192.                 if (qTimer >= 100) //timert
  193.                 {
  194.                     AddArmourToChar(PlayerChar,15); //add armour to char
  195.                     GetCharHealth(PlayerChar, &health);
  196.                     health = health + 10; //add health
  197.                     SetCharHealth(PlayerChar, health);
  198.                     qTimer = 0;
  199.                 }
  200.                
  201.                 if (aEnergy > 10)
  202.                 {
  203.                     at = at + 1;
  204.                    
  205.                     if (at > 3)
  206.                     {
  207.                         GetCharArmour(PlayerChar, &armor1);
  208.                         GetCharHealth(PlayerChar, &ahealth1);
  209.                         at = 1;
  210.                     }
  211.                    
  212.                     GetCharHealth(PlayerChar, &ahealth2);
  213.                     GetCharArmour(PlayerChar, &armor2);
  214.                    
  215.                     if (armor1 > armor2)
  216.                     {
  217.                         armor = armor1-armor2;
  218.                         AddArmourToChar(PlayerChar, int(0.6*armor));
  219.                         aEnergy = aEnergy - 10;
  220.                         DrawLightWithRange(x, y, z, 255, 255, 255, 6, 2.5f);
  221.                     }
  222.                    
  223.                     if (ahealth1 > ahealth2)
  224.                     {
  225.                         newhealth = int(ahealth2 + 0.6 * (ahealth1 - ahealth2));
  226.                        
  227.                         if (IsPlayerDead(PlayerIndex) == true)
  228.                         {
  229.                             newhealth = 0;
  230.                         }
  231.                        
  232.                         SetCharHealth(PlayerChar, newhealth);
  233.                         aEnergy = aEnergy - 10;
  234.                         DrawLightWithRange(x, y, z, 255, 255, 255, 6, 2.5f);
  235.                     }
  236.                 }
  237.                
  238.                 if (aEnergy < 0)
  239.                 {
  240.                     aEnergy = -aEnergy + 1;
  241.                 }
  242.                 aEnergy = aEnergy + a;
  243.             }
  244.             else
  245.             {
  246.                 SetCharProofs(PlayerChar, false, false, false, false, false);
  247.             }
  248.  
  249.             int kStealth = GetPrivateProfileInt(TEXT("Keys"),TEXT("StealthKey"),112,TEXT("./Nanosuit.ini"));
  250.            
  251.             if (IsGameKeyboardKeyJustPressed(kStealth))
  252.             {
  253.                 stealthkey++;
  254.             }
  255.            
  256.             if (stealthkey == 1)
  257.             {
  258.                 ktimer++;
  259.                 //DisplayTextWithNumber(0.8f,0.2f,"NUMBER",int(ktimer));
  260.                 if (ktimer >= doubletap)
  261.                 {
  262.                     stealthkey = 0;
  263.                     ktimer = 0;
  264.                 }
  265.             }
  266.            
  267.             if (stealthkey == 2)
  268.             {
  269.                 Stealth = !Stealth;
  270.                 if(Stealth)
  271.                 {
  272.                     if(SoundEffect == true)
  273.                     {
  274.                         PlaySound(TEXT("cloak.wav"), NULL, SND_FILENAME | SND_ASYNC);
  275.                     }
  276.                    
  277.                     PrintStringWithLiteralStringNow("STRING", "CLOAK ENGAGED", 1000, true);
  278.                     Armor = false; //disable other modes
  279.                     Speed = false;
  280.                     Power = false;
  281.                     DrawLightWithRange(x, y, z, 0, 0, 200, 10, 10);
  282.                 }
  283.                 else
  284.                 {
  285.                     PrintStringWithLiteralStringNow("STRING", "CLOAK DISABLED", 1000, true);
  286.                     Armor = true; //enable armor if stealth is off
  287.                     if(SoundEffect == true)
  288.                     {
  289.                         PlaySound(TEXT("armor.wav"), NULL, SND_FILENAME | SND_ASYNC);
  290.                     }
  291.                 }
  292.                 stealthkey = 0;
  293.             }
  294.  
  295.             if ((Stealth == true) && (lEnergy == false)) //won't enable stealth if energy is low
  296.             {
  297.                 SetEveryoneIgnorePlayer(PlayerIndex, 1); //everybody ignores player
  298.                 SetPedAlpha(PlayerChar, 80); //nice to see character not disappearing, but also not visible.
  299.                 aEnergy = aEnergy - 0.07; //in cloak mode, energy will decrease
  300.                 b = 0; //don't add energy anymore. it's in here because only this mode needs constant energy
  301.                 DrawLightWithRange(x, y, z, 0, 0, 200, 4, 1.3f);
  302.                 if (IsCharPlayingAnim(PlayerChar, "move_melee", "run") || IsCharPlayingAnim(PlayerChar, "move_rifle", "sprint") || IsCharPlayingAnim(PlayerChar, "move_rpg", "sprint")) //if running
  303.                 {
  304.                     aEnergy = aEnergy - 0.5; //increase energy decrease
  305.                 }
  306.                 if (IsCharInAnyCar(PlayerChar) == true) //if in car
  307.                 {
  308.                     SetEveryoneIgnorePlayer(PlayerIndex, 0); //player won't be ignored anymore
  309.                 }
  310.                 if (AreAnyCharsNearChar(PlayerChar, 5))
  311.                 {
  312.                    
  313.                 }
  314.                 if (aEnergy < 10) //if energy is low
  315.                 {
  316.                     Stealth = false; //disable stealth mode
  317.                     PrintStringWithLiteralStringNow("STRING", "LOW ENERGY. CLOAK DISABLED", 1000, true);
  318.                     Armor = true; //re-enable armor
  319.                 }
  320.                 if (IsCharShooting(PlayerChar) == true) //if shooting
  321.                 {
  322.                     PrintStringWithLiteralStringNow("STRING", "LOW ENERGY. CLOAK DISABLED", 1000, true);
  323.                     aEnergy = 0; //all energy drained
  324.                 }
  325.                 if (IsCharDucking(PlayerChar) == true) //if crouching
  326.                 {
  327.                     aEnergy = aEnergy + 0.04;
  328.                 }
  329.             }
  330.             else
  331.             {
  332.                 SetEveryoneIgnorePlayer(PlayerIndex, 0); //not ignored
  333.                 SetPedAlpha(PlayerChar, 255); //vully visible
  334.                 b = 0.05; //set added energy to this
  335.             }
  336.  
  337.             int kSpeed = GetPrivateProfileInt(TEXT("Keys"),TEXT("SpeedKey"),113,TEXT("./Nanosuit.ini"));
  338.             if (IsGameKeyboardKeyJustPressed(kSpeed))
  339.             {
  340.                 speedkey = speedkey + 1;
  341.             }
  342.             if (speedkey == 1)
  343.             {
  344.                 ktimer++;
  345.                 //DisplayTextWithNumber(0.8f,0.2f,"NUMBER",int(ktimer));
  346.                 if (ktimer >= doubletap)
  347.                 {
  348.                     speedkey = 0;
  349.                     ktimer = 0;
  350.                 }
  351.             }
  352.             if (speedkey == 2)
  353.             {
  354.                 Speed = !Speed;
  355.                 //Speed = true;
  356.                 if(Speed)
  357.                 {
  358.                     if(SoundEffect == true)
  359.                     {
  360.                         PlaySound(TEXT("speed.wav"), NULL, SND_FILENAME | SND_ASYNC);
  361.                     }
  362.                     PrintStringWithLiteralStringNow("STRING", "SPEED MODE ENGAGED", 1000, true);
  363.                     Armor = false;
  364.                     Stealth = false;
  365.                     Power = false;
  366.                 }
  367.                 else
  368.                 {
  369.                     PrintStringWithLiteralStringNow("STRING", "SPEED MODE DISABLED", 1000, true);
  370.                     Armor = true;
  371.                     if(SoundEffect == true)
  372.                     {
  373.                         PlaySound(TEXT("armor.wav"), NULL, SND_FILENAME | SND_ASYNC);
  374.                     }
  375.                 }
  376.                 speedkey = 0;
  377.             }
  378.            
  379.             if ((Speed == true) && (lEnergy == false))
  380.             {
  381.                 SetCharMoveAnimSpeedMultiplier(PlayerChar, 2.0f); //animation speed for moving is 2x
  382.                 SetCharClimbAnimRate(PlayerChar, 2.0f); //vaulting is also faster
  383.                 DrawLightWithRange(x, y, z, 200, 200, 0, 3, 2.3f);
  384.                 /*if (IsCharInWater(PlayerChar) == true)
  385.                 {
  386.                     SetSwimSpeed(PlayerChar, 4.0);
  387.                     f32 wx, wy, wz;
  388.                     f32 wx2, wy2;
  389.                     GetCharVelocity(PlayerChar, &wx, &wy, &wz);
  390.                     if (wx < 20)
  391.                     {
  392.                         wx2 = wx+wx;
  393.                         wy2 = wy+wy;
  394.                     }
  395.                     if (wx == 20) //otherwise Niko will go faster than light and your computer become a black hole
  396.                     {
  397.                         wx2 = wx-0.5*wx;
  398.                         wy2 = wy-0.5*wy;
  399.                     }
  400.                     SetCharVelocity(PlayerChar, wx2, wy2, wz);
  401.                 }*/
  402.                 if (IsCharPlayingAnim(PlayerChar, "move_player", "run") || IsCharPlayingAnim(PlayerChar, "move_player", "sprint") || IsCharPlayingAnim(PlayerChar, "move_rifle", "sprint") || IsCharPlayingAnim(PlayerChar, "move_rpg", "sprint"))
  403.                 {
  404.                     aEnergy = aEnergy - 0.60; //set energy decrease
  405.                     SetCharMoveAnimSpeedMultiplier(PlayerChar, 4.0f); //even faster anims
  406.                     SetSwimSpeed(PlayerChar, 8.0);
  407.                     DrawLightWithRange(x, y, z, 200, 200, 0, 6, 2.3f);
  408.                 }
  409.                 if (aEnergy < 10)
  410.                 {
  411.                     Speed = false;
  412.                     PrintStringWithLiteralStringNow("STRING", "LOW ENERGY. SPEED DISABLED", 1000, true);
  413.                     Armor = true;
  414.                 }
  415.             }
  416.             else //reset everything
  417.             {
  418.                 SetCharMoveAnimSpeedMultiplier(PlayerChar, 1.0f);
  419.                 SetCharClimbAnimRate(PlayerChar, 1.0f);
  420.                 SetSwimSpeed(PlayerChar, 1.0);
  421.             }
  422.  
  423.             int kStrength = GetPrivateProfileInt(TEXT("Keys"),TEXT("StrengthKey"),114,TEXT("./Nanosuit.ini"));
  424.             if (IsGameKeyboardKeyJustPressed(kStrength))
  425.             {
  426.                 strengthkey++;
  427.             }
  428.             if (strengthkey == 1)
  429.             {
  430.                 ktimer++;
  431.                 //DisplayTextWithNumber(0.8f,0.2f,"NUMBER",int(ktimer));
  432.                 if (ktimer >= doubletap)
  433.                 {
  434.                     strengthkey = 0;
  435.                     ktimer = 0;
  436.                 }
  437.             }
  438.             if (strengthkey == 2)
  439.             {
  440.                 Power = !Power;
  441.                 if(Power)
  442.                 {
  443.                     if(SoundEffect == true)
  444.                     {
  445.                         PlaySound(TEXT("strength.wav"), NULL, SND_FILENAME | SND_ASYNC);
  446.                     }
  447.                     PrintStringWithLiteralStringNow("STRING", "STRENGTH MODE ENGAGED", 1000, true);
  448.                     Armor = false;
  449.                     Speed = false;
  450.                     Stealth = false;
  451.                     DrawLightWithRange(x, y, z, 100, 0, 0, 10, 10);
  452.                 }
  453.                 else
  454.                 {
  455.                     PrintStringWithLiteralStringNow("STRING", "STRENGTH MODE DISABLED", 1000, true);
  456.                     Armor = true;
  457.                     if(SoundEffect == true)
  458.                     {
  459.                         PlaySound(TEXT("armor.wav"), NULL, SND_FILENAME | SND_ASYNC);
  460.                     }
  461.                 }
  462.                 strengthkey = 0;
  463.             }
  464.  
  465.             if ((Power == true) && (lEnergy == false))
  466.             {
  467.                 Ped otherChar;
  468.                 Vehicle otherVeh;
  469.                 f32 offsetX, offsetY, offsetZ;
  470.                 DrawLightWithRange(x, y, z, 100, 0, 0, 5, 2.3f);
  471.  
  472.                 otherVeh = GetClosestCar(x, y, z, 10.0f, true, 70); //get closest car
  473.                 if ( (DoesVehicleExist(otherVeh) == true) && (IsCharTouchingVehicle(PlayerChar, otherVeh) == true)) //if vehicle exists and is in range and if player is touching it
  474.                 {
  475.                     if ( (IsCharTouchingVehicle(PlayerChar, otherVeh) == true) && ((IsCharInMeleeCombat(PlayerChar)& 1) == true) ) //check for player in melee
  476.                     {
  477.                         DrawLightWithRange(x, y, z, 100, 0, 0, 10, 10);
  478.                         aEnergy = aEnergy - 30; //energy decrease
  479.                         //SetCarHeading(otherVeh, 0);
  480.                         GetCarCoordinates(otherVeh, &vehx, &vehy, &vehz); //getting car coords
  481.                         offsetX = vehx-x;
  482.                         offsetY = vehy-y;
  483.                         offsetZ = vehz-z;
  484.                         //ApplyForceToCar(otherVeh, 3, 10*offsetX, 10*offsetY, 10*offsetZ, rotx, roty, rotz, 0, vehicle heading in consideration, 1, 1);
  485.                         ApplyForceToCar(otherVeh, 3, 5*offsetX, 5*offsetY, 5*offsetZ, 0.0f, 0.0f, 2.0f, 0, 0, 1, 1);
  486.                         //SetCarHealth(otherVeh, 0);
  487.                         //SetPetrolTankHealth(otherVeh, 0);
  488.                         SetEngineHealth(otherVeh, -1.0f);
  489.                         Ped card, carp0, carp1, carp2;
  490.                         GetDriverOfCar(otherVeh, &card);
  491.                         if (DoesCharExist(card))
  492.                         {
  493.                             SetCharHealth(card, 0);
  494.                         }
  495.                    
  496.                     }
  497.                 }
  498.                
  499.                 /*if (IsCharPlayingAnim(PlayerChar, "throw_grenade", "grenade_throw_short"))
  500.                 {
  501.                     //eWeapon weaponinhand;
  502.                     //GetCurrentCharWeapon(PlayerChar, &weaponinhand);
  503.                     //if ((weaponinhand == 4) || (weaponinhand == 5))
  504.                     //{
  505.  
  506.                     //}
  507.                     Object obj;
  508.                     obj = GetObjectPedIsHolding(PlayerChar);
  509.                     //if (DoesObjectExist(obj))
  510.                     //{
  511.                         Wait(200);
  512.                         f32 ox, oy, oz, difx, dify, difz;
  513.                         GetObjectCoordinates(obj, &ox, &oy, &oz);
  514.                         difx = ox-x;
  515.                         dify = oy-y;
  516.                         difz = oz-z;
  517.                         ApplyForceToObject(obj, 3, 50*ox, 50*oy, 50*oz, 0, 0, 0, 0, 0, 1, 1);
  518.                         aEnergy = aEnergy - 10;
  519.                     //}
  520.                 }*/
  521.  
  522.                 if (IsCharPlayingAnim(PlayerChar, "jump_std", "jump_takeoff_l") || IsCharPlayingAnim(PlayerChar, "jump_std", "jump_takeoff_r") || IsCharPlayingAnim(PlayerChar, "jump_rifle", "jump_takeoff_r") || IsCharPlayingAnim(PlayerChar, "jump_rifle", "jump_takeoff_l") || IsCharPlayingAnim(PlayerChar, "jump_std", "jump_on_spot")
  523.          || IsCharPlayingAnim(PlayerChar, "jump_rifle", "jump_on_spot"))
  524.                 {
  525.                     DrawLightWithRange(x, y, z, 100, 0, 0, 10, 10);
  526.                     GetCharVelocity(PlayerChar, &ovx, &ovy, &ovz);
  527.                     //ovx = ovx*0.84f;
  528.                     //ovy = ovy*0.84f;
  529.                     SetCharVelocity(PlayerChar, 1.04f*ovx, 1.04f*ovy, 6.0f); // add upward speed + speed maintained during flight.
  530.                     aEnergy = aEnergy - 1; //decrease energy
  531.                 }
  532.  
  533.                 if (aEnergy < 10)
  534.                 {
  535.                     Power = false;
  536.                     PrintStringWithLiteralStringNow("STRING", "LOW ENERGY. STRENGTH DISABLED", 1000, true);
  537.                     Armor = true;
  538.                 }
  539.             }
  540.         }
  541.     }
  542. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement