Advertisement
Guest User

Untitled

a guest
Dec 22nd, 2012
261
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.69 KB | None | 0 0
  1. /*
  2.  
  3.  
  4. ___________________________________________________________________
  5. / | |
  6. / |
  7. / THIS include has been created by [D]ry[D]esert |
  8. / copyright(c) to [D]ry[D]esert. |
  9. / v0.1 beta |
  10. /___________________________________________________________________|
  11.  
  12. */
  13. /*
  14. #define MAX_RADARS (30) //Maxium ammount of radars can be created.
  15. #define ALLOWED_SPEED (120) //The allowed of vehicle's speed(KM).
  16. #define CREATE_3DTEXT_LABEL (true) //Create the Text 'Radar' on the rader. true for yes, false for no
  17. #define LABEL_DRAW_DISTANCE (20) //Draw distance for the label.(Wont work if CREATE_3DTEXT_LABEL == false.
  18. #define CAMERA_RANGE (12) //The range which camera can reach to detect if player has passed the limited speed
  19. #define PLAY_CAMERA_SOUND (true) //when player pass the limite speed, it will play camera sound. true for enable and false for disable.
  20. #define LABEL_COLOR_TEXT (0x0000BBAA) //Set label color.(wont work if CREATE_3DTEXT_LABEL == false.)
  21. #define LABEL_TEXT "Radar" //Set label Text.(wont work if CREATE_3DTEXT_LABEL == false.)
  22. */
  23. #include <a_samp>
  24. #if defined _dRadar_included
  25. #endinput
  26. #endif
  27. #define _dRadar_included
  28.  
  29. #if !defined _samp_included
  30. #error "You need to include the a_samp.inc include file before the dRadar.inc file!!"
  31. #endif
  32.  
  33. #if !defined MAX_RADARS
  34. #define MAX_RADARS (30)
  35. #endif
  36. #if !defined ALLOWED_SPEED
  37. #define ALLOWED_SPEED (120) //KM
  38. #endif
  39. #if !defined CAMERA_RANGE
  40. #define CAMERA_RANGE (12) //The range which camera can reach to detect if player has passed the limited speed
  41. #endif
  42.  
  43. #if !defined PLAY_CAMERA_SOUND
  44. #define PLAY_CAMERA_SOUND (true) //when player pass the limite speed, it will play camera sound. true for enable and false for disable.
  45. #endif
  46.  
  47.  
  48. #if !defined CREATE_3DTEXT_LABEL
  49. #define CREATE_3DTEXT_LABEL (true) //Create the Text 'Radar' on the rader. true for yes, false for no
  50. #endif
  51. #if !defined LABEL_DRAW_DISTANCE
  52. #define LABEL_DRAW_DISTANCE (20)
  53. #endif
  54. #if !defined LABEL_COLOR_TEXT
  55. #define LABEL_COLOR_TEXT (0x0000BBAA) //blue color.
  56. #endif
  57. #if !defined LABEL_TEXT
  58. #define LABEL_TEXT "Radar"
  59. #endif
  60.  
  61.  
  62. enum d_Radar
  63. {
  64. RadarObject,
  65. Text3D:RaderLable,
  66. Float:R_X,
  67. Float:R_Y,
  68. Float:R_Z,
  69. bool:Exist
  70. };
  71. new dRadar[MAX_RADARS][d_Radar];
  72. new RadarCounter;
  73. new lastcheck[MAX_PLAYERS];
  74. forward pCheck();
  75. forward dRadar_OnGameModeInit();
  76. forward OnVehiclePassTheLimitedSpeed(playerid, vehicleid);
  77.  
  78. public OnGameModeInit()
  79. {
  80. print("====================================");
  81. print("| dRadar v0.1 beta |");
  82. print("| ©[D]ry[D]esert |");
  83. print("====================================");
  84. SetTimer("pCheck",10,true);
  85. CallLocalFunction("dRadar_OnGameModeInit","");
  86. return 1;
  87. }
  88. #if defined _ALS_OnGameModeInit
  89. #undef OnGameModeInit
  90. #else
  91. #define _ALS_OnGameModeInit
  92. #endif
  93. #define OnGameModeInit dRadar_OnGameModeInit
  94. forward dRadar_OnGameModeInit();
  95.  
  96. stock Float:Radar_GetPlayerSpeed(playerid)
  97. {
  98. new Float:SpeedX, Float:SpeedY, Float:SpeedZ;
  99. new Float:Speed;
  100. GetVehicleVelocity(GetPlayerVehicleID(playerid), SpeedX, SpeedY, SpeedZ);
  101. Speed = floatsqroot(floatadd(floatpower(SpeedX, 2.0), floatpower(SpeedY, 2.0)));
  102. Speed = floatround(Speed * 100 * 1.60);
  103. return Speed;
  104. }
  105. public pCheck()
  106. {
  107. for(new i=0;i<MAX_PLAYERS;i++)
  108. {
  109. if(IsPlayerConnected(i))
  110. {
  111. new newmessage = gettime();
  112. for(new r=0;r<MAX_RADARS;r++)
  113. {
  114. if(dRadar[r][Exist] == true)
  115. {
  116. if(IsPlayerInRangeOfPoint(i,CAMERA_RANGE,dRadar[r][R_X],dRadar[r][R_Y],dRadar[r][R_Z]))
  117. {
  118. if(IsPlayerInAnyVehicle(i))
  119. {
  120. if(Radar_GetPlayerSpeed(i) >= ALLOWED_SPEED)
  121. {
  122. switch(newmessage - lastcheck[i])
  123. {
  124. case 0..2:
  125. {
  126. return 0;
  127. }
  128. default:
  129. {
  130. new vehicleid = GetPlayerVehicleID(i);
  131. #if PLAY_CAMERA_SOUND == true
  132. PlayerPlaySound(i,1132,0,0,0);
  133. #endif
  134. CallLocalFunction("OnVehiclePassTheLimitedSpeed","ii",i,vehicleid);
  135. lastcheck[i] = gettime();
  136. }
  137. }
  138. }
  139. }
  140. }
  141. }
  142. }
  143. }
  144. }
  145. return 1;
  146. }
  147. stock CreateRadar(type,Float:x,Float:y,Float:z,Float:rx,Float:ry,Float:rz,Float:DrawDistance)
  148. {
  149. if(RadarCounter == MAX_RADARS)
  150. {
  151. print("dRADAR ERROR: cant create radar, radars has reached the maximum ammount");
  152. }
  153. else
  154. {
  155. if(type == 0)
  156. {
  157. dRadar[RadarCounter][RadarObject] = CreateObject(18653,x,y,z-0.5,rx,ry,rz,DrawDistance);
  158. }
  159. else if(type == 1)
  160. {
  161. dRadar[RadarCounter][RadarObject] = CreateObject(18880,x,y,z-0.5,rx,ry,rz,DrawDistance);
  162. }
  163. else
  164. {
  165. print("dRADAR ERROR: Unknow type.");
  166. }
  167. dRadar[RadarCounter][R_X] = x;
  168. dRadar[RadarCounter][R_Y] = y;
  169. dRadar[RadarCounter][R_Z] = z;
  170. dRadar[RadarCounter][Exist] = true;
  171. #if CREATE_3DTEXT_LABEL == true
  172. dRadar[RadarCounter][RaderLable] = Create3DTextLabel(LABEL_TEXT,LABEL_COLOR_TEXT,x,y,z,LABEL_DRAW_DISTANCE,0);
  173. #endif
  174. RadarCounter++;
  175. }
  176. }
  177.  
  178. // © All rights Reserve to [D]ry[D]esert. 2013.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement