AryanV

hklfjhklfgjhk Driving Test

Jul 14th, 2015
284
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.17 KB | None | 0 0
  1. #include <a_samp>
  2. #include <zcmd>
  3.  
  4. #define COLOR_RED 0xC00000FF //Red Color
  5. #define COLOR_GREEN 0x009647FF //Green Color
  6. #define COLOR_BLUE 0x0093BBFF //Blue Color
  7. #define VEHICLE_ID 426 //Current Vehicle is Premier
  8. #define VEH_DAMAGE 900
  9. #define MINI_SPEED 50
  10. #define MAX_SPEEDING 5
  11.  
  12. new ncar[MAX_PLAYERS];
  13. enum pinfo{
  14. bool:license,
  15. CP,
  16. speeding,
  17. };
  18. new gPlayer[MAX_PLAYERS][pinfo];
  19. new currenthealth[MAX_PLAYERS];
  20.  
  21.  
  22.  
  23. public OnFilterScriptInit()
  24. {
  25. print("\n======================================");
  26. print(" TRL Driving Test By Rage Loaded!!");
  27. print("======================================\n");
  28. return 1;
  29. }
  30.  
  31. public OnFilterScriptExit()
  32. {
  33. print("\n======================================");
  34. print(" TRL Driving Test By Rage UNLoaded!!");
  35. print("======================================\n");
  36. return 1;
  37. }
  38.  
  39.  
  40. public OnPlayerConnect(playerid)
  41. {
  42. return 1;
  43. }
  44.  
  45. public OnPlayerDisconnect(playerid, reason)
  46. {
  47. return 1;
  48. }
  49.  
  50. public OnVehicleSpawn(vehicleid)
  51. {
  52. return 1;
  53. }
  54.  
  55. CMD:drivingtest(playerid,params[]){ //Making the command
  56. new money;
  57. money=GetPlayerMoney(playerid);
  58. if(gPlayer[playerid][license]==1) return SendClientMessage(playerid, COLOR_RED,"You already have a driving license");
  59. if(money<2000) return SendClientMessage(playerid, COLOR_RED,"You must have $2000 to begin driving test");
  60. gPlayer[playerid][CP]=1;
  61. SendClientMessage(playerid, COLOR_GREEN,"Instruction: Destination Saved. Make your way to the red marker to begin driving test.");
  62. SetPlayerCheckpoint(playerid,1271.5436,-1545.9067,13.5648,4.0);
  63.  
  64. return 1;
  65. }
  66.  
  67.  
  68. public OnVehicleDeath(vehicleid, killerid)
  69. {
  70. return 1;
  71. }
  72.  
  73. public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
  74. {
  75. return 1;
  76. }
  77.  
  78.  
  79. public OnPlayerStateChange(playerid, newstate, oldstate)
  80. {
  81. return 1;
  82. }
  83.  
  84. public OnPlayerEnterCheckpoint(playerid)
  85. {
  86. if(gPlayer[playerid][CP]==1){
  87. DisablePlayerCheckpoint(playerid);
  88. ShowPlayerDialog(playerid, 1, DIALOG_STYLE_MSGBOX, "Driving Test Approval","Are you sure you want to begin your driving test?","Yes","No");
  89.  
  90. }
  91. else if(gPlayer[playerid][CP]==2){
  92. DisablePlayerCheckpoint(playerid);
  93. gPlayer[playerid][CP]=3;
  94. SetPlayerCheckpoint(playerid,1295.2511,-1602.4054,13.3828,4.0);
  95. IsSpeeding(playerid);
  96. }
  97.  
  98. else if(gPlayer[playerid][CP]==3){
  99. DisablePlayerCheckpoint(playerid);
  100. gPlayer[playerid][CP]=4;
  101. SetPlayerCheckpoint(playerid,1295.0060,-1654.1892,13.3828,4.0);
  102.  
  103. }
  104. else if(gPlayer[playerid][CP]==4){
  105. DisablePlayerCheckpoint(playerid);
  106. gPlayer[playerid][CP]=5;
  107. SetPlayerCheckpoint(playerid,1295.4152,-1708.8987,13.3828,4.0);
  108. IsSpeeding(playerid);
  109.  
  110. }
  111. else if(gPlayer[playerid][CP]==5){
  112. DisablePlayerCheckpoint(playerid);
  113. gPlayer[playerid][CP]=6;
  114. SetPlayerCheckpoint(playerid,1256.7621,-1709.6104,13.3828,4.0);
  115. }
  116. else if(gPlayer[playerid][CP]==6){
  117. DisablePlayerCheckpoint(playerid);
  118. gPlayer[playerid][CP]=7;
  119. SetPlayerCheckpoint(playerid,1201.9366,-1709.9708,13.3828,4.0);
  120. IsSpeeding(playerid);
  121. }
  122. else if(gPlayer[playerid][CP]==7){
  123. DisablePlayerCheckpoint(playerid);
  124. gPlayer[playerid][CP]=8;
  125. SetPlayerCheckpoint(playerid,1156.5132,-1709.4323,13.7813,4.0);
  126.  
  127. }
  128. else if(gPlayer[playerid][CP]==8){
  129. DisablePlayerCheckpoint(playerid);
  130. gPlayer[playerid][CP]=9;
  131. SetPlayerCheckpoint(playerid,1109.7393,-1709.3726,13.3828,4.0);
  132. IsSpeeding(playerid);
  133. }
  134. else if(gPlayer[playerid][CP]==9){
  135. DisablePlayerCheckpoint(playerid);
  136. gPlayer[playerid][CP]=10;
  137. SetPlayerCheckpoint(playerid,1040.7274,-1709.6338,13.3828,4.0);
  138. }
  139. else if(gPlayer[playerid][CP]==10){
  140. DisablePlayerCheckpoint(playerid);
  141. gPlayer[playerid][CP]=11;
  142. SetPlayerCheckpoint(playerid,1040.4951,-1673.3054,13.3828,4.0);
  143. IsSpeeding(playerid);
  144. }
  145. else if(gPlayer[playerid][CP]==11){
  146. DisablePlayerCheckpoint(playerid);
  147. gPlayer[playerid][CP]=12;
  148. SetPlayerCheckpoint(playerid,1039.7523,-1614.5819,13.3828,4.0);
  149. }
  150. else if(gPlayer[playerid][CP]==12){
  151. DisablePlayerCheckpoint(playerid);
  152. gPlayer[playerid][CP]=13;
  153. SetPlayerCheckpoint(playerid,1050.4260,-1574.9825,13.3892,4.0);
  154. IsSpeeding(playerid);
  155. }
  156. else if(gPlayer[playerid][CP]==13){
  157. DisablePlayerCheckpoint(playerid);
  158. gPlayer[playerid][CP]=14;
  159. SetPlayerCheckpoint(playerid,1118.1987,-1574.7905,13.3966,4.0);
  160. }
  161. else if(gPlayer[playerid][CP]==14){
  162.  
  163. DisablePlayerCheckpoint(playerid);
  164. gPlayer[playerid][CP]=15;
  165. SetPlayerCheckpoint(playerid,1147.7310,-1584.6283,13.3395,4.0);
  166. IsSpeeding(playerid);
  167. }
  168. else if(gPlayer[playerid][CP]==15){
  169. DisablePlayerCheckpoint(playerid);
  170. gPlayer[playerid][CP]=16;
  171. SetPlayerCheckpoint(playerid,1147.5430,-1629.2367,13.7813,4.0);
  172. }
  173. else if(gPlayer[playerid][CP]==16){
  174. DisablePlayerCheckpoint(playerid);
  175. gPlayer[playerid][CP]=17;
  176. SetPlayerCheckpoint(playerid,1147.7458,-1704.4374,13.7813,4.0);
  177. IsSpeeding(playerid);
  178. }
  179. else if(gPlayer[playerid][CP]==17){
  180. DisablePlayerCheckpoint(playerid);
  181. gPlayer[playerid][CP]=18;
  182. SetPlayerCheckpoint(playerid,1181.2891,-1714.7313,13.5279,4.0);
  183. IsSpeeding(playerid);
  184. }
  185. else if(gPlayer[playerid][CP]==18){
  186. DisablePlayerCheckpoint(playerid);
  187. gPlayer[playerid][CP]=19;
  188. SetPlayerCheckpoint(playerid,1239.9648,-1715.3239,13.3828,4.0);
  189. }
  190. else if(gPlayer[playerid][CP]==19){
  191. DisablePlayerCheckpoint(playerid);
  192. gPlayer[playerid][CP]=20;
  193. SetPlayerCheckpoint(playerid,1286.8646,-1714.1796,13.3828,4.0);
  194. IsSpeeding(playerid);
  195. }
  196. else if(gPlayer[playerid][CP]==20){
  197. DisablePlayerCheckpoint(playerid);
  198. gPlayer[playerid][CP]=21;
  199. SetPlayerCheckpoint(playerid,1300.1241,-1670.1123,13.3828,4.0);
  200. IsSpeeding(playerid);
  201.  
  202. }
  203. else if(gPlayer[playerid][CP]==21){
  204. DisablePlayerCheckpoint(playerid);
  205. gPlayer[playerid][CP]=22;
  206. SetPlayerCheckpoint(playerid,1300.7595,-1625.7065,13.3828,4.0);
  207. IsSpeeding(playerid);
  208. }
  209. else if(gPlayer[playerid][CP]==22){
  210. DisablePlayerCheckpoint(playerid);
  211. gPlayer[playerid][CP]=23;
  212. SetPlayerCheckpoint(playerid,1300.3802,-1570.8374,13.3828,4.0);
  213.  
  214. }
  215. else if(gPlayer[playerid][CP]==23){
  216. DisablePlayerCheckpoint(playerid);
  217. gPlayer[playerid][CP]=24;
  218. SetPlayerCheckpoint(playerid,1271.1886,-1570.4200,13.3828,4.0);
  219. IsSpeeding(playerid);
  220. }
  221. else if(gPlayer[playerid][CP]==24){
  222. DisablePlayerCheckpoint(playerid);
  223. gPlayer[playerid][CP]=25;
  224. SetPlayerCheckpoint(playerid,1271.5436,-1545.9067,13.5648,4.0);
  225. }
  226. else if(gPlayer[playerid][CP]==25){
  227. DisablePlayerCheckpoint(playerid);
  228. new Float:health;
  229. currenthealth[playerid] = GetVehicleHealth(ncar[playerid],health);
  230. if(currenthealth[playerid]>VEH_DAMAGE && gPlayer[playerid][speeding]<MAX_SPEEDING){
  231. SendClientMessage(playerid, COLOR_BLUE,"Congratulations! You have successfully acquired your driving license");
  232. gPlayer[playerid][license] = true;
  233. }
  234. else{
  235. SendClientMessage(playerid, COLOR_RED,"Sorry! But you failed driving test, Try again to get your driving license");
  236. }
  237. return 1;
  238. }
  239. return 1;
  240. }
  241.  
  242. public OnPlayerLeaveCheckpoint(playerid)
  243. {
  244. return 1;
  245. }
  246.  
  247.  
  248. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  249. {
  250. if(dialogid==1){
  251. if(response){
  252. gPlayer[playerid][CP]=2;
  253. SetPlayerCheckpoint(playerid,1282.1848,-1574.9357,13.3828,4.0);
  254. ncar[playerid]=AddStaticVehicle(VEHICLE_ID,1271.5435,-1545.9233,13.1358,177.9724,3,8);
  255. PutPlayerInVehicle(playerid, ncar[playerid], 0);
  256. SendClientMessage(playerid, COLOR_GREEN,"Instruction: Your driving test has started. Drive carefully on the right lane(Make your way through Checkpoints)");
  257. }
  258. else{
  259. SendClientMessage(playerid,COLOR_RED,"Rejected: It seems you don't want to have driving test");
  260. }
  261. }
  262. return 1;
  263. }
  264.  
  265. GetVehicleSpeed(vehicleid)
  266. {
  267. new Float:Vx, Float:Vy, Float:Vz;
  268. GetVehicleVelocity(vehicleid, Vx, Vy, Vz);
  269. new Float:rtn;
  270. rtn = floatsqroot(floatpower(Vx*100,2) + floatpower(Vy*100,2));
  271. rtn = floatsqroot(floatpower(rtn,2) + floatpower(Vz*100,2));
  272. return floatround(rtn);
  273. }
  274.  
  275. stock IsSpeeding(playerid)
  276. {
  277. if(GetVehicleSpeed(ncar[playerid])>MINI_SPEED)
  278. {
  279. gPlayer[playerid][speeding]++;
  280. SendClientMessage(playerid, COLOR_RED, "Slow down! Or You will Fail your driving test!");
  281. }
  282. }
Add Comment
Please, Sign In to add comment