XADRENALINEIX

K3R3DOR'S Levitate Mod

Jul 6th, 2013
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 7.11 KB | None | 0 0
  1. ///******   LEVITATION BY K3R3D0R  ******///
  2. ////////////
  3. ////////////
  4. //   Controls:
  5. //
  6. //   Mode select = DPad Right
  7. //
  8. //   Levitate = xbox-A / ps3-X
  9. //
  10.  
  11. #include <natives.h>
  12. #include <common.h>
  13. #include <strings.h>
  14. #include <types.h>
  15. #include <consts.h>
  16.  
  17. #define L2  0x5
  18. #define R2  0x7
  19. #define R1  0x6
  20. #define DPAD_UP  0x8
  21. #define DPAD_RIGHT  0xB
  22. #define X  0x10
  23. #define SQUARE  0xE
  24.  
  25.  
  26.  
  27.  
  28. Vehicle closestcar, car, pcar;
  29. int netid, pnetid, b;
  30. float x, y, z, px, py, pz, mx, my, mz, distance;
  31. int mode=0;
  32. int button_select=0;
  33. Ped* chararray[16];
  34.  
  35. bool RequestNet(uint netid)
  36. {
  37.    uint i = 0;
  38.    while ( !REQUEST_CONTROL_OF_NETWORK_ID(netid) && i < 10 )
  39.    {
  40.       i++;
  41.       WAIT(100);
  42.    }
  43.    return HAS_CONTROL_OF_NETWORK_ID(netid);
  44. }
  45.  
  46. void scalevector(float *x, float *y, float *z, float scale)
  47. {
  48.    if (*x != 0 || *y != 0 || *z != 0)
  49.    {
  50.       float Dist = SQRT(POW(*x,2) + POW(*y,2) + POW(*z,2));
  51.       *x = (*x / Dist) * scale;
  52.       *y = (*y / Dist) * scale;
  53.       *z = (*z / Dist) * scale;
  54.    }
  55. }
  56.  
  57. Vehicle GetCurrentPlayerVehicle(void)
  58. {
  59.    Vehicle pVehicle;
  60.    GET_CAR_CHAR_IS_USING(GetPlayerPed(), &pVehicle);
  61.    return pVehicle;
  62. }
  63.  
  64. void anims(void)
  65. {
  66.    REQUEST_ANIMS("missgambetti1");
  67.    while(!HAVE_ANIMS_LOADED("missgambetti1")) WAIT(0);
  68.    TASK_PLAY_ANIM_WITH_FLAGS(GetPlayerPed(),"handsup","missgambetti1",8.0,0,0);
  69. }
  70.  
  71. void levitate(void)
  72. {
  73.    GET_CHAR_COORDINATES(GetPlayerPed(), &mx, &my, &mz);
  74.    closestcar = GET_CLOSEST_CAR(mx, my, mz, 100, 0, 70);
  75.    if( DOES_VEHICLE_EXIST(closestcar))
  76.    {
  77.       GET_NETWORK_ID_FROM_VEHICLE(closestcar, &netid);
  78.       if (RequestNet(netid))
  79.       {
  80.          if(!IS_CAR_STUCK_ON_ROOF(closestcar))
  81.          {
  82.             APPLY_FORCE_TO_CAR(closestcar, 0.0f, 0.0f, 0.0f, 100.0f , 0.0f,0.0f,0.0f, 0, 1, 1, 1 );
  83.             if(IS_BUTTON_PRESSED(0, R2))
  84.             {
  85.                if(RequestNet(closestcar))
  86.                {
  87.                   if(DOES_VEHICLE_EXIST(closestcar))
  88.                   {
  89.                      SET_CAR_CAN_BE_DAMAGED(closestcar, true);
  90.                      SET_CAR_CAN_BE_VISIBLY_DAMAGED(closestcar, true);
  91.                      EXPLODE_CAR(closestcar, true, false);
  92.                   }
  93.                }
  94.             }
  95.             if(IS_BUTTON_PRESSED(0, R1))
  96.             {
  97.                if(RequestNet(closestcar))
  98.                {
  99.                   if(DOES_VEHICLE_EXIST(closestcar))
  100.                   {
  101.                      DELETE_CAR(&closestcar);
  102.                   }
  103.                }
  104.             }
  105.          }
  106.          else
  107.          {
  108.             SET_CAR_ON_GROUND_PROPERLY(closestcar);
  109.             APPLY_FORCE_TO_CAR(closestcar, 0.0f, 0.0f, 0.0f, 100.0f , 0.0f,0.0f,0.0f, 0, 1, 1, 1 );
  110.          }
  111.       }
  112.  
  113.    }
  114.  
  115. }
  116.  
  117. void levitate_peds(void)
  118. {
  119.    float x, y, z;
  120.    bool searchdelpid = true;
  121.    Ped myped = GetPlayerPed();
  122.    int leviped, levipedid = -1;
  123.    GET_CHAR_COORDINATES(myped, &x, &y, &z);
  124.    while (searchdelpid)
  125.    {
  126.       levipedid++;
  127.       if ( levipedid > 10000 )
  128.          searchdelpid = false;
  129.  
  130.       GET_PED_FROM_NETWORK_ID(levipedid, &leviped);
  131.       if ( DOES_CHAR_EXIST(leviped) )
  132.       {
  133.          if ( IS_CHAR_IN_AREA_2D(leviped, x+60.0f, y+60.0f, x-60.0f, y-60.0f, false) )
  134.          {
  135.             if ( myped == leviped )
  136.                continue;
  137.             if ( RequestNet(levipedid) )
  138.                APPLY_FORCE_TO_PED(leviped,true,0.0,0.0,20,0.0,0.0,0.0,true,true,true,true);
  139.          }
  140.          if(IS_BUTTON_PRESSED(0, R1))
  141.          {
  142.             GET_CHAR_COORDINATES(leviped, &x, &y, &z);
  143.             ADD_EXPLOSION(x, y, z, EXPLOSION_SHIP_DESTROY, 7.50, 1, 0, 0.7);
  144.          }
  145.       }
  146.    }
  147. }
  148.  
  149. void suck_peds(void)
  150. {
  151.    float cx, cy, cz, fx, fy, fz;
  152.    bool searchdelpid = true;
  153.    Ped myped = GetPlayerPed();
  154.    int leviped, levipedid = -1;
  155.    while (searchdelpid)
  156.    {
  157.       levipedid++;
  158.       if ( levipedid > 10000 )
  159.          searchdelpid = false;
  160.  
  161.       GET_PED_FROM_NETWORK_ID(levipedid, &leviped);
  162.       if ( DOES_CHAR_EXIST(leviped) )
  163.       {
  164.          GET_CHAR_COORDINATES(myped, &x, &y, &z);
  165.          if ( IS_CHAR_IN_AREA_2D(leviped, x+60.0f, y+60.0f, x-60.0f, y-60.0f, false) )
  166.          {
  167.             if ( myped == leviped )
  168.                continue;
  169.             if ( RequestNet(levipedid) )
  170.             {
  171.                GET_CHAR_COORDINATES(leviped, &cx, &cy, &cz);
  172.                fx = x - cx;
  173.                fy = y - cy;
  174.                fz = z - cz;
  175.                scalevector(&fx, &fy, &fz, 40);
  176.                if(!IS_CHAR_IN_ANY_CAR(leviped))
  177.                {
  178.                   APPLY_FORCE_TO_PED(leviped, true, fx, fy, fz, 0, 0, 0, true, false, true, true);
  179.                }
  180.             }
  181.          }
  182.       }
  183.    }
  184. }
  185.  
  186. void levitate_all(void)
  187. {
  188.    float x, y, z, fx, fy, fz;
  189.    bool searchdelid = true;
  190.    int pedcar, levicarid = -1;
  191.    int mycar = GetCurrentPlayerVehicle();
  192.    GET_CHAR_COORDINATES(GetPlayerPed(), &x, &y, &z);
  193.    while (searchdelid)
  194.    {
  195.       levicarid++;
  196.       if ( levicarid > 10000 )
  197.          searchdelid = false;
  198.  
  199.       GET_VEHICLE_FROM_NETWORK_ID(levicarid, &pedcar);
  200.  
  201.       if ( DOES_VEHICLE_EXIST(pedcar) )
  202.       {
  203.          if ( IS_CAR_IN_AREA_2D(pedcar, x+60.0f, y+60.0f, x-60.0f, y-60.0f, false) )
  204.          {
  205.             if ( mycar == pedcar )
  206.                continue;
  207.             if ( RequestNet(levicarid) )
  208.             {
  209.                if(!HAS_CONTROL_OF_NETWORK_ID(levicarid)) continue;
  210.                {
  211.                   APPLY_FORCE_TO_CAR(pedcar, true, 0, 0, 8.0f, 0, 0, 0, true, true, true, true);
  212.                   GET_CAR_COORDINATES(pedcar,&fx, &fy, &fz);
  213.                   ADD_EXPLOSION(fx , fy , fz, EXPLOSION_MOLOTOV, 7.50, 1, 0, 0);
  214.                }
  215.             }
  216.          }
  217.       }
  218.    }
  219. }
  220.  
  221. void mode_select(void)
  222. {
  223.   if((mode==0) &&  (IS_BUTTON_JUST_PRESSED(0, DPAD_RIGHT)))
  224.   {
  225.       mode = 1;
  226.       print("~y~Ped Only Mode Enabled");
  227.       WAIT(100);
  228.  
  229.   }
  230.   if((mode==1) &&  (IS_BUTTON_JUST_PRESSED(0, DPAD_RIGHT)))
  231.   {
  232.       mode = 2;
  233.       print("~y~Ped Hoover Mode Enabled");
  234.       WAIT(100);
  235.  
  236.   }
  237.   if((mode==2) &&  (IS_BUTTON_JUST_PRESSED(0, DPAD_RIGHT)))
  238.   {
  239.       mode = 3;
  240.       print("~y~Levitation Mode Enabled");
  241.       WAIT(100);
  242.  
  243.   }
  244.   if((mode==3) &&  (IS_BUTTON_JUST_PRESSED(0, DPAD_RIGHT)))
  245.   {
  246.       mode = 0;
  247.       print("~y~Car Only Mode Enabled");
  248.       WAIT(100);
  249.  
  250.   }
  251. }
  252. void activate_button(void)
  253. {
  254.    if(IS_BUTTON_PRESSED(0, X))
  255.    {
  256.       if(mode==0)
  257.       {
  258.          levitate();
  259.       }
  260.       if(mode==1)
  261.       {
  262.          levitate_peds();
  263.       }
  264.       if(mode==2)
  265.       {
  266.          suck_peds();
  267.       }
  268.       if(mode==3)
  269.       {
  270.          levitate_all();
  271.          if(!IS_CHAR_PLAYING_ANIM(GetPlayerPed(), "missgambetti1", "handsup") )
  272.          {
  273.             anims();
  274.          }
  275.       }
  276.    }
  277. }
  278.  
  279. void main(void)
  280. {
  281.    THIS_SCRIPT_IS_SAFE_FOR_NETWORK_GAME();
  282.    PRINT_STRING_WITH_LITERAL_STRING_NOW("STRING", "~y~LEVITATION  ~COL_NET_4~BY  ~BLIP_90~ ~BLIP_83~ ~BLIP_27~ ~BLIP_83~ ~BLIP_53~ ~BLIP_52~ ~BLIP_27~", 5000, 1);
  283.  
  284.    while(TRUE)
  285.    {
  286.       activate_button();
  287.       mode_select();
  288.       WAIT(0);
  289.    }
  290. }
Advertisement
Add Comment
Please, Sign In to add comment