Advertisement
Nanory

OnEmptyVehicleDamage v0.3

Jul 28th, 2011
1,345
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 11.02 KB | None | 0 0
  1. #include <a_samp>
  2.  
  3. #define KORREKTUR_VEK 0
  4. #define SHOT_MS 200
  5.  
  6. #pragma tabsize 0
  7. //==================================================================================//
  8. //      This Include allows you to damage vehicle althrough nobody is inside        //
  9. //        Furthermore thank you to RyDeR` for his "GetVehicleSize" Function,        //
  10. //                      wups for his alternativ Hook method                         //
  11. //                    the person who made the Holding define                        //
  12. //                    to [BEP]AcerPilot who gave me a tip ;)                        //
  13. //                                                                                  //
  14. //                              Made by Nanory (2011)                               //
  15. //                                  Version 0.3                                     //
  16. //                                                                                  //
  17. //  If you want to edit this include you can do this, but edit my name inside it.   //
  18. //              Last but not least I apologize for my bad english :P                //
  19. //==================================================================================//
  20.  
  21. #if defined Holding
  22. #else
  23.         #define Holding(%0) \
  24.         ((newkeys & (%0)) == (%0))
  25. #endif
  26.  
  27. #if defined PRESSED
  28. #else
  29.     #define PRESSED(%0) \
  30.     (((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
  31. #endif
  32.  
  33. forward OnEmptyVehicleDamage(vehicleid,playerid,exems);
  34.  
  35. new playerblock[MAX_PLAYERS];
  36. new playershottick[MAX_PLAYERS];
  37.  
  38.  
  39.  
  40. stock GetVehicleSize(modelID, &Float: size_X, &Float: size_Y, &Float: size_Z) // Author: RyDeR`
  41. {
  42.     static const
  43.         Float: sizeData[212][3] =
  44.         {
  45.             { 2.32, 5.11, 1.63 }, { 2.56, 5.82, 1.71 }, { 2.41, 5.80, 1.52 }, { 3.15, 9.22, 4.17 },
  46.             { 2.20, 5.80, 1.84 }, { 2.34, 6.00, 1.49 }, { 5.26, 11.59, 4.42 }, { 2.84, 8.96, 2.70 },
  47.             { 3.11, 10.68, 3.91 }, { 2.36, 8.18, 1.52 }, { 2.25, 5.01, 1.79 }, { 2.39, 5.78, 1.37 },
  48.             { 2.45, 7.30, 1.38 }, { 2.27, 5.88, 2.23 }, { 2.51, 7.07, 4.59 }, { 2.31, 5.51, 1.13 },
  49.             { 2.73, 8.01, 3.40 }, { 5.44, 23.27, 6.61 }, { 2.56, 5.67, 2.14 }, { 2.40, 6.21, 1.40 },
  50.             { 2.41, 5.90, 1.76 }, { 2.25, 6.38, 1.37 }, { 2.26, 5.38, 1.54 }, { 2.31, 4.84, 4.90 },
  51.             { 2.46, 3.85, 1.77 }, { 5.15, 18.62, 5.19 }, { 2.41, 5.90, 1.76 }, { 2.64, 8.19, 3.23 },
  52.             { 2.73, 6.28, 3.48 }, { 2.21, 5.17, 1.27 }, { 4.76, 16.89, 5.92 }, { 3.00, 12.21, 4.42 },
  53.             { 4.30, 9.17, 3.88 }, { 3.40, 10.00, 4.86 }, { 2.28, 4.57, 1.72 }, { 3.16, 13.52, 4.76 },
  54.             { 2.27, 5.51, 1.72 }, { 3.03, 11.76, 4.01 }, { 2.41, 5.82, 1.72 }, { 2.22, 5.28, 1.47 },
  55.             { 2.30, 5.55, 2.75 }, { 0.87, 1.40, 1.01 }, { 2.60, 6.67, 1.75 }, { 4.15, 20.04, 4.42 },
  56.             { 3.66, 6.01, 3.28 }, { 2.29, 5.86, 1.75 }, { 4.76, 17.02, 4.30 }, { 2.42, 14.80, 3.15 },
  57.             { 0.70, 2.19, 1.62 }, { 3.02, 9.02, 4.98 }, { 3.06, 13.51, 3.72 }, { 2.31, 5.46, 1.22 },
  58.             { 3.60, 14.56, 3.28 }, { 5.13, 13.77, 9.28 }, { 6.61, 19.04, 13.84 }, { 3.31, 9.69, 3.63 },
  59.             { 3.23, 9.52, 4.98 }, { 1.83, 2.60, 2.72 }, { 2.41, 6.13, 1.47 }, { 2.29, 5.71, 2.23 },
  60.             { 10.85, 13.55, 4.44 }, { 0.69, 2.46, 1.67 }, { 0.70, 2.19, 1.62 }, { 0.69, 2.42, 1.34 },
  61.             { 1.58, 1.54, 1.14 }, { 0.87, 1.40, 1.01 }, { 2.52, 6.17, 1.64 }, { 2.52, 6.36, 1.66 },
  62.             { 0.70, 2.23, 1.41 }, { 2.42, 14.80, 3.15 }, { 2.66, 5.48, 2.09 }, { 1.41, 2.00, 1.71 },
  63.             { 2.67, 9.34, 4.86 }, { 2.90, 5.40, 2.22 }, { 2.43, 6.03, 1.69 }, { 2.45, 5.78, 1.48 },
  64.             { 11.02, 11.28, 3.28 }, { 2.67, 5.92, 1.39 }, { 2.45, 5.57, 1.74 }, { 2.25, 6.15, 1.99 },
  65.             { 2.26, 5.26, 1.41 }, { 0.70, 1.87, 1.32 }, { 2.33, 5.69, 1.87 }, { 2.04, 6.19, 2.10 },
  66.             { 5.34, 26.20, 7.15 }, { 1.97, 4.07, 1.44 }, { 4.34, 7.84, 4.44 }, { 2.32, 15.03, 4.67 },
  67.             { 2.32, 12.60, 4.65 }, { 2.53, 5.69, 2.14 }, { 2.92, 6.92, 2.14 }, { 2.30, 6.32, 1.28 },
  68.             { 2.34, 6.17, 1.78 }, { 4.76, 17.82, 3.84 }, { 2.25, 6.48, 1.50 }, { 2.77, 5.44, 1.99 },
  69.             { 2.27, 4.75, 1.78 }, { 2.32, 15.03, 4.65 }, { 2.90, 6.59, 4.28 }, { 2.64, 7.19, 3.75 },
  70.             { 2.28, 5.01, 1.85 }, { 0.87, 1.40, 1.01 }, { 2.34, 5.96, 1.51 }, { 2.21, 6.13, 1.62 },
  71.             { 2.52, 6.03, 1.64 }, { 2.53, 5.69, 2.14 }, { 2.25, 5.21, 1.16 }, { 2.56, 6.59, 1.62 },
  72.             { 2.96, 8.05, 3.33 }, { 0.70, 1.89, 1.32 }, { 0.72, 1.74, 1.12 }, { 21.21, 21.19, 5.05 },
  73.             { 11.15, 6.15, 2.99 }, { 8.69, 9.00, 2.23 }, { 3.19, 10.06, 3.05 }, { 3.54, 9.94, 3.42 },
  74.             { 2.59, 6.23, 1.71 }, { 2.52, 6.32, 1.64 }, { 2.43, 6.00, 1.57 }, { 20.30, 19.29, 6.94 },
  75.             { 8.75, 14.31, 2.16 }, { 0.69, 2.46, 1.67 }, { 0.69, 2.46, 1.67 }, { 0.69, 2.47, 1.67 },
  76.             { 3.58, 8.84, 3.64 }, { 3.04, 6.46, 3.28 }, { 2.20, 5.40, 1.25 }, { 2.43, 5.71, 1.74 },
  77.             { 2.54, 5.55, 2.14 }, { 2.38, 5.63, 1.86 }, { 1.58, 4.23, 2.68 }, { 1.96, 3.70, 1.66 },
  78.             { 8.61, 11.39, 4.17 }, { 2.38, 5.42, 1.49 }, { 2.18, 6.26, 1.15 }, { 2.67, 5.48, 1.58 },
  79.             { 2.46, 6.42, 1.29 }, { 3.32, 18.43, 5.19 }, { 3.26, 16.59, 4.94 }, { 2.50, 3.86, 2.55 },
  80.             { 2.58, 6.07, 1.50 }, { 2.26, 4.94, 1.24 }, { 2.48, 6.40, 1.70 }, { 2.38, 5.73, 1.86 },
  81.             { 2.80, 12.85, 3.89 }, { 2.19, 4.80, 1.69 }, { 2.56, 5.86, 1.66 }, { 2.49, 5.84, 1.76 },
  82.             { 4.17, 24.42, 4.90 }, { 2.40, 5.53, 1.42 }, { 2.53, 5.88, 1.53 }, { 2.66, 6.71, 1.76 },
  83.             { 2.65, 6.71, 3.55 }, { 28.73, 23.48, 7.38 }, { 2.68, 6.17, 2.08 }, { 2.00, 5.13, 1.41 },
  84.             { 3.66, 6.36, 3.28 }, { 3.66, 6.26, 3.28 }, { 2.23, 5.25, 1.75 }, { 2.27, 5.48, 1.39 },
  85.             { 2.31, 5.40, 1.62 }, { 2.50, 5.80, 1.78 }, { 2.25, 5.30, 1.50 }, { 3.39, 18.62, 4.71 },
  86.             { 0.87, 1.40, 1.01 }, { 2.02, 4.82, 1.50 }, { 2.50, 6.46, 1.65 }, { 2.71, 6.63, 1.58 },
  87.             { 2.71, 4.61, 1.41 }, { 3.25, 18.43, 5.03 }, { 3.47, 21.06, 5.19 }, { 1.57, 2.32, 1.58 },
  88.             { 1.65, 2.34, 2.01 }, { 2.93, 7.38, 3.16 }, { 1.62, 3.84, 2.50 }, { 2.49, 5.82, 1.92 },
  89.             { 2.42, 6.36, 1.85 }, { 62.49, 61.43, 34.95 }, { 3.15, 11.78, 2.77 }, { 2.47, 6.21, 2.55 },
  90.             { 2.66, 5.76, 2.24 }, { 0.69, 2.46, 1.67 }, { 2.44, 7.21, 3.19 }, { 1.66, 3.66, 3.21 },
  91.             { 3.54, 15.90, 3.40 }, { 2.44, 6.53, 2.05 }, { 0.69, 2.79, 1.96 }, { 2.60, 5.76, 1.45 },
  92.             { 3.07, 8.61, 7.53 }, { 2.25, 5.09, 2.11 }, { 3.44, 18.39, 5.03 }, { 3.18, 13.63, 4.65 },
  93.             { 44.45, 57.56, 18.43 }, { 12.59, 13.55, 3.56 }, { 0.50, 0.92, 0.30 }, { 2.84, 13.47, 2.21 },
  94.             { 2.41, 5.90, 1.76 }, { 2.41, 5.90, 1.76 }, { 2.41, 5.78, 1.76 }, { 2.92, 6.15, 2.14 },
  95.             { 2.40, 6.05, 1.55 }, { 3.07, 6.96, 3.82 }, { 2.31, 5.53, 1.28 }, { 2.64, 6.07, 1.42 },
  96.             { 2.52, 6.17, 1.64 }, { 2.38, 5.73, 1.86 }, { 2.93, 3.38, 1.97 }, { 3.01, 3.25, 1.60 },
  97.             { 1.45, 4.65, 6.36 }, { 2.90, 6.59, 4.21 }, { 2.48, 1.42, 1.62 }, { 2.13, 3.16, 1.83 }
  98.         }
  99.     ;
  100.     if(400 <= modelID <= 611)
  101.     {
  102.         size_X = sizeData[modelID - 400][0];
  103.         size_Y = sizeData[modelID - 400][1];
  104.         size_Z = sizeData[modelID - 400][2];      
  105.         return 1;
  106.     }
  107.     return 0;
  108. }
  109.  
  110. stock GetPlayerLookingPos(playerid,Float:radius,&Float:x,&Float:y,&Float:z)
  111. {
  112.     if(IsPlayerConnected(playerid))
  113.     {
  114.         new
  115.             Float:fPX, Float:fPY, Float:fPZ,
  116.             Float:fVX, Float:fVY, Float:fVZ,
  117.             Float:tmpz;
  118.  
  119.         GetPlayerPos(playerid, fPX, fPY, fPZ);
  120.         GetPlayerCameraFrontVector(playerid, fVX, fVY, fVZ);
  121.        
  122.         //--[Correction of the Cameraview (From Players Head)] ---------
  123.         /**/ if(GetPlayerSpecialAction(playerid) != 1){fPZ += 0.7;} /**/
  124.         /**/ tmpz = fVZ*0.5;                                        /**/
  125.         /**/ fVZ = tmpz;                                            /**/
  126.         //--------------------------------------------------------------
  127.  
  128.         x = fPX + ((radius)*fVX); // Geradengleichung (Vektoren)
  129.         y = fPY + ((radius)*fVY); // Geradengleichung
  130.         z = fPZ + ((radius)*fVZ); // Geradengleichung
  131.     }
  132.     return 1;
  133. }
  134.  
  135. stock VehicleToPoint(Float:radi, vehicleid, Float:x, Float:y, Float:z)
  136. {
  137.     new Float:oldposx, Float:oldposy, Float:oldposz;
  138.     new Float:tempposx, Float:tempposy, Float:tempposz;
  139.     GetVehiclePos(vehicleid, oldposx, oldposy, oldposz);
  140.     tempposx = (oldposx -x);
  141.     tempposy = (oldposy -y);
  142.     tempposz = (oldposz -z);
  143.     if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
  144.     {
  145.         return 1;
  146.     }
  147.     return 0;
  148. }
  149.  
  150. stock IsPlayerLookingAtVehicle(playerid,vehicleid)
  151. {
  152.     if(IsPlayerConnected(playerid) && GetVehicleModel(vehicleid))
  153.     {
  154.         new Float:VehPos[3],Float:PlyDis,Float:PlyPos[3],Float:VehSize[3];//,Float:ZDif,Float:RealDis;
  155.         GetVehiclePos(vehicleid,VehPos[0],VehPos[1],VehPos[2]);
  156.         PlyDis = GetPlayerDistanceFromPoint(playerid,VehPos[0],VehPos[1],VehPos[2]);
  157.         GetPlayerLookingPos(playerid,PlyDis,PlyPos[0],PlyPos[1],PlyPos[2]);
  158.         GetVehicleSize(GetVehicleModel(vehicleid),VehSize[0],VehSize[1],VehSize[2]);
  159.         if(VehicleToPoint(VehSize[1],vehicleid,PlyPos[0],PlyPos[1],PlyPos[2]))
  160.         {
  161.             return 1;
  162.         }
  163.     }
  164.     return 0;
  165. }
  166.  
  167. stock GiveVehicleHealth(vehicleid,Float:health)
  168. {
  169.     if(GetVehicleModel(vehicleid))
  170.     {
  171.         new Float:gpHealth;
  172.         GetVehicleHealth(vehicleid,gpHealth);
  173.         if(gpHealth + health >= 1000){gpHealth = 1000;}
  174.         else if(gpHealth + health <= 0){gpHealth = 0;}
  175.         else{gpHealth += health;}
  176.         SetVehicleHealth(vehicleid,gpHealth);
  177.     }
  178.     return 1;
  179. }
  180.  
  181. public OnUnoccupiedVehicleUpdate(vehicleid, playerid, passenger_seat)
  182. {
  183.     new testtick = GetTickCount();
  184.     CallLocalFunction("VB_OnUnoccupiedVehicleUpdate", "iii", vehicleid, playerid, passenger_seat);
  185.     new cammode = GetPlayerCameraMode(playerid);
  186.     if(cammode == 7 || cammode == 8 || cammode == 53 || GetPlayerWeapon(playerid) <= 15)
  187.     {
  188.         new newkeys,plylr,plyup;
  189.         GetPlayerKeys(playerid,newkeys,plyup,plylr);
  190.         if(Holding(KEY_FIRE) || (GetTickCount()-playershottick[playerid]) <= SHOT_MS)
  191.         {
  192.             if(GetPlayerWeapon(playerid) <= 15)
  193.             {
  194.                 new Float:VehSize[3],Float:VehPos[3];
  195.                 GetVehicleSize(GetVehicleModel(vehicleid),VehSize[0],VehSize[1],VehSize[2]);
  196.                 GetVehiclePos(vehicleid,VehPos[0],VehPos[1],VehPos[2]);
  197.                 if(IsPlayerInRangeOfPoint(playerid,VehSize[1],VehPos[0],VehPos[1],VehPos[2]))
  198.                 {
  199.                     new animidx = GetPlayerAnimationIndex(playerid);
  200.                     if( animidx == 1136 || animidx == 1137 || animidx == 1138 || animidx == 1141 || //Fightstyle ...
  201.                         animidx == 17 || animidx == 18 || animidx == 19 || // Bat
  202.                         animidx == 749 || animidx == 750 || animidx == 751 || // Knife
  203.                         animidx == 1545 || animidx == 1546 || animidx == 1547 || // Sword
  204.                         animidx == 313 || animidx == 314 || animidx == 315 || // CSaw
  205.                         animidx == 423 || animidx == 424 || animidx == 425 || // Dildo
  206.                         animidx == 533) //Flowerattack
  207.                     {  
  208.                         if(playerblock[playerid] == 0){playerblock[playerid] = 1;}
  209.                         else{return 1;}
  210.                     }
  211.                     else
  212.                     {
  213.                         playerblock[playerid] = 0;
  214.                         return 1;
  215.                     }
  216.                 }
  217.                 else{return 1;}
  218.             }
  219.             CallRemoteFunction("OnEmptyVehicleDamage","iii",vehicleid,playerid,(GetTickCount()-testtick));//}
  220.         }
  221.         else if(playerblock[playerid] == 1){playerblock[playerid] = 0;}
  222.     }
  223.     return 1;
  224. }
  225. forward VB_OnUnoccupiedVehicleUpdate(vehicleid, playerid, passenger_seat);
  226. #if defined _ALS_OnUnoccupiedVehicleUpdate
  227.     #undef OnUnoccupiedVehicleUpdate
  228. #else
  229.     #define _ALS_OnUnoccupiedVehicleUpdate
  230. #endif
  231. #define OnUnoccupiedVehicleUpdate VB_OnUnoccupiedVehicleUpdate
  232.  
  233. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  234. {
  235.     if(PRESSED(KEY_FIRE)){playershottick[playerid] = GetTickCount();}
  236.     return CallLocalFunction("VB_OnPlayerKeyStateChange", "iii", playerid, newkeys, oldkeys);
  237. }
  238. forward VB_OnPlayerKeyStateChange(playerid, newkeys, oldkeys);
  239. #if defined _ALS_OnPlayerKeyStateChange
  240.     #undef OnPlayerKeyStateChange
  241. #else
  242.     #define _ALS_OnPlayerKeyStateChange
  243. #endif
  244. #define OnPlayerKeyStateChange VB_OnPlayerKeyStateChange
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement