garages.inc 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558
  1. #define MAX_GARAGES 500
  2. static str[144], sendername[MAX_PLAYER_NAME+1];
  3. new Text3D:GarageInfoText3D[MAX_GARAGES];
  4. new EditingGarage[MAX_PLAYERS];
  5. enum gInfo
  6. {
  7. gCreatedBy[MAX_PLAYER_NAME+1],
  8. gCreated,
  9. gOwnerID,
  10. Float:gOutsideX,
  11. Float:gOutsideY,
  12. Float:gOutsideZ,
  13. Float:gOutsideA,
  14. Float:gOutsideCarX,
  15. Float:gOutsideCarY,
  16. Float:gOutsideCarZ,
  17. Float:gInsideX,
  18. Float:gInsideY,
  19. Float:gInsideZ,
  20. Float:gInsideA,
  21. gLocked,
  22. gOutsidePickup,
  23. };
  24. new GarageInfo[MAX_GARAGES][gInfo];
  25. stock SetGarageType(gid, type) //more types might get added in the future..
  26. {
  27. if(GarageInfo[gid][gCreated] != 0)
  28. {
  29. switch(type)
  30. {
  31. case 1:
  32. {
  33. GarageInfo[gid][gInsideX] = 2565.6995;
  34. GarageInfo[gid][gInsideY] = -832.8325;
  35. GarageInfo[gid][gInsideZ] = 68;
  36. GarageInfo[gid][gInsideA] = -90;
  37. }
  38. case 2:
  39. {
  40. GarageInfo[gid][gInsideX] = 2565.6995;
  41. GarageInfo[gid][gInsideY] = -845.6425;
  42. GarageInfo[gid][gInsideZ] = 68;
  43. GarageInfo[gid][gInsideA] = -90;
  44. }
  45. }
  46. }
  47. }
  48. CMD:editgarage(playerid, params[])
  49. {
  50. if(PlayerInfo[playerid][pAdmin] >= 4 || PlayerInfo[playerid][pDev] >= 2 || PlayerInfo[playerid][pMapper] == MAPPERRANK_MANAGER || PlayerInfo[playerid][pBizMod] != 0 || PlayerInfo[playerid][pShopMod] != 0)
  51. {
  52. new action[24], nothing;
  53. if(!sscanf(params, "s[24]I(-1)", action, nothing))
  54. {
  55. if(!strcmp(action, "create", true))
  56. {
  57. new gType, confirmed[24];
  58. if(!sscanf(params, "s[24]iS()[24]", action, gType, confirmed))
  59. {
  60. if(gType < 1 || gType > 2) return SendClientMessage(playerid, COLOR_GRAD2, "Invalid garage type.");
  61. new garageid, bool:found =false;
  62. for(new i =1; i <MAX_GARAGES; i++)
  63. {
  64. if(GarageInfo[i][gCreated] == 0)
  65. {
  66. found = true;
  67. garageid = i;
  68. break;
  69. }
  70. }
  71. if(found)
  72. {
  73. new Float:x, Float:y, Float:z, Float:a, garagestring[64];
  74. GetPlayerFacingAngle(playerid, a);
  75. GetPlayerPos(playerid, x, y, z);
  76. strmid(sendername, PlayerICName(playerid), 0, MAX_PLAYER_NAME);
  77. GarageInfo[garageid][gCreatedBy] = sendername;
  78. GarageInfo[garageid][gOutsideX] = x;
  79. GarageInfo[garageid][gOutsideY] = y;
  80. GarageInfo[garageid][gOutsideZ] = z;
  81. GarageInfo[garageid][gOutsideCarX] = x;
  82. GarageInfo[garageid][gOutsideCarY] = y;
  83. GarageInfo[garageid][gOutsideCarZ] = z;
  84. GarageInfo[garageid][gOutsideA] = (a -180);
  85. GarageInfo[garageid][gCreated] = 1;
  86. SetGarageType(garageid, gType);
  87. if(GarageInfo[garageid][gOutsidePickup])
  88. {
  89. DestroyDynamicPickup(GarageInfo[garageid][gOutsidePickup]);
  90. }
  91. GarageInfo[garageid][gOutsidePickup] = CreateDynamicPickup(2485, 1, GarageInfo[garageid][gOutsideX], GarageInfo[garageid][gOutsideY], (GarageInfo[garageid][gOutsideZ]));
  92. //format(garagestring, sizeof(garagestring), "HID: %d", GarageInfo[garageid][gOwnerID]);
  93. format(garagestring, sizeof(garagestring), "{E2C582}Garage{FFFFFF}\nOwner ID: %d", GarageInfo[garageid][gOwnerID]);
  94. GarageInfoText3D[garageid] = CreateDynamic3DTextLabel(garagestring, COLOR_GARAGETEXT, GarageInfo[garageid][gOutsideX], GarageInfo[garageid][gOutsideY], GarageInfo[garageid][gOutsideZ] +0.5, 20.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 1, -1, -1, -1, 100);
  95. format(str, sizeof(str), "You have succesfully spawned garage(%d) at your current position.", garageid);
  96. SendClientMessage(playerid, COLOR_GRAD1, str);
  97. format(str, sizeof(str), "{FF0000}AdmWarning{FFFFFF}: %s has spawned garage(%d) at their position.", PlayerICName(playerid), garageid);
  98. ABroadCast(COLOR_WHITE, str, 1);
  99. EditingGarage[playerid] = garageid;
  100. }
  101. else
  102. {
  103. SendClientMessage(playerid, COLOR_GRAD2, "Error: Maximum garages have been reached.");
  104. }
  105. }
  106. else
  107. {
  108. SendClientMessage(playerid, COLOR_GRAD2, "{00BFFF}Usage:{FFFFFF} /editgarage create [garagetype (1-2)]");
  109. }
  110. }
  111. else if(!strcmp(action, "id", true))
  112. {
  113. new gid;
  114. if(!sscanf(params, "s[24]i", action, gid))
  115. {
  116. if(gid == 0 || gid > MAX_GARAGES) return SendClientMessage(playerid, COLOR_GRAD1, "Invalid garage ID.");
  117. if(GarageInfo[gid][gCreated] == 1)
  118. {
  119. EditingGarage[playerid] = gid;
  120. format(str, sizeof(str), "You are now editing garage(%d).", EditingGarage[playerid]);
  121. SendClientMessage(playerid, COLOR_GRAD1, str);
  122. }
  123. else
  124. {
  125. SendClientMessage(playerid, COLOR_GRAD1, "Invalid garage Id.");
  126. }
  127. }
  128. else
  129. {
  130. SendClientMessage(playerid, COLOR_GRAD2, "{00BFFF}Usage:{FFFFFF} /editgarage id [GARAGEID)]");
  131. }
  132. }
  133. else if(!strcmp(action, "pickupposition", true))
  134. {
  135. if(EditingGarage[playerid] != 0)
  136. {
  137. if(!sscanf(params, "s[24]", action))
  138. {
  139. new Float:px, Float:py, Float:pz, Float:pa;
  140. GetPlayerPos(playerid, px, py, pz);
  141. GetPlayerFacingAngle(playerid, pa);
  142. DestroyDynamic3DTextLabel(GarageInfoText3D[EditingGarage[playerid]]);
  143. GarageInfo[EditingGarage[playerid]][gOutsideX] = px;
  144. GarageInfo[EditingGarage[playerid]][gOutsideY] = py;
  145. GarageInfo[EditingGarage[playerid]][gOutsideZ] = pz;
  146. GarageInfo[EditingGarage[playerid]][gOutsideA] = pa;
  147. GarageInfo[EditingGarage[playerid]][gOutsideCarX] = px;
  148. GarageInfo[EditingGarage[playerid]][gOutsideCarY] = py;
  149. GarageInfo[EditingGarage[playerid]][gOutsideCarZ] = pz;
  150. if(GarageInfo[EditingGarage[playerid]][gOutsidePickup])
  151. {
  152. DestroyDynamicPickup(GarageInfo[EditingGarage[playerid]][gOutsidePickup]);
  153. }
  154. GarageInfo[EditingGarage[playerid]][gOutsidePickup] = CreateDynamicPickup(2485, 1, GarageInfo[EditingGarage[playerid]][gOutsideX], GarageInfo[EditingGarage[playerid]][gOutsideY], GarageInfo[EditingGarage[playerid]][gOutsideZ]);
  155. new garagestring[64];
  156. //format(garagestring, sizeof(garagestring), "HID: %d", GarageInfo[EditingGarage[playerid]][gOwnerID]);
  157. format(garagestring, sizeof(garagestring), "{E2C582}Garage{FFFFFF}\nOwner ID: %d", GarageInfo[EditingGarage[playerid]][gOwnerID]);
  158. GarageInfoText3D[EditingGarage[playerid]] = CreateDynamic3DTextLabel(garagestring, COLOR_GARAGETEXT, GarageInfo[EditingGarage[playerid]][gOutsideX], GarageInfo[EditingGarage[playerid]][gOutsideY], GarageInfo[EditingGarage[playerid]][gOutsideZ] +0.5, 20.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 1, -1, -1, -1, 100);
  159. UpdateDynamic3DTextLabelText(GarageInfoText3D[EditingGarage[playerid]], COLOR_GARAGETEXT, garagestring);
  160. format(str, sizeof(str), "You have fully moved garage(%d) to your current position.", EditingGarage[playerid]);
  161. SendClientMessage(playerid, COLOR_GRAD1, str);
  162. }
  163. }
  164. else
  165. {
  166. SendClientMessage(playerid, COLOR_GRAD1, "You are not editing any garage.");
  167. }
  168. }
  169. else if(!strcmp(action,"enterposition",true))
  170. {
  171. if(EditingGarage[playerid] != 0){
  172. new Float:px, Float:py, Float:pz, Float:pa;
  173. GetPlayerPos(playerid, px, py, pz);
  174. if(IsPlayerInAnyVehicle(playerid))
  175. {
  176. GetVehicleZAngle(GetPlayerVehicleID(playerid), pa);
  177. } else {
  178. GetPlayerFacingAngle(playerid, pa);
  179. }
  180. GarageInfo[EditingGarage[playerid]][gInsideX] = px;
  181. GarageInfo[EditingGarage[playerid]][gInsideY] = py;
  182. GarageInfo[EditingGarage[playerid]][gInsideZ] = pz;
  183. GarageInfo[EditingGarage[playerid]][gInsideA] = pa;
  184. format(str, sizeof(str), "Enter position of garage(%d) adjusted.", EditingGarage[playerid]);
  185. SendClientMessage(playerid, COLOR_GRAD1, str);
  186. }
  187. else{
  188. SendClientMessage(playerid, COLOR_GRAD1, "You are not editing any garage.");
  189. }
  190. }
  191. else if(!strcmp(action,"exitposition",true))
  192. {
  193. if(EditingGarage[playerid] != 0)
  194. {
  195. new Float:px, Float:py, Float:pz, Float:pa;
  196. GetPlayerPos(playerid, px, py, pz);
  197. if(IsPlayerInAnyVehicle(playerid))
  198. {
  199. GetVehicleZAngle(GetPlayerVehicleID(playerid), pa);
  200. } else {
  201. GetPlayerFacingAngle(playerid, pa);
  202. }
  203. GarageInfo[EditingGarage[playerid]][gOutsideCarX] = px;
  204. GarageInfo[EditingGarage[playerid]][gOutsideCarY] = py;
  205. GarageInfo[EditingGarage[playerid]][gOutsideCarZ] = pz;
  206. GarageInfo[EditingGarage[playerid]][gOutsideA] = pa;
  207. format(str, sizeof(str), "Exit position of garage(%d) adjusted.", EditingGarage[playerid]);
  208. SendClientMessage(playerid, COLOR_GRAD1, str);
  209. }
  210. else{
  211. SendClientMessage(playerid, COLOR_GRAD1, " You are not editing any garage !");
  212. }
  213. }
  214. /*else if(!strcmp(action, "houseid", true))
  215. {
  216. if(EditingGarage[playerid] != 0)
  217. {
  218. new hid;
  219. if(!sscanf(params, "s[24]i", action, hid))
  220. {
  221. if(HouseInfo[hid][hCreated] == 1)
  222. {
  223. GarageInfo[EditingGarage[playerid]][gOwnerID] = hid;
  224. format(str, sizeof(str), "Garage(%d) was succesfully connected to house %i.", EditingGarage[playerid], hid);
  225. SendClientMessage(playerid, COLOR_GRAD1, str);
  226. new garagestring[64];
  227. //format(garagestring, sizeof(garagestring), "HID: %d", GarageInfo[EditingGarage[playerid]][gOwnerID]);
  228. format(garagestring, sizeof(garagestring), "{E2C582}Garage{FFFFFF}\nOwner ID: %d", GarageInfo[EditingGarage[playerid]][gOwnerID]);
  229. UpdateDynamic3DTextLabelText(GarageInfoText3D[EditingGarage[playerid]], COLOR_DARKRED, garagestring);
  230. }
  231. else
  232. {
  233. SendClientMessage(playerid, COLOR_GRAD1, "Invalid house ID.");
  234. }
  235. }
  236. else
  237. {
  238. SendClientMessage(playerid, COLOR_GREY, "{00BFFF}Usage:{FFFFFF} /editgarage houseid [HOUSEID(to connect the garage to)]");
  239. }
  240. }
  241. else
  242. {
  243. SendClientMessage(playerid, COLOR_GRAD1, "You are not editing any garage.");
  244. }
  245. }*/
  246. else if(!strcmp(action, "ownerid", true))
  247. {
  248. if(EditingGarage[playerid] != 0)
  249. {
  250. new oid;
  251. if(!sscanf(params, "s[24]i", action, oid))
  252. {
  253. GarageInfo[EditingGarage[playerid]][gOwnerID] = oid;
  254. format(str, sizeof(str), "Garage(%d) was succesfully connected to Owner ID %i.", EditingGarage[playerid], oid);
  255. SendClientMessage(playerid, COLOR_GRAD1, str);
  256. new garagestring[64];
  257. //format(garagestring, sizeof(garagestring), "HID: %d", GarageInfo[EditingGarage[playerid]][gOwnerID]);
  258. format(garagestring, sizeof(garagestring), "{E2C582}Garage{FFFFFF}\nOwner ID: %d", GarageInfo[EditingGarage[playerid]][gOwnerID]);
  259. UpdateDynamic3DTextLabelText(GarageInfoText3D[EditingGarage[playerid]], COLOR_DARKRED, garagestring);
  260. }
  261. else
  262. {
  263. SendClientMessage(playerid, COLOR_GREY, "{00BFFF}Usage:{FFFFFF} /editgarage ownerid [/nametosql for the SQL ID]");
  264. }
  265. }
  266. else
  267. {
  268. SendClientMessage(playerid, COLOR_GRAD1, "You are not editing any garage.");
  269. }
  270. }
  271. else if(!strcmp(action, "delete", true))
  272. {
  273. if(EditingGarage[playerid] != 0)
  274. {
  275. strmid(GarageInfo[EditingGarage[playerid]][gCreatedBy], "", 0, strlen("None"), 255);
  276. DestroyDynamic3DTextLabel(GarageInfoText3D[EditingGarage[playerid]]);
  277. GarageInfoText3D[EditingGarage[playerid]] = Text3D:INVALID_3DTEXT_ID;
  278. GarageInfo[EditingGarage[playerid]][gOutsideX] = 0;
  279. GarageInfo[EditingGarage[playerid]][gOutsideY] = 0;
  280. GarageInfo[EditingGarage[playerid]][gOutsideZ] = 0;
  281. GarageInfo[EditingGarage[playerid]][gOutsideA] = 0;
  282. GarageInfo[EditingGarage[playerid]][gOutsideCarX] = 0;
  283. GarageInfo[EditingGarage[playerid]][gOutsideCarY] = 0;
  284. GarageInfo[EditingGarage[playerid]][gOutsideCarZ] = 0;
  285. GarageInfo[EditingGarage[playerid]][gInsideX] = 0;
  286. GarageInfo[EditingGarage[playerid]][gInsideY] = 0;
  287. GarageInfo[EditingGarage[playerid]][gInsideZ] = 0;
  288. GarageInfo[EditingGarage[playerid]][gInsideA] = 0;
  289. GarageInfo[EditingGarage[playerid]][gLocked] = 0;
  290. GarageInfo[EditingGarage[playerid]][gOwnerID] = 0;
  291. GarageInfo[EditingGarage[playerid]][gCreated] = 0;
  292. if(GarageInfo[EditingGarage[playerid]][gOutsidePickup])
  293. {
  294. DestroyDynamicPickup(GarageInfo[EditingGarage[playerid]][gOutsidePickup]);
  295. }
  296. format(str, sizeof(str), "You have fully deleted garage(%d).", EditingGarage[playerid]);
  297. SendClientMessage(playerid, COLOR_GRAD1, str);
  298. format(str, sizeof(str), "{FF0000}AdmWarning{FFFFFF}: %s has deleted garage(%d).", PlayerICName(playerid), EditingGarage[playerid]);
  299. ABroadCast(COLOR_WHITE, str, 1);
  300. EditingGarage[playerid] = 0;
  301. }
  302. else
  303. {
  304. SendClientMessage(playerid, COLOR_GRAD1, "You are not editing any garage.");
  305. }
  306. }
  307. else if(!strcmp(action, "stop", true))
  308. {
  309. if(EditingGarage[playerid] != 0)
  310. {
  311. SendClientMessage(playerid, COLOR_GRAD1, "Editing progress was ended.");
  312. EditingGarage[playerid] = 0;
  313. }
  314. else
  315. {
  316. SendClientMessage(playerid, COLOR_GRAD1, "You are not editing any garage.");
  317. }
  318. }
  319. else
  320. {
  321. SendClientMessage(playerid, COLOR_WHITE, "Invalid action.");
  322. }
  323. }
  324. else
  325. {
  326. SendClientMessage(playerid, COLOR_GREY, "{00BFFF}Usage:{FFFFFF} /editgarage [action]");
  327. SendClientMessage(playerid, COLOR_GREY, "Available actions: create, id, pickupposition, enterposition, exitposition, houseid, delete, stop");
  328. }
  329. }
  330. else
  331. {
  332. AdmErrorMsg;
  333. }
  334. return 1;
  335. }
  336. CMD:gotogarage(playerid, params[])
  337. {
  338. new gid;
  339. if(PlayerInfo[playerid][pDev] >= 2 || PlayerInfo[playerid][pAdmin] >= 4 || PlayerInfo[playerid][pMapper] == MAPPERRANK_MANAGER)
  340. {
  341. if(GetPlayerState(playerid) == PLAYER_STATE_SPECTATING)
  342. {
  343. SendClientMessage(playerid, COLOR_GREY, "You can not do that while spectating.");
  344. return 1;
  345. }
  346. if(!sscanf(params, "d", gid))
  347. {
  348. if(gid > MAX_GARAGES)
  349. {
  350. return SendClientMessage(playerid, COLOR_GRAD1, "Garage ID was above the max garages.");
  351. }
  352. if(GarageInfo[gid][gCreated] == 1)
  353. {
  354. SetPlayerPos(playerid, GarageInfo[gid][gOutsideX], GarageInfo[gid][gOutsideY], GarageInfo[gid][gOutsideZ]);
  355. SetPlayerInterior(playerid, 0);
  356. PlayerInfo[playerid][pInt] = 0;
  357. SetPlayerVirtualWorld(playerid, 0);
  358. PlayerInfo[playerid][pVirtualWorld] = 0;
  359. format(str, sizeof(str), "~w~Teleporting to ~b~Garage~w~.");
  360. displayCenterHUDInfo(playerid, str, 8); //display for 8 seconds
  361. }
  362. else
  363. {
  364. SendClientMessage(playerid, COLOR_GRAD1, "Invalid garage ID.");
  365. }
  366. }
  367. else
  368. {
  369. SendClientMessage(playerid, COLOR_GRAD2, "{00BFFF}Usage:{FFFFFF} /gotogarage [Garageid]");
  370. }
  371. }
  372. else
  373. {
  374. AdmErrorMsg;
  375. }
  376. return 1;
  377. }
  378. CMD:garageinfo(playerid, params[])
  379. {
  380. if(PlayerInfo[playerid][pDev] >= 2 || PlayerInfo[playerid][pAdmin] >= 4 || PlayerInfo[playerid][pMapper] == MAPPERRANK_MANAGER)
  381. {
  382. for(new gr =1; gr <MAX_GARAGES; gr++)
  383. {
  384. if(GarageInfo[gr][gCreated] == 1)
  385. {
  386. if(IsPlayerInRangeOfPoint(playerid, 4.0, GarageInfo[gr][gOutsideX], GarageInfo[gr][gOutsideY], GarageInfo[gr][gOutsideZ]))
  387. {
  388. SendClientMessage(playerid, COLOR_YELLOW, "____________________________________________");
  389. format(str, sizeof(str), "Garage ID : %i", gr);
  390. SendClientMessage(playerid, COLOR_WHITE, str);
  391. format(str, sizeof(str), "Created by: %s", GarageInfo[gr][gCreatedBy]);
  392. SendClientMessage(playerid, COLOR_WHITE, str);
  393. format(str, sizeof(str), "Owner ID: %i [/sqltoname for owner name]", GarageInfo[gr][gOwnerID]);
  394. SendClientMessage(playerid, COLOR_WHITE, str);
  395. }
  396. }
  397. }
  398. }
  399. else
  400. {
  401. AdmErrorMsg;
  402. }
  403. return 1;
  404. }
  405. CMD:lockgarage(playerid, params[])
  406. {
  407. new gcount = 0, chcount = 0;
  408. for(new gr =1; gr <MAX_GARAGES; gr++)
  409. {
  410. if(GarageInfo[gr][gCreated] == 1)
  411. {
  412. if(GarageInfo[gr][gOwnerID] == PlayerInfo[playerid][pID])
  413. {
  414. if(IsPlayerInRangeOfPoint(playerid, 4.0, GarageInfo[gr][gOutsideX], GarageInfo[gr][gOutsideY], GarageInfo[gr][gOutsideZ]))
  415. {
  416. if(GarageInfo[gr][gLocked] == 0)
  417. {
  418. GarageInfo[gr][gLocked] = 1;
  419. SendClientMessage(playerid, COLOR_GREY, "Garage {FF0000}locked{FFFFFF}.");
  420. format(str, sizeof(str), "* %s has locked their garage.", PlayerICName(playerid));
  421. ProxDetector(30.0, playerid, str, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
  422. }
  423. else
  424. {
  425. GarageInfo[gr][gLocked] = 0;
  426. SendClientMessage(playerid, COLOR_GREY, "Garage {00FF00}unlocked{FFFFFF}.");
  427. format(str, sizeof(str), "* %s has unlocked their garage.", PlayerICName(playerid));
  428. ProxDetector(30.0, playerid, str, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
  429. }
  430. chcount++;
  431. }
  432. gcount++;
  433. }
  434. }
  435. }
  436. if(gcount == 0)
  437. {
  438. SendClientMessage(playerid, COLOR_RED, "You do not own a garage .");
  439. }
  440. else if(chcount == 0)
  441. {
  442. SendClientMessage(playerid, COLOR_RED, "You are not in range of your garage .");
  443. }
  444. return 1;
  445. }
  446. //==================================[GARAGES]===================================
  447. public SaveGarages()
  448. {
  449. new idx = 1;
  450. new File:file;
  451. file = fopen("garages.cfg", io_write);
  452. fclose(file);
  453. file = fopen("garages.cfg", io_append);
  454. new coordsstring[512];
  455. if(file) {
  456. while(idx < sizeof(GarageInfo))
  457. {
  458. format(coordsstring, sizeof(coordsstring), "%s|%d|%d|%f|%f|%f|%f|%f|%f|%f|%f|%f|%f|%d\r\n",
  459. GarageInfo[idx][gCreatedBy],
  460. GarageInfo[idx][gCreated],
  461. GarageInfo[idx][gOwnerID],
  462. GarageInfo[idx][gOutsideX],
  463. GarageInfo[idx][gOutsideY],
  464. GarageInfo[idx][gOutsideZ],
  465. GarageInfo[idx][gOutsideA],
  466. GarageInfo[idx][gOutsideCarX],
  467. GarageInfo[idx][gOutsideCarY],
  468. GarageInfo[idx][gOutsideCarZ],
  469. GarageInfo[idx][gInsideX],
  470. GarageInfo[idx][gInsideY],
  471. GarageInfo[idx][gInsideZ],
  472. GarageInfo[idx][gInsideA],
  473. GarageInfo[idx][gLocked]);
  474. fwrite(file, coordsstring);
  475. idx++;
  476. }
  477. fclose(file);
  478. } else {
  479. printf("[error] Failed to find garages.cfg");
  480. }
  481. return 1;
  482. }
  483. public LoadGarages()
  484. {
  485. new arrCoords[15][126], strFromFile2[512], File: file = fopen("garages.cfg", io_read);
  486. if(file)
  487. {
  488. new idx = 1;
  489. while(idx < sizeof(GarageInfo))
  490. {
  491. fread(file, strFromFile2);
  492. split(strFromFile2, arrCoords, '|');
  493. strmid(GarageInfo[idx][gCreatedBy], arrCoords[0], 0, strlen(arrCoords[0]), 255);
  494. GarageInfo[idx][gCreated] = strval(arrCoords[1]);
  495. GarageInfo[idx][gOwnerID] = strval(arrCoords[2]);
  496. GarageInfo[idx][gOutsideX] = floatstr(arrCoords[3]);
  497. GarageInfo[idx][gOutsideY] = floatstr(arrCoords[4]);
  498. GarageInfo[idx][gOutsideZ] = floatstr(arrCoords[5]);
  499. GarageInfo[idx][gOutsideA] = floatstr(arrCoords[6]);
  500. GarageInfo[idx][gOutsideCarX] = floatstr(arrCoords[7]);
  501. GarageInfo[idx][gOutsideCarY] = floatstr(arrCoords[8]);
  502. GarageInfo[idx][gOutsideCarZ] = floatstr(arrCoords[9]);
  503. GarageInfo[idx][gInsideX] = floatstr(arrCoords[10]);
  504. GarageInfo[idx][gInsideY] = floatstr(arrCoords[11]);
  505. GarageInfo[idx][gInsideZ] = floatstr(arrCoords[12]);
  506. GarageInfo[idx][gInsideA] = floatstr(arrCoords[13]);
  507. GarageInfo[idx][gLocked] = strval(arrCoords[14]);
  508. new string3[64];
  509. if(GarageInfo[idx][gCreated] == 1)
  510. {
  511. if(GarageInfo[idx][gOutsidePickup])
  512. {
  513. DestroyDynamicPickup(GarageInfo[idx][gOutsidePickup]);
  514. }
  515. GarageInfo[idx][gOutsidePickup] = CreateDynamicPickup(2485, 1, GarageInfo[idx][gOutsideX], GarageInfo[idx][gOutsideY], GarageInfo[idx][gOutsideZ]);
  516. //format(string3, sizeof(string3), "HID: %d", GarageInfo[idx][gOwnerID]);
  517. format(string3, sizeof(string3), "{E2C582}Garage{FFFFFF}\nOwner ID: %d", GarageInfo[idx][gOwnerID]);
  518. GarageInfoText3D[idx] = CreateDynamic3DTextLabel(string3, COLOR_GARAGETEXT, GarageInfo[idx][gOutsideX], GarageInfo[idx][gOutsideY], GarageInfo[idx][gOutsideZ] +0.5, 20.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 1, -1, -1, -1, 100);
  519. UpdateDynamic3DTextLabelText(GarageInfoText3D[idx], COLOR_GARAGETEXT, string3);
  520. }
  521. idx++;
  522. }
  523. fclose(file);
  524. } else {
  525. printf("[error] Failed to find garages.cfg");
  526. }
  527. return 1;
  528. }
  529. CMD:agaragehelp(playerid, params[])
  530. {
  531. if(PlayerInfo[playerid][pAdmin] >= 4 || PlayerInfo[playerid][pMapper] == 3)
  532. {
  533. SendClientMessage(playerid, COLOR_YELLOW, "____________________________________________");
  534. SendClientMessage(playerid, COLOR_WHITE, "COMMANDS: /editgarage, /gotogarage, /garageinfo");
  535. }
  536. else
  537. {
  538. AdmErrorMsg;
  539. }
  540. return 1;
  541. }