Advertisement
Guest User

Untitled

a guest
Jan 19th, 2019
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 43.79 KB | None | 0 0
  1. /*
  2. Garage system (include) by Edison for Burned RPG gamemode.
  3. Started date: 05.11.2017, 9:38 AM
  4. Version: 0.1
  5.  
  6. Mentinuti:
  7. > Adaugat in baza de date la vehicule un nou rand cu Virtual World
  8. */
  9. #include <YSI\y_hooks>
  10.  
  11. #define MAX_GARAGES 10
  12. #define SELL_GARAGE_PRICE 100000
  13.  
  14. #define DIALOG_CREATEGARAGE 600
  15. #define DIALOG_MOVEGARAGE 601
  16. #define DIALOG_BUYGARAGE 602
  17. #define DIALOG_SELLGARAGE 603
  18. #define DIALOG_PARKVEHICLE 604
  19.  
  20. enum gInfo {
  21. gID,
  22. gOwner[32],
  23. gUserID,
  24. gPrice,
  25. gVirtualID,
  26. gPickup,
  27. Text3D:garageLabel,
  28. Float:gPos[3],
  29. Float:gAngle
  30. };
  31.  
  32. new Float: garageCamera[10][3] = {
  33. {489.4090, -407.8293, 2759.0259},
  34. {487.9755, -413.0212, 2758.8210},
  35. {488.2816, -417.9112, 2759.0208},
  36. {487.9942, -422.5949, 2758.6604},
  37. {488.0660, -427.1760, 2758.8335},
  38. {487.4478, -407.2060, 2759.0398},
  39. {487.2461, -413.1223, 2759.0398},
  40. {487.0870, -418.3049, 2759.0398},
  41. {486.8073, -423.0642, 2759.0398},
  42. {486.5077, -427.8227, 2759.0398}
  43. };
  44.  
  45. new Float: garageCamera_at[10][3] = {
  46. {488.5297, -407.3569, 2758.8579},
  47. {487.1125, -412.5193, 2758.7012},
  48. {487.3769, -417.4890, 2758.8955},
  49. {487.0796, -422.1945, 2758.5706},
  50. {487.1324, -426.8218, 2758.6987},
  51. {488.4458, -407.2309, 2758.8540},
  52. {488.2441, -413.1472, 2758.8540},
  53. {488.0849, -418.3358, 2758.8540},
  54. {487.8037, -423.1270, 2758.8589},
  55. {487.5041, -427.8854, 2758.8589}
  56. };
  57.  
  58. new
  59. garageInfo[MAX_GARAGES][gInfo], garages,
  60. PlayerText: BarTD, BarTimer[MAX_PLAYERS], Step[MAX_PLAYERS],
  61. PlayerText: GaragePTD[3], Text: GarageTD[5];
  62.  
  63. hook OnGameModeInit() {
  64. SetTimer("LoadGarages", 1000, false);
  65. load_garage_map();
  66.  
  67. GarageTD[0] = TextDrawCreate(537.499511, 331.866485, "My Garage");
  68. TextDrawLetterSize(GarageTD[0], 0.215999, 1.222517);
  69. TextDrawTextSize(GarageTD[0], 0.000000, 128.000000);
  70. TextDrawAlignment(GarageTD[0], 2);
  71. TextDrawColor(GarageTD[0], -1);
  72. TextDrawUseBox(GarageTD[0], 1);
  73. TextDrawBoxColor(GarageTD[0], 255);
  74. TextDrawSetShadow(GarageTD[0], 0);
  75. TextDrawSetOutline(GarageTD[0], 1);
  76. TextDrawBackgroundColor(GarageTD[0], 62);
  77. TextDrawFont(GarageTD[0], 2);
  78. TextDrawSetProportional(GarageTD[0], 1);
  79. TextDrawSetShadow(GarageTD[0], 0);
  80.  
  81. GarageTD[1] = TextDrawCreate(466.199737, 392.188903, "LD_BEAT:chit");
  82. TextDrawLetterSize(GarageTD[1], 0.000000, 0.000000);
  83. TextDrawTextSize(GarageTD[1], 26.000000, 28.000000);
  84. TextDrawAlignment(GarageTD[1], 1);
  85. TextDrawColor(GarageTD[1], 255);
  86. TextDrawSetShadow(GarageTD[1], 0);
  87. TextDrawSetOutline(GarageTD[1], 0);
  88. TextDrawBackgroundColor(GarageTD[1], 255);
  89. TextDrawFont(GarageTD[1], 4);
  90. TextDrawSetProportional(GarageTD[1], 0);
  91. TextDrawSetShadow(GarageTD[1], 0);
  92.  
  93. GarageTD[2] = TextDrawCreate(586.300292, 392.259368, "LD_BEAT:chit");
  94. TextDrawLetterSize(GarageTD[2], 0.000000, 0.000000);
  95. TextDrawTextSize(GarageTD[2], 26.000000, 28.000000);
  96. TextDrawAlignment(GarageTD[2], 1);
  97. TextDrawColor(GarageTD[2], 255);
  98. TextDrawSetShadow(GarageTD[2], 0);
  99. TextDrawSetOutline(GarageTD[2], 0);
  100. TextDrawBackgroundColor(GarageTD[2], 255);
  101. TextDrawFont(GarageTD[2], 4);
  102. TextDrawSetProportional(GarageTD[2], 0);
  103. TextDrawSetShadow(GarageTD[2], 0);
  104.  
  105. GarageTD[3] = TextDrawCreate(472.366821, 399.140869, "LD_BEAT:left");
  106. TextDrawLetterSize(GarageTD[3], 0.000000, 0.000000);
  107. TextDrawTextSize(GarageTD[3], 13.000000, 15.000000);
  108. TextDrawAlignment(GarageTD[3], 1);
  109. TextDrawColor(GarageTD[3], 8388827);
  110. TextDrawSetShadow(GarageTD[3], 0);
  111. TextDrawSetOutline(GarageTD[3], 0);
  112. TextDrawBackgroundColor(GarageTD[3], 255);
  113. TextDrawFont(GarageTD[3], 4);
  114. TextDrawSetProportional(GarageTD[3], 0);
  115. TextDrawSetShadow(GarageTD[3], 0);
  116. TextDrawSetSelectable(GarageTD[3], true);
  117.  
  118. GarageTD[4] = TextDrawCreate(594.000183, 398.851959, "LD_BEAT:right");
  119. TextDrawLetterSize(GarageTD[4], 0.000000, 0.000000);
  120. TextDrawTextSize(GarageTD[4], 13.000000, 15.000000);
  121. TextDrawAlignment(GarageTD[4], 1);
  122. TextDrawColor(GarageTD[4], 8388827);
  123. TextDrawSetShadow(GarageTD[4], 0);
  124. TextDrawSetOutline(GarageTD[4], 0);
  125. TextDrawBackgroundColor(GarageTD[4], 255);
  126. TextDrawFont(GarageTD[4], 4);
  127. TextDrawSetProportional(GarageTD[4], 0);
  128. TextDrawSetShadow(GarageTD[4], 0);
  129. TextDrawSetSelectable(GarageTD[4], true);
  130. }
  131.  
  132. hook OnPlayerConnect(playerid) {
  133. BarTD = CreatePlayerTextDraw(playerid, -41.333301, -35.244438, "box");
  134. PlayerTextDrawLetterSize(playerid, BarTD, 0.000000, 99.100013);
  135. PlayerTextDrawTextSize(playerid, BarTD, 1125.000000, 0.000000);
  136. PlayerTextDrawAlignment(playerid, BarTD, 1);
  137. PlayerTextDrawColor(playerid, BarTD, -1);
  138. PlayerTextDrawUseBox(playerid, BarTD, 1);
  139. PlayerTextDrawBoxColor(playerid, BarTD, 0x000000FF);
  140. PlayerTextDrawSetShadow(playerid, BarTD, 0);
  141. PlayerTextDrawSetOutline(playerid, BarTD, 0);
  142. PlayerTextDrawBackgroundColor(playerid, BarTD, 255);
  143. PlayerTextDrawFont(playerid, BarTD, 1);
  144. PlayerTextDrawSetProportional(playerid, BarTD, 1);
  145. PlayerTextDrawSetShadow(playerid, BarTD, 0);
  146.  
  147. GaragePTD[0] = CreatePlayerTextDraw(playerid, 537.999572, 347.214721, "Vehicle: Infernus~n~Odometer: 565 km~n~Doors: ~r~~h~Locked~w~~h~~n~Plate: IS 001 EDD");
  148. PlayerTextDrawLetterSize(playerid, GaragePTD[0], 0.215999, 1.222517);
  149. PlayerTextDrawTextSize(playerid, GaragePTD[0], 0.000000, 128.000000);
  150. PlayerTextDrawAlignment(playerid, GaragePTD[0], 2);
  151. PlayerTextDrawColor(playerid, GaragePTD[0], -1);
  152. PlayerTextDrawUseBox(playerid, GaragePTD[0], 1);
  153. PlayerTextDrawBoxColor(playerid, GaragePTD[0], 67);
  154. PlayerTextDrawSetShadow(playerid, GaragePTD[0], 0);
  155. PlayerTextDrawSetOutline(playerid, GaragePTD[0], 1);
  156. PlayerTextDrawBackgroundColor(playerid, GaragePTD[0], 62);
  157. PlayerTextDrawFont(playerid, GaragePTD[0], 2);
  158. PlayerTextDrawSetProportional(playerid, GaragePTD[0], 1);
  159. PlayerTextDrawSetShadow(playerid, GaragePTD[0], 0);
  160.  
  161. GaragePTD[1] = CreatePlayerTextDraw(playerid, 539.432678, 401.889160, "Slot 1 (empty)");
  162. PlayerTextDrawLetterSize(playerid, GaragePTD[1], 0.221664, 1.006814);
  163. PlayerTextDrawTextSize(playerid, GaragePTD[1], 0.000000, 105.000000);
  164. PlayerTextDrawAlignment(playerid, GaragePTD[1], 2);
  165. PlayerTextDrawColor(playerid, GaragePTD[1], -1);
  166. PlayerTextDrawUseBox(playerid, GaragePTD[1], 1);
  167. PlayerTextDrawBoxColor(playerid, GaragePTD[1], 255);
  168. PlayerTextDrawSetShadow(playerid, GaragePTD[1], 0);
  169. PlayerTextDrawSetOutline(playerid, GaragePTD[1], 1);
  170. PlayerTextDrawBackgroundColor(playerid, GaragePTD[1], 62);
  171. PlayerTextDrawFont(playerid, GaragePTD[1], 2);
  172. PlayerTextDrawSetProportional(playerid, GaragePTD[1], 1);
  173. PlayerTextDrawSetShadow(playerid, GaragePTD[1], 0);
  174.  
  175. GaragePTD[2] = CreatePlayerTextDraw(playerid, 546.999328, 289.400024, "");
  176. PlayerTextDrawLetterSize(playerid, GaragePTD[2], 0.000000, 0.000000);
  177. PlayerTextDrawTextSize(playerid, GaragePTD[2], 65.000000, 73.000000);
  178. PlayerTextDrawAlignment(playerid, GaragePTD[2], 1);
  179. PlayerTextDrawColor(playerid, GaragePTD[2], -1);
  180. PlayerTextDrawSetShadow(playerid, GaragePTD[2], 0);
  181. PlayerTextDrawSetOutline(playerid, GaragePTD[2], 0);
  182. PlayerTextDrawBackgroundColor(playerid, GaragePTD[2], 0);
  183. PlayerTextDrawFont(playerid, GaragePTD[2], 5);
  184. PlayerTextDrawSetProportional(playerid, GaragePTD[2], 0);
  185. PlayerTextDrawSetShadow(playerid, GaragePTD[2], 0);
  186. PlayerTextDrawSetPreviewModel(playerid, GaragePTD[2], 565);
  187. PlayerTextDrawSetPreviewRot(playerid, GaragePTD[2], 0.000000, 0.000000, 31.000000, 1.000000);
  188. PlayerTextDrawSetPreviewVehCol(playerid, GaragePTD[2], 1, 1);
  189. }
  190.  
  191. show_garage_tds(playerid) {
  192. new
  193. string[128],
  194. slot = garage_slot(playerid, GetPVarInt(playerid, "garageSlot"));
  195.  
  196. if(slot == -1) {
  197. PlayerTextDrawHide(playerid, GaragePTD[0]);
  198. PlayerTextDrawHide(playerid, GaragePTD[2]);
  199. TextDrawHideForPlayer(playerid, GarageTD[0]);
  200.  
  201. format(string, sizeof(string), "~g~~h~Slot %d (empty)", GetPVarInt(playerid, "garageSlot")+1);
  202. PlayerTextDrawSetString(playerid, GaragePTD[1], string);
  203. PlayerTextDrawShow(playerid, GaragePTD[1]);
  204. for(new i = 1; i < 5; i++) TextDrawShowForPlayer(playerid, GarageTD[i]);
  205. }
  206. else {
  207. new status[32], idd = PlayerInfo[playerid][pCarKey][slot];
  208.  
  209. if(CarInfo[idd][cLock] == 1) status = "Doors: ~r~~h~Locked~w~~h~";
  210. else status = "Doors: ~g~~h~Unlocked~w~~h~";
  211.  
  212. format(string, sizeof(string), "%s~n~Odometer: %.2f~n~%s~n~Fuel: %s%d", aVehicleNames[CarInfo[idd][cModel]-400], CarInfo[idd][KM], status, "%", CarInfo[idd][cFuel]);
  213. PlayerTextDrawSetString(playerid, GaragePTD[0], string);
  214.  
  215. if(CarInfo[idd][Spawned] != 0) format(string, sizeof(string), "Slot %d (%s)", GetPVarInt(playerid, "garageSlot")+1, aVehicleNames[CarInfo[idd][cModel]-400]);
  216. else format(string, sizeof(string), "~r~Slot %d (%s)", GetPVarInt(playerid, "garageSlot")+1, aVehicleNames[CarInfo[idd][cModel]-400]);
  217. PlayerTextDrawSetString(playerid, GaragePTD[1], string);
  218.  
  219. PlayerTextDrawSetPreviewModel(playerid, GaragePTD[2], CarInfo[idd][cModel]);
  220. PlayerTextDrawSetPreviewVehCol(playerid, GaragePTD[2], CarInfo[idd][cColorOne], CarInfo[idd][cColorTwo]);
  221.  
  222. for(new i = 0; i < 3; i++) PlayerTextDrawShow(playerid, GaragePTD[i]);
  223. for(new i = 0; i < 5; i++) TextDrawShowForPlayer(playerid, GarageTD[i]);
  224. }
  225. return 1;
  226. }
  227.  
  228. hide_garage_tds(playerid) {
  229. for(new i = 0; i < 3; i++) PlayerTextDrawHide(playerid, GaragePTD[i]);
  230. for(new i = 0; i < 5; i++) TextDrawHideForPlayer(playerid, GarageTD[i]);
  231. SetCameraBehindPlayer(playerid);
  232. TogglePlayerControllable(playerid, 1);
  233. return 1;
  234. }
  235.  
  236. garage_camera(playerid, now = 0) {
  237. new last = GetPVarInt(playerid, "lastGarage");
  238. SetPVarInt(playerid, "lastGarage", now);
  239. InterpolateCameraPos(playerid, garageCamera[last][0], garageCamera[last][1], garageCamera[last][2], garageCamera[now][0], garageCamera[now][1], garageCamera[now][2], 2000);
  240. InterpolateCameraLookAt(playerid, garageCamera_at[last][0], garageCamera_at[last][1], garageCamera_at[last][2], garageCamera_at[now][0], garageCamera_at[now][1], garageCamera_at[now][2], 2000);
  241. return 1;
  242. }
  243.  
  244. hook OnPlayerSpawn(playerid) {
  245. if(GetPVarInt(playerid, "inGarage") == 1) {
  246. SetPVarInt(playerid, "inGarage", 0);
  247. hide_garage_tds(playerid);
  248. }
  249. return 1;
  250. }
  251.  
  252. hook OnPlayerKeyStateChange(playerid, newkeys, oldkeys) { //aici
  253. if((newkeys & KEY_SECONDARY_ATTACK) && !IsPlayerInAnyVehicle(playerid) || newkeys & KEY_CROUCH) {
  254. for(new i = 1; i < MAX_GARAGES; i++) {
  255. if(IsPlayerInRangeOfPoint(playerid, 2.0, garageInfo[i][gPos][0], garageInfo[i][gPos][1], garageInfo[i][gPos][2]) && garageInfo[i][gUserID] != 0) {
  256. if(user_have_garage(playerid) == 0) return SendClientMessage(playerid, COLOR_GRAD3, "You dont have a garage!");
  257. if(PlayerInfo[playerid][pWantedLevel] > 0) return SendClientMessage(playerid, COLOR_GRAD3, "Nu poti intra in garaj cand ai wanted!");
  258. if(GetPVarInt(playerid, "inGarage") != 0) return 1;
  259. SetPVarInt(playerid, "inGarage", i);
  260.  
  261. if(IsPlayerInAnyVehicle(playerid)) {
  262. if(garageInfo[i][gPrice] > 0) return SendClientMessage(playerid, 0xC90202FF, "(Garage) {FFFFFF}You can not come with a vehicle if the garage is for sale.");
  263. if(PersonalCar(playerid) == -1) return SCM(playerid, COLOR_GRAD3, "Poti intra doar cu vehiculele personale!");
  264. if(vehicles_in_garage(playerid) == 10 && vehicle_in_garage(playerid, GetPlayerVehicleID(playerid)) == -1) return 1;
  265. new slot = vehicle_in_garage(playerid, GetPlayerVehicleID(playerid));
  266. if(slot == -1) ShowPlayerDialog(playerid, DIALOG_PARKVEHICLE, DIALOG_STYLE_MSGBOX, "Park", "Esti sigur ca vrei sa-l adaugi in garaj?", "Yes", "No");
  267. else {
  268. SendClientMessage(playerid, 0xC90202FF, "(Garage) {FFFFFF}Vehiculul tau personal a fost adaugat in garaj!");
  269. SetVehicleVirtualWorld(GetPlayerVehicleID(playerid), i);
  270. SetVehicleToRespawn(GetPlayerVehicleID(playerid));
  271. SetPVarInt(playerid, "inGarage", 0);
  272. }
  273. }
  274. else {
  275. SendClientMessage(playerid, 0xC90202FF, "(Garage) {FFFFFF}PENTRU A CONTROLA POZITIA FOLOSITI: NUM4(stanga), NUM6(dreapta), Enter(selectare vehicul) si Space (iesire).");
  276. SendClientMessage(playerid, 0xC90202FF, "(Garage) {FFFFFF}Inaintea parcarii oricarui vehicul trebuie sa-l parcati langa garaj (/park) apoi sa-l bagati in garaj (apasati H langa garaj din vehicul).");
  277. SendClientMessage(playerid, 0xC90202FF, "(Garage) {FFFFFF}Vehiculele trebuie sa fie spawnate pentru a putea fii vizibile in garaj!");
  278.  
  279. SetPlayerPosEx2(playerid, 487.5861,-437.8022,2758.2688);
  280. SetPlayerVirtualWorld(playerid, i);
  281.  
  282. if(BarTimer[playerid]) KillTimer(BarTimer[playerid]);
  283. BarTimer[playerid] = SetTimerEx("BlackBar", 100, true, "%d", playerid);
  284.  
  285. SetPVarInt(playerid, "garageSlot", 0);
  286. show_garage_tds(playerid);
  287. garage_camera(playerid);
  288. TogglePlayerControllable(playerid, 0);
  289. }
  290.  
  291.  
  292. Freezed[playerid] = 1;
  293. }
  294. }
  295. }
  296.  
  297. if(newkeys & KEY_SECONDARY_ATTACK) {
  298. if(GetPVarInt(playerid, "inGarage") != 0 && GetPlayerVirtualWorld(playerid) != 0 && IsPlayerInRangeOfPoint(playerid, 100.0, 487.9106,-431.6140,2757.9956)) {
  299. new id = GetPVarInt(playerid, "inGarage"), vehid;
  300. if(garage_slot(playerid, GetPVarInt(playerid, "garageSlot")) != -1) vehid = CarInfo[PlayerInfo[playerid][pCarKey][garage_slot(playerid, GetPVarInt(playerid, "garageSlot"))]][Spawned];
  301. if(garage_slot(playerid, GetPVarInt(playerid, "garageSlot")) == -1) return SendClientMessage(playerid, COLOR_WARNING, "Nu ai adaugat un vehicul pe acest slot din garaj!");
  302. else if(GetVehicleVirtualWorld(vehid) == 0) return SendClientMessage(playerid, COLOR_WARNING, "Vehiculul a fost scos din garaj deja!");
  303. else if(vehid == 0 && vehicle_in_garage(playerid, vehid)) return SendClientMessage(playerid, COLOR_WARNING, "Vehiculul nu este spawnat!");
  304. hide_garage_tds(playerid);
  305.  
  306. SetVehiclePos(vehid, garageInfo[id][gPos][0], garageInfo[id][gPos][1], garageInfo[id][gPos][2]);
  307. PutPlayerInVehicle(playerid, vehid, 0);
  308. SetVehicleZAngleEx(GetPlayerVehicleID(playerid), garageInfo[id][gAngle]);
  309. SetPlayerVirtualWorld(playerid, 0);
  310. SetVehicleVirtualWorld(vehid, 0);
  311. SetPVarInt(playerid, "inGarage", 0);
  312.  
  313. if(BarTimer[playerid]) KillTimer(BarTimer[playerid]);
  314. BarTimer[playerid] = SetTimerEx("BlackBar", 100, true, "%d", playerid);
  315. }
  316. }
  317.  
  318. if(GetPVarInt(playerid, "inGarage") != 0) {
  319. if(newkeys & KEY_ANALOG_LEFT) {
  320. // left
  321. new slot = GetPVarInt(playerid, "garageSlot");
  322. if(slot == 9) slot = -1;
  323. SetPVarInt(playerid, "garageSlot", slot+1);
  324. show_garage_tds(playerid);
  325. garage_camera(playerid, GetPVarInt(playerid, "garageSlot"));
  326. }
  327. if(newkeys & KEY_ANALOG_RIGHT) {
  328. // right
  329. new slot = GetPVarInt(playerid, "garageSlot");
  330. if(slot == 0) slot = 10;
  331. SetPVarInt(playerid, "garageSlot", slot-1);
  332. show_garage_tds(playerid);
  333. garage_camera(playerid, GetPVarInt(playerid, "garageSlot"));
  334. }
  335. if(newkeys & KEY_SPRINT) {
  336. hide_garage_tds(playerid);
  337. new id = GetPVarInt(playerid, "inGarage");
  338. SetPlayerPosEx2(playerid, garageInfo[id][gPos][0], garageInfo[id][gPos][1], garageInfo[id][gPos][2]);
  339. SetPlayerVirtualWorld(playerid, 0);
  340. if(BarTimer[playerid]) KillTimer(BarTimer[playerid]);
  341. BarTimer[playerid] = SetTimerEx("BlackBar", 100, true, "%d", playerid);
  342. SetPVarInt(playerid, "inGarage", 0);
  343. TogglePlayerControllable(playerid, 1);
  344. Freezed[playerid] = 0;
  345. }
  346. }
  347. return 1;
  348. }
  349.  
  350. hook OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) {
  351. switch(dialogid) {
  352.  
  353. case DIALOG_CREATEGARAGE: {
  354. if(!response) return 1;
  355. if(PlayerInfo[playerid][pAdmin] < 7) return 1;
  356. if(garages >= MAX_GARAGES) return SendClientMessage(playerid, COLOR_GRAD3, "There are too many garages!");
  357. new id = garage_id_empty();
  358. if(id == -1) return SendClientMessage(playerid, COLOR_WARNING, "Error with garage ID!");
  359.  
  360. new
  361. Float: Pos[3],
  362. Float:Angle,
  363. query[150];
  364.  
  365. GetPlayerFacingAngle(playerid, Angle);
  366. GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
  367. mysql_format(SQL, query, sizeof(query), "INSERT INTO `garages` (`Price`, `X`, `Y`, `Z`, `Angle`) VALUES ('%d', '%f', '%f', '%f', '%f')", GetPVarInt(playerid, "garagePrice"), Pos[0], Pos[1], Pos[2], Angle);
  368. mysql_tquery(SQL, query, "", "");
  369.  
  370. format(garageInfo[id][gOwner], 32, "The State");
  371. garageInfo[id][gID] = id;
  372. garageInfo[id][gVirtualID] = id;
  373. garageInfo[id][gPrice] = GetPVarInt(playerid, "garagePrice");
  374. garageInfo[id][gPos][0] = Pos[0];
  375. garageInfo[id][gPos][1] = Pos[1];
  376. garageInfo[id][gPos][2] = Pos[2];
  377. garageInfo[id][gAngle] = Angle;
  378.  
  379. garageInfo[id][gPickup] = CreateDynamicPickup(1277, 23, garageInfo[id][gPos][0], garageInfo[id][gPos][1], garageInfo[id][gPos][2]);
  380. garage_label(id);
  381.  
  382. SendClientMessage(playerid, 0xFFA200FF, "You have successfully added a garage!");
  383.  
  384. DeletePVar(playerid, "garagePrice");
  385. }
  386. case DIALOG_MOVEGARAGE: {
  387. if(!response) return 1;
  388. if(PlayerInfo[playerid][pAdmin] < 7) return 1;
  389.  
  390. new
  391. id = GetPVarInt(playerid, "garageID"),
  392. query[126],
  393. Float: Pos[3],
  394. Float: Angle;
  395.  
  396. GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
  397. GetPlayerFacingAngle(playerid, Angle);
  398.  
  399. mysql_format(SQL, query, sizeof(query), "UPDATE `garages` SET `X`='%f', `Y`='%f', `Z`='%f', `Angle`='%f' WHERE `ID`='%d'", Pos[0], Pos[1], Pos[2], Angle, id);
  400. mysql_tquery(SQL, query, "", "");
  401.  
  402. garageInfo[id][gPos][0] = Pos[0];
  403. garageInfo[id][gPos][1] = Pos[1];
  404. garageInfo[id][gPos][2] = Pos[2];
  405. garageInfo[id][gAngle] = Angle;
  406.  
  407. DestroyDynamicPickup(garageInfo[id][gPickup]);
  408. garageInfo[id][gPickup] = CreateDynamicPickup(1277, 23, garageInfo[id][gPos][0], garageInfo[id][gPos][1], garageInfo[id][gPos][2]);
  409. garage_label(id);
  410.  
  411. SendClientMessage(playerid, 0xFFA200FF, "You've successfully moved the garage!");
  412.  
  413. DeletePVar(playerid, "garageID");
  414. }
  415. case DIALOG_BUYGARAGE: {
  416. if(!response) return 1;
  417. new id = GetPVarInt(playerid, "garageID");
  418. if(garageInfo[id][gPrice] == 0) return SendClientMessage(playerid, COLOR_GRAD3, "This garage is not available!");
  419. if(GetPlayerCash(playerid) < garageInfo[id][gPrice]) return SendClientMessage(playerid, COLOR_GRAD3, "You do not have that amount of money!");
  420. new string[128];
  421. GivePlayerCash(playerid, -garageInfo[id][gPrice]);
  422.  
  423.  
  424. if(garageInfo[id][gUserID] != 0) {
  425. new
  426. idd = GetPlayerID(garageInfo[id][gOwner]),
  427. szQuery[128],
  428. moneys,
  429. newmoneys;
  430.  
  431. if(idd != INVALID_PLAYER_ID) {
  432. PlayerInfo[idd][pAccount] += garageInfo[id][gPrice];
  433. format(string, sizeof(string), "* %s ti-a cumparat garajul pentru {19CF2E}$%s{239931}. Banii au fost transferati in contul tau bancar.", GetName(playerid), FormatNumber(garageInfo[id][gPrice]));
  434. format(szQuery,sizeof(szQuery),"UPDATE users SET `Bank`='%d' WHERE `ID`='%d'",PlayerInfo[id][pAccount],PlayerInfo[id][pSQLID]);
  435. }
  436. else {
  437. format(szQuery, sizeof(szQuery), "SELECT * FROM `users` WHERE `ID` = '%s'", garageInfo[id][gUserID]);
  438. new Cache: result = mysql_query(SQL, szQuery);
  439. if(cache_get_row_count() != 0) {
  440. cache_get_field_content(0, "Bank", string); moneys = strval(string), newmoneys = moneys + garageInfo[id][gPrice];
  441. }
  442. cache_delete(result);
  443. format(szQuery,sizeof(szQuery),"UPDATE users SET `Bank`='%d' WHERE `ID`='%d'",newmoneys,garageInfo[id][gUserID]);
  444. }
  445.  
  446. SendClientMessage(id, 0x239931FF, string);
  447. mysql_query(SQL,szQuery);
  448. }
  449.  
  450. format(garageInfo[id][gOwner], 32, GetName(playerid));
  451. garageInfo[id][gUserID] = PlayerInfo[playerid][pSQLID];
  452.  
  453. UpdateGarage_str(id, "Owner", GetName(playerid));
  454. UpdateGarage_int(id, "UserID", PlayerInfo[playerid][pSQLID]);
  455. UpdateGarage_int(id, "Price", 0);
  456.  
  457. format(string, sizeof(string), "You successfully bought this garage with $%s.", FormatNumber(garageInfo[id][gPrice]));
  458. SendClientMessage(playerid, COLOR_MONEY, string);
  459. SendClientMessage(playerid, COLOR_MONEY, "To see your garage commands, use /garagehelp.");
  460.  
  461. garageInfo[id][gPrice] = 0;
  462. garage_label(id);
  463.  
  464. DeletePVar(playerid, "garageID");
  465. }
  466. case DIALOG_SELLGARAGE: {
  467. if(!response) return 1;
  468. if(user_have_garage(playerid) == 0) return SendClientMessage(playerid, COLOR_GRAD3, "You dont have a garage!");
  469. new id = user_garage(playerid);
  470.  
  471. format(garageInfo[id][gOwner], 32, "The State");
  472. garageInfo[id][gUserID] = 0;
  473. garageInfo[id][gPrice] = 100000;
  474.  
  475. UpdateGarage_str(id, "Owner", "The State");
  476. UpdateGarage_int(id, "UserID", 0);
  477. UpdateGarage_int(id, "Price", 0);
  478.  
  479. garage_label(id);
  480. GivePlayerCash(playerid, SELL_GARAGE_PRICE);
  481.  
  482. SendClientMessage(playerid, COLOR_MONEY, "Ai vandut garajul la stat!");
  483. }
  484. case DIALOG_PARKVEHICLE: {
  485. if(!response) return 1;
  486. Command_ReProcess(playerid, "parkcar", true);
  487. SetPVarInt(playerid, "inGarage", 0);
  488. }
  489. }
  490. return 1;
  491. }
  492.  
  493. function garage_id_empty() {
  494. for(new i = 1; i < MAX_GARAGES; i++) {
  495. if(garageInfo[i][gID] == 0) return i;
  496. }
  497. return -1;
  498. }
  499.  
  500. function user_have_garage(playerid) {
  501. for(new i = 1; i < MAX_GARAGES; i++) {
  502. if(garageInfo[i][gUserID] == PlayerInfo[playerid][pSQLID]) return 1;
  503. }
  504. return 0;
  505. }
  506.  
  507. function user_garage(playerid) {
  508. for(new i = 1; i < MAX_GARAGES; i++) {
  509. if(garageInfo[i][gUserID] == PlayerInfo[playerid][pSQLID]) return i;
  510. }
  511. return 0;
  512. }
  513.  
  514.  
  515. function LoadGarages() {
  516. new Cache: db = mysql_query(SQL, "SELECT * FROM `garages`");
  517. new x, result[126];
  518. for(new i, j = cache_get_row_count (); i != j; ++i) {
  519. garages ++;
  520. cache_get_field_content(i, "ID", result); x = strval(result), garageInfo[garages][gID] = x;
  521. cache_get_field_content(i, "Owner", result); format(garageInfo[x][gOwner], 32, result);
  522. cache_get_field_content(i, "UserID", result); garageInfo[x][gUserID] = strval(result);
  523. cache_get_field_content(i, "Price", result); garageInfo[x][gPrice] = strval(result);
  524.  
  525. garageInfo[x][gPos][0] = cache_get_field_content_float(i, "X");
  526. garageInfo[x][gPos][1] = cache_get_field_content_float(i, "Y");
  527. garageInfo[x][gPos][2] = cache_get_field_content_float(i, "Z");
  528. garageInfo[x][gAngle] = cache_get_field_content_float(i, "Angle");
  529.  
  530. garageInfo[x][gVirtualID] = x;
  531.  
  532. garageInfo[x][gPickup] = CreateDynamicPickup(1277, 23, garageInfo[x][gPos][0], garageInfo[x][gPos][1], garageInfo[x][gPos][2]);
  533. garage_label(x);
  534. }
  535. printf("Garages loaded: %d", garages);
  536. cache_delete(db);
  537. return 1;
  538. }
  539.  
  540. function UpdateGarage_int(id, varname[], amount) {
  541. new query[128];
  542. mysql_format(SQL, query, sizeof(query), "UPDATE `garages` SET `%s`='%d' WHERE `ID`='%d'", varname, amount, id);
  543. mysql_tquery(SQL, query, "", "");
  544. return 1;
  545. }
  546.  
  547. function UpdateGarage_str(id, varname[], amount[]) {
  548. new query[128];
  549. mysql_format(SQL, query, sizeof(query), "UPDATE `garages` SET `%s`='%s' WHERE `ID`='%d'", varname, amount, id);
  550. mysql_tquery(SQL, query, "", "");
  551. return 1;
  552. }
  553.  
  554. function vehicles_in_garage(playerid) {
  555. new x;
  556. for(new i = 0; i < 10; i++) {
  557. if(PlayerInfo[playerid][pCarKey][i] != 0 && CarInfo[PlayerInfo[playerid][pCarKey][i]][cVirtual] != 0) x++;
  558. }
  559. return x;
  560. }
  561.  
  562. stock SetPlayerPosEx2(playerid, Float:x, Float:y, Float:z) {
  563. if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER) SetVehiclePosEx(playerid, GetPlayerVehicleID(playerid), x, y, z);
  564. else SetPlayerPos(playerid, x, y, z);
  565.  
  566. GetPlayerPos(playerid, LastPos[playerid][0], LastPos[playerid][1], LastPos[playerid][2]);
  567. Exception[playerid] += 1;
  568. foreach(Player, i) {
  569. if(Spectate[i] == playerid) {
  570. TogglePlayerSpectating(i, 1);
  571. SetPlayerInterior(i, GetPlayerInterior(playerid));
  572. SetPlayerVirtualWorld(i, GetPlayerVirtualWorld(playerid));
  573. if(IsPlayerInAnyVehicle(playerid)) PlayerSpectateVehicle(i, GetPlayerVehicleID(playerid));
  574. else PlayerSpectatePlayer(i, playerid);
  575. }
  576. }
  577. if(GetPVarInt(playerid, "Undercover") == 1) {
  578. foreach(Player, i) ShowPlayerNameTagForPlayer(i, playerid, false);
  579. PlayerTextDrawShow(playerid, UndercoverTD);
  580. }
  581. return 1;
  582. }
  583.  
  584. function BlackBar(playerid) {
  585. switch(Step[playerid]) {
  586. case 0: PlayerTextDrawBoxColor(playerid, BarTD, 0x000000FF);
  587. case 1: PlayerTextDrawBoxColor(playerid, BarTD, 0x00000090);
  588. case 2: PlayerTextDrawBoxColor(playerid, BarTD, 0x00000080);
  589. case 3: PlayerTextDrawBoxColor(playerid, BarTD, 0x00000070);
  590. case 4: PlayerTextDrawBoxColor(playerid, BarTD, 0x00000060);
  591. case 5: PlayerTextDrawBoxColor(playerid, BarTD, 0x00000050);
  592. case 6: PlayerTextDrawBoxColor(playerid, BarTD, 0x00000040);
  593. case 7: PlayerTextDrawBoxColor(playerid, BarTD, 0x00000030);
  594. case 8: PlayerTextDrawBoxColor(playerid, BarTD, 0x00000020);
  595. case 9: PlayerTextDrawBoxColor(playerid, BarTD, 0x00000010);
  596. case 10: {
  597. PlayerTextDrawHide(playerid, BarTD);
  598. Step[playerid] = 0;
  599. KillTimer(BarTimer[playerid]);
  600. return 1;
  601. }
  602. }
  603. PlayerTextDrawShow(playerid, BarTD);
  604. Step[playerid] ++;
  605. return 1;
  606. }
  607.  
  608. stock saveCarPark(idd) {
  609. if(idd == 0) return 1;
  610. new query[512];
  611. mysql_format(SQL, query, sizeof(query),
  612. "UPDATE cars SET Model='%d', Locationx='%f', Locationy='%f', Locationz='%f', Angle='%f', ColorOne='%d', ColorTwo='%d', Owner='%s', Value='%d', License='%s', Userid='%d', `Virtual`='%d' WHERE ID=%d",
  613. CarInfo[idd][cModel], CarInfo[idd][cLocationx], CarInfo[idd][cLocationy], CarInfo[idd][cLocationz], CarInfo[idd][cAngle], CarInfo[idd][cColorOne], CarInfo[idd][cColorTwo], CarInfo[idd][cOwner], CarInfo[idd][cValue],
  614. CarInfo[idd][cLicense], CarInfo[idd][Userid], CarInfo[idd][cVirtual], idd);
  615. mysql_tquery(SQL, query, "", "");
  616. return 1;
  617. }
  618.  
  619. /*
  620. YCMD:debugsystem(playerid, params[], help) {
  621. new string[126], model[64];
  622. format(string, 64, "%d/10 vehicles", vehicles_in_garage(playerid));
  623. SendClientMessage(playerid, -1, string);
  624. for(new i = 0; i < 10; i++) {
  625. if(garage_slot(playerid, i) == -1) model = "None";
  626. else format(model, sizeof(model), "%s", aVehicleNames[CarInfo[PlayerInfo[playerid][pCarKey][garage_slot(playerid, i)]][cModel]-400]);
  627.  
  628. format(string, sizeof(string), "Slot %d - %s", i, model);
  629. SendClientMessage(playerid, COLOR_WARNING, string);
  630. }
  631.  
  632. return 1;
  633. }
  634. */
  635.  
  636. function vehicle_in_garage(playerid, carid) {
  637. new slot = -1;
  638. for(new i = 0; i < 10; i++) {
  639. if(CarInfo[PlayerInfo[playerid][pCarKey][i]][Spawned] == carid) {
  640. new idd = PlayerInfo[playerid][pCarKey][i], Float: Pos[2];
  641. Pos[0] = CarInfo[idd][cLocationx], Pos[1] = CarInfo[idd][cLocationy];
  642.  
  643. if(Pos[0] == 481.85 && Pos[1] == -405.426) slot = i;
  644. else if(Pos[0] == 481.85 && Pos[1] == -410.9) slot = i;
  645. else if(Pos[0] == 481.85 && Pos[1] == -416.301) slot = i;
  646. else if(Pos[0] == 481.85 && Pos[1] == -421.104) slot = i;
  647. else if(Pos[0] == 481.85 && Pos[1] == -425.924) slot = i;
  648. else if(Pos[0] == 493.998 && Pos[1] == -405.426) slot = i;
  649. else if(Pos[0] == 493.998 && Pos[1] == -410.9) slot = i;
  650. else if(Pos[0] == 493.998 && Pos[1] == -416.301) slot = i;
  651. else if(Pos[0] == 493.998 && Pos[1] == -421.104) slot = i;
  652. else if(Pos[0] == 493.998 && Pos[1] == -425.924) slot = i;
  653. }
  654. }
  655. return slot;
  656. }
  657.  
  658. function garage_slot(playerid, id) {
  659. new slot = -1;
  660. for(new i = 0; i < 10; i++) {
  661. if(PlayerInfo[playerid][pCarKey][i] != 0) {
  662. new idd = PlayerInfo[playerid][pCarKey][i], Float: Pos[2];
  663. Pos[0] = CarInfo[idd][cLocationx], Pos[1] = CarInfo[idd][cLocationy];
  664.  
  665. if(Pos[0] == 481.85 && Pos[1] == -405.426 && !IsPlayerInVehicle(playerid, CarInfo[idd][Spawned]) && id == 0) slot = i;
  666. if(Pos[0] == 481.85 && Pos[1] == -410.9 && !IsPlayerInVehicle(playerid, CarInfo[idd][Spawned]) && id == 1) slot = i;
  667. if(Pos[0] == 481.85 && Pos[1] == -416.301 && !IsPlayerInVehicle(playerid, CarInfo[idd][Spawned]) && id == 2) slot = i;
  668. if(Pos[0] == 481.85 && Pos[1] == -421.104 && !IsPlayerInVehicle(playerid, CarInfo[idd][Spawned]) && id == 3) slot = i;
  669. if(Pos[0] == 481.85 && Pos[1] == -425.924 && !IsPlayerInVehicle(playerid, CarInfo[idd][Spawned]) && id == 4) slot = i;
  670. if(Pos[0] == 493.998 && Pos[1] == -405.426 && !IsPlayerInVehicle(playerid, CarInfo[idd][Spawned]) && id == 5) slot = i;
  671. if(Pos[0] == 493.998 && Pos[1] == -410.9 && !IsPlayerInVehicle(playerid, CarInfo[idd][Spawned]) && id == 6) slot = i;
  672. if(Pos[0] == 493.998 && Pos[1] == -416.301 && !IsPlayerInVehicle(playerid, CarInfo[idd][Spawned]) && id == 7) slot = i;
  673. if(Pos[0] == 493.998 && Pos[1] == -421.104 && !IsPlayerInVehicle(playerid, CarInfo[idd][Spawned]) && id == 8) slot = i;
  674. if(Pos[0] == 493.998 && Pos[1] == -425.924 && !IsPlayerInVehicle(playerid, CarInfo[idd][Spawned]) && id == 9) slot = i;
  675. }
  676. }
  677. return slot;
  678. }
  679.  
  680. garage_label(x) {
  681. new string[126];
  682. DestroyDynamic3DTextLabel(garageInfo[x][garageLabel]);
  683. if(garageInfo[x][gPrice] == 0) format(string, sizeof(string), "Garage %d{C90202}\nGarage Owner: {FFFFFF}%s", x, garageInfo[x][gOwner]);
  684. else format(string, sizeof(string), "Garage %d{C90202}\nGarage Owner: {FFFFFF}%s\n{C90202}Garage price: {FFFFFF}$%s\n(/buygarage)", x, garageInfo[x][gOwner], FormatNumber(garageInfo[x][gPrice]));
  685. garageInfo[x][garageLabel] = CreateDynamic3DTextLabel(string, 0xC90202FF, garageInfo[x][gPos][0], garageInfo[x][gPos][1], garageInfo[x][gPos][2], 10, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 1, 0, -1, -1, 100.0);
  686. }
  687.  
  688. // Commands with ZCMD
  689. YCMD:garagehelp(playerid, params[], help) {
  690. if(PlayerInfo[playerid][pAdmin] >= 7) SendClientMessage(playerid, COLOR_WARNING, "(admins commands) {FFFFFF}/creategarage, /movegarage, /gotogarage.");
  691. SendClientMessage(playerid, -1, "(garage commands) {FFFFFF}/buygarage, /sellgarage, /sellgaragetostate, /mygarage, /findgarage.");
  692. return 1;
  693. }
  694.  
  695. YCMD:mygarage(playerid, params[], help) {
  696. if(user_have_garage(playerid) == 0) return SendClientMessage(playerid, COLOR_GRAD3, "You dont have a garage!");
  697. new string[64];
  698. format(string, sizeof(string), "Your garage has ID %d. Use /findgarage to locate.", user_have_garage(playerid));
  699. SendClientMessage(playerid, -1, string);
  700. return 1;
  701. }
  702.  
  703. YCMD:findgarage(playerid, params[], help) {
  704. if(CP[playerid] != 0) return ShowPlayerDialog(playerid, DIALOG_CHECKPOINT, DIALOG_STYLE_MSGBOX, "Checkpoint", "Ai deja un checkpoint activ.\nDoresti sa-l anulezi? Daca da, apasa pe 'Ok'.", "Ok", "Exit");
  705. new id;
  706. if(sscanf(params, "i",id)) return SendClientMessage(playerid, COLOR_GREY, "USAGE: {FFFFFF}/findgarage <garage ID>");
  707. if(id < 1 || id > MAX_GARAGES) return SendClientMessage(playerid, COLOR_GRAD3, "Invalid garage ID!");
  708. if(garageInfo[id][gID] != id) return SendClientMessage(playerid, COLOR_GRAD3, "Invalid garage ID!");
  709. CP[playerid] = 43;
  710. SetPlayerCheckpointEx(playerid, garageInfo[id][gPos][0], garageInfo[id][gPos][1], garageInfo[id][gPos][2], 2.0);
  711. new string[180];
  712. format(string, sizeof(string), "Follow checkpoint to reach to the garage. %d. Distance: %0.2fm", id, GetPlayerDistanceFromPoint(playerid, garageInfo[id][gPos][0], garageInfo[id][gPos][1], garageInfo[id][gPos][2]));
  713. SendClientMessage(playerid, COLOR_YELLOW, string);
  714. return 1;
  715. }
  716.  
  717. YCMD:creategarage(playerid, params[], help) {
  718. if(PlayerInfo[playerid][pAdmin] < 7) return 1;
  719. if(garages >= MAX_GARAGES) return SendClientMessage(playerid, COLOR_GRAD3, "There are too many garages!");
  720. new price;
  721. if(sscanf(params, "i", price)) return SendClientMessage(playerid, COLOR_GREY, "Syntax: {FFFFFF}/creategarage <garage price>");
  722. if(price < 1 || price > 100000000) return SendClientMessage(playerid, COLOR_GRAD3, "Error: Invalid price!");
  723. SetPVarInt(playerid, "garagePrice", price);
  724. ShowPlayerDialog(playerid, DIALOG_CREATEGARAGE, DIALOG_STYLE_MSGBOX, "Create garage", "Are you sure you want to add a garage here?", "Yes", "No");
  725. return 1;
  726. }
  727.  
  728. YCMD:movegarage(playerid, params[], help) {
  729. if(PlayerInfo[playerid][pAdmin] < 7) return 1;
  730. new id;
  731. if(sscanf(params, "i", id)) return SendClientMessage(playerid, COLOR_GREY, "Syntax: {FFFFFF}/movegarage <garage ID>");
  732. if(id < 1 || id > MAX_GARAGES) return SendClientMessage(playerid, COLOR_GRAD3, "Invalid garage ID!");
  733. if(garageInfo[id][gID] != id) return SendClientMessage(playerid, COLOR_GRAD3, "Invalid garage ID!");
  734. SetPVarInt(playerid, "garageID", id);
  735. ShowPlayerDialog(playerid, DIALOG_MOVEGARAGE, DIALOG_STYLE_MSGBOX, "Move garage", "Are you sure you want to move that garage here?", "Yes", "No");
  736. return 1;
  737. }
  738.  
  739. YCMD:gotogarage(playerid, params[], help) {
  740. if(PlayerInfo[playerid][pAdmin] < 7) return 1;
  741. new id;
  742. if(sscanf(params, "i", id)) return SendClientMessage(playerid, COLOR_GREY, "Syntax: {FFFFFF}/movegarage <garage ID>");
  743. if(id < 1 || id > MAX_GARAGES) return SendClientMessage(playerid, COLOR_GRAD3, "Invalid garage ID!");
  744. if(garageInfo[id][gID] != id) return SendClientMessage(playerid, COLOR_GRAD3, "Invalid garage ID!");
  745. SetPlayerPos(playerid, garageInfo[id][gPos][0], garageInfo[id][gPos][1], garageInfo[id][gPos][2]);
  746. SetPlayerVirtualWorld(playerid, 0);
  747. SetPlayerInterior(playerid, 0);
  748. return 1;
  749. }
  750.  
  751. YCMD:buygarage(playerid, params[], help) {
  752. if(user_have_garage(playerid) == 1) return SendClientMessage(playerid, COLOR_GRAD3, "You already have a garage!");
  753. if(PlayerInfo[playerid][pLevel] < 5) return SendClientMessage(playerid, COLOR_WARNING, "You need level 5+ to buy a garage!");
  754. for(new i = 1; i < MAX_GARAGES; i++) {
  755. if(IsPlayerInRangeOfPoint(playerid, 2.0, garageInfo[i][gPos][0], garageInfo[i][gPos][1], garageInfo[i][gPos][2])) {
  756. if(garageInfo[i][gPrice] == 0) return SendClientMessage(playerid, COLOR_GRAD3, "This garage is not available!");
  757. if(GetPlayerCash(playerid) < garageInfo[i][gPrice]) return SendClientMessage(playerid, COLOR_GRAD3, "You do not have that amount of money!");
  758. ShowPlayerDialog(playerid, DIALOG_BUYGARAGE, DIALOG_STYLE_MSGBOX, "Buy garage", "Are you sure you want to buy this garage?", "Yes", "No");
  759. SetPVarInt(playerid, "garageID", i);
  760. }
  761. }
  762. return 1;
  763. }
  764.  
  765. YCMD:sellgarage(playerid, params[], help) {
  766. if(user_have_garage(playerid) == 0) return SendClientMessage(playerid, COLOR_GRAD3, "You dont have a garage!");
  767. if(vehicles_in_garage(playerid) > 0) return SendClientMessage(playerid, COLOR_GRAD3, "You can not sell the garage if you have vehicles in the garage.");
  768. new price;
  769. if(sscanf(params, "i", price)) return SendClientMessage(playerid, COLOR_GREY, "Syntax: {FFFFFF}/sellgarage <garage price (0=cancel)>");
  770. if(price < 1 || price > 100000000) return SendClientMessage(playerid, COLOR_GRAD3, "Error: Invalid price!");
  771. new id = user_garage(playerid), string[126];
  772. if(price == 0) SendClientMessage(playerid, COLOR_MONEY, "Garajul tau nu mai este acum de vanzare!");
  773. else {
  774. format(string, sizeof(string), "Garajul tau este de vanzare la suma de $%s.", FormatNumber(price));
  775. SendClientMessage(playerid, COLOR_MONEY, string);
  776. }
  777. garageInfo[id][gPrice] = price;
  778. UpdateGarage_int(id, "Price", garageInfo[id][gPrice]);
  779. garage_label(id);
  780. return 1;
  781. }
  782.  
  783. YCMD:sellgaragetostate(playerid, params[], help) {
  784. if(user_have_garage(playerid) == 0) return SendClientMessage(playerid, COLOR_GRAD3, "You dont have a garage!");
  785. if(vehicles_in_garage(playerid) > 0) return SendClientMessage(playerid, COLOR_GRAD3, "You can not sell the garage if you have vehicles in the garage.");
  786. new string[98];
  787. format(string, sizeof(string), "Are you sure you want to sell the garage to the state for %s?", FormatNumber(SELL_GARAGE_PRICE));
  788. ShowPlayerDialog(playerid, DIALOG_SELLGARAGE, DIALOG_STYLE_MSGBOX, "Sell garage to state", string, "Yes", "No");
  789. return 1;
  790. }
  791.  
  792. YCMD:parkcar(playerid, params[], help) {
  793. new car = GetPlayerVehicleID(playerid);
  794. if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_GREY, "Nu esti in vehiculul tau.");
  795. if(GetVehicles(playerid) == 0) return SendClientMessage(playerid, COLOR_GREY, "Nu ai un vehicul personal!");
  796. if(PersonalCar(playerid) == -1) return SCM(playerid, COLOR_LGREEN, "Eroare: Nu esti in unul dintre vehiculele tale personale!");
  797. if(GetPlayerState(playerid) != 2) return SCM(playerid, COLOR_LGREEN, "* Trebuie sa fii la volan pentru a putea folosi aceasta comanda!");
  798. new idd = PersonalCar(playerid);
  799. new Float: vhp;
  800. GetVehicleHealth(car, vhp);
  801. if(vhp < 800) return SendClientMessage(playerid, COLOR_GREY, "Nu poti parca masina cand are sub 800 'viata'!");
  802. if(PlayerToPoint(150.0, playerid, 1716.9065,-1902.4526,13.5661)) return SCM(playerid, -1, "Nu poti parca o masina in jurul spawn-ului.");
  803. new Float:x, Float:y, Float:z, Float:a;
  804. CheckVehicle(CarInfo[idd][Spawned]);
  805. saveTuning(playerid, CarInfo[idd][Spawned]);
  806. GetVehiclePos(car, x, y, z);
  807. GetVehicleZAngle(car, a);
  808.  
  809. CarInfo[idd][cVirtual] = 0;
  810. if(GetPVarInt(playerid, "inGarage") != 0) {
  811. if(garage_slot(playerid, 0) == -1) x = 481.85, y = -405.426, z = 2758.0046;
  812. else if(garage_slot(playerid, 1) == -1) x = 481.85, y = -410.9, z = 2758.0046;
  813. else if(garage_slot(playerid, 2) == -1) x = 481.85, y = -416.301, z = 2758.0046;
  814. else if(garage_slot(playerid, 3) == -1) x = 481.85, y = -421.104, z = 2758.0046;
  815. else if(garage_slot(playerid, 4) == -1) x = 481.85, y = -425.924, z = 2758.0046;
  816. else if(garage_slot(playerid, 5) == -1) x = 493.998, y = -405.426, z = 2758.0046;
  817. else if(garage_slot(playerid, 6) == -1) x = 493.998, y = -410.9, z = 2758.0046;
  818. else if(garage_slot(playerid, 7) == -1) x = 493.998, y = -416.301, z = 2758.0046;
  819. else if(garage_slot(playerid, 8) == -1) x = 493.998, y = -421.104, z = 2758.0046;
  820. else if(garage_slot(playerid, 9) == -1) x = 493.998, y = -425.924, z = 2758.0046;
  821. if(x == 481.85) a = -131.1600;
  822. if(x == 493.998) a = 131.1600;
  823.  
  824. CarInfo[idd][cVirtual] = GetPVarInt(playerid, "inGarage");
  825. SCM(playerid, COLOR_GRAD3, "Your vehicle was parked in the garage.");
  826. }
  827.  
  828. CarInfo[idd][cLocationx] = x;
  829. CarInfo[idd][cLocationy] = y;
  830. CarInfo[idd][cLocationz] = z;
  831.  
  832.  
  833. CarInfo[idd][cAngle] = a;
  834. VehicleOwned[CarInfo[idd][Spawned]] = 0;
  835. VehicleSQL[CarInfo[idd][Spawned]] = 0;
  836.  
  837. DestroyVehicle(car);
  838.  
  839. if(CarInfo[idd][cNeon] != 0) {
  840. DestroyDynamicObject(neon[0][CarInfo[idd][Spawned]]);
  841. DestroyDynamicObject(neon[1][CarInfo[idd][Spawned]]);
  842. neon[0][CarInfo[idd][Spawned]] = 0;
  843. neon[1][CarInfo[idd][Spawned]] = 0;
  844. }
  845. if(strlen(CarInfo[idd][cText]) >= 3) {
  846. DestroyDynamicObject(nameobject[CarInfo[idd][Spawned]]);
  847. }
  848. CarInfo[idd][Spawned] = CreateVehicleEx(CarInfo[idd][cModel],CarInfo[idd][cLocationx],CarInfo[idd][cLocationy],CarInfo[idd][cLocationz],CarInfo[idd][cAngle],CarInfo[idd][cColorOne],CarInfo[idd][cColorTwo],-1);
  849. SetVehicleVirtualWorld(CarInfo[idd][Spawned], CarInfo[idd][cVirtual]);
  850. VehicleOwned[CarInfo[idd][Spawned]] = CarInfo[idd][Spawned];
  851. VehicleSQL[CarInfo[idd][Spawned]] = idd;
  852. if(CarInfo[idd][cNeon] != 0) {
  853. new h = CarInfo[idd][Spawned];
  854. if(CarInfo[idd][cNeon] == 1)
  855. {
  856. neon[0][h] = CreateDynamicObject(18648,0,0,0,0,0,0);
  857. neon[1][h] = CreateDynamicObject(18648,0,0,0,0,0,0);
  858. }
  859. else if(CarInfo[idd][cNeon] == 2)
  860. {
  861. neon[0][h] = CreateDynamicObject(18649,0,0,0,0,0,0);
  862. neon[1][h] = CreateDynamicObject(18649,0,0,0,0,0,0);
  863. }
  864. else if(CarInfo[idd][cNeon] == 3)
  865. {
  866. neon[0][h] = CreateDynamicObject(18650,0,0,0,0,0,0);
  867. neon[1][h] = CreateDynamicObject(18650,0,0,0,0,0,0);
  868. }
  869. else if(CarInfo[idd][cNeon] == 4)
  870. {
  871. neon[0][h] = CreateDynamicObject(18652,0,0,0,0,0,0);
  872. neon[1][h] = CreateDynamicObject(18652,0,0,0,0,0,0);
  873. }
  874. else if(CarInfo[idd][cNeon] == 5)
  875. {
  876. neon[0][h] = CreateDynamicObject(18651,0,0,0,0,0,0);
  877. neon[1][h] = CreateDynamicObject(18651,0,0,0,0,0,0);
  878. }
  879. else if(CarInfo[idd][cNeon] == 6)
  880. {
  881. neon[0][h] = CreateDynamicObject(18647,0,0,0,0,0,0);
  882. neon[1][h] = CreateDynamicObject(18647,0,0,0,0,0,0);
  883. }
  884. AttachDynamicObjectToVehicle(neon[0][h], h, -0.8, 0.0, -0.70, 0.0, 0.0, 0.0);
  885. AttachDynamicObjectToVehicle(neon[1][h], h, 0.8, 0.0, -0.70, 0.0, 0.0, 0.0);
  886. }
  887. attach_vip_text(idd);
  888.  
  889. SetTunning(idd);
  890. SetVehicleNumberPlate(CarInfo[idd][Spawned], CarInfo[idd][cLicense]);
  891. saveCarPark(idd);
  892. new Float: Pos[3];
  893. GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
  894. CarInfo[idd][cLastPos][0] = Pos[0];
  895. CarInfo[idd][cLastPos][1] = Pos[1];
  896. CarInfo[idd][cLastPos][2] = Pos[2];
  897. return 1;
  898. }
  899. // objects
  900. load_garage_map() {
  901.  
  902. new suelocochera[1];
  903. suelocochera[0] = CreateObject(6959,477.0000000,-419.3999900,2757.3000000,0.0000000,0.0000000,0.0000000);
  904. SetObjectMaterial(suelocochera[0], 0, 16150, "ufo_bar", "dinerfloor01_128", 0xFFFFFFFF);
  905.  
  906. new paredescochera[4];
  907. paredescochera[0] = CreateObject(6959,496.7000100,-419.7000100,2742.6001000,0.0000000,91.6560000,359.9730000);
  908. paredescochera[1] = CreateObject(6959,477.6000100,-418.8999900,2742.6001000,0.0000000,91.6530000,359.9730000);
  909. paredescochera[2] = CreateObject(6959,497.2999900,-399.6000100,2742.6001000,0.0000000,91.6530000,269.0490000);
  910. paredescochera[3] = CreateObject(6959,496.5000000,-438.6000100,2742.6001000,0.0000000,91.6480000,269.0440000);
  911. for(new index=0; index<4; index++) SetObjectMaterial(paredescochera[index], 0, 16150, "ufo_bar", "GEwhite1_64", 0xFFFFFFFF);
  912.  
  913. new techocochera[1];
  914. techocochera[0] = CreateObject(6959,477.0000000,-419.3999900,2762.3000000,0.0000000,0.0000000,0.0000000);
  915. SetObjectMaterial(techocochera[0], 0, 16150, "ufo_bar", "GEwhite1_64", 0xFFFFFFFF);
  916.  
  917.  
  918. CreateObject(13187,491.7999900,-438.8999900,2758.6001000,0.0000000,0.0000000,88.3620000);
  919. CreateObject(13187,483.5000000,-438.7999900,2758.6001000,0.0000000,0.0000000,89.6380000);
  920. CreateObject(2323,488.7000100,-401.2999900,2757.3000000,0.0000000,0.0000000,0.0000000);
  921. CreateObject(2306,491.2999900,-401.3999900,2757.3000000,0.0000000,0.0000000,0.0000000);
  922. CreateObject(1730,493.2999900,-400.2000100,2757.3000000,0.0000000,0.0000000,0.0000000);
  923. CreateObject(1518,493.5000000,-400.2999900,2758.7000000,0.0000000,0.0000000,0.0000000);
  924. CreateObject(2226,491.2999900,-400.2000100,2758.3000000,0.0000000,0.0000000,0.0000000);
  925. CreateObject(2229,494.7000100,-400.1000100,2757.3000000,0.0000000,0.0000000,0.0000000);
  926. CreateObject(2229,492.8999900,-400.1000100,2757.3000000,0.0000000,0.0000000,0.0000000);
  927. CreateObject(2297,488.5000000,-400.2000100,2759.3000000,0.0000000,0.0000000,316.4590000);
  928. CreateObject(2654,490.6000100,-400.2999900,2757.5000000,0.0000000,0.0000000,0.0000000);
  929. CreateObject(2980,495.1000100,-400.2000100,2758.1001000,0.0000000,0.0000000,0.0000000);
  930. CreateObject(2614,487.2000100,-400.0000000,2761.3999000,0.0000000,0.0000000,0.0000000);
  931. CreateObject(2611,492.0000000,-400.1000100,2760.0000000,0.0000000,0.0000000,0.0000000);
  932. CreateObject(1616,496.8999900,-439.1000100,2762.1001000,0.0000000,0.0000000,0.0000000);
  933. CreateObject(1584,497.2000100,-404.0000000,2759.5000000,0.0000000,0.0000000,278.3490000);
  934. CreateObject(1585,478.2000100,-432.3999900,2759.5000000,0.0000000,0.0000000,271.6380000);
  935. CreateObject(14699,494.0000000,-430.1000100,2760.5000000,0.0000000,0.0000000,92.2040000);
  936. CreateObject(14699,493.7000100,-420.7000100,2760.5000000,0.0000000,0.0000000,92.2030000);
  937. CreateObject(14699,493.2999900,-410.99900,2760.5000000,0.0000000,0.0000000,92.2030000);
  938. CreateObject(14699,493.2999900,-403.2999900,2760.5000000,0.0000000,0.0000000,92.2030000);
  939. CreateObject(14699,485.7999900,-403.0000000,2760.5000000,0.0000000,0.0000000,92.2030000);
  940. CreateObject(14699,486.1000100,-411.3999900,2760.5000000,0.0000000,0.0000000,92.2030000);
  941. CreateObject(14699,486.7999900,-420.6000100,2760.5000000,0.0000000,0.0000000,92.2030000);
  942. CreateObject(14699,485.7000100,-430.5000000,2760.5000000,0.0000000,0.0000000,92.2030000);
  943. CreateObject(2502,478.8999900,-400.0000000,2757.3000000,0.0000000,0.0000000,0.0000000);
  944. CreateObject(19273, 487.68793, -438.88925, 2758.78760, 0.00000, 0.00000, 175.91960);
  945. CreateObject(19900, 480.10303, -400.07925, 2757.25903, 0.00000, 0.00000, 0.00000);
  946. CreateObject(19900, 480.74579, -400.07465, 2757.25903, 0.00000, 0.00000, 0.00000);
  947. CreateObject(19815, 482.35214, -399.79022, 2758.80859, 0.00000, 0.00000, -0.78000);
  948. CreateObject(11737, 481.59167, -401.42493, 2757.26416, 0.00000, 0.00000, 0.00000);
  949. CreateObject(2465, 479.12677, -400.20123, 2758.53125, 0.00000, 0.00000, 0.00000);
  950. CreateObject(19617, 487.34158, -399.89642, 2760.01953, 0.00000, 0.00000, 0.00000);
  951. CreateObject(19804, 488.39011, -400.00421, 2758.41748, 0.00000, 0.00000, 0.00000);
  952. CreateObject(19805, 485.45383, -399.87045, 2759.29175, 0.00000, 0.00000, 0.00000);
  953. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement