SHARE
TWEET

IsPlayerNear v1.2

a guest Aug 9th, 2013 487 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #if defined _IsPlayerNear_included
  2.     #endinput
  3. #endif
  4. #define _IsPlayerNear_included
  5. #include <a_samp>
  6. #include <foreach>
  7. /*============================================================================*\
  8. ================================================================================
  9. ====================|                     IsPlayerNear* v1.2            |===================
  10. ====================|                   Created by: White_116           |===================
  11. ================================================================================
  12. ================================================================================
  13.                                         Return INVALID_VEHICLE_ID or vehicleid;
  14. ================================================================================
  15. native GetVehicleIfPlayerNearVehicle(playerid, Float:Range=15.0, Float:MaxAngle=30.0);
  16. native GetVehicleIfPlayerNearBoot(playerid, Float:Range=1.5, Float:MaxAngle=30.0);
  17. native GetVehicleIfPlayerNearBonnet(playerid, Float:Range=1.5, Float:MaxAngle=30.0);
  18. native GetVehicleIfPlayerNearPetrolCap(playerid, Float:Range=0.75, Float:MaxAngle=30.0);
  19. native GetVehicleIfPlayerNearDoor(playerid, door, Float:Range=0.75, Float:MaxAngle=30.0);
  20. native GetVehicleIfPlayerNearDoor0(playerid, Float:Range=0.75, Float:MaxAngle=30.0);
  21. native GetVehicleIfPlayerNearDoor1(playerid, Float:Range=0.75, Float:MaxAngle=30.0);
  22. native GetVehicleIfPlayerNearDoor2(playerid, Float:Range=0.75, Float:MaxAngle=30.0);
  23. native GetVehicleIfPlayerNearDoor3(playerid, Float:Range=0.75, Float:MaxAngle=30.0);
  24. native GetVehicleIfPlayerNearWheel(playerid, wheel, Float:Range=0.75, Float:MaxAngle=30.0);
  25. native GetVehicleIfPlayerNearWheel0(playerid, Float:Range=0.75, Float:MaxAngle=30.0);
  26. native GetVehicleIfPlayerNearWheel1(playerid, Float:Range=0.75, Float:MaxAngle=30.0);
  27. native GetVehicleIfPlayerNearWheel2(playerid, Float:Range=0.75, Float:MaxAngle=30.0);
  28. native GetVehicleIfPlayerNearWheel3(playerid, Float:Range=0.75, Float:MaxAngle=30.0);
  29. ================================================================================
  30. ================================================================================
  31.                                                         Return 0 or 1 & x,y,z
  32. ================================================================================
  33. native GetVehicleBootPos(vehicleid, &Float:x, &Float:y, &Float:z);
  34. native GetVehicleBonnetPos(vehicleid, &Float:x, &Float:y, &Float:z);
  35. native GetVehiclePetrolCapPos(vehicleid, &Float:x, &Float:y, &Float:z);
  36. native GetVehicleDoorPos(vehicleid, door, &Float:x, &Float:y, &Float:z);
  37. native GetVehicleDoor0Pos(vehicleid, &Float:x, &Float:y, &Float:z);
  38. native GetVehicleDoor1Pos(vehicleid, &Float:x, &Float:y, &Float:z);
  39. native GetVehicleDoor2Pos(vehicleid, &Float:x, &Float:y, &Float:z);
  40. native GetVehicleDoor3Pos(vehicleid, &Float:x, &Float:y, &Float:z);
  41. native GetVehicleWheelPos(vehicleid, wheel, &Float:x, &Float:y, &Float:z);
  42. native GetVehicleWheel0Pos(vehicleid, &Float:x, &Float:y, &Float:z);
  43. native GetVehicleWheel1Pos(vehicleid, &Float:x, &Float:y, &Float:z);
  44. native GetVehicleWheel2Pos(vehicleid, &Float:x, &Float:y, &Float:z);
  45. native GetVehicleWheel3Pos(vehicleid, &Float:x, &Float:y, &Float:z);
  46. ================================================================================
  47. ================================================================================
  48.                                                                 Return 0 or 1;
  49. ================================================================================
  50. native IsPlayerNearVehicle(playerid, vehicleid, Float:Range=15.0, Float:MaxAngle=30.0);
  51. native IsPlayerNearVehicleBoot(playerid, vehicleid, Float:Range=1.5, Float:MaxAngle=30.0);
  52. native IsPlayerNearVehicleBonnet(playerid, vehicleid, Float:Range=1.5, Float:MaxAngle=30.0);
  53. native IsPlayerNearVehiclePetrolCap(playerid, vehicleid, Float:Range=0.75, Float:MaxAngle=30.0);
  54. native IsPlayerNearVehicleDoor(playerid, vehicleid, door, Float:Range=0.75, Float:MaxAngle=30.0);
  55. native IsPlayerNearVehicleDoor0(playerid, vehicleid, Float:Range=0.75, Float:MaxAngle=30.0);
  56. native IsPlayerNearVehicleDoor1(playerid, vehicleid, Float:Range=0.75, Float:MaxAngle=30.0);
  57. native IsPlayerNearVehicleDoor2(playerid, vehicleid, Float:Range=0.75, Float:MaxAngle=30.0);
  58. native IsPlayerNearVehicleDoor3(playerid, vehicleid, Float:Range=0.75, Float:MaxAngle=30.0);
  59. native IsPlayerNearVehicleWheel(playerid, vehicleid, wheel, Float:Range=0.75, Float:MaxAngle=30.0);
  60. native IsPlayerNearVehicleWheel0(playerid, vehicleid, Float:Range=0.75, Float:MaxAngle=30.0);
  61. native IsPlayerNearVehicleWheel1(playerid, vehicleid, Float:Range=0.75, Float:MaxAngle=30.0);
  62. native IsPlayerNearVehicleWheel2(playerid, vehicleid, Float:Range=0.75, Float:MaxAngle=30.0);
  63. native IsPlayerNearVehicleWheel3(playerid, vehicleid, Float:Range=0.75, Float:MaxAngle=30.0);
  64. ================================================================================
  65. \*============================================================================*/
  66. stock Float:GetAngleBetwen2Angles(Float:d, Float:a)
  67. {
  68.         if(floatcmp(d, a) >= 0) d=floatsub(d,a); else d=floatsub(a,d);
  69.         return (floatcmp(d, 180.0) > 0 ? floatabs(floatsub(360.0,d)) : d);
  70. }
  71. /*============================================================================*\
  72. ================================================================================
  73. \*============================================================================*/
  74. new Float:VehicleSizeY[212];
  75. new Float:VehicleSizeYD[212];
  76. new Float:VehicleDoorFA[212];
  77. new Float:VehicleDoorFD[212];
  78. new Float:VehicleDoorRA[212];
  79. new Float:VehicleDoorRD[212];
  80.  
  81. new Float:VehicleWheelFA[212];
  82. new Float:VehicleWheelFD[212];
  83. new Float:VehicleWheelRA[212];
  84. new Float:VehicleWheelRD[212];
  85. new Float:VehiclePetrolCapA[212];
  86. new Float:VehiclePetrolCapD[212];
  87. new Iterator:VehicleStreamFor[MAX_PLAYERS]<MAX_VEHICLES>;
  88. new W_MaxPassengers[212 char]={50397441, 50528257, 16974081, 16974081, 50397953,
  89. 50528513, 16777987, 50397192,65807, 17302273, 50331905, 16973825, 69377, 1, 16843523,
  90. 16843009, 16843523,16843521, 257, 65795, 16777985,3, 16843521, 50331905, 16974593,
  91. 16843009,16843011,16777217, 257, 50397440, 65793, 16843009, 16973824, 65793, 16843008,
  92. 50397441,16843523, 16843523, 16777473, 16843009, 50528513, 66307, 983296, 65537, 16843011,
  93. 50397952, 251855105, 16846607, 16843008, 50529025, 16843009, 50401039, 251858703};
  94. new W_BootSideDoor[212 char]={0xFFFFFFFF,...};
  95.  
  96.  
  97. new W_HasC,W_HasSO,W_HasSI;
  98. #if defined FILTERSCRIPT
  99. public OnFilterScriptInit()
  100. {
  101.     W_HasC=funcidx("W_OnPlayerConnect") != -1;
  102.     W_HasSO=funcidx("W_OnVehicleStreamOut") != -1;
  103.     W_HasSI=funcidx("W_OnVehicleStreamIn") != -1;
  104.  
  105.         W_BootSideDoor{209}=0;
  106.         W_BootSideDoor{182}=0;
  107.         W_BootSideDoor{98}=0;
  108.         W_BootSideDoor{82}=0;
  109.         W_BootSideDoor{59}=0;
  110.         W_BootSideDoor{40}=0;
  111.         W_BootSideDoor{28}=0;
  112.         W_BootSideDoor{16}=0;
  113.         W_BootSideDoor{27}=0;
  114.         W_BootSideDoor{13}=0;
  115.        
  116.         Iter_Init(VehicleStreamFor);
  117.         for(new Float:x,Float:y,Float:z, id; id < 212; id++)
  118.         {
  119.             GetVehicleModelInfo(id+400, 1, x, y, z);
  120.             VehicleSizeY[id]=0.25+(y/2.0);
  121.             VehicleSizeYD[id]=3.0+(y/2.0);
  122.  
  123.             GetVehicleModelInfo(id+400, VEHICLE_MODEL_INFO_PETROLCAP, x, y, z);
  124.             x+=0.25;
  125.                 VehiclePetrolCapD[id]=floatsqroot((x*x)+(y*y));
  126.                 VehiclePetrolCapA[id]=atan2(x, y);
  127.  
  128.                 GetVehicleModelInfo(id+400, VEHICLE_MODEL_INFO_FRONTSEAT, x, y, z);
  129.                 x+=1.0;
  130.                 VehicleDoorFD[id]=floatsqroot((x*x)+(y*y));
  131.                 VehicleDoorFA[id]=atan2(x, y);
  132.  
  133.                 if(W_BootSideDoor{id})
  134.                 {
  135.                         GetVehicleModelInfo(id+400, VEHICLE_MODEL_INFO_REARSEAT, x, y, z);
  136.                         x+=1.0;
  137.                         VehicleDoorRD[id]=floatsqroot((x*x)+(y*y));
  138.                         VehicleDoorRA[id]=atan2(x, y);
  139.                 }
  140.                 else
  141.                 {
  142.                         GetVehicleModelInfo(id+400, VEHICLE_MODEL_INFO_REARSEAT, x, y, z);
  143.                         y=-VehicleSizeY[id];
  144.                         x-=0.15;
  145.                         VehicleDoorRD[id]=floatsqroot((x*x)+(y*y));
  146.                         VehicleDoorRA[id]=atan2(x, y);
  147.                 }
  148.                
  149.                 GetVehicleModelInfo(id+400, VEHICLE_MODEL_INFO_WHEELSFRONT, x, y, z);
  150.                 x+=0.25;
  151.                 VehicleWheelFD[id]=floatsqroot((x*x)+(y*y));
  152.                 VehicleWheelFA[id]=atan2(x, y);
  153.  
  154.                 GetVehicleModelInfo(id+400, VEHICLE_MODEL_INFO_WHEELSREAR, x, y, z);
  155.                 x+=0.25;
  156.                 VehicleWheelRD[id]=floatsqroot((x*x)+(y*y));
  157.                 VehicleWheelRA[id]=atan2(x, y);
  158.     }
  159.         if(funcidx("W_OnFilterScriptInit") != -1)
  160.     {
  161.         return CallLocalFunction("W_OnFilterScriptInit", "");
  162.     }
  163.     return 1;
  164. }
  165. #if defined _ALS_OnFilterScriptInit
  166.     #undef OnFilterScriptInit
  167. #else
  168.     #define _ALS_OnFilterScriptInit
  169. #endif
  170. #define OnFilterScriptInit W_OnFilterScriptInit
  171. forward W_OnFilterScriptInit();
  172. #else /*not a filterscript*/
  173. public OnGameModeInit()
  174. {
  175.     W_HasC=funcidx("W_OnPlayerConnect") != -1;
  176.     W_HasSO=funcidx("W_OnVehicleStreamOut") != -1;
  177.     W_HasSI=funcidx("W_OnVehicleStreamIn") != -1;
  178.    
  179.         W_BootSideDoor{209}=0;
  180.         W_BootSideDoor{182}=0;
  181.         W_BootSideDoor{98}=0;
  182.         W_BootSideDoor{82}=0;
  183.         W_BootSideDoor{59}=0;
  184.         W_BootSideDoor{40}=0;
  185.         W_BootSideDoor{28}=0;
  186.         W_BootSideDoor{16}=0;
  187.         W_BootSideDoor{27}=0;
  188.         W_BootSideDoor{13}=0;
  189.        
  190.         Iter_Init(VehicleStreamFor);
  191.         for(new Float:x,Float:y,Float:z, id; id < 212; id++)
  192.         {
  193.             GetVehicleModelInfo(id+400, 1, x, y, z);
  194.             VehicleSizeY[id]=0.25+(y/2.0);
  195.             VehicleSizeYD[id]=3.0+(y/2.0);
  196.  
  197.             GetVehicleModelInfo(id+400, VEHICLE_MODEL_INFO_PETROLCAP, x, y, z);
  198.             x+=0.25;
  199.                 VehiclePetrolCapD[id]=floatsqroot((x*x)+(y*y));
  200.                 VehiclePetrolCapA[id]=atan2(x, y);
  201.  
  202.                 GetVehicleModelInfo(id+400, VEHICLE_MODEL_INFO_FRONTSEAT, x, y, z);
  203.                 x+=1.0;
  204.                 VehicleDoorFD[id]=floatsqroot((x*x)+(y*y));
  205.                 VehicleDoorFA[id]=atan2(x, y);
  206.  
  207.                 if(W_BootSideDoor{id})
  208.                 {
  209.                         GetVehicleModelInfo(id+400, VEHICLE_MODEL_INFO_REARSEAT, x, y, z);
  210.                         x+=1.0;
  211.                         VehicleDoorRD[id]=floatsqroot((x*x)+(y*y));
  212.                         VehicleDoorRA[id]=atan2(x, y);
  213.                 }
  214.                 else
  215.                 {
  216.                         GetVehicleModelInfo(id+400, VEHICLE_MODEL_INFO_REARSEAT, x, y, z);
  217.                         y=-VehicleSizeY[id];
  218.                         x-=0.15;
  219.                         VehicleDoorRD[id]=floatsqroot((x*x)+(y*y));
  220.                         VehicleDoorRA[id]=atan2(x, y);
  221.                 }
  222.                
  223.                 GetVehicleModelInfo(id+400, VEHICLE_MODEL_INFO_WHEELSFRONT, x, y, z);
  224.                 x+=0.25;
  225.                 VehicleWheelFD[id]=floatsqroot((x*x)+(y*y));
  226.                 VehicleWheelFA[id]=atan2(x, y);
  227.  
  228.                 GetVehicleModelInfo(id+400, VEHICLE_MODEL_INFO_WHEELSREAR, x, y, z);
  229.                 x+=0.25;
  230.                 VehicleWheelRD[id]=floatsqroot((x*x)+(y*y));
  231.                 VehicleWheelRA[id]=atan2(x, y);
  232.     }
  233.         if(funcidx("W_OnGameModeInit") != -1)
  234.     {
  235.         return CallLocalFunction("W_OnGameModeInit", "");
  236.     }
  237.     return 1;
  238. }
  239. #if defined _ALS_OnGameModeInit
  240.     #undef OnGameModeInit
  241. #else
  242.     #define _ALS_OnGameModeInit
  243. #endif
  244. #define OnGameModeInit W_OnGameModeInit
  245. forward W_OnGameModeInit();
  246. #endif /*if defined FILTERSCRIPT*/
  247. //------------------------------------------------------------------------------
  248. public OnPlayerConnect(playerid)
  249. {
  250.     Iter_Clear(VehicleStreamFor[playerid]);
  251.     if(W_HasC)return CallLocalFunction("W_OnPlayerConnect", "i",playerid);
  252.         return 1;
  253. }
  254. #if defined _ALS_OnPlayerConnect
  255.     #undef OnPlayerConnect
  256. #else
  257.     #define _ALS_OnPlayerConnect
  258. #endif
  259. #define OnPlayerConnect W_OnPlayerConnect
  260. forward W_OnPlayerConnect(playerid);
  261. //------------------------------------------------------------------------------
  262. public OnVehicleStreamIn(vehicleid, forplayerid)
  263. {
  264.         if(IsPlayerNPC(forplayerid)) return 1;
  265.         Iter_Add(VehicleStreamFor[forplayerid],vehicleid);
  266.         if(W_HasSI)return CallLocalFunction("W_OnVehicleStreamIn", "ii", vehicleid, forplayerid);
  267.         return 1;
  268.        
  269. }
  270. #if defined _ALS_OnVehicleStreamIn
  271.     #undef OnVehicleStreamIn
  272. #else
  273.     #define _ALS_OnVehicleStreamIn
  274. #endif
  275. #define OnVehicleStreamIn W_OnVehicleStreamIn
  276. forward W_OnVehicleStreamIn(vehicleid, forplayerid);
  277. //------------------------------------------------------------------------------
  278. public OnVehicleStreamOut(vehicleid, forplayerid)
  279. {
  280.     if(IsPlayerNPC(forplayerid)) return 1;
  281.         Iter_Remove(VehicleStreamFor[forplayerid], vehicleid);
  282.         if(W_HasSO)return CallLocalFunction("W_OnVehicleStreamOut", "ii", vehicleid, forplayerid);
  283.         return 1;
  284. }
  285. #if defined _ALS_OnVehicleStreamOut
  286.     #undef OnVehicleStreamOut
  287. #else
  288.     #define _ALS_OnVehicleStreamOut
  289. #endif
  290. #define OnVehicleStreamOut W_OnVehicleStreamOut
  291. forward W_OnVehicleStreamOut(vehicleid, forplayerid);
  292. //------------------------------------------------------------------------------
  293. stock GetVehicleIfPlayerNearVehicle(playerid, Float:Range=15.0, Float:MaxAngle=30.0)
  294. {
  295.     new Float:x,Float:y,Float:z,Float:a,Float:d, Float:rx,Float:ry,Float:rz;
  296.     foreach(new vehicleid : VehicleStreamFor[playerid])
  297.         {
  298.             if(!IsValidVehicle(vehicleid))continue;
  299.                 GetVehiclePos(vehicleid, x, y, z);
  300.                 if(IsPlayerInRangeOfPoint(playerid, Range, x, y, z))
  301.                 {
  302.                     if(MaxAngle>=180.0)return vehicleid;
  303.                         GetPlayerFacingAngle(playerid, d);
  304.                     GetPlayerPos(playerid, rx, ry, rz);
  305.                     if((a=atan2(x-rx,y-ry)) < 0)a*=-1;else a=360-a;
  306.                         if(floatcmp(MaxAngle, GetAngleBetwen2Angles(d, a)) == 1)return vehicleid;
  307.                 }
  308.         }
  309.         return 0;
  310. }
  311.  
  312. stock GetVehicleIfPlayerNearBoot(playerid, Float:Range=1.5, Float:MaxAngle=30.0)
  313. {
  314.     new m, Float:x,Float:y,Float:z,Float:a,Float:d;
  315.     GetPlayerFacingAngle(playerid, d);
  316.         foreach(new vehicleid : VehicleStreamFor[playerid])
  317.         {
  318.             if((m=GetVehicleModel(vehicleid)-400) < 0)continue;
  319.         GetVehiclePos(vehicleid, x, y, z);
  320.         if(IsPlayerInRangeOfPoint(playerid,VehicleSizeYD[m],x,y,z))
  321.         {
  322.             GetVehicleZAngle(vehicleid, a);
  323.                 x+=(VehicleSizeY[m] * floatsin(a, degrees));
  324.                 y-=(VehicleSizeY[m] * floatcos(a, degrees));
  325.                         if(IsPlayerInRangeOfPoint(playerid, Range, x, y, z))
  326.                         {
  327.                                 if(floatcmp(MaxAngle, GetAngleBetwen2Angles(d, a)) == 1)return vehicleid;
  328.                         }
  329.                 }
  330.         }
  331.         return INVALID_VEHICLE_ID;
  332. }
  333.  
  334. stock GetVehicleIfPlayerNearBonnet(playerid, Float:Range=1.5, Float:MaxAngle=30.0)
  335. {
  336.     new m, Float:x,Float:y,Float:z,Float:a,Float:d;
  337.     GetPlayerFacingAngle(playerid, d); d+=180.0;
  338.         foreach(new vehicleid : VehicleStreamFor[playerid])
  339.         {
  340.             if((m=GetVehicleModel(vehicleid)-400) < 0)continue;
  341.         GetVehiclePos(vehicleid, x, y, z);
  342.         if(IsPlayerInRangeOfPoint(playerid,VehicleSizeYD[m],x,y,z))
  343.         {
  344.             GetVehicleZAngle(vehicleid, a);
  345.                 x-=(VehicleSizeY[m] * floatsin(a, degrees));
  346.                 y+=(VehicleSizeY[m] * floatcos(a, degrees));
  347.                         if(IsPlayerInRangeOfPoint(playerid, Range, x, y, z))
  348.                         {
  349.                                 if(floatcmp(MaxAngle, GetAngleBetwen2Angles(d, a)) == 1)return vehicleid;
  350.                         }
  351.                 }
  352.         }
  353.         return INVALID_VEHICLE_ID;
  354. }
  355.  
  356. stock GetVehicleIfPlayerNearPetrolCap(playerid, Float:Range=0.75, Float:MaxAngle=30.0)
  357. {
  358.     new m, Float:x,Float:y,Float:z,Float:a,Float:d;
  359.     GetPlayerFacingAngle(playerid, d);
  360.         foreach(new vehicleid : VehicleStreamFor[playerid])
  361.         {
  362.             if((m=GetVehicleModel(vehicleid)-400) < 0)continue;
  363.         GetVehiclePos(vehicleid, x, y, z);
  364.         if(IsPlayerInRangeOfPoint(playerid,VehicleSizeYD[m],x,y,z))
  365.         {
  366.             GetVehicleZAngle(vehicleid, a);
  367.                         x+=VehiclePetrolCapD[m]*floatsin(VehiclePetrolCapA[m]-a,degrees);
  368.                         y+=VehiclePetrolCapD[m]*floatcos(VehiclePetrolCapA[m]-a,degrees);
  369.                         if(IsPlayerInRangeOfPoint(playerid, Range, x, y, z))
  370.                         {
  371.                                 if(VehiclePetrolCapA[m] >= 0.0)x=d+270.0; else x=d+90.0;
  372.                                 if(floatcmp(MaxAngle, GetAngleBetwen2Angles(x, a)) == 1)return vehicleid;
  373.                         }
  374.                 }
  375.         }
  376.         return INVALID_VEHICLE_ID;
  377. }
  378.  
  379. stock GetVehicleIfPlayerNearDoor(playerid, door, Float:Range=0.75, Float:MaxAngle=30.0)
  380. {
  381.         switch(door)
  382.         {
  383.                 case 0: return GetVehicleIfPlayerNearDoor0(playerid, Range, MaxAngle);
  384.                 case 1: return GetVehicleIfPlayerNearDoor1(playerid, Range, MaxAngle);
  385.                 case 2: return GetVehicleIfPlayerNearDoor2(playerid, Range, MaxAngle);
  386.                 case 3: return GetVehicleIfPlayerNearDoor3(playerid, Range, MaxAngle);
  387.         }
  388.     return INVALID_VEHICLE_ID;
  389. }
  390.  
  391. stock GetVehicleIfPlayerNearDoor0(playerid, Float:Range=0.75, Float:MaxAngle=30.0)
  392. {
  393.     new m, Float:x,Float:y,Float:z,Float:a,Float:d;
  394.     GetPlayerFacingAngle(playerid, d); d+=90.0;
  395.         foreach(new vehicleid : VehicleStreamFor[playerid])
  396.         {
  397.             if((m=GetVehicleModel(vehicleid)-400) < 0)continue;
  398.         GetVehiclePos(vehicleid, x, y, z);
  399.         if(IsPlayerInRangeOfPoint(playerid,VehicleSizeYD[m],x,y,z))
  400.         {
  401.             GetVehicleZAngle(vehicleid, a);
  402.                         x+=VehicleDoorFD[m]*floatsin(-VehicleDoorFA[m]-a,degrees);
  403.                         y+=VehicleDoorFD[m]*floatcos(-VehicleDoorFA[m]-a,degrees);
  404.                         if(IsPlayerInRangeOfPoint(playerid, Range, x, y, z))
  405.                         {
  406.                                 if(floatcmp(MaxAngle, GetAngleBetwen2Angles(d, a)) == 1)return vehicleid;
  407.                         }
  408.                 }
  409.         }
  410.         return INVALID_VEHICLE_ID;
  411. }
  412.  
  413. stock GetVehicleIfPlayerNearDoor1(playerid, Float:Range=0.75, Float:MaxAngle=30.0)
  414. {
  415.     new m, Float:x,Float:y,Float:z,Float:a,Float:d;
  416.     GetPlayerFacingAngle(playerid, d); d+=270.0;
  417.         foreach(new vehicleid : VehicleStreamFor[playerid])
  418.         {
  419.                 if((m=GetVehicleModel(vehicleid)-400) < 0)continue;
  420.             if(W_MaxPassengers{m} < 1)continue;
  421.         GetVehiclePos(vehicleid, x, y, z);
  422.         if(IsPlayerInRangeOfPoint(playerid,VehicleSizeYD[m],x,y,z))
  423.         {
  424.             GetVehicleZAngle(vehicleid, a);
  425.                         x+=VehicleDoorFD[m]*floatsin(VehicleDoorFA[m]-a,degrees);
  426.                         y+=VehicleDoorFD[m]*floatcos(VehicleDoorFA[m]-a,degrees);
  427.                         if(IsPlayerInRangeOfPoint(playerid, Range, x, y, z))
  428.                         {
  429.                                 if(floatcmp(MaxAngle, GetAngleBetwen2Angles(d, a)) == 1)return vehicleid;
  430.                         }
  431.                 }
  432.         }
  433.         return INVALID_VEHICLE_ID;
  434. }
  435.  
  436. stock GetVehicleIfPlayerNearDoor2(playerid, Float:Range=0.75, Float:MaxAngle=30.0)
  437. {
  438.     new m, Float:x,Float:y,Float:z,Float:a,Float:d;
  439.     GetPlayerFacingAngle(playerid, d);
  440.         foreach(new vehicleid : VehicleStreamFor[playerid])
  441.         {
  442.             if((m=GetVehicleModel(vehicleid)-400) < 0)continue;
  443.             if(W_MaxPassengers{m} < 2)continue;
  444.         GetVehiclePos(vehicleid, x, y, z);
  445.         if(IsPlayerInRangeOfPoint(playerid,VehicleSizeYD[m],x,y,z))
  446.         {
  447.             GetVehicleZAngle(vehicleid, a);
  448.                         x+=VehicleDoorRD[m]*floatsin(-VehicleDoorRA[m]-a,degrees);
  449.                         y+=VehicleDoorRD[m]*floatcos(-VehicleDoorRA[m]-a,degrees);
  450.                         if(IsPlayerInRangeOfPoint(playerid, Range, x, y, z))
  451.                         {
  452.                             if(W_BootSideDoor{m})x=d+90.0;
  453.                                 if(floatcmp(MaxAngle, GetAngleBetwen2Angles(x, a)) == 1)return vehicleid;
  454.                         }
  455.                 }
  456.         }
  457.         return INVALID_VEHICLE_ID;
  458. }
  459.  
  460. stock GetVehicleIfPlayerNearDoor3(playerid, Float:Range=0.75, Float:MaxAngle=30.0)
  461. {
  462.     new m, Float:x,Float:y,Float:z,Float:a,Float:d;
  463.     GetPlayerFacingAngle(playerid, d);
  464.         foreach(new vehicleid : VehicleStreamFor[playerid])
  465.         {
  466.             if((m=GetVehicleModel(vehicleid)-400) < 0)continue;
  467.             if(W_MaxPassengers{m} < 3)continue;
  468.         GetVehiclePos(vehicleid, x, y, z);
  469.         if(IsPlayerInRangeOfPoint(playerid,VehicleSizeYD[m],x,y,z))
  470.         {
  471.             GetVehicleZAngle(vehicleid, a);
  472.                         x+=VehicleDoorRD[m]*floatsin(VehicleDoorRA[m]-a,degrees);
  473.                         y+=VehicleDoorRD[m]*floatcos(VehicleDoorRA[m]-a,degrees);
  474.                         if(IsPlayerInRangeOfPoint(playerid, Range, x, y, z))
  475.                         {
  476.                             if(W_BootSideDoor{m})x=d+270.0;
  477.                                 if(floatcmp(MaxAngle, GetAngleBetwen2Angles(x, a)) == 1)return vehicleid;
  478.                         }
  479.                 }
  480.         }
  481.         return INVALID_VEHICLE_ID;
  482. }
  483.  
  484.  
  485. stock GetVehicleIfPlayerNearWheel(playerid, wheel, Float:Range=0.75, Float:MaxAngle=30.0)
  486. {
  487.         switch(wheel)
  488.         {
  489.                 case 0: return GetVehicleIfPlayerNearWheel0(playerid, Range, MaxAngle);
  490.                 case 1: return GetVehicleIfPlayerNearWheel1(playerid, Range, MaxAngle);
  491.                 case 2: return GetVehicleIfPlayerNearWheel2(playerid, Range, MaxAngle);
  492.                 case 3: return GetVehicleIfPlayerNearWheel3(playerid, Range, MaxAngle);
  493.         }
  494.     return INVALID_VEHICLE_ID;
  495. }
  496.  
  497. stock GetVehicleIfPlayerNearWheel0(playerid, Float:Range=0.75, Float:MaxAngle=30.0)
  498. {
  499.     new m, Float:x,Float:y,Float:z,Float:a,Float:d;
  500.     GetPlayerFacingAngle(playerid, d); d+=90.0;
  501.         foreach(new vehicleid : VehicleStreamFor[playerid])
  502.         {
  503.             if((m=GetVehicleModel(vehicleid)-400) < 0)continue;
  504.         GetVehiclePos(vehicleid, x, y, z);
  505.         if(IsPlayerInRangeOfPoint(playerid,VehicleSizeYD[m],x,y,z))
  506.         {
  507.             GetVehicleZAngle(vehicleid, a);
  508.                         x+=VehicleWheelFD[m]*floatsin(-VehicleWheelFA[m]-a,degrees);
  509.                         y+=VehicleWheelFD[m]*floatcos(-VehicleWheelFA[m]-a,degrees);
  510.                         if(IsPlayerInRangeOfPoint(playerid, Range, x, y, z))
  511.                         {
  512.                                 if(floatcmp(MaxAngle, GetAngleBetwen2Angles(d, a)) == 1)return vehicleid;
  513.                         }
  514.                 }
  515.         }
  516.         return INVALID_VEHICLE_ID;
  517. }
  518.  
  519. stock GetVehicleIfPlayerNearWheel1(playerid, Float:Range=0.75, Float:MaxAngle=30.0)
  520. {
  521.     new m, Float:x,Float:y,Float:z,Float:a,Float:d;
  522.     GetPlayerFacingAngle(playerid, d); d+=270.0;
  523.         foreach(new vehicleid : VehicleStreamFor[playerid])
  524.         {
  525.                 if((m=GetVehicleModel(vehicleid)-400) < 0)continue;
  526.         GetVehiclePos(vehicleid, x, y, z);
  527.         if(IsPlayerInRangeOfPoint(playerid,VehicleSizeYD[m],x,y,z))
  528.         {
  529.             GetVehicleZAngle(vehicleid, a);
  530.                         x+=VehicleWheelFD[m]*floatsin(VehicleWheelFA[m]-a,degrees);
  531.                         y+=VehicleWheelFD[m]*floatcos(VehicleWheelFA[m]-a,degrees);
  532.                         if(IsPlayerInRangeOfPoint(playerid, Range, x, y, z))
  533.                         {
  534.                                 if(floatcmp(MaxAngle, GetAngleBetwen2Angles(d, a)) == 1)return vehicleid;
  535.                         }
  536.                 }
  537.         }
  538.         return INVALID_VEHICLE_ID;
  539. }
  540.  
  541. stock GetVehicleIfPlayerNearWheel2(playerid, Float:Range=0.75, Float:MaxAngle=30.0)
  542. {
  543.     new m, Float:x,Float:y,Float:z,Float:a,Float:d;
  544.     GetPlayerFacingAngle(playerid, d); d+=90.0;
  545.         foreach(new vehicleid : VehicleStreamFor[playerid])
  546.         {
  547.             if((m=GetVehicleModel(vehicleid)-400) < 0)continue;
  548.         GetVehiclePos(vehicleid, x, y, z);
  549.         if(IsPlayerInRangeOfPoint(playerid,VehicleSizeYD[m],x,y,z))
  550.         {
  551.             GetVehicleZAngle(vehicleid, a);
  552.                         x+=VehicleWheelRD[m]*floatsin(-VehicleWheelRA[m]-a,degrees);
  553.                         y+=VehicleWheelRD[m]*floatcos(-VehicleWheelRA[m]-a,degrees);
  554.                         if(IsPlayerInRangeOfPoint(playerid, Range, x, y, z))
  555.                         {
  556.                                 if(floatcmp(MaxAngle, GetAngleBetwen2Angles(d, a)) == 1)return vehicleid;
  557.                         }
  558.                 }
  559.         }
  560.         return INVALID_VEHICLE_ID;
  561. }
  562.  
  563. stock GetVehicleIfPlayerNearWheel3(playerid, Float:Range=0.75, Float:MaxAngle=30.0)
  564. {
  565.     new m, Float:x,Float:y,Float:z,Float:a,Float:d;
  566.     GetPlayerFacingAngle(playerid, d); d+=270.0;
  567.         foreach(new vehicleid : VehicleStreamFor[playerid])
  568.         {
  569.             if((m=GetVehicleModel(vehicleid)-400) < 0)continue;
  570.         GetVehiclePos(vehicleid, x, y, z);
  571.         if(IsPlayerInRangeOfPoint(playerid,VehicleSizeYD[m],x,y,z))
  572.         {
  573.             GetVehicleZAngle(vehicleid, a);
  574.                         x+=VehicleWheelRD[m]*floatsin(VehicleWheelRA[m]-a,degrees);
  575.                         y+=VehicleWheelRD[m]*floatcos(VehicleWheelRA[m]-a,degrees);
  576.                         if(IsPlayerInRangeOfPoint(playerid, Range, x, y, z))
  577.                         {
  578.                                 if(floatcmp(MaxAngle, GetAngleBetwen2Angles(d, a)) == 1)return vehicleid;
  579.                         }
  580.                 }
  581.         }
  582.         return INVALID_VEHICLE_ID;
  583. }
  584.  
  585. //******************************************************************************
  586. //******************************************************************************
  587. //******************************************************************************
  588. stock GetVehicleBootPos(vehicleid, &Float:x, &Float:y, &Float:z)
  589. {
  590.         new m=GetVehicleModel(vehicleid)-400;if(m<0)return 0;
  591.     new Float:a;
  592.     GetVehicleZAngle(vehicleid, a);
  593.     GetVehiclePos(vehicleid, x, y, z);
  594.     x+=(VehicleSizeY[m] * floatsin(a, degrees));
  595.         y-=(VehicleSizeY[m] * floatcos(a, degrees));
  596.     return 1;
  597. }
  598.  
  599. stock GetVehicleBonnetPos(vehicleid, &Float:x, &Float:y, &Float:z)
  600. {
  601.         new m=GetVehicleModel(vehicleid)-400;if(m<0)return 0;
  602.     new Float:a;
  603.     GetVehicleZAngle(vehicleid, a);
  604.     GetVehiclePos(vehicleid, x, y, z);
  605.     x-=(VehicleSizeY[m] * floatsin(a, degrees));
  606.         y+=(VehicleSizeY[m] * floatcos(a, degrees));
  607.     return 1;
  608. }
  609.  
  610. stock GetVehiclePetrolCapPos(vehicleid, &Float:x, &Float:y, &Float:z)
  611. {
  612.         new m=GetVehicleModel(vehicleid)-400;if(m<0)return 0;
  613.     new Float:a;
  614.     GetVehicleZAngle(vehicleid, a);
  615.     GetVehiclePos(vehicleid, x, y, z);
  616.         x+=VehiclePetrolCapD[m]*floatsin(VehiclePetrolCapA[m]-a,degrees);
  617.         y+=VehiclePetrolCapD[m]*floatcos(VehiclePetrolCapA[m]-a,degrees);
  618.     return 1;
  619. }
  620.  
  621. stock GetVehicleDoorPos(vehicleid, door, &Float:x, &Float:y, &Float:z)
  622. {
  623.         switch(door)
  624.         {
  625.                 case 0: return GetVehicleDoor0Pos(vehicleid, x, y, z);
  626.                 case 1: return GetVehicleDoor1Pos(vehicleid, x, y, z);
  627.                 case 2: return GetVehicleDoor2Pos(vehicleid, x, y, z);
  628.                 case 3: return GetVehicleDoor3Pos(vehicleid, x, y, z);
  629.         }
  630.     return 0;
  631. }
  632.  
  633. stock GetVehicleDoor0Pos(vehicleid, &Float:x, &Float:y, &Float:z)
  634. {
  635.         new m=GetVehicleModel(vehicleid)-400;if(m<0)return 0;
  636.     new Float:a;
  637.     GetVehicleZAngle(vehicleid, a);
  638.     GetVehiclePos(vehicleid, x, y, z);
  639.         x+=VehicleDoorFD[m]*floatsin(-VehicleDoorFA[m]-a,degrees);
  640.         y+=VehicleDoorFD[m]*floatcos(-VehicleDoorFA[m]-a,degrees);
  641.     return 1;
  642. }
  643.  
  644. stock GetVehicleDoor1Pos(vehicleid, &Float:x, &Float:y, &Float:z)
  645. {
  646.         new m=GetVehicleModel(vehicleid)-400;if(m<0)return 0;
  647.     new Float:a;
  648.     GetVehicleZAngle(vehicleid, a);
  649.     GetVehiclePos(vehicleid, x, y, z);
  650.         x+=VehicleDoorFD[m]*floatsin(VehicleDoorFA[m]-a,degrees);
  651.         y+=VehicleDoorFD[m]*floatcos(VehicleDoorFA[m]-a,degrees);
  652.     return 1;
  653. }
  654.  
  655. stock GetVehicleDoor2Pos(vehicleid, &Float:x, &Float:y, &Float:z)
  656. {
  657.         new m=GetVehicleModel(vehicleid)-400;if(m<0)return 0;
  658.     new Float:a;
  659.     GetVehicleZAngle(vehicleid, a);
  660.     GetVehiclePos(vehicleid, x, y, z);
  661.         x+=VehicleDoorRD[m]*floatsin(-VehicleDoorRA[m]-a,degrees);
  662.         y+=VehicleDoorRD[m]*floatcos(-VehicleDoorRA[m]-a,degrees);
  663.     return 1;
  664. }
  665.  
  666. stock GetVehicleDoor3Pos(vehicleid, &Float:x, &Float:y, &Float:z)
  667. {
  668.         new m=GetVehicleModel(vehicleid)-400;if(m<0)return 0;
  669.     new Float:a;
  670.     GetVehicleZAngle(vehicleid, a);
  671.     GetVehiclePos(vehicleid, x, y, z);
  672.         x+=VehicleDoorRD[m]*floatsin(VehicleDoorRA[m]-a,degrees);
  673.         y+=VehicleDoorRD[m]*floatcos(VehicleDoorRA[m]-a,degrees);
  674.     return 1;
  675. }
  676.  
  677. stock GetVehicleWheelPos(vehicleid, wheel, &Float:x, &Float:y, &Float:z)
  678. {
  679.         switch(wheel)
  680.         {
  681.                 case 0: return GetVehicleWheel0Pos(vehicleid, x, y, z);
  682.                 case 1: return GetVehicleWheel1Pos(vehicleid, x, y, z);
  683.                 case 2: return GetVehicleWheel2Pos(vehicleid, x, y, z);
  684.                 case 3: return GetVehicleWheel3Pos(vehicleid, x, y, z);
  685.         }
  686.     return 0;
  687. }
  688.  
  689. stock GetVehicleWheel0Pos(vehicleid, &Float:x, &Float:y, &Float:z)
  690. {
  691.         new m=GetVehicleModel(vehicleid)-400;if(m<0)return 0;
  692.     new Float:a;
  693.     GetVehicleZAngle(vehicleid, a);
  694.     GetVehiclePos(vehicleid, x, y, z);
  695.         x+=VehicleWheelFD[m]*floatsin(-VehicleWheelFA[m]-a,degrees);
  696.         y+=VehicleWheelFD[m]*floatcos(-VehicleWheelFA[m]-a,degrees);
  697.     return 1;
  698. }
  699.  
  700. stock GetVehicleWheel1Pos(vehicleid, &Float:x, &Float:y, &Float:z)
  701. {
  702.         new m=GetVehicleModel(vehicleid)-400;if(m<0)return 0;
  703.     new Float:a;
  704.     GetVehicleZAngle(vehicleid, a);
  705.     GetVehiclePos(vehicleid, x, y, z);
  706.         x+=VehicleWheelFD[m]*floatsin(VehicleWheelFA[m]-a,degrees);
  707.         y+=VehicleWheelFD[m]*floatcos(VehicleWheelFA[m]-a,degrees);
  708.     return 1;
  709. }
  710.  
  711. stock GetVehicleWheel2Pos(vehicleid, &Float:x, &Float:y, &Float:z)
  712. {
  713.         new m=GetVehicleModel(vehicleid)-400;if(m<0)return 0;
  714.     new Float:a;
  715.     GetVehicleZAngle(vehicleid, a);
  716.     GetVehiclePos(vehicleid, x, y, z);
  717.         x+=VehicleWheelRD[m]*floatsin(-VehicleWheelRA[m]-a,degrees);
  718.         y+=VehicleWheelRD[m]*floatcos(-VehicleWheelRA[m]-a,degrees);
  719.     return 1;
  720. }
  721.  
  722. stock GetVehicleWheel3Pos(vehicleid, &Float:x, &Float:y, &Float:z)
  723. {
  724.         new m=GetVehicleModel(vehicleid)-400;if(m<0)return 0;
  725.     new Float:a;
  726.     GetVehicleZAngle(vehicleid, a);
  727.     GetVehiclePos(vehicleid, x, y, z);
  728.         x+=VehicleWheelRD[m]*floatsin(VehicleWheelRA[m]-a,degrees);
  729.         y+=VehicleWheelRD[m]*floatcos(VehicleWheelRA[m]-a,degrees);
  730.     return 1;
  731. }
  732. //******************************************************************************
  733. //******************************************************************************
  734. //******************************************************************************
  735. stock IsPlayerNearVehicle(playerid, vehicleid, Float:Range=15.0, Float:MaxAngle=30.0)
  736. {
  737.     new  Float:x,Float:y,Float:z,Float:a,Float:d, Float:rx,Float:ry,Float:rz;
  738.     if(!IsValidVehicle(vehicleid))return 0;
  739.         GetVehiclePos(vehicleid, x, y, z);
  740.         if(IsPlayerInRangeOfPoint(playerid, Range, x, y, z))
  741.         {
  742.             if(MaxAngle>=180.0)return vehicleid;
  743.                 GetPlayerFacingAngle(playerid, d);
  744.             GetPlayerPos(playerid, rx, ry, rz);
  745.             if((a=atan2(x-rx,y-ry)) < 0)a*=-1;else a=360-a;
  746.         if(floatcmp(MaxAngle, GetAngleBetwen2Angles(d, a)) == 1)return 1;
  747.         }
  748.         return 0;
  749. }
  750.  
  751. stock IsPlayerNearVehicleBoot(playerid, vehicleid, Float:Range=1.5, Float:MaxAngle=30.0)
  752. {
  753.     new m, Float:x,Float:y,Float:z,Float:a,Float:d;
  754.     if((m=GetVehicleModel(vehicleid)-400) < 0)return 0;
  755.     GetPlayerFacingAngle(playerid, d);
  756.     GetVehiclePos(vehicleid, x, y, z);
  757.     GetVehicleZAngle(vehicleid, a);
  758.     x+=(VehicleSizeY[m] * floatsin(a, degrees));
  759.         y-=(VehicleSizeY[m] * floatcos(a, degrees));
  760.         if(IsPlayerInRangeOfPoint(playerid, Range, x, y, z))
  761.         {
  762.                 if(floatcmp(MaxAngle, GetAngleBetwen2Angles(d, a)) == 1)return 1;
  763.         }
  764.         return 0;
  765. }
  766.  
  767. stock IsPlayerNearVehicleBonnet(playerid, vehicleid, Float:Range=1.5, Float:MaxAngle=30.0)
  768. {
  769.     new m, Float:x,Float:y,Float:z,Float:a,Float:d;
  770.     if((m=GetVehicleModel(vehicleid)-400) < 0)return 0;
  771.     GetPlayerFacingAngle(playerid, d); d+=180.0;
  772.         GetVehiclePos(vehicleid, x, y, z);
  773.     GetVehicleZAngle(vehicleid, a);
  774.     x-=(VehicleSizeY[m] * floatsin(a, degrees));
  775.         y+=(VehicleSizeY[m] * floatcos(a, degrees));
  776.         if(IsPlayerInRangeOfPoint(playerid, Range, x, y, z))
  777.         {
  778.                 if(floatcmp(MaxAngle, GetAngleBetwen2Angles(d, a)) == 1)return 1;
  779.         }
  780.         return 0;
  781. }
  782.  
  783. stock IsPlayerNearVehiclePetrolCap(playerid, vehicleid, Float:Range=0.75, Float:MaxAngle=30.0)
  784. {
  785.     new m, Float:x,Float:y,Float:z,Float:a,Float:d;
  786.     if((m=GetVehicleModel(vehicleid)-400) < 0)return 0;
  787.     GetPlayerFacingAngle(playerid, d);
  788.     GetVehiclePos(vehicleid, x, y, z);
  789.     GetVehicleZAngle(vehicleid, a);
  790.         x+=VehiclePetrolCapD[m]*floatsin(VehiclePetrolCapA[m]-a,degrees);
  791.         y+=VehiclePetrolCapD[m]*floatcos(VehiclePetrolCapA[m]-a,degrees);
  792.         if(IsPlayerInRangeOfPoint(playerid, Range, x, y, z))
  793.         {
  794.                 if(VehiclePetrolCapA[m] >= 0.0)d+=270.0; else d+=90.0;
  795.                 if(floatcmp(MaxAngle, GetAngleBetwen2Angles(d, a)) == 1)return 1;
  796.         }
  797.         return 0;
  798. }
  799.  
  800. stock IsPlayerNearVehicleDoor(playerid, vehicleid, door, Float:Range=0.75, Float:MaxAngle=30.0)
  801. {
  802.         switch(door)
  803.         {
  804.                 case 0: return IsPlayerNearVehicleDoor0(playerid, vehicleid, Range, MaxAngle);
  805.                 case 1: return IsPlayerNearVehicleDoor1(playerid, vehicleid, Range, MaxAngle);
  806.                 case 2: return IsPlayerNearVehicleDoor2(playerid, vehicleid, Range, MaxAngle);
  807.                 case 3: return IsPlayerNearVehicleDoor3(playerid, vehicleid, Range, MaxAngle);
  808.         }
  809.     return 0;
  810. }
  811.  
  812. stock IsPlayerNearVehicleDoor0(playerid, vehicleid, Float:Range=0.75, Float:MaxAngle=30.0)
  813. {
  814.     new m, Float:x,Float:y,Float:z,Float:a,Float:d;
  815.     if((m=GetVehicleModel(vehicleid)-400) < 0)return 0;
  816.     GetPlayerFacingAngle(playerid, d);d+=90.0;
  817.     GetVehiclePos(vehicleid, x, y, z);
  818.         GetVehicleZAngle(vehicleid, a);
  819.         x+=VehicleDoorFD[m]*floatsin(-VehicleDoorFA[m]-a,degrees);
  820.         y+=VehicleDoorFD[m]*floatcos(-VehicleDoorFA[m]-a,degrees);
  821.         if(IsPlayerInRangeOfPoint(playerid, Range, x, y, z))
  822.         {
  823.                 if(floatcmp(MaxAngle, GetAngleBetwen2Angles(d, a)) == 1)return 1;
  824.         }
  825.         return 0;
  826. }
  827.  
  828. stock IsPlayerNearVehicleDoor1(playerid, vehicleid, Float:Range=0.75, Float:MaxAngle=30.0)
  829. {
  830.     new m, Float:x,Float:y,Float:z,Float:a,Float:d;
  831.         if((m=GetVehicleModel(vehicleid)-400) < 0)return 0;
  832.     if(W_MaxPassengers{m} < 1)return 0;
  833.     GetPlayerFacingAngle(playerid, d);d+=270.0;
  834.     GetVehiclePos(vehicleid, x, y, z);
  835.     GetVehicleZAngle(vehicleid, a);
  836.         x+=VehicleDoorFD[m]*floatsin(VehicleDoorFA[m]-a,degrees);
  837.         y+=VehicleDoorFD[m]*floatcos(VehicleDoorFA[m]-a,degrees);
  838.         if(IsPlayerInRangeOfPoint(playerid, Range, x, y, z))
  839.         {
  840.                 if(floatcmp(MaxAngle, GetAngleBetwen2Angles(d, a)) == 1)return 1;
  841.         }
  842.         return 0;
  843. }
  844.  
  845. stock IsPlayerNearVehicleDoor2(playerid, vehicleid, Float:Range=0.75, Float:MaxAngle=30.0)
  846. {
  847.     new m, Float:x,Float:y,Float:z,Float:a,Float:d;
  848.     if((m=GetVehicleModel(vehicleid)-400) < 0)return 0;
  849.     if(W_MaxPassengers{m} < 2)return 0;
  850.     GetPlayerFacingAngle(playerid, d);
  851.     GetVehiclePos(vehicleid, x, y, z);
  852.     GetVehicleZAngle(vehicleid, a);
  853.         x+=VehicleDoorRD[m]*floatsin(-VehicleDoorRA[m]-a,degrees);
  854.         y+=VehicleDoorRD[m]*floatcos(-VehicleDoorRA[m]-a,degrees);
  855.         if(IsPlayerInRangeOfPoint(playerid, Range, x, y, z))
  856.         {
  857.             if(W_BootSideDoor{m})d+=90.0;
  858.                 if(floatcmp(MaxAngle, GetAngleBetwen2Angles(d, a)) == 1)return 1;
  859.         }
  860.         return 0;
  861. }
  862.  
  863. stock IsPlayerNearVehicleDoor3(playerid, vehicleid, Float:Range=0.75, Float:MaxAngle=30.0)
  864. {
  865.     new m, Float:x,Float:y,Float:z,Float:a,Float:d;
  866.     if((m=GetVehicleModel(vehicleid)-400) < 0)return 0;
  867.     if(W_MaxPassengers{m} < 3)return 0;
  868.     GetPlayerFacingAngle(playerid, d);
  869.     GetVehiclePos(vehicleid, x, y, z);
  870.     GetVehicleZAngle(vehicleid, a);
  871.         x+=VehicleDoorRD[m]*floatsin(VehicleDoorRA[m]-a,degrees);
  872.         y+=VehicleDoorRD[m]*floatcos(VehicleDoorRA[m]-a,degrees);
  873.         if(IsPlayerInRangeOfPoint(playerid, Range, x, y, z))
  874.         {
  875.             if(W_BootSideDoor{m})d+=270.0;
  876.                 if(floatcmp(MaxAngle, GetAngleBetwen2Angles(d, a)) == 1)return 1;
  877.         }
  878.         return 0;
  879. }
  880.  
  881. stock IsPlayerNearVehicleWheel(playerid, vehicleid, wheel, Float:Range=0.75, Float:MaxAngle=30.0)
  882. {
  883.         switch(wheel)
  884.         {
  885.                 case 0: return IsPlayerNearVehicleWheel0(playerid, vehicleid, Range, MaxAngle);
  886.                 case 1: return IsPlayerNearVehicleWheel1(playerid, vehicleid, Range, MaxAngle);
  887.                 case 2: return IsPlayerNearVehicleWheel2(playerid, vehicleid, Range, MaxAngle);
  888.                 case 3: return IsPlayerNearVehicleWheel3(playerid, vehicleid, Range, MaxAngle);
  889.         }
  890.     return 0;
  891. }
  892.  
  893. stock IsPlayerNearVehicleWheel0(playerid, vehicleid, Float:Range=0.75, Float:MaxAngle=30.0)
  894. {
  895.     new m, Float:x,Float:y,Float:z,Float:a,Float:d;
  896.     if((m=GetVehicleModel(vehicleid)-400) < 0)return 0;
  897.     GetPlayerFacingAngle(playerid, d); d+=90.0;
  898.     GetVehiclePos(vehicleid, x, y, z);
  899.         GetVehicleZAngle(vehicleid, a);
  900.         x+=VehicleWheelFD[m]*floatsin(-VehicleWheelFA[m]-a,degrees);
  901.         y+=VehicleWheelFD[m]*floatcos(-VehicleWheelFA[m]-a,degrees);
  902.         if(IsPlayerInRangeOfPoint(playerid, Range, x, y, z))
  903.         {
  904.                 if(floatcmp(MaxAngle, GetAngleBetwen2Angles(d, a)) == 1)return 1;
  905.         }
  906.         return 0;
  907. }
  908.  
  909. stock IsPlayerNearVehicleWheel1(playerid, vehicleid, Float:Range=0.75, Float:MaxAngle=30.0)
  910. {
  911.     new m, Float:x,Float:y,Float:z,Float:a,Float:d;
  912.         if((m=GetVehicleModel(vehicleid)-400) < 0)return 0;
  913.     GetPlayerFacingAngle(playerid, d); d+=270.0;
  914.     GetVehiclePos(vehicleid, x, y, z);
  915.     GetVehicleZAngle(vehicleid, a);
  916.         x+=VehicleWheelFD[m]*floatsin(VehicleWheelFA[m]-a,degrees);
  917.         y+=VehicleWheelFD[m]*floatcos(VehicleWheelFA[m]-a,degrees);
  918.         if(IsPlayerInRangeOfPoint(playerid, Range, x, y, z))
  919.         {
  920.                 if(floatcmp(MaxAngle, GetAngleBetwen2Angles(d, a)) == 1)return 1;
  921.         }
  922.         return 0;
  923. }
  924.  
  925. stock IsPlayerNearVehicleWheel2(playerid, vehicleid, Float:Range=0.75, Float:MaxAngle=30.0)
  926. {
  927.     new m, Float:x,Float:y,Float:z,Float:a,Float:d;
  928.     if((m=GetVehicleModel(vehicleid)-400) < 0)return 0;
  929.     GetPlayerFacingAngle(playerid, d); d+=90.0;
  930.     GetVehiclePos(vehicleid, x, y, z);
  931.     GetVehicleZAngle(vehicleid, a);
  932.         x+=VehicleWheelRD[m]*floatsin(-VehicleWheelRA[m]-a,degrees);
  933.         y+=VehicleWheelRD[m]*floatcos(-VehicleWheelRA[m]-a,degrees);
  934.         if(IsPlayerInRangeOfPoint(playerid, Range, x, y, z))
  935.         {
  936.             if(floatcmp(MaxAngle, GetAngleBetwen2Angles(d, a)) == 1)return 1;
  937.         }
  938.         return 0;
  939. }
  940.  
  941. stock IsPlayerNearVehicleWheel3(playerid, vehicleid, Float:Range=0.75, Float:MaxAngle=30.0)
  942. {
  943.     new m, Float:x,Float:y,Float:z,Float:a,Float:d;
  944.     if((m=GetVehicleModel(vehicleid)-400) < 0)return 0;
  945.     GetPlayerFacingAngle(playerid, d); d+=270.0;
  946.     GetVehiclePos(vehicleid, x, y, z);
  947.     GetVehicleZAngle(vehicleid, a);
  948.         x+=VehicleWheelRD[m]*floatsin(VehicleWheelRA[m]-a,degrees);
  949.         y+=VehicleWheelRD[m]*floatcos(VehicleWheelRA[m]-a,degrees);
  950.         if(IsPlayerInRangeOfPoint(playerid, Range, x, y, z))
  951.         {
  952.             if(floatcmp(MaxAngle, GetAngleBetwen2Angles(d, a)) == 1)return 1;
  953.         }
  954.         return 0;
  955. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top