Guest User

Untitled

a guest
Feb 2nd, 2012
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.35 KB | None | 0 0
  1. /*
  2. This Filterscript was created by Sgt (Sascha).
  3. It was made for SA-MP.com.
  4. Everyone may use this script, however you may not claim it as your own!
  5. Editing or removing this credit lines is strictly forbidden!
  6. */
  7. #define FILTERSCRIPT
  8.  
  9. #include <a_samp>
  10.  
  11. #define COLOR_RED 0xAC0404AA
  12. #define COLOR_GREEN 0x39CC00AA
  13. #define COLOR_GREY 0x7F7F7FAA
  14.  
  15. enum PlayerSaves
  16. {
  17. InPickUp,
  18. Step,
  19. Vehicle,
  20. Float:VH,
  21. CP
  22. }
  23.  
  24. new PlayerData[MAX_PLAYERS][PlayerSaves];
  25. new sgt_vehicle[MAX_VEHICLES];
  26. new sgt_pickup;
  27.  
  28. new Float:DLCP[][3] =
  29. {
  30. {-2139.1184,-67.6470,34.8747},
  31. {-2164.3535,-5.3747,34.8748},
  32. {-2147.4089,141.9391,34.8747},
  33. {-2145.1216,203.2645,34.9041},
  34. {-2240.3752,210.3592,34.8759},
  35. {-2249.6257,299.2788,34.8670},
  36. {-2267.1807,379.7694,33.6897},
  37. {-2226.7854,451.8703,34.7200},
  38. {-2224.2454,491.4290,34.7199},
  39. {-2203.1504,505.9410,34.7199},
  40. {-2017.6952,502.7208,34.7195},
  41. {-1999.1963,568.5953,34.7188},
  42. {-2001.2145,717.5591,45.0009},
  43. {-1921.2731,728.7740,44.9997},
  44. {-1786.3118,727.6964,34.6941},
  45. {-1717.1865,727.5161,24.4405},
  46. {-1576.4340,725.9528,6.9685},
  47. {-1562.2461,644.9578,6.7419},
  48. {-1561.7367,538.1397,6.7341},
  49. {-1623.6094,433.2332,6.7355},
  50. {-1735.0300,323.9233,6.7353},
  51. {-1797.1927,362.7714,16.7668},
  52. {-1828.9827,389.4973,16.7243},
  53. {-1864.4146,323.8641,25.1619},
  54. {-1893.4323,148.3535,37.9035},
  55. {-1908.6934,-61.4659,37.9390},
  56. {-1918.5394,-144.3143,37.9450},
  57. {-1957.4513,-280.2197,37.8157},
  58. {-2011.4530,-320.0841,34.8930},
  59. {-2013.9233,-303.9021,35.2562},
  60. {-2002.5878,-265.7924,35.0847},
  61. {-2003.1021,-125.2738,35.4138},
  62. {-2004.1389,-78.6670,34.8729},
  63. {-2028.7639,-67.5475,34.8747},
  64. {-2047.0619,-82.0102,34.8706},
  65. {-2084.7534,-95.2673,34.8683},
  66. {-2076.9590,-84.0764,34.8686}
  67. };
  68.  
  69. public OnFilterScriptInit()
  70. {
  71. print("\n--------------------------------------");
  72. print("Driving License v0.6 by Sgt aka Sascha");
  73. print("--------------------------------------\n");
  74.  
  75. sgt_pickup = CreatePickup(1239, 23, -2033.4329,-117.4139,1035.1719, -1);
  76. return 1;
  77. }
  78.  
  79. public OnFilterScriptExit()
  80. {
  81. print("\n--------------------------------------");
  82. print("Shutting down Sgt's Driving License v0.6");
  83. print("--------------------------------------\n");
  84. return 1;
  85. }
  86.  
  87. public OnPlayerSpawn(playerid)
  88. {
  89. PlayerData[playerid][InPickUp] = 0;
  90. PlayerData[playerid][Step] = 0;
  91. PlayerData[playerid][CP] = -1;
  92. return 1;
  93. }
  94.  
  95. public OnPlayerDeath(playerid, killerid, reason)
  96. {
  97. if(PlayerData[playerid][Step] > 1)
  98. {
  99. SendClientMessage(playerid, COLOR_RED, "You've failed your driving test.");
  100. }
  101. return 1;
  102. }
  103.  
  104. public OnVehicleSpawn(vehicleid)
  105. {
  106. if(sgt_vehicle[vehicleid] == 1)
  107. {
  108. DestroyVehicle(vehicleid);
  109. }
  110. return 1;
  111. }
  112.  
  113. public OnVehicleDeath(vehicleid, killerid)
  114. {
  115. if(sgt_vehicle[vehicleid] == 1)
  116. {
  117. DestroyVehicle(vehicleid);
  118. }
  119. return 1;
  120. }
  121.  
  122. public OnPlayerStateChange(playerid, newstate, oldstate)
  123. {
  124. if(newstate == PLAYER_STATE_DRIVER)
  125. {
  126. if(PlayerData[playerid][Step] >= 1)
  127. {
  128. PlayerData[playerid][Vehicle] = GetPlayerVehicleID(playerid);
  129. GetVehicleHealth(GetPlayerVehicleID(playerid), PlayerData[playerid][VH]);
  130. SendClientMessage(playerid, COLOR_GREEN, "Drive to the first checkpoint and follow the following ones");
  131. PlayerData[playerid][Step] = 2;
  132. SetPlayerRaceCheckpoint(playerid, 0, -2048.1689,-83.5252,34.8684, -2139.1184,-67.6470,34.8747, 3.00);
  133. PlayerData[playerid][CP] = 0;
  134. return 1;
  135. }
  136. else if(PlayerData[playerid][Step] == 0)
  137. {
  138. if(!IsDLFree(GetPlayerVehicleID(playerid)))
  139. {
  140. new string[100], pname[MAX_PLAYER_NAME];
  141. GetPlayerName(playerid, pname, sizeof(pname));
  142. format(string, sizeof(string), "SgtDL/%s.sgt", pname);
  143. if(!fexist(string))
  144. {
  145. RemovePlayerFromVehicle(playerid);
  146. SendClientMessage(playerid, COLOR_RED, "You need a driving license to drive the vehicle! (SF Driving School)");
  147. }
  148. }
  149. }
  150. }
  151. return 1;
  152. }
  153.  
  154. public OnPlayerEnterCheckpoint(playerid)
  155. {
  156. if(PlayerData[playerid][Step] == 1 && !IsPlayerInAnyVehicle(playerid))
  157. {
  158. new v = CreateVehicle(551,-2026.1503,-94.4133,34.8685,90.0000,-1,-1,300);
  159. sgt_vehicle[v] = 1;
  160. SendClientMessage(playerid, COLOR_GREEN, "Get into the vehicle and follow the checkpoints.");
  161. DisablePlayerCheckpoint(playerid);
  162. }
  163. return 1;
  164. }
  165.  
  166. public OnPlayerEnterRaceCheckpoint(playerid)
  167. {
  168. if(IsPlayerInAnyVehicle(playerid) && GetPlayerVehicleID(playerid) == PlayerData[playerid][Vehicle] && PlayerData[playerid][Step] >= 2)
  169. {
  170. if(PlayerData[playerid][CP] <= 35)
  171. {
  172. new n = PlayerData[playerid][CP];
  173. new n2 = PlayerData[playerid][CP] + 1;
  174. SetPlayerRaceCheckpoint(playerid, 0, DLCP[n][0], DLCP[n][1], DLCP[n][2], DLCP[n2][0], DLCP[n2][1], DLCP[n2][2], 2.00);
  175. PlayerData[playerid][CP]++;
  176. }
  177. else if(PlayerData[playerid][CP] == 36)
  178. {
  179. new n = PlayerData[playerid][CP];
  180. SetPlayerRaceCheckpoint(playerid, 1, DLCP[n][0], DLCP[n][1], DLCP[n][2], DLCP[n][0], DLCP[n][1], DLCP[n][2], 2.00);
  181. PlayerData[playerid][CP]++;
  182. }
  183. else
  184. {
  185. DisablePlayerRaceCheckpoint(playerid);
  186. new v = GetPlayerVehicleID(playerid);
  187. new Float:vhp;
  188. GetVehicleHealth(v, vhp);
  189. new Float:Dif = ((PlayerData[playerid][VH] / 10) - (vhp / 10));
  190. PlayerData[playerid][CP] = -1;
  191. if(Dif <= 2)
  192. {
  193. ShowPlayerDialog(playerid, 138, DIALOG_STYLE_MSGBOX, "Driving License", "Congratulations!\nYou have passed the test and are now\nthe owner of a driving license!", "Close", "");
  194. SetPVarInt(playerid, "SgtDL", 1);
  195. }
  196. else
  197. {
  198. ShowPlayerDialog(playerid, 138, DIALOG_STYLE_MSGBOX, "Driving License", "We are sorry.\nYou have failed the driving test.\nPlease try it again, later.", "Close", "");
  199. SetPVarInt(playerid, "SgtDL", 2);
  200. }
  201. }
  202. }
  203. return 1;
  204. }
  205.  
  206. public OnPlayerPickUpPickup(playerid, pickupid)
  207. {
  208. if(pickupid == sgt_pickup)
  209. {
  210. if(PlayerData[playerid][InPickUp] == 0)
  211. {
  212. PlayerData[playerid][InPickUp] = 1;
  213. SetTimerEx("OnPlayerLeavePickUp", 5000, false, "i", playerid);
  214. new pname[MAX_PLAYER_NAME], string[100];
  215. GetPlayerName(playerid, pname, sizeof(pname));
  216. format(string, sizeof(string), "SgtDL/%s.sgt", pname);
  217. if(fexist(string)) return SendClientMessage(playerid, COLOR_GREY, "You already have a driving license.");
  218. else ShowPlayerDialog(playerid, 137, DIALOG_STYLE_MSGBOX, "Driving License", "Welcome Sir!\nYou don't have got a driving license yet.\nIf you would like to get one, click onto\n'Continue'", "Continue", "Cancel");
  219. }
  220. }
  221. return 1;
  222. }
  223.  
  224. forward OnPlayerLeavePickUp(playerid);
  225. public OnPlayerLeavePickUp(playerid)
  226. {
  227. PlayerData[playerid][InPickUp] = 0;
  228. return 1;
  229. }
  230.  
  231. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  232. {
  233. if(dialogid == 137)
  234. {
  235. if(response)
  236. {
  237. PlayerData[playerid][Step] = 1;
  238. SendClientMessage(playerid, COLOR_GREY, "Walk out onto the car park and go into the checkpoint.");
  239. SetPlayerCheckpoint(playerid, -2028.2227,-91.8504,33.3203, 2.00);
  240. }
  241. }
  242. else if(dialogid == 138)
  243. {
  244. if(GetPVarInt(playerid, "SgtDL") == 2)
  245. {
  246. SetPVarInt(playerid, "SgtDL", 0);
  247. PlayerData[playerid][Step] = 0;
  248. RemovePlayerFromVehicle(playerid);
  249. DestroyVehicle(PlayerData[playerid][Vehicle]);
  250. }
  251. else if(GetPVarInt(playerid, "SgtDL") == 1)
  252. {
  253. new pname[MAX_PLAYER_NAME], string[100];
  254. GetPlayerName(playerid, pname, sizeof(pname));
  255. format(string, sizeof(string), "SgtDL/%s.sgt", pname);
  256. new File:sgt_file = fopen(string, io_write);
  257. new day, year, month;
  258. getdate(year, month, day);
  259. format(string, sizeof(string), "%s is owning this driving license since: %d/%d/%d\r\n", pname, day, month, year);
  260. fwrite(sgt_file, string);
  261. fclose(sgt_file);
  262. PlayerData[playerid][Step] = 0;
  263. RemovePlayerFromVehicle(playerid);
  264. DestroyVehicle(PlayerData[playerid][Vehicle]);
  265. }
  266. }
  267. return 1;
  268. }
  269.  
  270. stock IsDLFree(vehicleid)
  271. {
  272. new m = GetVehicleModel(vehicleid);
  273. if(m == 509 || m == 481 || m == 510 || m == 462 || m == 448 || m == 592 || m == 577 || m == 511 || m == 512
  274. || m == 593 || m == 520 || m == 448 || m == 553 || m == 476 || m == 519 || m == 460 || m == 513 || m == 548
  275. || m == 425 || m == 417 || m == 487 || m == 488 || m == 497 || m == 469 || m == 563 || m == 447)
  276. {
  277. return 1;
  278. }
  279. return 0;
  280. }
Advertisement
Add Comment
Please, Sign In to add comment