Guest User

Untitled

a guest
Jul 17th, 2017
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 26.35 KB | None | 0 0
  1.  
  2. /*
  3.  
  4. This is Camp Trailer System.
  5. Credits: Pachino ( www.facebook.com/ErvinSnoopy )
  6.  
  7. Dont delete credits. Enjoy :-)
  8.  
  9. Maded 25.1.2016
  10. */
  11.  
  12. #include <a_samp>
  13. #include < YSI\y_ini >
  14. #include < YSI\y_amx >
  15. #include < YSI\y_commands >
  16. #include < sscanf2 >
  17. #include < streamer >
  18. #include < foreach >
  19.  
  20. //BOJE
  21. #define RED "{F81414}"
  22. #define WHITE "{FFFFFF}"
  23. #define YELLOW "{F3FF02}"
  24. #define GREEN "{6EF83C}"
  25.  
  26. enum
  27. {
  28. DIALOG_CAMPBUY,
  29. DIALOG_CAMP,
  30. DIALOG_CAMPSELL,
  31. DIALOG_CAMPINFO,
  32. INFOBUY_DIALOG
  33. }
  34.  
  35. new LocateCamp[MAX_PLAYERS];
  36. new TowedCamp[MAX_PLAYERS];
  37. new freeze[MAX_PLAYERS];
  38. new EnteredInCamp[MAX_PLAYERS];
  39. new objekt;
  40. ////////////////////////////////////////////////////////////////////////////////
  41. #define MAX_KAMP 900
  42. #define CAMP_FILE "Trailers/%d.ini"
  43. enum kInfo
  44. {
  45. Float:cPosition[4],
  46. cOwner[MAX_PLAYER_NAME],
  47. cID,
  48. cLocked,
  49. cVW
  50. }
  51. new CampInfo[MAX_KAMP][kInfo];
  52. ////////////////////////////////////////////////////////////////////////////////
  53. new Float:RandomKampSpawn[4][4] =
  54. {
  55. {257.0985,-1397.4440,13.7161,209.1387},
  56. {266.8461,-1392.3018,13.8020,194.2435},
  57. {276.3607,-1384.3616,13.8890,206.1503},
  58. {285.1536,-1378.3163,13.9568,201.7636}
  59. };
  60. ////////////////////////////////////////////////////////////////////////////////
  61. #define CAMPUSERS "Campusers/%s.ini"
  62. enum pInfo
  63. {
  64. pCampTrailer
  65. }
  66. new PlayerInfo[MAX_PLAYERS][pInfo];
  67.  
  68. public OnFilterScriptInit()
  69. {
  70. CreateObject(14385, 2511.64355, -1725.43652, 779.20868, 0.00000, 0.00000, 0.00000);
  71. CreateObject(14386, 2511.68457, -1726.33496, 779.07117, 0.00000, 0.00000, 0.00000);
  72. CreateObject(6959, 2509.99023, -1725.06543, 777.64142, 0.00000, 0.00000, 0.00000);
  73. CreateObject(5856, 2509.32813, -1728.60352, 779.61633, 0.00000, 0.00000, 0.00000);
  74. CreateObject(5856, 2508.47363, -1723.26367, 780.11633, 0.00000, 0.00000, 90.00000);
  75. CreateObject(5856, 2511.74902, -1732.35547, 780.64136, 0.00000, 0.00000, 90.00000);
  76. CreateObject(5856, 2512.50391, -1718.44824, 780.11633, 0.00000, 0.00000, 90.00000);
  77. CreateObject(5856, 2508.47168, -1720.57617, 780.11633, 0.00000, 0.00000, 90.00000);
  78. CreateObject(5856, 2513.87891, -1726.26563, 777.88574, 0.00000, 0.00000, 0.00000);
  79. CreateObject(1535, 2513.88281, -1729.93542, 777.63409, 0.00000, 0.00000, 90.51917);
  80. CreateObject(1506, 2513.99487, -1728.44849, 779.47076, 0.00000, 0.00000, 270.26917);
  81. CreateObject(970, 2511.74805, -1732.07617, 778.16162, 90.00000, 179.99451, 0.00000);
  82. CreateObject(970, 2509.78320, -1732.34277, 778.18854, 90.00000, 168.45886, 281.53564);
  83. CreateObject(970, 2513.58301, -1732.32410, 778.08844, 90.00000, 165.52246, 104.47751);
  84. CreateObject(970, 2513.65479, -1725.87256, 778.06342, 90.00000, 191.09619, 78.89282);
  85. CreateObject(970, 2513.97803, -1726.01221, 778.08276, 90.00000, 179.99451, 359.00000);
  86. CreateObject(970, 2513.85938, -1725.26660, 778.63898, 90.00000, 179.99451, 0.00000);
  87. CreateObject(970, 2513.40234, -1723.74805, 778.63898, 90.00000, 179.99451, 90.00000);
  88. CreateObject(970, 2513.82715, -1725.81848, 778.18854, 0.00000, 0.00000, 0.00000);
  89. CreateObject(1271, 2509.66895, -1727.24316, 779.76306, 0.00000, 0.00000, 0.00000);
  90. CreateObject(2238, 2509.91040, -1729.96411, 779.80548, 0.00000, 0.00000, 0.00000);
  91. CreateObject(970, 2510.55396, -1720.80042, 778.18854, 0.00000, 90.00000, 269.98901);
  92. CreateObject(970, 2510.74414, -1719.35400, 778.06342, 90.00000, 180.00549, 178.74170);
  93. CreateObject(2238, 2513.51245, -1724.43384, 779.59894, 0.00000, 0.00000, 0.00000);
  94. CreateObject(2238, 2513.54004, -1723.88220, 779.57098, 0.00000, 0.00000, 0.00000);
  95. CreateObject(2238, 2513.49609, -1722.42236, 779.68225, 0.00000, 0.00000, 0.00000);
  96. CreateObject(2238, 2513.49609, -1721.91296, 779.62988, 0.00000, 0.00000, 0.00000);
  97. CreateObject(2238, 2513.51782, -1723.09290, 779.81281, 0.00000, 90.00000, 89.99994);
  98. CreateObject(2238, 2509.82715, -1726.54150, 780.41589, 0.00000, 1.24695, 0.00000);
  99. CreateObject(2238, 2510.29443, -1726.65588, 778.85077, 0.00000, 0.00000, 18.00000);
  100. CreateObject(14811, 2503.91211, -1725.65723, 780.97998, 0.00000, 0.00000, 179.99451);
  101. CreateObject(14792, 2524.25366, -1730.83765, 770.23480, 0.00000, 270.00000, 84.74207);
  102. CreateObject(3882, 2507.34399, -1730.58899, 778.89697, 0.00000, 0.00000, 270.00000);
  103. CreateObject(3882, 2515.62158, -1727.21484, 778.73315, 0.00000, 0.00000, 173.50000);
  104. CreateObject(14792, 2499.67480, -1731.37695, 777.90527, 0.00000, 179.99451, 0.24719);
  105. CreateObject(3882, 2507.34375, -1730.58594, 779.45837, 0.00000, 0.00000, 270.00000);
  106. CreateObject(3882, 2507.34180, -1729.19165, 780.48315, 0.00000, 270.00000, 272.00000);
  107. CreateObject(3882, 2507.34302, -1728.20898, 776.28320, 0.00330, 89.74979, 266.49097);
  108. CreateObject(3119, 2511.17334, -1731.36597, 778.46405, 0.00000, 0.00000, 279.99756);
  109. CreateObject(14633, 2498.01660, -1727.52539, 780.12848, 0.00000, 0.00000, 229.49890);
  110. CreateObject(2801, 2512.41235, -1725.27368, 778.33301, 0.00000, 0.00000, 160.00000);
  111. CreateObject(18059, 2503.31372, -1726.64905, 779.76477, 270.79053, 341.55078, 341.55261);
  112. CreateObject(14399, 2502.31055, -1729.33398, 782.71124, 0.00000, 179.99451, 0.00000);
  113. CreateObject(14399, 2507.34692, -1723.35071, 777.56036, 359.97723, 90.24921, 359.99988);
  114. CreateObject(14827, 2506.91602, -1715.21484, 778.83691, 0.00000, 0.00000, 270.00000);
  115. CreateObject(951, 2514.33398, -1729.16504, 778.62836, 0.00000, 0.00000, 90.00000);
  116. CreateObject(14515, 2480.00684, -1686.86035, 778.87195, 0.00000, 0.00000, 91.99402);
  117. CreateObject(14515, 2510.33594, -1711.49023, 778.10120, 0.00000, 0.00000, 0.48889);
  118. CreateObject(14515, 2542.93457, -1703.63281, 777.85095, 0.00000, 179.49463, 269.98901);
  119. CreateObject(14515, 2542.21289, -1768.89941, 779.00488, 0.00000, 0.00000, 270.24719);
  120. CreateObject(18105, 2513.10962, -1738.30774, 781.04999, 0.00000, 0.00000, 89.75000);
  121. CreateObject(18109, 2518.55176, -1718.56738, 779.46002, 0.00000, 0.00000, 359.74731);
  122. CreateObject(2074, 2512.24878, -1727.47363, 779.84137, 0.00000, 0.00000, 338.25000);
  123. CreateObject(2342, 2512.08130, -1730.60217, 778.27698, 0.00000, 0.00000, 90.50000);
  124. CreateObject(2213, 2512.46143, -1727.53589, 778.55298, 334.64355, 23.07678, 342.83923);
  125. CreateObject(2212, 2514.13452, -1724.98169, 778.72101, 334.41833, 23.12863, 77.69974);
  126. CreateObject(14651, 2514.03516, -1729.05273, 782.37476, 0.00000, 179.99451, 89.99451);
  127. CreateObject(2486, 2513.62598, -1728.41602, 780.11041, 0.00000, 0.00000, 354.99573);
  128. CreateObject(2542, 2509.67285, -1727.23926, 780.11279, 7.24548, 0.00000, 90.48889);
  129. CreateObject(14863, 2514.41626, -1721.61475, 777.73029, 358.25043, 1.25058, 100.03818);
  130. CreateObject(14521, 2516.21582, -1719.97852, 777.89374, 359.00024, 355.74829, 56.92566);
  131. CreateObject(14521, 2512.98560, -1717.36743, 777.76862, 0.00000, 0.00000, 356.99609);
  132. CreateObject(2846, 2509.38184, -1725.77344, 779.51123, 0.98877, 72.27356, 274.89990);
  133. CreateObject(15027, 2515.75171, -1721.22876, 778.91803, 358.75031, 1.25030, 316.02731);
  134. CreateObject(15028, 2508.43262, -1728.42773, 778.88507, 5.49316, 1.50513, 137.85095);
  135. CreateObject(8251, 2501.36523, -1720.72363, 779.16528, 0.00000, 179.99451, 0.24719);
  136. CreateObject(3069, 2509.57324, -1716.11426, 778.48383, 0.00000, 269.74182, 173.73779);
  137. CreateObject(2768, 2512.41431, -1727.64221, 778.57001, 0.00000, 0.00000, 90.00000);
  138. CreateObject(2215, 2513.61768, -1725.02319, 778.71051, 334.46390, 23.40106, 10.56726);
  139. CreateObject(1510, 2511.97144, -1727.27576, 778.53699, 0.00000, 0.00000, 0.00000);
  140. CreateObject(1485, 2511.78125, -1727.24219, 778.56299, 0.00000, 4.25000, 0.00000);
  141. CreateObject(3503, 2512.20288, -1727.49988, 777.14349, 0.00000, 0.00000, 179.99719);
  142. CreateObject(1897, 2510.34766, -1723.40527, 777.56226, 0.00000, 179.99451, 270.00000);
  143. CreateObject(14482, 2517.00391, -1733.34473, 778.15485, 0.00000, 0.00000, 270.00000);
  144. CreateObject(2006, 2510.07617, -1726.57227, 779.75000, 90.00000, 0.00000, 5.50000);
  145. CreateObject(1933, 2512.23779, -1727.38184, 778.43787, 0.00000, 0.00000, 0.00000);
  146. CreateObject(1916, 2512.12622, -1727.17908, 778.51294, 0.00000, 0.00000, 0.00000);
  147. CreateObject(2141, 2513.40967, -1721.14746, 777.66742, 0.00000, 0.00000, 269.74731);
  148. CreateObject(14802, 2516.44873, -1716.70764, 778.92389, 0.00000, 0.00000, 182.50000);
  149. CreateObject(2372, 2510.67285, -1725.29980, 777.46191, 0.00000, 0.00000, 0.24719);
  150. CreateObject(11353, 2509.90430, -1706.01855, 781.41321, 0.00000, 270.00000, 0.00000);
  151. CreateObject(3002, 2510.08984, -1726.57910, 779.82001, 0.00000, 0.00000, 249.99939);
  152. CreateObject(11292, 2507.32617, -1722.26172, 779.37451, 0.00000, 0.00000, 269.74731);
  153. CreateObject(11292, 2505.13867, -1730.87988, 780.05017, 0.00000, 0.00000, 179.99451);
  154. CreateObject(5856, 2510.47266, -1718.52710, 780.11633, 0.00000, 0.00000, 180.00000);
  155. CreateObject(2225, 2511.54834, -1730.32129, 778.16162, 0.00000, 180.00000, 0.25000);
  156. CreateObject(2812, 2509.82324, -1723.68848, 778.48224, 0.00000, 0.00000, 340.75000);
  157. CreateObject(2816, 2510.21362, -1731.61340, 778.29999, 357.50092, 1.50143, 332.81543);
  158. CreateObject(2813, 2509.28662, -1729.17590, 779.66187, 275.53827, 263.26288, 82.82956);
  159. CreateObject(2813, 2509.34277, -1729.13794, 779.52472, 70.22913, 87.48904, 356.76605);
  160. CreateObject(2831, 2510.16040, -1724.59290, 778.70001, 0.00000, 0.00000, 156.00000);
  161. CreateObject(2827, 2509.64233, -1727.96570, 778.78723, 0.00000, 359.50000, 25.75000);
  162. CreateObject(2827, 2509.54468, -1727.57922, 778.67438, 43.50488, 90.23724, 266.40210);
  163. CreateObject(2824, 2513.54150, -1726.11646, 778.28772, 359.08655, 1.00000, 89.42963);
  164. CreateObject(2853, 2509.61719, -1727.18042, 778.94037, 0.74985, 180.25049, 70.24658);
  165. CreateObject(14830, 2498.98999, -1721.88245, 779.26385, 0.00000, 0.00000, 270.25000);
  166. CreateObject(2247, 2510.05200, -1723.52014, 780.00183, 334.13693, 349.43109, 160.84692);
  167. CreateObject(2684, 2511.98950, -1727.61658, 778.54401, 271.03418, 299.16052, 219.31554);
  168. CreateObject(1324, 2511.34741, -1720.61023, 779.22156, 0.00000, 0.50000, 269.50000);
  169. CreateObject(7313, 2509.38794, -1728.04419, 776.30499, 359.75122, 269.97278, 90.50012);
  170. CreateObject(7313, 2509.39185, -1728.04468, 776.06177, 359.74731, 269.97253, 90.24695);
  171. CreateObject(12954, 2509.72559, -1735.59570, 772.49335, 338.10974, 269.99451, 179.93958);
  172. CreateObject(1897, 2510.03979, -1729.11389, 778.63708, 89.73633, 72.40540, 287.50391);
  173. CreateObject(2860, 2513.73828, -1721.21521, 780.16400, 0.00000, 0.00000, 164.00000);
  174. CreateObject(1209, 2513.19287, -1721.95972, 778.08490, 0.00000, 270.00000, 90.00000);
  175. CreateObject(2558, 2514.14819, -1727.60510, 778.66211, 0.00000, 0.00000, 90.00000);
  176. CreateObject(2872, 2509.50293, -1727.84033, 777.83728, 344.75000, 0.00000, 106.50000);
  177. CreateObject(18866, 2511.70630, -1730.56201, 778.14502, 0.00000, 0.00000, 40.00000);
  178. CreateObject(18644, 2513.01465, -1724.63196, 778.70099, 90.00000, 0.00000, 250.00000);
  179. CreateObject(18635, 2513.01611, -1725.57214, 778.66998, 90.00000, 111.00000, 0.00000);
  180. CreateObject(2673, 2509.37109, -1728.60034, 779.81000, 0.00000, 0.00000, 239.00000);
  181. //==========================================================================
  182. for(new i = 0; i < sizeof(CampInfo); i++)
  183. {
  184. new kFile[50];
  185. format(kFile, sizeof(kFile), CAMP_FILE, i);
  186. if(fexist(kFile))
  187. {
  188. INI_ParseFile(kFile, "UcitajKamp", .bExtra = true, .extra = i);
  189. CampInfo[i][cID] = CreateVehicle(607, CampInfo[i][cPosition][0], CampInfo[i][cPosition][1], CampInfo[i][cPosition][2], CampInfo[i][cPosition][3], 0, 0, -1);
  190. objekt = CreateObject(3171, 0,0,0,0,0,0);
  191. AttachObjectToVehicle(objekt, CampInfo[i][cID], 0.084999, -2.125115, -1.144999, -3.014999, 0.000000, 178.890090);
  192. }
  193. }
  194. CreateDynamicPickup(19132, 1, 257.0985,-1397.4440,13.7161);
  195. CreateDynamic3DTextLabel(""WHITE"[ "GREEN"/buycamp "WHITE"]",-1,257.0985,-1397.4440,13.7161, 30, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, -1, -1, -1, 20.0);
  196. return 1;
  197. }
  198. public OnFilterScriptExit()
  199. {
  200. foreach(Player, i)
  201. {
  202. KillTimer(freeze[i]);
  203. }
  204. return 1;
  205. }
  206. public OnPlayerConnect(playerid)
  207. {
  208. PlayerInfo[playerid][pCampTrailer] = -1; TowedCamp[playerid] = 0;
  209. EnteredInCamp[playerid] = 0;
  210. if(fexist(Campusers(playerid)))
  211. {
  212. INI_ParseFile(Campusers(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
  213. }
  214. return 1;
  215. }
  216. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  217. {
  218. if(newkeys & KEY_NO)
  219. {
  220. for(new i; i < MAX_KAMP; i++)
  221. {
  222. if(IsPlayerInRangeOfPoint(playerid, 4.0, CampInfo[i][cPosition][0], CampInfo[i][cPosition][1], CampInfo[i][cPosition][2]))
  223. {
  224. if(EnteredInCamp[playerid] == 0)
  225. {
  226. GameTextForPlayer(playerid, "~y~Objects loading...", 5000, 4);
  227. freeze[playerid] = SetTimerEx("Freeze",3000, false, "i", playerid);
  228. TogglePlayerControllable(playerid, 0);
  229. SetPlayerPos(playerid, 2513.19897, -1729.12073, 778.67657);
  230. SetPlayerVirtualWorld(playerid, CampInfo[i][cVW]);
  231. EnteredInCamp[playerid] = 1;
  232. }
  233. }
  234. else if(IsPlayerInRangeOfPoint(playerid, 2.0, 2513.19897, -1729.12073, 778.67657))
  235. {
  236. if(EnteredInCamp[playerid] == 1)
  237. {
  238. SetPlayerPos(playerid, CampInfo[i][cPosition][0], CampInfo[i][cPosition][1], CampInfo[i][cPosition][2]);
  239. SetPlayerVirtualWorld(playerid, 0); SetPlayerInterior(playerid, 0);
  240. EnteredInCamp[playerid] = 0;
  241. }
  242. }
  243. }
  244. }
  245. if(newkeys & KEY_YES)
  246. {
  247. if(IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
  248. {
  249. new i = PlayerInfo[playerid][pCampTrailer];
  250. new Float:Poz[3];
  251. GetVehiclePos(CampInfo[i][cID], Poz[0], Poz[1], Poz[2]);
  252. if(IsPlayerInRangeOfPoint(playerid, 6.0, Poz[0], Poz[1], Poz[2]))
  253. {
  254. if(TowedCamp[playerid] == 0)
  255. {
  256. objekt = CreateObject(3171, 0,0,0,0,0,0);
  257. new vehicleid = GetPlayerVehicleID(playerid);
  258. AttachObjectToVehicle(objekt, CampInfo[i][cID], 0.084999, -2.125115, -1.144999, -3.014999, 0.000000, 178.890090);
  259. AttachTrailerToVehicle(CampInfo[i][cID], vehicleid); TowedCamp[playerid] = 1;
  260. SendClientMessage(playerid,-1,""GREEN"You are sucessfuly towed Camp Trailer!");
  261. }
  262. else if(TowedCamp[playerid] == 1)
  263. {
  264. new newcartr = GetPlayerVehicleID(playerid);
  265. if(IsTrailerAttachedToVehicle(newcartr))
  266. {
  267. new vehicleid = GetPlayerVehicleID(playerid);
  268. DetachTrailerFromVehicle(vehicleid);
  269. TowedCamp[playerid] = 0;
  270. SendClientMessage(playerid,-1,""GREEN"You are sucessfuly untowed Camp Trailer!");
  271. }
  272. }
  273. }
  274. }
  275. }
  276. return 1;
  277. }
  278. public OnPlayerDeath(playerid, killerid, reason)
  279. {
  280. if(EnteredInCamp[playerid] == 1)
  281. {
  282. EnteredInCamp[playerid] = 0; SetPlayerVirtualWorld(playerid, 0);
  283. }
  284. if(TowedCamp[playerid] == 1)
  285. {
  286. TowedCamp[playerid] = 0;
  287. }
  288. return 1;
  289. }
  290. public OnVehicleDeath(vehicleid, killerid)
  291. {
  292. for(new i; i < MAX_KAMP; i++)
  293. {
  294. if(vehicleid == CampInfo[i][cID])
  295. {
  296. DestroyObject(objekt);
  297. }
  298. }
  299. return 1;
  300. }
  301.  
  302. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  303. {
  304. if(dialogid == DIALOG_CAMPBUY)
  305. {
  306. if(!response) return SendClientMessage(playerid,-1,""WHITE"You are exit from Camp Trailer Buy Menu!");
  307. if(response)
  308. {
  309. if(GetPlayerMoney(playerid) < 10000) return SendClientMessage(playerid,-1,""RED"[!] "WHITE"You dont have money!");
  310. for(new i = 0; i < sizeof(CampInfo); i++)
  311. {
  312. new Fajl[64];
  313. format(Fajl, sizeof(Fajl), CAMP_FILE, i);
  314. if(!fexist(Fajl))
  315. {
  316. new poz = random(sizeof(RandomKampSpawn));
  317. CampInfo[i][cPosition][0] = RandomKampSpawn[poz][0];
  318. CampInfo[i][cPosition][1] = RandomKampSpawn[poz][1];
  319. CampInfo[i][cPosition][2] = RandomKampSpawn[poz][2];
  320. CampInfo[i][cPosition][3] = RandomKampSpawn[poz][3];
  321. CampInfo[i][cLocked] = 1; CampInfo[i][cVW] = i;
  322. strmid(CampInfo[i][cOwner], GetName(playerid), 0, strlen(GetName(playerid)), 999);
  323. CampInfo[i][cID] = CreateVehicle(607, CampInfo[i][cPosition][0], CampInfo[i][cPosition][1], CampInfo[i][cPosition][2], CampInfo[i][cPosition][3], 0, 0, 100);
  324. objekt = CreateObject(3171, 0,0,0,0,0,0);
  325. AttachObjectToVehicle(objekt, CampInfo[i][cID], 0.084999, -2.125115, -1.144999, -3.014999, 0.000000, 178.890090);
  326. GivePlayerMoney(playerid,-10000); PlayerInfo[playerid][pCampTrailer] = i;
  327. SaveCamp(i); SavePlayer(playerid);
  328. ShowPlayerDialog(playerid,INFOBUY_DIALOG,DIALOG_STYLE_MSGBOX,""GREEN"Camp Trailer",""WHITE"You are sucessfuly buy Camp Trailer, use "GREEN"/camptrailer\n"WHITE"If you want to tow trailer use key "GREEN"'Y'"WHITE", for enter in trailer use key "GREEN"'N'","Okey","");
  329. break;
  330. }
  331. }
  332. }
  333. }
  334. if(dialogid == DIALOG_CAMP)
  335. {
  336. if(!response) return 1;
  337. if(PlayerInfo[playerid][pCampTrailer] == -1) return SendClientMessage(playerid,-1,""RED"[!] "WHITE"Vi ne posjedujete kamp prikolicu!");
  338. new i = PlayerInfo[playerid][pCampTrailer];
  339. switch(listitem)
  340. {
  341. case 0:
  342. {
  343. new kPrikolica[250];
  344. new z[5]; if(CampInfo[i][cLocked] == 1) z = "Da"; else z = "Ne";
  345. format(kPrikolica, sizeof(kPrikolica), ""GREEN"_______________________________\n\n\
  346. "WHITE"Locked: "WHITE"%s | "WHITE"Owner: "WHITE"%s\n\n\
  347. "GREEN"_______________________________", z, CampInfo[i][cOwner]);
  348. ShowPlayerDialog(playerid, DIALOG_CAMPINFO, DIALOG_STYLE_MSGBOX, ""GREEN"Camp Trailer Info", kPrikolica, "Okey", "");
  349. }
  350. case 1:
  351. {
  352. new Float:Poz[3];
  353. GetVehiclePos(CampInfo[i][cID], Poz[0], Poz[1], Poz[2]);
  354. if(!IsPlayerInRangeOfPoint(playerid, 6.0, Poz[0], Poz[1], Poz[2])) return SendClientMessage(playerid,-1,""RED"[!] "WHITE"You need to be near your Camp Trailer!");
  355. if(CampInfo[i][cLocked] == 0)
  356. {
  357. CampInfo[i][cLocked] = 1; SaveCamp(i);
  358. GameTextForPlayer(playerid, "~w~Camp trailer ~r~locked", 5000, 3);
  359. }
  360. else
  361. {
  362. CampInfo[i][cLocked] = 0; SaveCamp(i);
  363. GameTextForPlayer(playerid, "~w~Camp Trailer ~g~unlocked", 5000, 3);
  364. }
  365. }
  366. case 2:
  367. {
  368. new Float:Poz[4];
  369. GetVehiclePos(CampInfo[i][cID], Poz[0], Poz[1], Poz[2]);
  370. GetVehicleZAngle(CampInfo[i][cID], Poz[3]);
  371. new vehicleid = GetPlayerVehicleID(playerid);
  372. if(!IsPlayerInVehicle(playerid,vehicleid)) return SendClientMessage(playerid,-1,""RED"[!] "WHITE"You need to be in vehicle!");
  373. if(!IsPlayerInRangeOfPoint(playerid, 6.0, Poz[0], Poz[1], Poz[2])) return SendClientMessage(playerid,-1,""RED"[!] "WHITE"You need to be near your Camp Trailer!");
  374. if(TowedCamp[playerid] == 1)
  375. {
  376. CampInfo[i][cPosition][0] = Poz[0]; CampInfo[i][cPosition][1] = Poz[1];
  377. CampInfo[i][cPosition][2] = Poz[2]; CampInfo[i][cPosition][3] = Poz[3];
  378. DestroyVehicle(CampInfo[i][cID]);
  379. CampInfo[i][cID] = CreateVehicle(607, CampInfo[i][cPosition][0], CampInfo[i][cPosition][1], CampInfo[i][cPosition][2], CampInfo[i][cPosition][3], 0, 0, -1);
  380. SendClientMessage(playerid,-1,""RED"[!] "WHITE"Camp Trailer sucessfuly parked!");
  381. SaveCamp(i); SetVehicleToRespawn(CampInfo[i][cID]);
  382. }
  383. else return SendClientMessage(playerid,-1,""RED"[!] "WHITE"You need to tow Camp Trailer on vehicle (Key: Y)!");
  384. }
  385. case 3:
  386. {
  387. new Float:Poz[3]; LocateCamp[playerid] = 1;
  388. GetVehiclePos(CampInfo[i][cID], Poz[0], Poz[1], Poz[2]);
  389. SetPlayerCheckpoint(playerid, Poz[0], Poz[1], Poz[2], 4.0);
  390. SendClientMessage(playerid,-1,""GREEN"Your Camp Trailer are marked on radar!");
  391. }
  392. case 4:
  393. {
  394. new Float:Poz[3];
  395. GetVehiclePos(CampInfo[i][cID], Poz[0], Poz[1], Poz[2]);
  396. if(!IsPlayerInRangeOfPoint(playerid, 6.0, Poz[0], Poz[1], Poz[2])) return SendClientMessage(playerid,-1,""RED"[!] "WHITE"You need to be near your Camp trailer!");
  397. ShowPlayerDialog(playerid,DIALOG_CAMPSELL,DIALOG_STYLE_MSGBOX,""GREEN"Sell Camp Trailer",""WHITE"Do you want sell your Camp Trailer for $5000?","Sell","Cancel");
  398. }
  399. }
  400. }
  401. if(dialogid == DIALOG_CAMPSELL)
  402. {
  403. if(!response) return SendClientMessage(playerid,-1,""GREEN"You have been withdrawn from the sale of Camp trailer!");
  404. if(response)
  405. {
  406. new i = PlayerInfo[playerid][pCampTrailer];
  407. DestroyVehicle(CampInfo[i][cID]); DestroyObject(objekt);
  408. IzbrisiKampPrikolicu(PlayerInfo[playerid][pCampTrailer]);
  409. PlayerInfo[playerid][pCampTrailer] = -1;
  410. GivePlayerMoney(playerid,5000); SavePlayer(playerid);
  411. SendClientMessage(playerid,-1,""GREEN"You are succesfuly sold your Camp Trailer!");
  412. }
  413. }
  414. return 1;
  415. }
  416. YCMD:camptrailer(playerid, params[], help)
  417. {
  418. #pragma unused help
  419. #pragma unused params
  420. if(PlayerInfo[playerid][pCampTrailer] == -1) return SendClientMessage(playerid,-1,""RED"[!] "WHITE"You are not own Camp Trailer!");
  421. ShowPlayerDialog(playerid,DIALOG_CAMP,DIALOG_STYLE_LIST,""GREEN"Manage Your Camp trailer",""WHITE"Information\n"RED"Lock"WHITE"/"GREEN"Unlock\n"WHITE"Park\nLocate\nSell","Continue","Cancel");
  422. return 1;
  423. }
  424. YCMD:buycamp(playerid, params[], help)
  425. {
  426. #pragma unused help
  427. #pragma unused params
  428. if(!IsPlayerInRangeOfPoint(playerid, 5.0, 257.0985, -1397.4440, 13.7161)) return SendClientMessage(playerid,-1,""RED"[!] "WHITE"You have to be in place for the purchase of camp trailers!");
  429. if(PlayerInfo[playerid][pCampTrailer] != -1) return SendClientMessage(playerid,-1,""RED"[!] "WHITE"You already have Camp Trailer!");
  430. ShowPlayerDialog(playerid,DIALOG_CAMPBUY,DIALOG_STYLE_MSGBOX,""GREEN"Buy Camp Trailer",""WHITE"Do you want buy Camp Trailer for $10000?","Buy","Cancel");
  431. return 1;
  432. }
  433. stock IzbrisiKampPrikolicu(id)
  434. {
  435. new kampFile[32];
  436. format(kampFile, sizeof(kampFile), CAMP_FILE, id);
  437. if(fexist(kampFile))
  438. {
  439. fremove(kampFile);
  440. }
  441. return 1;
  442. }
  443. stock GetName(playerid)
  444. {
  445. new pName[MAX_PLAYER_NAME];
  446. GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
  447. for(new i = 0; i < MAX_PLAYER_NAME; i++)
  448. {
  449. if(pName[i] == '_') pName[i] = ' ';
  450. }
  451. return pName;
  452. }
  453. forward LoadUser_data(playerid,name[],value[]);
  454. public LoadUser_data(playerid,name[],value[])
  455. {
  456. INI_Int("CampTrailer",PlayerInfo[playerid][pCampTrailer]);
  457. return 1;
  458. }
  459. forward UcitajKamp(id, name[], value[]);
  460. public UcitajKamp(id, name[], value[])
  461. {
  462. INI_Int("ID", CampInfo[id][cID]);
  463. INI_Float("X", CampInfo[id][cPosition][0]);
  464. INI_Float("Y", CampInfo[id][cPosition][1]);
  465. INI_Float("Z", CampInfo[id][cPosition][2]);
  466. INI_Float("A", CampInfo[id][cPosition][3]);
  467. INI_String("Owner", CampInfo[id][cOwner],MAX_PLAYER_NAME);
  468. INI_Int("Locked", CampInfo[id][cLocked]);
  469. INI_Int("VirtualWorld", CampInfo[id][cVW]);
  470. return 1;
  471. }
  472. forward Freeze(playerid);
  473. public Freeze(playerid)
  474. {
  475. TogglePlayerControllable(playerid, 1);
  476. GameTextForPlayer(playerid, "~b~Objects succesfuly loaded!", 5000, 4);
  477. return 1;
  478. }
  479. /////////////////////////////////////////////////////
  480. stock SaveCamp(id)
  481. {
  482. new kFile[80];
  483. format(kFile, sizeof(kFile), CAMP_FILE, id);
  484. new INI:File = INI_Open(kFile);
  485. INI_WriteInt(File,"ID", CampInfo[id][cID]);
  486. INI_WriteFloat(File,"X", CampInfo[id][cPosition][0]);
  487. INI_WriteFloat(File,"Y", CampInfo[id][cPosition][1]);
  488. INI_WriteFloat(File,"Z", CampInfo[id][cPosition][2]);
  489. INI_WriteFloat(File,"A", CampInfo[id][cPosition][3]);
  490. INI_WriteString(File,"Owner", CampInfo[id][cOwner]);
  491. INI_WriteInt(File,"Locked", CampInfo[id][cLocked]);
  492. INI_WriteInt(File,"VirtualWorld", CampInfo[id][cVW]);
  493. INI_Close(File);
  494. return 1;
  495. }
  496. ////////////////////////////////////////////////
  497. stock SavePlayer(playerid)
  498. {
  499. new INI:File = INI_Open(Campusers(playerid));
  500. INI_SetTag(File,"data");
  501. INI_WriteInt(File,"CampTrailer",PlayerInfo[playerid][pCampTrailer]);
  502. INI_Close(File);
  503. return 1;
  504. }
  505. stock Campusers(playerid)
  506. {
  507. new string[128];
  508. format(string,sizeof(string),CAMPUSERS,GetName(playerid));
  509. return string;
  510. }
  511. public OnPlayerEnterCheckpoint(playerid)
  512. {
  513. if(LocateCamp[playerid] == 1) return DisablePlayerCheckpoint(playerid), LocateCamp[playerid] = 0, GameTextForPlayer(playerid, "~y~CAMP TRAILER LOCATED", 5000, 3);
  514. return 1;
  515. }
Advertisement
Add Comment
Please, Sign In to add comment