Toll.pwn 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729
  1. /*****************************************************************************\
  2. * ,-----, *
  3. * /----/ | ,---, ,----, *
  4. * | | | ,------, ,----, ,----, ,----, ,---/---/ \ /---/ | *
  5. * | | | /-----/ |/----/ \/---/ |/----/ \/--- \ \ / / / *
  6. * | | | | ,__|/ | \| | || \| | \ \/ / / *
  7. * | | |____ | ---,/|| \ | || \ | |\ / / *
  8. * | |____/ || ,__|/ | ^\ | || ^\ | | | | | *
  9. * | | || ---,/|| | \ | /| | \ | | | | | *
  10. * |_________|/ |_____|/ |___,/ \____,/ |___,/ \____,/ |____,/ *
  11. * Information about THIS module/file/part of project: *
  12. * *
  13. * Allowing civilians to pay the toll guard to open the tolls for them, as *
  14. * long as the tolls aren't locked by the police. *
  15. * *
  16. * @Author of THIS file: Lenny *
  17. * @Startdate of THIS file: 22 Dec 09 *
  18. \* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  19. ////////////////////////////////////////////////////////////////////////////////
  20. ///////////////////////////////////* NOTES *////////////////////////////////////
  21. ////////////////////////////////////////////////////////////////////////////////
  22. /*
  23. This script requires some configuration to run properly as an include,
  24. and obviously will only function properly with the LS-RP script.
  25. It works as a debug version when used as a filterscript, meaning it's not
  26. configured for a roleplay server - that would require some additional
  27. configuration.
  28. §§§§§§§§§§§§§§§§§§§§§§§§§§§[ INSTALL INSTRUCTIONS ]§§§§§§§§§§§§§§§§§§§§§§§§§
  29. The following functions need to be called in their publics and forwarded:
  30. - Toll_OnPlayerPickUpPickup(playerid,pickupid)
  31. - Toll_OnPlayerDisconnect(playerid)
  32. - Toll_OnPlayerUpdate(playerid)
  33. - Toll_OnGameModeInit()
  34. And the commands:
  35. - ycmd_opentoll(playerid, cmdtext[])
  36. - ycmd_toll(playerid, cmdtext[])
  37. Change the define of TollFS to 0.
  38. Please also take some time to look over the other defines for configuration.
  39. §§§§§§§§§§§§§§§§§§§§§§§§[ INSTALL INSTRUCTIONS END ]§§§§§§§§§§§§§§§§§§§§§§§§
  40. */
  41. ////////////////////////////////////////////////////////////////////////////////
  42. //////////////////////////////////* SCRIPT *////////////////////////////////////
  43. ////////////////////////////////////////////////////////////////////////////////
  44. // Main configuration
  45. #define TollFS (1) // 0 = Include, 1 = Filterscript
  46. #define TollCost (50) // How much it costs to pass the tolls
  47. #define TollPayCops (0) // Amount of percent that goes to the LSPD and SASD (Ex: 20 = 20% to LSPD, 20% to SASD, total 40% to cops)
  48. #define TollPickupModel (1239) // The model of the pickups
  49. #define TollPickupType (14) // The type of pickups
  50. #define TollPickupVirtualWorld (-1) // The virtual world of the pickups
  51. #define TollDelayCivilian (6) // The timespace in seconds between each /opentoll command for the same player
  52. #define TollDelayCop (2) // The timespace in seconds between each /toll command for all cops (To avoid spam)
  53. #define TollOpenDistance (8.0) // The distance in units the player can be from the icon to open the toll
  54. #define TollTimer (30) // The amount of seconds that tolls are locked normally
  55. #define TollTimerEmergency (60) // The amount of seconds that all tolls are locked after /toll emergency
  56. // Other defines
  57. #define MAX_TOLLS (3) // Amount of tolls
  58. #define INVALID_TOLL_ID (-1)
  59. #define RichmanToll (0)
  60. #define FlintToll (1)
  61. #define LVToll (2)
  62. #define L_sz_TollStringLocked ("Toll guard says: I'm sorry, but I can't open this right now. You'll have to come back later.")
  63. #define L_sz_TollStringNoMoney ("You don't have enough money to pay the guard.")
  64. #define L_sz_TollStringBye ("Toll guard says: Thank you, drive safe.")
  65. #define L_sz_TollStringHurryUp ("You have 6 seconds to get past the barrier, make sure you don't get stuck!")
  66. // End of defines
  67. #if TollFS == 1
  68. #include <a_samp>
  69. #endif
  70. enum E_TOLLDATA
  71. {
  72. E_tAllowReq, // One timer for each toll
  73. E_tLocked, // 0 = Richhman, 1 = Flint, 2 = LV, 3 = Airport
  74. E_tTimer // 0 = Richhman, 1 = Flint, 2 = LV, 3 = Airport
  75. }
  76. new aTolls[MAX_TOLLS][E_TOLLDATA];
  77. new L_a_RequestAllowedCop, // The same timer for all /toll changes
  78. L_a_TollPerson[MAX_PLAYERS][2], // 0 = toll ID, 1 = UnixTime+X
  79. L_a_Pickup[MAX_TOLLS*2], // 0 & 1 = Richhman, 2 & 3 = Flint, 4 & 5 = LV, 6 = Airport
  80. L_a_TollObject[MAX_TOLLS*2]; // 0 & 1 = Richhman, 2 & 3 = Flint, 4 & 5 = LV, 6 = Airport
  81. #if TollFS == 1
  82. #define COLOR_FADE1 0xE6E6E6E6
  83. #define COLOR_FADE2 0xC8C8C8C8
  84. #define COLOR_FADE3 0xAAAAAAAA
  85. #define COLOR_FADE4 0x8C8C8C8C
  86. #define COLOR_FADE5 0x6E6E6E6E
  87. #define COLOR_GREY 0xAFAFAFAA
  88. #define COLOR_RED 0xFF6347AA
  89. #define COLOR_YELLOW 0xFFFF00AA
  90. #define COLOR_GRAD2 0xBFC0C2FF
  91. #define TEAM_BLUE_COLOR 0x8D8DFFC8
  92. #define COLOR_PURPLE 0xC2A2DAAA
  93. #define COLOR_GOLD 0xB8860BAA
  94. forward Toll_OnPlayerPickUpPickup(playerid,pickupid);
  95. forward Toll_OnPlayerDisconnect(playerid);
  96. forward Toll_OnPlayerUpdate(playerid);
  97. forward Toll_OnGameModeInit();
  98. forward ycmd_opentoll(playerid, cmdtext[]);
  99. forward ycmd_toll(playerid, cmdtext[]);
  100. new PDDuty[MAX_PLAYERS];
  101. #define IsNull(%1) \
  102. ((%1[0] == 0) || (%1[0] == 1 && %1[1] == 0))
  103. public OnPlayerPickUpPickup(playerid,pickupid)
  104. {
  105. Toll_OnPlayerPickUpPickup(playerid,pickupid);
  106. }
  107. public OnPlayerDisconnect(playerid)
  108. {
  109. Toll_OnPlayerDisconnect(playerid);
  110. }
  111. public OnPlayerUpdate(playerid)
  112. {
  113. Toll_OnPlayerUpdate(playerid);
  114. return 1;
  115. }
  116. public OnFilterScriptInit()
  117. {
  118. Toll_OnGameModeInit();
  119. }
  120. public OnPlayerCommandText(playerid, cmdtext[])
  121. {
  122. if(!strcmp(cmdtext, "/opentoll", true, 9))
  123. {
  124. return ycmd_opentoll(playerid, cmdtext);
  125. }
  126. if(!strcmp(cmdtext, "/toll", true, 5))
  127. {
  128. return ycmd_toll(playerid, cmdtext);
  129. }
  130. return 0;
  131. }
  132. stock ProxDetector(Float:radi, playerid, string[], col1, col2, col3, col4, col5)
  133. {
  134. new Float:posx, Float:posy, Float:posz;
  135. new Float:oldposx, Float:oldposy, Float:oldposz;
  136. new Float:tempposx, Float:tempposy, Float:tempposz;
  137. GetPlayerPos(playerid, oldposx, oldposy, oldposz);
  138. for(new i = 0; i < MAX_PLAYERS; i++)
  139. {
  140. if(IsPlayerConnected(i))
  141. {
  142. if(GetPlayerVirtualWorld(i)==GetPlayerVirtualWorld(playerid))
  143. {
  144. GetPlayerPos(i, posx, posy, posz);
  145. tempposx = (oldposx -posx);
  146. tempposy = (oldposy -posy);
  147. tempposz = (oldposz -posz);
  148. if (((tempposx < radi/16) && (tempposx > -radi/16)) && ((tempposy < radi/16) && (tempposy > -radi/16)) && ((tempposz < radi/16) && (tempposz > -radi/16)))
  149. SendClientMessage(i, col1, string);
  150. else if (((tempposx < radi/8) && (tempposx > -radi/8)) && ((tempposy < radi/8) && (tempposy > -radi/8)) && ((tempposz < radi/8) && (tempposz > -radi/8)))
  151. SendClientMessage(i, col2, string);
  152. else if (((tempposx < radi/4) && (tempposx > -radi/4)) && ((tempposy < radi/4) && (tempposy > -radi/4)) && ((tempposz < radi/4) && (tempposz > -radi/4)))
  153. SendClientMessage(i, col3, string);
  154. else if (((tempposx < radi/2) && (tempposx > -radi/2)) && ((tempposy < radi/2) && (tempposy > -radi/2)) && ((tempposz < radi/2) && (tempposz > -radi/2)))
  155. SendClientMessage(i, col4, string);
  156. else if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
  157. SendClientMessage(i, col5, string);
  158. }
  159. }
  160. else
  161. SendClientMessage(i,col1,string);
  162. }
  163. return 1;
  164. }
  165. GetUnixTime()
  166. {
  167. return gettime();
  168. }
  169. CreateDynamicObj(modelid, Float:X, Float:Y, Float:Z, Float:rX, Float:rY, Float:rZ, titties)
  170. {
  171. titties++;
  172. return CreateObject(modelid, X, Y, Z, rX, rY, rZ);
  173. }
  174. SetDynamicObjectRot(objectid, Float:RotX, Float:RotY, Float:RotZ)
  175. {
  176. return SetObjectRot(objectid, RotX, RotY, RotZ);
  177. }
  178. GetICName(playerid)
  179. {
  180. new name[MAX_PLAYER_NAME];
  181. GetPlayerName(playerid, name, MAX_PLAYER_NAME);
  182. return name;
  183. }
  184. stock strtok(const string[], &index)
  185. {
  186. new length = strlen(string);
  187. while ((index < length) && (string[index] <= ' '))
  188. {
  189. index++;
  190. }
  191. new offset = index;
  192. new result[20];
  193. while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
  194. {
  195. result[index - offset] = string[index];
  196. index++;
  197. }
  198. result[index - offset] = EOS;
  199. return result;
  200. }
  201. SendTeamTypeMessage(nothing, color, string[])
  202. {
  203. nothing++;
  204. return SendClientMessageToAll(color, string);
  205. }
  206. #endif
  207. public Toll_OnPlayerPickUpPickup(playerid, pickupid) // Needs forwarding in the OnPlayerPickup function of the script
  208. {
  209. if(pickupid == L_a_Pickup[0] || pickupid == L_a_Pickup[1] || pickupid == L_a_Pickup[2] || pickupid == L_a_Pickup[3] || pickupid == L_a_Pickup[4] || pickupid == L_a_Pickup[5])
  210. {
  211. if(PDDuty[playerid])
  212. {
  213. ProxDetector(20.0, playerid, "Toll guard says: Hello officer, would you like to pass?", COLOR_FADE1, COLOR_FADE2, COLOR_FADE3, COLOR_FADE4, COLOR_FADE5);
  214. SendClientMessage(playerid, COLOR_GOLD, "Use \"/opentoll\" to open the toll.");
  215. return 1;
  216. }
  217. new szCostString[56];
  218. format(szCostString, 56, "Toll guard says: Hello, the toll is %d dollars please.", TollCost);
  219. ProxDetector(20.0, playerid, szCostString, COLOR_FADE1, COLOR_FADE2, COLOR_FADE3, COLOR_FADE4, COLOR_FADE5);
  220. SendClientMessage(playerid, COLOR_GOLD, "Use \"/opentoll\" to pay the guard.");
  221. }
  222. return 1;
  223. }
  224. public Toll_OnPlayerDisconnect(playerid) // And this needs forwarding in the OnPlayerDisconnect function of the script
  225. {
  226. if(L_a_TollPerson[playerid][0] != INVALID_TOLL_ID)
  227. {
  228. Toll_CloseToll(L_a_TollPerson[playerid][0]);
  229. L_a_TollPerson[playerid][0] = 0;
  230. }
  231. }
  232. public Toll_OnPlayerUpdate(playerid) // Needs to be called in the OnPlayerUpdate function
  233. {
  234. if(L_a_TollPerson[playerid][0] != INVALID_TOLL_ID)
  235. {
  236. if(GetUnixTime() > L_a_TollPerson[playerid][1])
  237. {
  238. Toll_CloseToll(L_a_TollPerson[playerid][0]);
  239. L_a_TollPerson[playerid][0] = 0;
  240. }
  241. else
  242. {
  243. switch(L_a_TollPerson[playerid][0])
  244. {
  245. case RichmanToll:
  246. {
  247. if(IsPlayerInRangeOfPoint(playerid, 1.0, 619.2152, -1174.6862, 20.5124) || IsPlayerInRangeOfPoint(playerid, 1.0, 612.2329, -1202.9524, 18.1094))
  248. {
  249. Toll_CloseToll(L_a_TollPerson[playerid][0]);
  250. L_a_TollPerson[playerid][0] = 0;
  251. }
  252. }
  253. case FlintToll:
  254. {
  255. if(IsPlayerInRangeOfPoint(playerid, 1.0, 29.2651,-1521.5536,4.8644) || IsPlayerInRangeOfPoint(playerid, 1.0, 73.2545, -1541.4111, 5.2093))
  256. {
  257. Toll_CloseToll(L_a_TollPerson[playerid][0]);
  258. L_a_TollPerson[playerid][0] = 0;
  259. }
  260. }
  261. case LVToll:
  262. {
  263. if(IsPlayerInRangeOfPoint(playerid, 1.0, 1797.5039, 714.3255, 14.4545) || IsPlayerInRangeOfPoint(playerid, 1.0, 1775.9889, 691.7012, 15.9699))
  264. {
  265. Toll_CloseToll(L_a_TollPerson[playerid][0]);
  266. L_a_TollPerson[playerid][0] = 0;
  267. }
  268. }
  269. }
  270. }
  271. }
  272. }
  273. public Toll_OnGameModeInit() // Needs to be called in the OnGameModeInit function!
  274. { // Thanks to Nexus for mapping!
  275. printf("Initializing toll system...");
  276. printf("____________________________________");
  277. printf(" (c) Lenny 2010 ");
  278. for(new i; i < MAX_PLAYERS; i++)
  279. L_a_TollPerson[i][0] = INVALID_TOLL_ID;
  280. /* Richman */
  281. CreateDynamicObj( 8168, 612.73895263672, -1191.4602050781, 20.294105529785, 0.000000, 5, 318.31237792969, -1 );
  282. CreateDynamicObj( 8168, 620.47265625, -1188.49609375, 20.044105529785, 0.000000, 352.99621582031, 138.94409179688, -1 );
  283. CreateDynamicObj( 966, 613.97229003906, -1197.7174072266, 17.475030899048, 0.000000, 0.000000, 23.81982421875, -1 );
  284. CreateDynamicObj( 997, 614.33209228516, -1194.3870849609, 17.709369659424, 0.000000, 0.000000, 266.70568847656, -1 );
  285. CreateDynamicObj( 973, 602.98425292969, -1202.1643066406, 18.000516891479, 0.000000, 0.000000, 19.849853515625, -1 );
  286. L_a_TollObject[0] = CreateDynamicObj( 968, 613.8935546875, -1197.7329101563, 18.109180450439, 0.000000, -90.000000, 23.81982421875, -1 );
  287. CreateDynamicObj( 966, 619.42913818359, -1181.6597900391, 18.725030899048, 0.000000, 0.000000, 214.37744140625, -1 );
  288. CreateDynamicObj( 973, 629.68823242188, -1176.0551757813, 19.500516891479, 0.000000, 0.000000, 21.831787109375, -1 );
  289. CreateDynamicObj( 997, 619.26574707031, -1181.6518554688, 18.709369659424, 0.000000, 0.000000, 268.68908691406, -1 );
  290. L_a_TollObject[1] = CreateDynamicObj( 968, 619.44201660156, -1181.6903076172, 19.525806427002, 0.000000, -90.000000, 214.37744140625, -1 );
  291. /* End of Richman */
  292. /* Flint */
  293. CreateDynamicObj( 8168, 61.256042480469, -1533.3946533203, 6.1042537689209, 0.000000, 0.000000, 9.9252624511719, -1 );
  294. CreateDynamicObj( 8168, 40.966598510742, -1529.5725097656, 6.1042537689209, 0.000000, 0.000000, 188.5712890625, -1 );
  295. L_a_TollObject[2] = CreateDynamicObj( 968, 35.838928222656, -1525.9034423828, 5.0012145042419, 0.000000, -90.000000, 270.67565917969, -1 );
  296. CreateDynamicObj( 966, 35.889751434326, -1526.0096435547, 4.2410612106323, 0.000000, 0.000000, 270.67565917969, -1 );
  297. CreateDynamicObj( 966, 67.093727111816, -1536.8275146484, 3.9910612106323, 0.000000, 0.000000, 87.337799072266, -1 );
  298. L_a_TollObject[3] = CreateDynamicObj( 968, 67.116600036621, -1536.8218994141, 4.7504549026489, 0.000000, -90.000000, 87.337799072266, -1 );
  299. CreateDynamicObj( 973, 52.9794921875, -1531.9252929688, 5.090488910675, 0.000000, 0.000000, 352.06005859375, -1 );
  300. CreateDynamicObj( 973, 49.042072296143, -1531.5065917969, 5.1758694648743, 0.000000, 0.000000, 352.05688476563, -1 );
  301. CreateDynamicObj( 997, 68.289916992188, -1546.6020507813, 4.0626411437988, 0.000000, 0.000000, 119.09942626953, -1 );
  302. CreateDynamicObj( 997, 34.5198097229, -1516.1402587891, 4.0626411437988, 0.000000, 0.000000, 292.50622558594, -1 );
  303. CreateDynamicObj( 997, 35.903915405273, -1525.8717041016, 4.0626411437988, 0.000000, 0.000000, 342.13012695313, -1 );
  304. CreateDynamicObj( 997, 63.914081573486, -1535.7126464844, 4.0626411437988, 0.000000, 0.000000, 342.130859375, -1 );
  305. /* End of Flint */
  306. /* LV */
  307. CreateDynamicObj( 8168, 1789.83203125, 703.189453125, 15.846367835999, 0.000000, 3, 99.24951171875, -1 );
  308. CreateDynamicObj( 8168, 1784.8334960938, 703.94799804688, 16.070636749268, 0.000000, 357, 278.61096191406, -1 );
  309. CreateDynamicObj( 966, 1781.4122314453, 697.32531738281, 14.636913299561, 0.000000, 0.000000, 348.09008789063, -1 );
  310. CreateDynamicObj( 996, 1767.3087158203, 700.50506591797, 15.281567573547, 0.000000, 0.000000, 346.10510253906, -1 );
  311. CreateDynamicObj( 997, 1781.6832275391, 697.34796142578, 14.698781013489, 0.000000, 3, 77.41455078125, -1 );
  312. CreateDynamicObj( 997, 1792.7745361328, 706.38543701172, 13.948781013489, 0.000000, 2.999267578125, 81.379638671875, -1 );
  313. CreateDynamicObj( 966, 1793.4289550781, 709.87982177734, 13.636913299561, 0.000000, 0.000000, 169.43664550781, -1 );
  314. CreateDynamicObj( 996, 1800.8060302734, 708.38299560547, 14.281567573547, 0.000000, 0.000000, 346.10229492188, -1 );
  315. L_a_TollObject[4] = CreateDynamicObj( 968, 1781.4133300781, 697.31750488281, 15.420023918152, 0.000000, -90.000000, 348.10229492188, -1 );
  316. L_a_TollObject[5] = CreateDynamicObj( 968, 1793.6700439453, 709.84631347656, 14.405718803406, 0.000000, -90.000000, 169.43664550781, -1 );
  317. /* End of LV */
  318. Toll_CreateTollPickup(L_a_Pickup[0], 623.9500, -1183.9774, 19.2260); // Richman 1
  319. Toll_CreateTollPickup(L_a_Pickup[1], 607.9684, -1194.2866, 19.0043); // Richman 2
  320. Toll_CreateTollPickup(L_a_Pickup[2], 39.7039, -1522.9891, 5.1995); // Flint 1
  321. Toll_CreateTollPickup(L_a_Pickup[3], 62.7378, -1539.9891, 5.0639); // Flint 2
  322. Toll_CreateTollPickup(L_a_Pickup[4], 1795.9447, 704.2550, 15.0006); // LV 1
  323. Toll_CreateTollPickup(L_a_Pickup[5], 1778.9886, 702.6728, 15.2574); // LV 2
  324. }
  325. Toll_CloseToll(TollID)
  326. {
  327. if(TollID == RichmanToll)
  328. {
  329. SetDynamicObjectRot(L_a_TollObject[0], 0.000000, -90.000000, 23.81982421875);
  330. SetDynamicObjectRot(L_a_TollObject[1], 0.000000, -90.000000, 214.37744140625);
  331. Toll_CreateTollPickup(L_a_Pickup[0], 623.9500, -1183.9774, 19.2260); // Richman 1
  332. Toll_CreateTollPickup(L_a_Pickup[1], 607.9684, -1194.2866, 19.0043); // Richman 2
  333. }
  334. else if(TollID == FlintToll)
  335. {
  336. SetDynamicObjectRot(L_a_TollObject[2], 0.000000, -90.000000, 270.67565917969);
  337. SetDynamicObjectRot(L_a_TollObject[3], 0.000000, -90.000000, 87.337799072266);
  338. Toll_CreateTollPickup(L_a_Pickup[2], 39.7039, -1522.9891, 5.1995); // Flint 1
  339. Toll_CreateTollPickup(L_a_Pickup[3], 62.7378, -1539.9891, 5.0639); // Flint 2
  340. }
  341. else if(TollID == LVToll)
  342. {
  343. SetDynamicObjectRot(L_a_TollObject[4], 0.000000, -90.000000, 348.10229492188);
  344. SetDynamicObjectRot(L_a_TollObject[5], 0.000000, -90.000000, 169.43664550781);
  345. Toll_CreateTollPickup(L_a_Pickup[4], 1795.9447, 704.2550, 15.0006); // LV 1
  346. Toll_CreateTollPickup(L_a_Pickup[5], 1778.9886, 702.6728, 15.2574); // LV 2
  347. }
  348. return 1;
  349. }
  350. Toll_OpenToll(TollID, playerid)
  351. {
  352. if(TollID == RichmanToll)
  353. {
  354. L_a_TollPerson[playerid][0] = RichmanToll;
  355. L_a_TollPerson[playerid][1] = (GetUnixTime() + 6);
  356. SetDynamicObjectRot(L_a_TollObject[0], 0.000000, 0.000000, 23.81982421875);
  357. SetDynamicObjectRot(L_a_TollObject[1], 0.000000, 0.000000, 214.37744140625);
  358. Toll_DestroyTollPickup(L_a_Pickup[0]); // Richman 1
  359. Toll_DestroyTollPickup(L_a_Pickup[1]); // Richman 2
  360. L_a_Pickup[0] = 0;
  361. L_a_Pickup[1] = 0;
  362. }
  363. else if(TollID == FlintToll)
  364. {
  365. L_a_TollPerson[playerid][0] = FlintToll;
  366. L_a_TollPerson[playerid][1] = (GetUnixTime() + 6);
  367. SetDynamicObjectRot(L_a_TollObject[2], 0.000000, 0.000000, 270.67565917969);
  368. SetDynamicObjectRot(L_a_TollObject[3], 0.000000, 0.000000, 87.337799072266);
  369. Toll_DestroyTollPickup(L_a_Pickup[2]); // Flint 1
  370. Toll_DestroyTollPickup(L_a_Pickup[3]); // Flint 2
  371. L_a_Pickup[2] = 0;
  372. L_a_Pickup[3] = 0;
  373. }
  374. else if(TollID == LVToll)
  375. {
  376. L_a_TollPerson[playerid][0] = LVToll;
  377. L_a_TollPerson[playerid][1] = (GetUnixTime() + 6);
  378. SetDynamicObjectRot(L_a_TollObject[4], 0.000000, 0.000000, 348.10229492188);
  379. SetDynamicObjectRot(L_a_TollObject[5], 0.000000, 0.000000, 169.43664550781);
  380. Toll_DestroyTollPickup(L_a_Pickup[4]); // LV 1
  381. Toll_DestroyTollPickup(L_a_Pickup[5]); // LV 2
  382. L_a_Pickup[4] = 0;
  383. L_a_Pickup[5] = 0;
  384. }
  385. }
  386. Toll_TimePassedCivil(TollID, playerid) // People have to wait <TollDelayCivilian> seconds between every /opentoll on the same toll
  387. {
  388. new L_i_tick = GetUnixTime();
  389. if(L_a_Pickup[TollID*2])
  390. {
  391. SendClientMessage(playerid, COLOR_RED, "The barrier is already open, wait for it to close before you pay.");
  392. return 0;
  393. }
  394. if(aTolls[TollID][E_tAllowReq] > L_i_tick && aTolls[TollID][E_tAllowReq] != 0)
  395. {
  396. new TollString[64];
  397. format(TollString, 64, "You need to wait at least %d seconds since the last time opened.", TollDelayCivilian);
  398. SendClientMessage(playerid, COLOR_RED, TollString);
  399. return 0;
  400. }
  401. aTolls[TollID][E_tAllowReq] = (L_i_tick + TollDelayCivilian);
  402. return 1;
  403. }
  404. Toll_TimePassedCops(playerid) // Cops have to wait for <TollDelayCop> seconds between every /toll (Global)
  405. {
  406. new L_i_tick = GetUnixTime();
  407. if(L_a_RequestAllowedCop > L_i_tick && L_a_RequestAllowedCop != 0)
  408. {
  409. new TollString[63];
  410. format(TollString, 63, "You need to wait at least %d seconds between each toll change.", TollDelayCop);
  411. SendClientMessage(playerid, COLOR_RED, TollString);
  412. return 0;
  413. }
  414. L_a_RequestAllowedCop = (L_i_tick + TollDelayCop);
  415. return 1;
  416. }
  417. Toll_CreateTollPickup(PickupID, Float:X, Float:Y, Float:Z) // This prevents more than one icon from being spawned at the same time
  418. {
  419. if(PickupID != 0)
  420. DestroyPickup(PickupID);
  421. PickupID = CreatePickup(TollPickupModel, TollPickupType, Float:X, Float:Y, Float:Z, TollPickupVirtualWorld);
  422. return 1;
  423. }
  424. Toll_DestroyTollPickup(PickupID)
  425. {
  426. DestroyPickup(PickupID);
  427. PickupID = 0;
  428. return 1;
  429. }
  430. public ycmd_opentoll(playerid, cmdtext[])
  431. {
  432. #if TollFS == 0
  433. if (cmdtext[0] == 1) cmdtext[0] = 0;
  434. if(!gPlayerLogged[playerid])
  435. {
  436. SendClientMessage(playerid, COLOR_RED, "You are not logged in.");
  437. return 1;
  438. }
  439. #endif
  440. new L_i_TollID;
  441. if(IsPlayerInRangeOfPoint(playerid, TollOpenDistance, 623.9500, -1183.9774, 19.2260) || IsPlayerInRangeOfPoint(playerid, 10.0, 607.9684, -1194.2866, 19.0043)) // Richman tolls
  442. {
  443. L_i_TollID = RichmanToll;
  444. }
  445. else if(IsPlayerInRangeOfPoint(playerid, TollOpenDistance, 39.7039, -1522.9891, 5.1995) || IsPlayerInRangeOfPoint(playerid, 10.0, 62.7378, -1539.9891, 5.0639)) // Flint tolls
  446. {
  447. L_i_TollID = FlintToll;
  448. }
  449. else if(IsPlayerInRangeOfPoint(playerid, TollOpenDistance, 1795.9447, 704.2550, 15.0006) || IsPlayerInRangeOfPoint(playerid, 10.0, 1778.9886, 702.6728, 15.2574)) // LV tolls
  450. {
  451. L_i_TollID = LVToll;
  452. }
  453. else
  454. {
  455. SendClientMessage(playerid, COLOR_RED, "You are not close enough to a toll booth.");
  456. return 1;
  457. }
  458. if(!Toll_TimePassedCivil(L_i_TollID, playerid))
  459. return 1;
  460. new L_sz_MessageString[156];
  461. if(!PDDuty[playerid])
  462. {
  463. if(aTolls[L_i_TollID][E_tLocked] && aTolls[L_i_TollID][E_tTimer] > GetUnixTime()) // If it's locked
  464. {
  465. ProxDetector(20.0, playerid, L_sz_TollStringLocked, COLOR_FADE1, COLOR_FADE2, COLOR_FADE3, COLOR_FADE4, COLOR_FADE5);
  466. return 1;
  467. }
  468. else if(aTolls[L_i_TollID][E_tLocked]) // If it's time to be unlocked
  469. {
  470. aTolls[L_i_TollID][E_tLocked] = 0;
  471. new szTollsUnlocked[100];
  472. switch(L_i_TollID)
  473. {
  474. case RichmanToll:
  475. {
  476. format(szTollsUnlocked, 100, "** HQ Announcement: The Richman tolls were automatically unlocked after the timer finished. **");
  477. }
  478. case FlintToll:
  479. {
  480. format(szTollsUnlocked, 100, "** HQ Announcement: The Flint tolls were automatically unlocked after the timer finished. **");
  481. }
  482. case LVToll:
  483. {
  484. format(szTollsUnlocked, 100, "** HQ Announcement: The Las Venturas tolls were automatically unlocked after the timer finished. **");
  485. }
  486. }
  487. #if !defined foreach
  488. #define foreach(%1,%2) for (new %2 = 0; %2 < MAX_PLAYERS; %2++) if (IsPlayerConnected(%2))
  489. #endif
  490. foreach(Player, i)
  491. {
  492. if(PDDuty[i])
  493. SendClientMessage(i, TEAM_BLUE_COLOR, szTollsUnlocked);
  494. }
  495. }
  496. if(GetPlayerMoney(playerid) < TollCost)
  497. {
  498. SendClientMessage(playerid, COLOR_RED, L_sz_TollStringNoMoney);
  499. return 1;
  500. }
  501. format(L_sz_MessageString, 156, "%s paid %d$ to the toll guard.", GetICName(playerid), TollCost);
  502. GivePlayerMoney(playerid, -TollCost);
  503. ProxDetector(20.0, playerid, L_sz_MessageString, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
  504. #if TollFS == 0
  505. PlayerInfo[playerid][pCash] -= TollCost;
  506. #if TollPayCops > 0
  507. FactionInfo[1][fFunds] += (TollCost/100)*TollPayCops;
  508. FactionInfo[6][fFunds] += (TollCost/100)*TollPayCops;
  509. #endif
  510. #endif
  511. }
  512. ProxDetector(20.0, playerid, L_sz_TollStringBye, COLOR_FADE1, COLOR_FADE2, COLOR_FADE3, COLOR_FADE4, COLOR_FADE5);
  513. SendClientMessage(playerid, COLOR_RED, L_sz_TollStringHurryUp);
  514. Toll_OpenToll(L_i_TollID, playerid);
  515. return 1;
  516. }
  517. public ycmd_toll(playerid, cmdtext[])
  518. {
  519. #if TollFS == 0
  520. if(cmdtext[0] == 1) cmdtext[0] = 0;
  521. if(!gPlayerLogged[playerid])
  522. {
  523. SendClientMessage(playerid, COLOR_RED, "You are not logged in.");
  524. return 1;
  525. }
  526. #endif
  527. new idx,
  528. L_sz_Input[256],
  529. L_sz_CopName[MAX_PLAYER_NAME],
  530. L_sz_MessageString[256],
  531. L_sz_Rank[56],
  532. L_sz_Faction[8];
  533. #if TollFS == 0
  534. if(!PolicePermission(playerid))
  535. {
  536. SendClientMessage(playerid, COLOR_RED, "You're not a cop, cowboy.");
  537. return 1;
  538. }
  539. format(L_sz_Rank, 56, "%s", FactionRank(PlayerInfo[playerid][pFamily], PlayerInfo[playerid][pFamilyRank]));
  540. format(L_sz_Faction, 8, "%s", FactionInfo[PlayerInfo[playerid][pFamily]][fName]);
  541. #else
  542. format(L_sz_Rank, 56, "Rank");
  543. format(L_sz_Faction, 8, "Faction");
  544. strtok(cmdtext, idx);
  545. #endif
  546. format(L_sz_CopName, MAX_PLAYER_NAME, GetICName(playerid));
  547. L_sz_Input = strtok(cmdtext, idx);
  548. if(IsNull(L_sz_Input))
  549. {
  550. SendClientMessage(playerid, COLOR_YELLOW, "Toll barrier command central for Los Santos");
  551. SendClientMessage(playerid, COLOR_GRAD2, "emergency/release - (Un)Locks all the barriers.");
  552. SendClientMessage(playerid, COLOR_GRAD2, "flint - (Un)locks flint tolls.");
  553. SendClientMessage(playerid, COLOR_GRAD2, "richman - (Un)locks Richman tunnel tolls.");
  554. SendClientMessage(playerid, COLOR_GRAD2, "lv - (Un)locks the Las Venturas Highway tolls.");
  555. return 1;
  556. }
  557. if(!Toll_TimePassedCops(playerid))
  558. return 1;
  559. if(strcmp(L_sz_Input, "emergency", true, strlen(L_sz_Input)) == 0)
  560. {
  561. aTolls[FlintToll][E_tLocked] = 1;
  562. aTolls[RichmanToll][E_tLocked] = 1;
  563. aTolls[LVToll][E_tLocked] = 1;
  564. Toll_CloseToll(FlintToll);
  565. Toll_CloseToll(RichmanToll);
  566. Toll_CloseToll(LVToll);
  567. new L_i_Time = (GetUnixTime() + TollTimerEmergency);
  568. aTolls[FlintToll][E_tTimer] = L_i_Time;
  569. aTolls[RichmanToll][E_tTimer] = L_i_Time;
  570. aTolls[LVToll][E_tTimer] = L_i_Time;
  571. format(L_sz_MessageString, 256, "** HQ Announcement: All toll booths were LOCKED by %s %s (%s)! **", L_sz_Rank, L_sz_CopName, L_sz_Faction);
  572. SendTeamTypeMessage(1, TEAM_BLUE_COLOR, L_sz_MessageString);
  573. }
  574. else if(strcmp(L_sz_Input, "release", true, strlen(L_sz_Input)) == 0)
  575. {
  576. aTolls[FlintToll][E_tLocked] = 0;
  577. aTolls[RichmanToll][E_tLocked] = 0;
  578. aTolls[LVToll][E_tLocked] = 0;
  579. format(L_sz_MessageString, 256, "** HQ Announcement: All toll booths were UNLOCKED by %s %s (%s)! **", L_sz_Rank, L_sz_CopName, L_sz_Faction);
  580. SendTeamTypeMessage(1, TEAM_BLUE_COLOR, L_sz_MessageString);
  581. }
  582. else if(strcmp(L_sz_Input, "flint", true, strlen(L_sz_Input)) == 0)
  583. {
  584. if(aTolls[FlintToll][E_tLocked] == 0)
  585. {
  586. aTolls[FlintToll][E_tLocked] = 1;
  587. aTolls[FlintToll][E_tTimer] = (GetUnixTime() + TollTimer);
  588. Toll_CloseToll(FlintToll);
  589. format(L_sz_MessageString, 256, "** HQ Announcement: Toll booths at Flint County were LOCKED by %s %s (%s). **", L_sz_Rank, L_sz_CopName, L_sz_Faction);
  590. SendTeamTypeMessage(1, TEAM_BLUE_COLOR, L_sz_MessageString);
  591. }
  592. else
  593. {
  594. aTolls[FlintToll][E_tLocked] = 0;
  595. format(L_sz_MessageString, 256, "** HQ Announcement: Toll booths at Flint County were UNLOCKED by %s %s (%s). **", L_sz_Rank, L_sz_CopName, L_sz_Faction);
  596. SendTeamTypeMessage(1, TEAM_BLUE_COLOR, L_sz_MessageString);
  597. }
  598. }
  599. else if(strcmp(L_sz_Input, "richman", true, strlen(L_sz_Input)) == 0)
  600. {
  601. if(aTolls[RichmanToll][E_tLocked] == 0)
  602. {
  603. aTolls[RichmanToll][E_tLocked] = 1;
  604. aTolls[RichmanToll][E_tTimer] = (GetUnixTime() + TollTimer);
  605. Toll_CloseToll(RichmanToll);
  606. format(L_sz_MessageString, 256, "** HQ Announcement: Toll booths at Richman were LOCKED by %s %s (%s). **", L_sz_Rank, L_sz_CopName, L_sz_Faction);
  607. SendTeamTypeMessage(1, TEAM_BLUE_COLOR, L_sz_MessageString);
  608. }
  609. else
  610. {
  611. aTolls[RichmanToll][E_tLocked] = 0;
  612. format(L_sz_MessageString, 256, "** HQ Announcement: Toll booths at Richman were UNLOCKED by %s %s (%s). **", L_sz_Rank, L_sz_CopName, L_sz_Faction);
  613. SendTeamTypeMessage(1, TEAM_BLUE_COLOR, L_sz_MessageString);
  614. }
  615. }
  616. else if(strcmp(L_sz_Input, "lv", true) == 0)
  617. {
  618. if(aTolls[LVToll][E_tLocked] == 0)
  619. {
  620. aTolls[LVToll][E_tLocked] = 1;
  621. aTolls[LVToll][E_tTimer] = (GetUnixTime() + TollTimer);
  622. Toll_CloseToll(LVToll);
  623. format(L_sz_MessageString, 256, "** HQ Announcement: Toll booths at Las Venturas were LOCKED by %s %s (%s). **", L_sz_Rank, L_sz_CopName, L_sz_Faction);
  624. SendTeamTypeMessage(1, TEAM_BLUE_COLOR, L_sz_MessageString);
  625. }
  626. else
  627. {
  628. aTolls[LVToll][E_tLocked] = 0;
  629. format(L_sz_MessageString, 256, "** HQ Announcement: Toll booths at Las Venturas were UNLOCKED by %s %s (%s). **", L_sz_Rank, L_sz_CopName, L_sz_Faction);
  630. SendTeamTypeMessage(1, TEAM_BLUE_COLOR, L_sz_MessageString);
  631. }
  632. }
  633. return 1;
  634. }