Guest User

Untitled

a guest
Mar 26th, 2013
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 100.12 KB | None | 0 0
  1. /*
  2. Emmet's awesome dealership script!
  3. Made by Emmet_ on August 2, 2012
  4.  
  5. Version: v1.1
  6.  
  7. This Source Code Form is subject to the terms of the Mozilla Public
  8. License, v. 2.0. If a copy of the MPL was not distributed with this
  9. file, You can obtain one at http://mozilla.org/MPL/2.0/.
  10. */
  11.  
  12. #include <a_samp>
  13. #include <foreach>
  14. #include <zcmd>
  15.  
  16. #define FILTERSCRIPT
  17.  
  18. #define WHITE 0xFFFFFFFF
  19. #define PURPLE 0xC2A2DAFF
  20. #define BLUE 0x0000FFFF
  21. #define RED 0xFF0000FF
  22. #define YELLOW 0xFFFF00FF
  23. #define GREEN 0x33AA33FF
  24. #define LIGHTBLUE 0x33CCFFFF
  25. #define LIGHTRED 0xFF6347FF
  26. #define DARKRED 0xAA3333FF
  27. #define GREY 0xAFAFAFFF
  28. #define ORANGE 0xFFA100FF
  29. #define YELLOW2 0xF5DEB3FF
  30. #define MAX_PLAYER_CARS 4
  31. #define LOCK_PRICE 20000
  32. #pragma dynamic 719196 // FUCKING STRINGS
  33.  
  34. enum vDealerData
  35. {
  36. vModel,
  37. Float:vX,
  38. Float:vY,
  39. Float:vZ,
  40. Float:vRot,
  41. vForSale,
  42. vPrice,
  43. Text3D:vLabel,
  44. vID,
  45. vSQL_ID
  46. };
  47.  
  48. enum pDealerData
  49. {
  50. pCarModel,
  51. Float:pCarX,
  52. Float:pCarY,
  53. Float:pCarZ,
  54. Float:pCarRot,
  55. pCarColor1,
  56. pCarColor2,
  57. pCarPaintjob,
  58. pCarMod1,
  59. pCarMod2,
  60. pCarMod3,
  61. pCarMod4,
  62. pCarMod5,
  63. pCarMod6,
  64. pCarMod7,
  65. pCarMod8,
  66. pCarMod9,
  67. pCarMod10,
  68. pCarMod11,
  69. pCarMod12,
  70. pCarMod13,
  71. pCarMod14,
  72. pCarMod15,
  73. pCarMod16,
  74. pCarMod17,
  75. pCarHasLock,
  76. pCarLocked,
  77. pCarTrunkCash,
  78. pCarTrunkGun1,
  79. pCarTrunkGun2,
  80. pCarTrunkGun3,
  81. pCarTrunkGun4,
  82. pCarTrunkAmmo1,
  83. pCarTrunkAmmo2,
  84. pCarTrunkAmmo3,
  85. pCarTrunkAmmo4,
  86. pCarSpawned,
  87. pCarOwned,
  88. pCarID
  89. };
  90. new PlayerVehicles[MAX_PLAYERS][MAX_PLAYER_CARS + 1][pDealerData];
  91. new DealershipVehicles[MAX_VEHICLES][vDealerData];
  92. new VehicleLocked[MAX_VEHICLES];
  93. new VehicleListitem[MAX_PLAYERS][MAX_PLAYER_CARS + 1];
  94. new DB:VehicleDatabase[MAX_PLAYERS];
  95. new DB:DealerVehicleDatabase;
  96. new dealershipCars;
  97.  
  98. new spoiler[20][0] = {1000, 1001, 1002, 1003, 1014, 1015, 1016, 1023, 1058, 1060, 1049, 1050, 1138, 1139, 1146, 1147, 1158, 1162, 1163, 1164};
  99. new nitro[3][0] = {1008, 1009, 1010};
  100. new front_bumper[23][0] = {1117, 1152, 1153, 1155, 1157, 1160, 1165, 1167, 1169, 1170, 1171, 1172, 1173, 1174, 1175, 1179, 1181, 1182, 1185, 1188, 1189, 1192, 1193};
  101. new rear_bumper[22][0] = {1140, 1141, 1148, 1149, 1150, 1151, 1154, 1156, 1159, 1161, 1166, 1168, 1176, 1177, 1178, 1180, 1183, 1184, 1186, 1187, 1190, 1191};
  102. new exhaust[28][0] = {1018, 1019, 1020, 1021, 1022, 1028, 1029, 1037, 1043, 1044, 1045, 1046, 1059, 1064, 1065, 1066, 1089, 1092, 1104, 1105, 1113, 1114, 1126, 1127, 1129, 1132, 1135, 1136};
  103. new bventr[2][0] = {1042, 1044};
  104. new bventl[2][0] = {1043, 1045};
  105. new bscoop[4][0] = {1004, 1005, 1011, 1012};
  106. new rscoop[13][0] = {1006, 1032, 1033, 1035, 1038, 1053, 1054, 1055, 1061, 1067, 1068, 1088, 1091};
  107. new left_sideskirt[21][0] = {1007, 1026, 1031, 1036, 1039, 1042, 1047, 1048, 1056, 1057, 1069, 1070, 1090, 1093, 1106, 1108, 1118, 1119, 1133, 1122, 1134};
  108. new right_sideskirt[21][0] = {1017, 1027, 1030, 1040, 1041, 1051, 1052, 1062, 1063, 1071, 1072, 1094, 1095, 1099, 1101, 1102, 1107, 1120, 1121, 1124, 1137};
  109. new hydraulics[1][0] = {1087};
  110. new bass[1][0] = {1086};
  111. new rbbars[2][0] = {1109, 1110};
  112. new fbbars[2][0] = {1115, 1116};
  113. new wheels[17][0] = {1025, 1073, 1074, 1075, 1076, 1077, 1078, 1079, 1080, 1081, 1082, 1083, 1084, 1085, 1096, 1097, 1098};
  114. new lights[2][0] = {1013, 1024};
  115.  
  116. stock PlayerName(playerid, bool:show_underscore = true)
  117. {
  118. new pName[24];
  119. GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
  120. if (show_underscore == false)
  121. {
  122. for (new i = 0; i < strlen(pName); i += 1)
  123. {
  124. if (pName[i] == '_') pName[i] = ' ';
  125. }
  126. }
  127. return pName;
  128. }
  129.  
  130. stock sscanf(string[], format[], {Float,_}:...)
  131. {
  132. #if defined isnull
  133. if (isnull(string))
  134. #else
  135. if (string[0] == 0 || (string[0] == 1 && string[1] == 0))
  136. #endif
  137. {
  138. return format[0];
  139. }
  140. #pragma tabsize 4
  141. new
  142. formatPos = 0,
  143. stringPos = 0,
  144. paramPos = 2,
  145. paramCount = numargs(),
  146. delim = ' ';
  147. while (string[stringPos] && string[stringPos] <= ' ')
  148. {
  149. stringPos++;
  150. }
  151. while (paramPos < paramCount && string[stringPos])
  152. {
  153. switch (format[formatPos++])
  154. {
  155. case '\0':
  156. {
  157. return 0;
  158. }
  159. case 'i', 'd':
  160. {
  161. new
  162. neg = 1,
  163. num = 0,
  164. ch = string[stringPos];
  165. if (ch == '-')
  166. {
  167. neg = -1;
  168. ch = string[++stringPos];
  169. }
  170. do
  171. {
  172. stringPos++;
  173. if ('0' <= ch <= '9')
  174. {
  175. num = (num * 10) + (ch - '0');
  176. }
  177. else
  178. {
  179. return -1;
  180. }
  181. }
  182. while ((ch = string[stringPos]) > ' ' && ch != delim);
  183. setarg(paramPos, 0, num * neg);
  184. }
  185. case 'h', 'x':
  186. {
  187. new
  188. num = 0,
  189. ch = string[stringPos];
  190. do
  191. {
  192. stringPos++;
  193. switch (ch)
  194. {
  195. case 'x', 'X':
  196. {
  197. num = 0;
  198. continue;
  199. }
  200. case '0' .. '9':
  201. {
  202. num = (num << 4) | (ch - '0');
  203. }
  204. case 'a' .. 'f':
  205. {
  206. num = (num << 4) | (ch - ('a' - 10));
  207. }
  208. case 'A' .. 'F':
  209. {
  210. num = (num << 4) | (ch - ('A' - 10));
  211. }
  212. default:
  213. {
  214. return -1;
  215. }
  216. }
  217. }
  218. while ((ch = string[stringPos]) > ' ' && ch != delim);
  219. setarg(paramPos, 0, num);
  220. }
  221. case 'c':
  222. {
  223. setarg(paramPos, 0, string[stringPos++]);
  224. }
  225. case 'f':
  226. {
  227.  
  228. new changestr[16], changepos = 0, strpos = stringPos;
  229. while(changepos < 16 && string[strpos] && string[strpos] != delim)
  230. {
  231. changestr[changepos++] = string[strpos++];
  232. }
  233. changestr[changepos] = '\0';
  234. setarg(paramPos,0,_:floatstr(changestr));
  235. }
  236. case 'p':
  237. {
  238. delim = format[formatPos++];
  239. continue;
  240. }
  241. case '\'':
  242. {
  243. new
  244. end = formatPos - 1,
  245. ch;
  246. while ((ch = format[++end]) && ch != '\'') {}
  247. if (!ch)
  248. {
  249. return -1;
  250. }
  251. format[end] = '\0';
  252. if ((ch = strfind(string, format[formatPos], false, stringPos)) == -1)
  253. {
  254. if (format[end + 1])
  255. {
  256. return -1;
  257. }
  258. return 0;
  259. }
  260. format[end] = '\'';
  261. stringPos = ch + (end - formatPos);
  262. formatPos = end + 1;
  263. }
  264. case 'u':
  265. {
  266. new
  267. end = stringPos - 1,
  268. id = 0,
  269. bool:num = true,
  270. ch;
  271. while ((ch = string[++end]) && ch != delim)
  272. {
  273. if (num)
  274. {
  275. if ('0' <= ch <= '9')
  276. {
  277. id = (id * 10) + (ch - '0');
  278. }
  279. else
  280. {
  281. num = false;
  282. }
  283. }
  284. }
  285. if (num && IsPlayerConnected(id))
  286. {
  287. setarg(paramPos, 0, id);
  288. }
  289. else
  290. {
  291. #if !defined foreach
  292. #define foreach(%1,%2) for (new %2 = 0; %2 < MAX_PLAYERS; %2++) if (IsPlayerConnected(%2))
  293. #define __SSCANF_FOREACH__
  294. #endif
  295. string[end] = '\0';
  296. num = false;
  297. new
  298. name[MAX_PLAYER_NAME];
  299. id = end - stringPos;
  300. foreach (Player, playerid)
  301. {
  302. GetPlayerName(playerid, name, sizeof (name));
  303. if (!strcmp(name, string[stringPos], true, id))
  304. {
  305. setarg(paramPos, 0, playerid);
  306. num = true;
  307. break;
  308. }
  309. }
  310. if (!num)
  311. {
  312. setarg(paramPos, 0, INVALID_PLAYER_ID);
  313. }
  314. string[end] = ch;
  315. #if defined __SSCANF_FOREACH__
  316. #undef foreach
  317. #undef __SSCANF_FOREACH__
  318. #endif
  319. }
  320. stringPos = end;
  321. }
  322. case 's', 'z':
  323. {
  324. new
  325. i = 0,
  326. ch;
  327. if (format[formatPos])
  328. {
  329. while ((ch = string[stringPos++]) && ch != delim)
  330. {
  331. setarg(paramPos, i++, ch);
  332. }
  333. if (!i)
  334. {
  335. return -1;
  336. }
  337. }
  338. else
  339. {
  340. while ((ch = string[stringPos++]))
  341. {
  342. setarg(paramPos, i++, ch);
  343. }
  344. }
  345. stringPos--;
  346. setarg(paramPos, i, '\0');
  347. }
  348. default:
  349. {
  350. continue;
  351. }
  352. }
  353. while (string[stringPos] && string[stringPos] != delim && string[stringPos] > ' ')
  354. {
  355. stringPos++;
  356. }
  357. while (string[stringPos] && (string[stringPos] == delim || string[stringPos] <= ' '))
  358. {
  359. stringPos++;
  360. }
  361. paramPos++;
  362. }
  363. do
  364. {
  365. if ((delim = format[formatPos++]) > ' ')
  366. {
  367. if (delim == '\'')
  368. {
  369. while ((delim = format[formatPos++]) && delim != '\'') {}
  370. }
  371. else if (delim != 'z')
  372. {
  373. return delim;
  374. }
  375. }
  376. }
  377. while (delim > ' ');
  378. return 0;
  379. }
  380.  
  381. stock DB_Escape(text[])
  382. {
  383. new
  384. ret[80 * 2],
  385. ch,
  386. i,
  387. j;
  388. while ((ch = text[i++]) && j < sizeof (ret))
  389. {
  390. if (ch == '\'')
  391. {
  392. if (j < sizeof (ret) - 2)
  393. {
  394. ret[j++] = '\'';
  395. ret[j++] = '\'';
  396. }
  397. }
  398. else if (j < sizeof (ret))
  399. {
  400. ret[j++] = ch;
  401. }
  402. else
  403. {
  404. j++;
  405. }
  406. }
  407. ret[sizeof (ret) - 1] = '\0';
  408. return ret;
  409. }
  410.  
  411. stock ReturnComponentSlot(componentid)
  412. {
  413. new i = 0;
  414. for(i = 0; i < 20; i ++) { if(spoiler[i][0] == componentid) { return 1; } }
  415. for(i = 0; i < 3; i ++) { if(nitro[i][0] == componentid) { return 2; } }
  416. for(i = 0; i < 23; i ++) { if(front_bumper[i][0] == componentid) { return 3; } }
  417. for(i = 0; i < 22; i ++) { if(rear_bumper[i][0] == componentid) { return 4; } }
  418. for(i = 0; i < 28; i ++) { if(exhaust[i][0] == componentid) { return 5; } }
  419. for(i = 0; i < 2; i ++) { if(bventr[i][0] == componentid) { return 6; } }
  420. for(i = 0; i < 2; i ++) { if(bventl[i][0] == componentid) { return 7; } }
  421. for(i = 0; i < 4; i ++) { if(bscoop[i][0] == componentid) { return 8; } }
  422. for(i = 0; i < 13; i ++) { if(rscoop[i][0] == componentid) { return 9; } }
  423. for(i = 0; i < 21; i ++) { if(left_sideskirt[i][0] == componentid) { return 10; } }
  424. for(i = 0; i < 21; i ++) { if(right_sideskirt[i][0] == componentid) { return 11; } }
  425. if(hydraulics[0][0] == componentid) { return 12; }
  426. if(bass[0][0] == componentid) { return 13; }
  427. for(i = 0; i < 2; i ++) { if(rbbars[i][0] == componentid) { return 14; } }
  428. for(i = 0; i < 2; i ++) { if(fbbars[i][0] == componentid) { return 15; } }
  429. for(i = 0; i < 17; i ++) { if(wheels[i][0] == componentid) { return 16; } }
  430. for(i = 0; i < 2; i ++) { if(lights[i][0] == componentid) { return 17; } }
  431. return 0;
  432. }
  433.  
  434. stock GetVehicleName(vehicleid)
  435. {
  436. new
  437. vehicle_name[32] = "None";
  438. if((vehicleid == INVALID_VEHICLE_ID) || (vehicleid < 1 || (vehicleid > MAX_VEHICLES - 1))) return vehicle_name;
  439. switch (GetVehicleModel(vehicleid))
  440. {
  441. case 400: vehicle_name = "Landstalker";
  442. case 401: vehicle_name = "Bravura";
  443. case 402: vehicle_name = "Buffalo";
  444. case 403: vehicle_name = "Linerunner";
  445. case 404: vehicle_name = "Perennial";
  446. case 405: vehicle_name = "Sentinel";
  447. case 406: vehicle_name = "Dumper";
  448. case 407: vehicle_name = "Firetruck";
  449. case 408: vehicle_name = "Trashmaster";
  450. case 409: vehicle_name = "Stretch";
  451. case 410: vehicle_name = "Manana";
  452. case 411: vehicle_name = "Infernus";
  453. case 412: vehicle_name = "Voodoo";
  454. case 413: vehicle_name = "Pony";
  455. case 414: vehicle_name = "Mule";
  456. case 415: vehicle_name = "Cheetah";
  457. case 416: vehicle_name = "Ambulance";
  458. case 417: vehicle_name = "Leviathan";
  459. case 418: vehicle_name = "Moonbeam";
  460. case 419: vehicle_name = "Esperanto";
  461. case 420: vehicle_name = "Taxi";
  462. case 421: vehicle_name = "Washington";
  463. case 422: vehicle_name = "Bobcat";
  464. case 423: vehicle_name = "Mr Whoopee";
  465. case 424: vehicle_name = "BF Injection";
  466. case 425: vehicle_name = "Hunter";
  467. case 426: vehicle_name = "Premier";
  468. case 427: vehicle_name = "Enforcer";
  469. case 428: vehicle_name = "Securicar";
  470. case 429: vehicle_name = "Banshee";
  471. case 430: vehicle_name = "Predator";
  472. case 431: vehicle_name = "Bus";
  473. case 432: vehicle_name = "Rhino";
  474. case 433: vehicle_name = "Barracks";
  475. case 434: vehicle_name = "Hotknife";
  476. case 435: vehicle_name = "Article Trailer";
  477. case 436: vehicle_name = "Previon";
  478. case 437: vehicle_name = "Coach";
  479. case 438: vehicle_name = "Cabbie";
  480. case 439: vehicle_name = "Stallion";
  481. case 440: vehicle_name = "Rumpo";
  482. case 441: vehicle_name = "RC Bandit";
  483. case 442: vehicle_name = "Romero";
  484. case 443: vehicle_name = "Packer";
  485. case 444: vehicle_name = "Monster";
  486. case 445: vehicle_name = "Admiral";
  487. case 446: vehicle_name = "Squalo";
  488. case 447: vehicle_name = "Seasparrow";
  489. case 448: vehicle_name = "Pizzaboy";
  490. case 449: vehicle_name = "Tram";
  491. case 450: vehicle_name = "Article Trailer 2";
  492. case 451: vehicle_name = "Turismo";
  493. case 452: vehicle_name = "Speeder";
  494. case 453: vehicle_name = "Reefer";
  495. case 454: vehicle_name = "Tropic";
  496. case 455: vehicle_name = "Flatbed";
  497. case 456: vehicle_name = "Yankee";
  498. case 457: vehicle_name = "Caddy";
  499. case 458: vehicle_name = "Solair";
  500. case 459: vehicle_name = "Berkley's RC Van";
  501. case 460: vehicle_name = "Skimmer";
  502. case 461: vehicle_name = "PCJ-600";
  503. case 462: vehicle_name = "Faggio";
  504. case 463: vehicle_name = "Freeway";
  505. case 464: vehicle_name = "RC Baron";
  506. case 465: vehicle_name = "RC Raider";
  507. case 466: vehicle_name = "Glendale";
  508. case 467: vehicle_name = "Oceanic";
  509. case 468: vehicle_name = "Sanchez";
  510. case 469: vehicle_name = "Sparrow";
  511. case 470: vehicle_name = "Patriot";
  512. case 471: vehicle_name = "Quad";
  513. case 472: vehicle_name = "Coastguard";
  514. case 473: vehicle_name = "Dinghy";
  515. case 474: vehicle_name = "Hermes";
  516. case 475: vehicle_name = "Sabre";
  517. case 476: vehicle_name = "Rustler";
  518. case 477: vehicle_name = "ZR-350";
  519. case 478: vehicle_name = "Walton";
  520. case 479: vehicle_name = "Regina";
  521. case 480: vehicle_name = "Comet";
  522. case 481: vehicle_name = "BMX";
  523. case 482: vehicle_name = "Burrito";
  524. case 483: vehicle_name = "Camper";
  525. case 484: vehicle_name = "Marquis";
  526. case 485: vehicle_name = "Baggage";
  527. case 486: vehicle_name = "Dozer";
  528. case 487: vehicle_name = "Maverick";
  529. case 488: vehicle_name = "SAN News Maverick";
  530. case 489, 505: vehicle_name = "Rancher";
  531. case 490: vehicle_name = "FBI Rancher";
  532. case 491: vehicle_name = "Virgo";
  533. case 492: vehicle_name = "Greenwood";
  534. case 493: vehicle_name = "Jetmax";
  535. case 494: vehicle_name = "Hotring Racer A";
  536. case 495: vehicle_name = "Sandking";
  537. case 496: vehicle_name = "Blista Compact";
  538. case 497: vehicle_name = "Police Maverick";
  539. case 498: vehicle_name = "Boxville";
  540. case 499: vehicle_name = "Benson";
  541. case 500: vehicle_name = "Mesa";
  542. case 501: vehicle_name = "RC Goblin";
  543. case 502: vehicle_name = "Hotring Racer B";
  544. case 503: vehicle_name = "Hotring Racer C";
  545. case 504: vehicle_name = "Bloodring Banger";
  546. case 506: vehicle_name = "Super GT";
  547. case 507: vehicle_name = "Elegant";
  548. case 508: vehicle_name = "Journey";
  549. case 509: vehicle_name = "Bike";
  550. case 510: vehicle_name = "Mountain Bike";
  551. case 511: vehicle_name = "Beagle";
  552. case 512: vehicle_name = "Cropduster";
  553. case 513: vehicle_name = "Stuntplane";
  554. case 514: vehicle_name = "Tanker";
  555. case 515: vehicle_name = "Roadtrain";
  556. case 516: vehicle_name = "Nebula";
  557. case 517: vehicle_name = "Majestic";
  558. case 518: vehicle_name = "Buccaneer";
  559. case 519: vehicle_name = "Shamal";
  560. case 520: vehicle_name = "Hydra";
  561. case 521: vehicle_name = "FCR-900";
  562. case 522: vehicle_name = "NRG-500";
  563. case 523: vehicle_name = "HPV1000";
  564. case 524: vehicle_name = "Cement Truck";
  565. case 525: vehicle_name = "Towtruck";
  566. case 526: vehicle_name = "Fortune";
  567. case 527: vehicle_name = "Cadrona";
  568. case 528: vehicle_name = "FBI Truck";
  569. case 529: vehicle_name = "Willard";
  570. case 530: vehicle_name = "Forklift";
  571. case 531: vehicle_name = "Tractor";
  572. case 532: vehicle_name = "Combine Harvester";
  573. case 533: vehicle_name = "Feltzer";
  574. case 534: vehicle_name = "Remington";
  575. case 535: vehicle_name = "Slamvan";
  576. case 536: vehicle_name = "Blade";
  577. case 537: vehicle_name = "Freight";
  578. case 538: vehicle_name = "Brownstreak";
  579. case 539: vehicle_name = "Vortex";
  580. case 540: vehicle_name = "Vincent";
  581. case 541: vehicle_name = "Bullet";
  582. case 542: vehicle_name = "Clover";
  583. case 543: vehicle_name = "Sadler";
  584. case 544: vehicle_name = "Firetruck LA";
  585. case 545: vehicle_name = "Hustler";
  586. case 546: vehicle_name = "Intruder";
  587. case 547: vehicle_name = "Primo";
  588. case 548: vehicle_name = "Cargobob";
  589. case 549: vehicle_name = "Tampa";
  590. case 550: vehicle_name = "Sunrise";
  591. case 551: vehicle_name = "Merit";
  592. case 552: vehicle_name = "Utility Van";
  593. case 553: vehicle_name = "Nevada";
  594. case 554: vehicle_name = "Yosemite";
  595. case 555: vehicle_name = "Windsor";
  596. case 556: vehicle_name = "Monster A";
  597. case 557: vehicle_name = "Monster B";
  598. case 558: vehicle_name = "Uranus";
  599. case 559: vehicle_name = "Jester";
  600. case 560: vehicle_name = "Sultan";
  601. case 561: vehicle_name = "Stratum";
  602. case 562: vehicle_name = "Elegy";
  603. case 563: vehicle_name = "Raindance";
  604. case 564: vehicle_name = "RC Tiger";
  605. case 565: vehicle_name = "Flash";
  606. case 566: vehicle_name = "Tahoma";
  607. case 567: vehicle_name = "Savanna";
  608. case 568: vehicle_name = "Bandito";
  609. case 569: vehicle_name = "Freight Flat Trailer";
  610. case 570: vehicle_name = "Streak Trailer";
  611. case 571: vehicle_name = "Kart";
  612. case 572: vehicle_name = "Mower";
  613. case 573: vehicle_name = "Dune";
  614. case 574: vehicle_name = "Sweeper";
  615. case 575: vehicle_name = "Broadway";
  616. case 576: vehicle_name = "Tornado";
  617. case 577: vehicle_name = "AT-400";
  618. case 578: vehicle_name = "DFT-30";
  619. case 579: vehicle_name = "Huntley";
  620. case 580: vehicle_name = "Stafford";
  621. case 581: vehicle_name = "BF-400";
  622. case 582: vehicle_name = "Newsvan";
  623. case 583: vehicle_name = "Tug";
  624. case 584: vehicle_name = "Petrol Trailer";
  625. case 585: vehicle_name = "Emperor";
  626. case 586: vehicle_name = "Wayfarer";
  627. case 587: vehicle_name = "Euros";
  628. case 588: vehicle_name = "Hotdog";
  629. case 589: vehicle_name = "Club";
  630. case 590: vehicle_name = "Freight Box Trailer";
  631. case 591: vehicle_name = "Article Trailer 3";
  632. case 592: vehicle_name = "Andromada";
  633. case 593: vehicle_name = "Dodo";
  634. case 594: vehicle_name = "RC Cam";
  635. case 595: vehicle_name = "Launch";
  636. case 596: vehicle_name = "LSPD Cruiser";
  637. case 597: vehicle_name = "SFPD Cruiser";
  638. case 598: vehicle_name = "LVPD Cruiser";
  639. case 599: vehicle_name = "Police Ranger";
  640. case 600: vehicle_name = "Picador";
  641. case 601: vehicle_name = "S.W.A.T.";
  642. case 602: vehicle_name = "Alpha";
  643. case 603: vehicle_name = "Phoenix";
  644. case 604: vehicle_name = "Glendale Shit";
  645. case 605: vehicle_name = "Sadler Shit";
  646. case 606: vehicle_name = "Baggage Trailer A";
  647. case 607: vehicle_name = "Baggage Trailer B";
  648. case 608: vehicle_name = "Tug Stairs";
  649. case 609: vehicle_name = "Boxville";
  650. case 610: vehicle_name = "Farm Trailer";
  651. case 611: vehicle_name = "Utility Trailer";
  652. default: vehicle_name = "None";
  653. }
  654. return vehicle_name;
  655. }
  656.  
  657. stock GetVehicleNameByModel(model)
  658. {
  659. new
  660. vehicle_name[32] = "None";
  661. if(model < 400 || model > 611) return vehicle_name;
  662. switch (model)
  663. {
  664. case 400: vehicle_name = "Landstalker";
  665. case 401: vehicle_name = "Bravura";
  666. case 402: vehicle_name = "Buffalo";
  667. case 403: vehicle_name = "Linerunner";
  668. case 404: vehicle_name = "Perennial";
  669. case 405: vehicle_name = "Sentinel";
  670. case 406: vehicle_name = "Dumper";
  671. case 407: vehicle_name = "Firetruck";
  672. case 408: vehicle_name = "Trashmaster";
  673. case 409: vehicle_name = "Stretch";
  674. case 410: vehicle_name = "Manana";
  675. case 411: vehicle_name = "Infernus";
  676. case 412: vehicle_name = "Voodoo";
  677. case 413: vehicle_name = "Pony";
  678. case 414: vehicle_name = "Mule";
  679. case 415: vehicle_name = "Cheetah";
  680. case 416: vehicle_name = "Ambulance";
  681. case 417: vehicle_name = "Leviathan";
  682. case 418: vehicle_name = "Moonbeam";
  683. case 419: vehicle_name = "Esperanto";
  684. case 420: vehicle_name = "Taxi";
  685. case 421: vehicle_name = "Washington";
  686. case 422: vehicle_name = "Bobcat";
  687. case 423: vehicle_name = "Mr Whoopee";
  688. case 424: vehicle_name = "BF Injection";
  689. case 425: vehicle_name = "Hunter";
  690. case 426: vehicle_name = "Premier";
  691. case 427: vehicle_name = "Enforcer";
  692. case 428: vehicle_name = "Securicar";
  693. case 429: vehicle_name = "Banshee";
  694. case 430: vehicle_name = "Predator";
  695. case 431: vehicle_name = "Bus";
  696. case 432: vehicle_name = "Rhino";
  697. case 433: vehicle_name = "Barracks";
  698. case 434: vehicle_name = "Hotknife";
  699. case 435: vehicle_name = "Article Trailer";
  700. case 436: vehicle_name = "Previon";
  701. case 437: vehicle_name = "Coach";
  702. case 438: vehicle_name = "Cabbie";
  703. case 439: vehicle_name = "Stallion";
  704. case 440: vehicle_name = "Rumpo";
  705. case 441: vehicle_name = "RC Bandit";
  706. case 442: vehicle_name = "Romero";
  707. case 443: vehicle_name = "Packer";
  708. case 444: vehicle_name = "Monster";
  709. case 445: vehicle_name = "Admiral";
  710. case 446: vehicle_name = "Squalo";
  711. case 447: vehicle_name = "Seasparrow";
  712. case 448: vehicle_name = "Pizzaboy";
  713. case 449: vehicle_name = "Tram";
  714. case 450: vehicle_name = "Article Trailer 2";
  715. case 451: vehicle_name = "Turismo";
  716. case 452: vehicle_name = "Speeder";
  717. case 453: vehicle_name = "Reefer";
  718. case 454: vehicle_name = "Tropic";
  719. case 455: vehicle_name = "Flatbed";
  720. case 456: vehicle_name = "Yankee";
  721. case 457: vehicle_name = "Caddy";
  722. case 458: vehicle_name = "Solair";
  723. case 459: vehicle_name = "Berkley's RC Van";
  724. case 460: vehicle_name = "Skimmer";
  725. case 461: vehicle_name = "PCJ-600";
  726. case 462: vehicle_name = "Faggio";
  727. case 463: vehicle_name = "Freeway";
  728. case 464: vehicle_name = "RC Baron";
  729. case 465: vehicle_name = "RC Raider";
  730. case 466: vehicle_name = "Glendale";
  731. case 467: vehicle_name = "Oceanic";
  732. case 468: vehicle_name = "Sanchez";
  733. case 469: vehicle_name = "Sparrow";
  734. case 470: vehicle_name = "Patriot";
  735. case 471: vehicle_name = "Quad";
  736. case 472: vehicle_name = "Coastguard";
  737. case 473: vehicle_name = "Dinghy";
  738. case 474: vehicle_name = "Hermes";
  739. case 475: vehicle_name = "Sabre";
  740. case 476: vehicle_name = "Rustler";
  741. case 477: vehicle_name = "ZR-350";
  742. case 478: vehicle_name = "Walton";
  743. case 479: vehicle_name = "Regina";
  744. case 480: vehicle_name = "Comet";
  745. case 481: vehicle_name = "BMX";
  746. case 482: vehicle_name = "Burrito";
  747. case 483: vehicle_name = "Camper";
  748. case 484: vehicle_name = "Marquis";
  749. case 485: vehicle_name = "Baggage";
  750. case 486: vehicle_name = "Dozer";
  751. case 487: vehicle_name = "Maverick";
  752. case 488: vehicle_name = "SAN News Maverick";
  753. case 489, 505: vehicle_name = "Rancher";
  754. case 490: vehicle_name = "FBI Rancher";
  755. case 491: vehicle_name = "Virgo";
  756. case 492: vehicle_name = "Greenwood";
  757. case 493: vehicle_name = "Jetmax";
  758. case 494: vehicle_name = "Hotring Racer A";
  759. case 495: vehicle_name = "Sandking";
  760. case 496: vehicle_name = "Blista Compact";
  761. case 497: vehicle_name = "Police Maverick";
  762. case 498: vehicle_name = "Boxville";
  763. case 499: vehicle_name = "Benson";
  764. case 500: vehicle_name = "Mesa";
  765. case 501: vehicle_name = "RC Goblin";
  766. case 502: vehicle_name = "Hotring Racer B";
  767. case 503: vehicle_name = "Hotring Racer C";
  768. case 504: vehicle_name = "Bloodring Banger";
  769. case 506: vehicle_name = "Super GT";
  770. case 507: vehicle_name = "Elegant";
  771. case 508: vehicle_name = "Journey";
  772. case 509: vehicle_name = "Bike";
  773. case 510: vehicle_name = "Mountain Bike";
  774. case 511: vehicle_name = "Beagle";
  775. case 512: vehicle_name = "Cropduster";
  776. case 513: vehicle_name = "Stuntplane";
  777. case 514: vehicle_name = "Tanker";
  778. case 515: vehicle_name = "Roadtrain";
  779. case 516: vehicle_name = "Nebula";
  780. case 517: vehicle_name = "Majestic";
  781. case 518: vehicle_name = "Buccaneer";
  782. case 519: vehicle_name = "Shamal";
  783. case 520: vehicle_name = "Hydra";
  784. case 521: vehicle_name = "FCR-900";
  785. case 522: vehicle_name = "NRG-500";
  786. case 523: vehicle_name = "HPV1000";
  787. case 524: vehicle_name = "Cement Truck";
  788. case 525: vehicle_name = "Towtruck";
  789. case 526: vehicle_name = "Fortune";
  790. case 527: vehicle_name = "Cadrona";
  791. case 528: vehicle_name = "FBI Truck";
  792. case 529: vehicle_name = "Willard";
  793. case 530: vehicle_name = "Forklift";
  794. case 531: vehicle_name = "Tractor";
  795. case 532: vehicle_name = "Combine Harvester";
  796. case 533: vehicle_name = "Feltzer";
  797. case 534: vehicle_name = "Remington";
  798. case 535: vehicle_name = "Slamvan";
  799. case 536: vehicle_name = "Blade";
  800. case 537: vehicle_name = "Freight";
  801. case 538: vehicle_name = "Brownstreak";
  802. case 539: vehicle_name = "Vortex";
  803. case 540: vehicle_name = "Vincent";
  804. case 541: vehicle_name = "Bullet";
  805. case 542: vehicle_name = "Clover";
  806. case 543: vehicle_name = "Sadler";
  807. case 544: vehicle_name = "Firetruck LA";
  808. case 545: vehicle_name = "Hustler";
  809. case 546: vehicle_name = "Intruder";
  810. case 547: vehicle_name = "Primo";
  811. case 548: vehicle_name = "Cargobob";
  812. case 549: vehicle_name = "Tampa";
  813. case 550: vehicle_name = "Sunrise";
  814. case 551: vehicle_name = "Merit";
  815. case 552: vehicle_name = "Utility Van";
  816. case 553: vehicle_name = "Nevada";
  817. case 554: vehicle_name = "Yosemite";
  818. case 555: vehicle_name = "Windsor";
  819. case 556: vehicle_name = "Monster A";
  820. case 557: vehicle_name = "Monster B";
  821. case 558: vehicle_name = "Uranus";
  822. case 559: vehicle_name = "Jester";
  823. case 560: vehicle_name = "Sultan";
  824. case 561: vehicle_name = "Stratum";
  825. case 562: vehicle_name = "Elegy";
  826. case 563: vehicle_name = "Raindance";
  827. case 564: vehicle_name = "RC Tiger";
  828. case 565: vehicle_name = "Flash";
  829. case 566: vehicle_name = "Tahoma";
  830. case 567: vehicle_name = "Savanna";
  831. case 568: vehicle_name = "Bandito";
  832. case 569: vehicle_name = "Freight Flat Trailer";
  833. case 570: vehicle_name = "Streak Trailer";
  834. case 571: vehicle_name = "Kart";
  835. case 572: vehicle_name = "Mower";
  836. case 573: vehicle_name = "Dune";
  837. case 574: vehicle_name = "Sweeper";
  838. case 575: vehicle_name = "Broadway";
  839. case 576: vehicle_name = "Tornado";
  840. case 577: vehicle_name = "AT-400";
  841. case 578: vehicle_name = "DFT-30";
  842. case 579: vehicle_name = "Huntley";
  843. case 580: vehicle_name = "Stafford";
  844. case 581: vehicle_name = "BF-400";
  845. case 582: vehicle_name = "Newsvan";
  846. case 583: vehicle_name = "Tug";
  847. case 584: vehicle_name = "Petrol Trailer";
  848. case 585: vehicle_name = "Emperor";
  849. case 586: vehicle_name = "Wayfarer";
  850. case 587: vehicle_name = "Euros";
  851. case 588: vehicle_name = "Hotdog";
  852. case 589: vehicle_name = "Club";
  853. case 590: vehicle_name = "Freight Box Trailer";
  854. case 591: vehicle_name = "Article Trailer 3";
  855. case 592: vehicle_name = "Andromada";
  856. case 593: vehicle_name = "Dodo";
  857. case 594: vehicle_name = "RC Cam";
  858. case 595: vehicle_name = "Launch";
  859. case 596: vehicle_name = "LSPD Cruiser";
  860. case 597: vehicle_name = "SFPD Cruiser";
  861. case 598: vehicle_name = "LVPD Cruiser";
  862. case 599: vehicle_name = "Police Ranger";
  863. case 600: vehicle_name = "Picador";
  864. case 601: vehicle_name = "S.W.A.T.";
  865. case 602: vehicle_name = "Alpha";
  866. case 603: vehicle_name = "Phoenix";
  867. case 604: vehicle_name = "Glendale Shit";
  868. case 605: vehicle_name = "Sadler Shit";
  869. case 606: vehicle_name = "Baggage Trailer A";
  870. case 607: vehicle_name = "Baggage Trailer B";
  871. case 608: vehicle_name = "Tug Stairs";
  872. case 609: vehicle_name = "Boxville";
  873. case 610: vehicle_name = "Farm Trailer";
  874. case 611: vehicle_name = "Utility Trailer";
  875. default: vehicle_name = "None";
  876. }
  877. return vehicle_name;
  878. }
  879.  
  880. stock CreateVehicleTables(playerid)
  881. {
  882. if (IsPlayerConnected(playerid))
  883. {
  884. new query[1536];
  885. format(query, sizeof(query), "CREATE TABLE IF NOT EXISTS `VEHICLES` ");
  886. strcat(query, "(`Name`, `Model`, `X`, `Y`, `Z`, `Rot`, `Color1`, `Color2`, `Paintjob`, `Mod1`, `Mod2`, `Mod3`, ");
  887. strcat(query, "`Mod4`, `Mod5`, `Mod6`, `Mod7`, `Mod8`, `Mod9`, `Mod10`, `Mod11`, `Mod12`, `Mod13`, ");
  888. strcat(query, "`Mod14`, `Mod15`, `Mod16`, `Mod17`, `HasLock`, `Locked`, `TrunkCash`, ");
  889. strcat(query, "`TrunkGun1`, `TrunkGun2`, `TrunkGun3`, `TrunkGun4`, `TrunkAmmo1`, `TrunkAmmo2`, `TrunkAmmo3`, ");
  890. strcat(query, "`TrunkAmmo4`, `Spawned`, `Owned`, `Slot`)");
  891. db_query(VehicleDatabase[playerid], query);
  892. }
  893. return 1;
  894. }
  895.  
  896. stock DeleteDealershipVehicle(vehicleid)
  897. {
  898. new query[128];
  899. if (DealershipVehicles[vehicleid][vForSale])
  900. {
  901. format(query, sizeof(query), "DELETE FROM `DEALERCARS` WHERE `vID` = '%d'", DealershipVehicles[vehicleid][vSQL_ID]);
  902. db_query(DealerVehicleDatabase, query);
  903. DealershipVehicles[vehicleid][vModel] = 0;
  904. DealershipVehicles[vehicleid][vX] = 0.0;
  905. DealershipVehicles[vehicleid][vY] = 0.0;
  906. DealershipVehicles[vehicleid][vZ] = 0.0;
  907. DealershipVehicles[vehicleid][vRot] = 0.0;
  908. DealershipVehicles[vehicleid][vForSale] = 0;
  909. DealershipVehicles[vehicleid][vPrice] = 0;
  910. Delete3DTextLabel(DealershipVehicles[vehicleid][vLabel]);
  911. DestroyVehicle(DealershipVehicles[vehicleid][vID]);
  912. DealershipVehicles[vehicleid][vID] = 0;
  913. DealershipVehicles[vehicleid][vSQL_ID] = 0;
  914. dealershipCars -= 1;
  915. return 1;
  916. }
  917. return 0;
  918. }
  919.  
  920. stock DeletePlayerVehicle(playerid, slot)
  921. {
  922. new query[128];
  923. if (PlayerVehicles[playerid][slot][pCarOwned])
  924. {
  925. format(query, sizeof(query), "DELETE FROM `VEHICLES` WHERE `Name` = '%s' AND `Slot` = '%d'", PlayerName(playerid), slot);
  926. db_query(VehicleDatabase[playerid], query);
  927. PlayerVehicles[playerid][slot][pCarModel] = 0;
  928. PlayerVehicles[playerid][slot][pCarX] = 0.0;
  929. PlayerVehicles[playerid][slot][pCarY] = 0.0;
  930. PlayerVehicles[playerid][slot][pCarZ] = 0.0;
  931. PlayerVehicles[playerid][slot][pCarRot] = 0.0;
  932. PlayerVehicles[playerid][slot][pCarColor1] = 0;
  933. PlayerVehicles[playerid][slot][pCarColor2] = 0;
  934. PlayerVehicles[playerid][slot][pCarPaintjob] = -1;
  935. PlayerVehicles[playerid][slot][pCarMod1] = 0;
  936. PlayerVehicles[playerid][slot][pCarMod2] = 0;
  937. PlayerVehicles[playerid][slot][pCarMod3] = 0;
  938. PlayerVehicles[playerid][slot][pCarMod4] = 0;
  939. PlayerVehicles[playerid][slot][pCarMod5] = 0;
  940. PlayerVehicles[playerid][slot][pCarMod6] = 0;
  941. PlayerVehicles[playerid][slot][pCarMod7] = 0;
  942. PlayerVehicles[playerid][slot][pCarMod8] = 0;
  943. PlayerVehicles[playerid][slot][pCarMod9] = 0;
  944. PlayerVehicles[playerid][slot][pCarMod10] = 0;
  945. PlayerVehicles[playerid][slot][pCarMod11] = 0;
  946. PlayerVehicles[playerid][slot][pCarMod12] = 0;
  947. PlayerVehicles[playerid][slot][pCarMod13] = 0;
  948. PlayerVehicles[playerid][slot][pCarMod14] = 0;
  949. PlayerVehicles[playerid][slot][pCarMod15] = 0;
  950. PlayerVehicles[playerid][slot][pCarMod16] = 0;
  951. PlayerVehicles[playerid][slot][pCarMod17] = 0;
  952. PlayerVehicles[playerid][slot][pCarHasLock] = 0;
  953. PlayerVehicles[playerid][slot][pCarLocked] = 0;
  954. PlayerVehicles[playerid][slot][pCarTrunkCash] = 0;
  955. PlayerVehicles[playerid][slot][pCarTrunkGun1] = 0;
  956. PlayerVehicles[playerid][slot][pCarTrunkGun2] = 0;
  957. PlayerVehicles[playerid][slot][pCarTrunkGun3] = 0;
  958. PlayerVehicles[playerid][slot][pCarTrunkGun4] = 0;
  959. PlayerVehicles[playerid][slot][pCarTrunkAmmo1] = 0;
  960. PlayerVehicles[playerid][slot][pCarTrunkAmmo2] = 0;
  961. PlayerVehicles[playerid][slot][pCarTrunkAmmo3] = 0;
  962. PlayerVehicles[playerid][slot][pCarTrunkAmmo4] = 0;
  963. PlayerVehicles[playerid][slot][pCarSpawned] = 0;
  964. PlayerVehicles[playerid][slot][pCarOwned] = 0;
  965. if (PlayerVehicles[playerid][slot][pCarID] != 0)
  966. {
  967. UnlockVehicle(PlayerVehicles[playerid][slot][pCarID]);
  968. DestroyVehicle(PlayerVehicles[playerid][slot][pCarID]);
  969. PlayerVehicles[playerid][slot][pCarID] = 0;
  970. }
  971. return 1;
  972. }
  973. return 0;
  974. }
  975.  
  976. stock CreateDealershipVehicle(model, price, Float:x, Float:y, Float:z, Float:rotation)
  977. {
  978. if (model < 400 || model > 611)
  979. return 0;
  980.  
  981. new
  982. vehicleid,
  983. string[256],
  984. query[1536];
  985.  
  986. vehicleid = CreateVehicle(model, x, y, z, rotation, 1, 1, 5);
  987. if (vehicleid == INVALID_VEHICLE_ID)
  988. return 0;
  989.  
  990. DealershipVehicles[vehicleid][vModel] = model;
  991. DealershipVehicles[vehicleid][vX] = x;
  992. DealershipVehicles[vehicleid][vY] = y;
  993. DealershipVehicles[vehicleid][vZ] = z;
  994. DealershipVehicles[vehicleid][vRot] = rotation;
  995. DealershipVehicles[vehicleid][vForSale] = 1;
  996. DealershipVehicles[vehicleid][vPrice] = price;
  997. DealershipVehicles[vehicleid][vID] = vehicleid;
  998. DealershipVehicles[vehicleid][vSQL_ID] = dealershipCars + 1;
  999. format(string, sizeof(string), "This {FFFFFF}%s {F5DEB3}is for sale.\nThe cost of this vehicle is {FFFFFF}$%d.\n{F5DEB3}For more information, enter the vehicle.", GetVehicleName(vehicleid), price);
  1000. DealershipVehicles[vehicleid][vLabel] = Create3DTextLabel(string, YELLOW2, x, y, z, 10.0, 0);
  1001. dealershipCars += 1;
  1002.  
  1003. format(query, sizeof(query), "INSERT INTO `DEALERCARS` (`vID`, `vModel`, `vX`, `vY`, `vZ`, `vRot`, `vForSale`, `vPrice`) VALUES('%d', '%d', '%f', '%f', '%f', '%f', '%d', '%d')", dealershipCars, model, x, y, z, rotation, 1, price);
  1004. db_query(DealerVehicleDatabase, query);
  1005. return vehicleid;
  1006. }
  1007.  
  1008. stock CreatePlayerVehicle(playerid, model, Float:x, Float:y, Float:z, Float:rotation)
  1009. {
  1010. new slot = -1;
  1011. for (new i = 1; i < MAX_PLAYER_CARS + 1; i += 1)
  1012. {
  1013. if (PlayerVehicles[playerid][i][pCarOwned] == 0)
  1014. {
  1015. slot = i;
  1016. break;
  1017. }
  1018. }
  1019. if (slot == -1) return 0;
  1020. new vehicleid = CreateVehicle(model, x, y, z, rotation, 1, 1, -1);
  1021. if (vehicleid == INVALID_VEHICLE_ID) return -1;
  1022. PlayerVehicles[playerid][slot][pCarModel] = model;
  1023. PlayerVehicles[playerid][slot][pCarX] = x;
  1024. PlayerVehicles[playerid][slot][pCarY] = y;
  1025. PlayerVehicles[playerid][slot][pCarZ] = z;
  1026. PlayerVehicles[playerid][slot][pCarRot] = rotation;
  1027. PlayerVehicles[playerid][slot][pCarColor1] = 1;
  1028. PlayerVehicles[playerid][slot][pCarColor2] = 1;
  1029. PlayerVehicles[playerid][slot][pCarPaintjob] = -1;
  1030. PlayerVehicles[playerid][slot][pCarMod1] = 0;
  1031. PlayerVehicles[playerid][slot][pCarMod2] = 0;
  1032. PlayerVehicles[playerid][slot][pCarMod3] = 0;
  1033. PlayerVehicles[playerid][slot][pCarMod4] = 0;
  1034. PlayerVehicles[playerid][slot][pCarMod5] = 0;
  1035. PlayerVehicles[playerid][slot][pCarMod6] = 0;
  1036. PlayerVehicles[playerid][slot][pCarMod7] = 0;
  1037. PlayerVehicles[playerid][slot][pCarMod8] = 0;
  1038. PlayerVehicles[playerid][slot][pCarMod9] = 0;
  1039. PlayerVehicles[playerid][slot][pCarMod10] = 0;
  1040. PlayerVehicles[playerid][slot][pCarMod11] = 0;
  1041. PlayerVehicles[playerid][slot][pCarMod12] = 0;
  1042. PlayerVehicles[playerid][slot][pCarMod13] = 0;
  1043. PlayerVehicles[playerid][slot][pCarMod14] = 0;
  1044. PlayerVehicles[playerid][slot][pCarMod15] = 0;
  1045. PlayerVehicles[playerid][slot][pCarMod16] = 0;
  1046. PlayerVehicles[playerid][slot][pCarMod17] = 0;
  1047. PlayerVehicles[playerid][slot][pCarHasLock] = 0;
  1048. PlayerVehicles[playerid][slot][pCarLocked] = 0;
  1049. PlayerVehicles[playerid][slot][pCarTrunkCash] = 0;
  1050. PlayerVehicles[playerid][slot][pCarTrunkGun1] = 0;
  1051. PlayerVehicles[playerid][slot][pCarTrunkGun2] = 0;
  1052. PlayerVehicles[playerid][slot][pCarTrunkGun3] = 0;
  1053. PlayerVehicles[playerid][slot][pCarTrunkGun4] = 0;
  1054. PlayerVehicles[playerid][slot][pCarTrunkAmmo1] = 0;
  1055. PlayerVehicles[playerid][slot][pCarTrunkAmmo2] = 0;
  1056. PlayerVehicles[playerid][slot][pCarTrunkAmmo3] = 0;
  1057. PlayerVehicles[playerid][slot][pCarTrunkAmmo4] = 0;
  1058. PlayerVehicles[playerid][slot][pCarSpawned] = 1;
  1059. PlayerVehicles[playerid][slot][pCarOwned] = 1;
  1060. PlayerVehicles[playerid][slot][pCarID] = vehicleid;
  1061.  
  1062. new query[1536], query2[1536];
  1063. format(query, sizeof(query), "INSERT INTO `VEHICLES` ");
  1064. strcat(query, "(`Name`, `Model`, `X`, `Y`, `Z`, `Rot`, `Color1`, `Color2`, `Paintjob`, `Mod1`, `Mod2`, `Mod3`, ");
  1065. strcat(query, "`Mod4`, `Mod5`, `Mod6`, `Mod7`, `Mod8`, `Mod9`, `Mod10`, `Mod11`, `Mod12`, `Mod13`, ");
  1066. strcat(query, "`Mod14`, `Mod15`, `Mod16`, `Mod17`, `HasLock`, `Locked`, `TrunkCash`, ");
  1067. strcat(query, "`TrunkGun1`, `TrunkGun2`, `TrunkGun3`, `TrunkGun4`, `TrunkAmmo1`, `TrunkAmmo2`, `TrunkAmmo3`, ");
  1068. strcat(query, "`TrunkAmmo4`, `Spawned`, `Owned`, `Slot`) ");
  1069.  
  1070. format(query2, sizeof(query2), "VALUES('%s', '%d', '%f', '%f', '%f', '%f', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d')",
  1071. DB_Escape(PlayerName(playerid)),
  1072. PlayerVehicles[playerid][slot][pCarModel],
  1073. PlayerVehicles[playerid][slot][pCarX],
  1074. PlayerVehicles[playerid][slot][pCarY],
  1075. PlayerVehicles[playerid][slot][pCarZ],
  1076. PlayerVehicles[playerid][slot][pCarRot],
  1077. PlayerVehicles[playerid][slot][pCarColor1],
  1078. PlayerVehicles[playerid][slot][pCarColor2],
  1079. PlayerVehicles[playerid][slot][pCarPaintjob],
  1080. PlayerVehicles[playerid][slot][pCarMod1],
  1081. PlayerVehicles[playerid][slot][pCarMod2],
  1082. PlayerVehicles[playerid][slot][pCarMod3],
  1083. PlayerVehicles[playerid][slot][pCarMod4],
  1084. PlayerVehicles[playerid][slot][pCarMod5],
  1085. PlayerVehicles[playerid][slot][pCarMod6],
  1086. PlayerVehicles[playerid][slot][pCarMod7],
  1087. PlayerVehicles[playerid][slot][pCarMod8],
  1088. PlayerVehicles[playerid][slot][pCarMod9],
  1089. PlayerVehicles[playerid][slot][pCarMod10],
  1090. PlayerVehicles[playerid][slot][pCarMod11],
  1091. PlayerVehicles[playerid][slot][pCarMod12],
  1092. PlayerVehicles[playerid][slot][pCarMod13],
  1093. PlayerVehicles[playerid][slot][pCarMod14],
  1094. PlayerVehicles[playerid][slot][pCarMod15],
  1095. PlayerVehicles[playerid][slot][pCarMod16],
  1096. PlayerVehicles[playerid][slot][pCarMod17],
  1097. PlayerVehicles[playerid][slot][pCarHasLock],
  1098. PlayerVehicles[playerid][slot][pCarLocked],
  1099. PlayerVehicles[playerid][slot][pCarTrunkCash],
  1100. PlayerVehicles[playerid][slot][pCarTrunkGun1],
  1101. PlayerVehicles[playerid][slot][pCarTrunkGun2],
  1102. PlayerVehicles[playerid][slot][pCarTrunkGun3],
  1103. PlayerVehicles[playerid][slot][pCarTrunkGun4],
  1104. PlayerVehicles[playerid][slot][pCarTrunkAmmo1],
  1105. PlayerVehicles[playerid][slot][pCarTrunkAmmo2],
  1106. PlayerVehicles[playerid][slot][pCarTrunkAmmo3],
  1107. PlayerVehicles[playerid][slot][pCarTrunkAmmo4],
  1108. PlayerVehicles[playerid][slot][pCarSpawned],
  1109. PlayerVehicles[playerid][slot][pCarOwned],
  1110. slot);
  1111. strcat(query, query2);
  1112. db_query(VehicleDatabase[playerid], query);
  1113. SavePlayerVehicle(playerid, slot);
  1114. return 1;
  1115. }
  1116.  
  1117. stock SavePlayerVehicle(playerid, slot)
  1118. {
  1119. if (PlayerVehicles[playerid][slot][pCarOwned])
  1120. {
  1121. new query[1536], query2[1536];
  1122. format(query, sizeof(query), "UPDATE `VEHICLES` SET ");
  1123. format(query2, sizeof(query2), "Name = '%s', Model = '%d', X = '%f', Y = '%f', Z = '%f', Rot = '%f', Color1 = '%d', Color2 = '%d', Paintjob = '%d', Mod1 = '%d', Mod2 = '%d', Mod3 = '%d', ",
  1124. DB_Escape(PlayerName(playerid)),
  1125. PlayerVehicles[playerid][slot][pCarModel],
  1126. PlayerVehicles[playerid][slot][pCarX],
  1127. PlayerVehicles[playerid][slot][pCarY],
  1128. PlayerVehicles[playerid][slot][pCarZ],
  1129. PlayerVehicles[playerid][slot][pCarRot],
  1130. PlayerVehicles[playerid][slot][pCarColor1],
  1131. PlayerVehicles[playerid][slot][pCarColor2],
  1132. PlayerVehicles[playerid][slot][pCarPaintjob],
  1133. PlayerVehicles[playerid][slot][pCarMod1],
  1134. PlayerVehicles[playerid][slot][pCarMod2],
  1135. PlayerVehicles[playerid][slot][pCarMod3]);
  1136. strcat(query, query2);
  1137.  
  1138. format(query2, sizeof(query2), "Mod4 = '%d', Mod5 = '%d', Mod6 = '%d', Mod7 = '%d', Mod8 = '%d', Mod9 = '%d', Mod10 = '%d', Mod11 = '%d', Mod12 = '%d', Mod13 = '%d', Mod14 = '%d', Mod15 = '%d', ",
  1139. PlayerVehicles[playerid][slot][pCarMod4],
  1140. PlayerVehicles[playerid][slot][pCarMod5],
  1141. PlayerVehicles[playerid][slot][pCarMod6],
  1142. PlayerVehicles[playerid][slot][pCarMod7],
  1143. PlayerVehicles[playerid][slot][pCarMod8],
  1144. PlayerVehicles[playerid][slot][pCarMod9],
  1145. PlayerVehicles[playerid][slot][pCarMod10],
  1146. PlayerVehicles[playerid][slot][pCarMod11],
  1147. PlayerVehicles[playerid][slot][pCarMod12],
  1148. PlayerVehicles[playerid][slot][pCarMod13],
  1149. PlayerVehicles[playerid][slot][pCarMod14],
  1150. PlayerVehicles[playerid][slot][pCarMod15]);
  1151. strcat(query, query2);
  1152.  
  1153. format(query2, sizeof(query2), "Mod16 = '%d', Mod17 = '%d', HasLock = '%d', Locked = '%d', TrunkCash = '%d', TrunkGun1 = '%d', TrunkGun2 = '%d', TrunkGun3 = '%d', TrunkGun4 = '%d', TrunkAmmo1 = '%d', TrunkAmmo2 = '%d', TrunkAmmo3 = '%d', ",
  1154. PlayerVehicles[playerid][slot][pCarMod16],
  1155. PlayerVehicles[playerid][slot][pCarMod17],
  1156. PlayerVehicles[playerid][slot][pCarHasLock],
  1157. PlayerVehicles[playerid][slot][pCarLocked],
  1158. PlayerVehicles[playerid][slot][pCarTrunkCash],
  1159. PlayerVehicles[playerid][slot][pCarTrunkGun1],
  1160. PlayerVehicles[playerid][slot][pCarTrunkGun2],
  1161. PlayerVehicles[playerid][slot][pCarTrunkGun3],
  1162. PlayerVehicles[playerid][slot][pCarTrunkGun4],
  1163. PlayerVehicles[playerid][slot][pCarTrunkAmmo1],
  1164. PlayerVehicles[playerid][slot][pCarTrunkAmmo2],
  1165. PlayerVehicles[playerid][slot][pCarTrunkAmmo3]);
  1166. strcat(query, query2);
  1167.  
  1168. format(query2, sizeof(query2), "TrunkAmmo4 = '%d', Spawned = '%d', Owned = '%d', Slot = '%d' WHERE Name = '%s' AND Slot = '%d'",
  1169. PlayerVehicles[playerid][slot][pCarTrunkAmmo4],
  1170. PlayerVehicles[playerid][slot][pCarSpawned],
  1171. PlayerVehicles[playerid][slot][pCarOwned],
  1172. slot,
  1173. DB_Escape(PlayerName(playerid)),
  1174. slot);
  1175. strcat(query, query2);
  1176. db_query(VehicleDatabase[playerid], query);
  1177. }
  1178. return 1;
  1179. }
  1180.  
  1181. stock LoadPlayerVehicles(playerid)
  1182. {
  1183. new DBResult:result;
  1184. new query[192], field[64];
  1185. for (new i = 1; i < MAX_PLAYER_CARS + 1; i += 1)
  1186. {
  1187. format(query, sizeof(query), "SELECT * FROM `VEHICLES` WHERE `Name` = '%s' COLLATE NOCASE AND `Slot` = '%d'", PlayerName(playerid), i);
  1188. result = db_query(VehicleDatabase[playerid], query);
  1189. if (db_num_rows(result))
  1190. {
  1191. db_get_field_assoc(result, "Model", field, sizeof(field)); PlayerVehicles[playerid][i][pCarModel] = strval(field);
  1192. db_get_field_assoc(result, "X", field, sizeof(field)); PlayerVehicles[playerid][i][pCarX] = floatstr(field);
  1193. db_get_field_assoc(result, "Y", field, sizeof(field)); PlayerVehicles[playerid][i][pCarY] = floatstr(field);
  1194. db_get_field_assoc(result, "Z", field, sizeof(field)); PlayerVehicles[playerid][i][pCarZ] = floatstr(field);
  1195. db_get_field_assoc(result, "Rot", field, sizeof(field)); PlayerVehicles[playerid][i][pCarRot] = floatstr(field);
  1196. db_get_field_assoc(result, "Color1", field, sizeof(field)); PlayerVehicles[playerid][i][pCarColor1] = strval(field);
  1197. db_get_field_assoc(result, "Color2", field, sizeof(field)); PlayerVehicles[playerid][i][pCarColor2] = strval(field);
  1198. db_get_field_assoc(result, "Paintjob", field, sizeof(field)); PlayerVehicles[playerid][i][pCarPaintjob] = strval(field);
  1199. db_get_field_assoc(result, "Mod1", field, sizeof(field)); PlayerVehicles[playerid][i][pCarMod1] = strval(field);
  1200. db_get_field_assoc(result, "Mod2", field, sizeof(field)); PlayerVehicles[playerid][i][pCarMod2] = strval(field);
  1201. db_get_field_assoc(result, "Mod3", field, sizeof(field)); PlayerVehicles[playerid][i][pCarMod3] = strval(field);
  1202. db_get_field_assoc(result, "Mod4", field, sizeof(field)); PlayerVehicles[playerid][i][pCarMod4] = strval(field);
  1203. db_get_field_assoc(result, "Mod5", field, sizeof(field)); PlayerVehicles[playerid][i][pCarMod5] = strval(field);
  1204. db_get_field_assoc(result, "Mod6", field, sizeof(field)); PlayerVehicles[playerid][i][pCarMod6] = strval(field);
  1205. db_get_field_assoc(result, "Mod7", field, sizeof(field)); PlayerVehicles[playerid][i][pCarMod7] = strval(field);
  1206. db_get_field_assoc(result, "Mod8", field, sizeof(field)); PlayerVehicles[playerid][i][pCarMod8] = strval(field);
  1207. db_get_field_assoc(result, "Mod9", field, sizeof(field)); PlayerVehicles[playerid][i][pCarMod9] = strval(field);
  1208. db_get_field_assoc(result, "Mod10", field, sizeof(field)); PlayerVehicles[playerid][i][pCarMod10] = strval(field);
  1209. db_get_field_assoc(result, "Mod11", field, sizeof(field)); PlayerVehicles[playerid][i][pCarMod11] = strval(field);
  1210. db_get_field_assoc(result, "Mod12", field, sizeof(field)); PlayerVehicles[playerid][i][pCarMod12] = strval(field);
  1211. db_get_field_assoc(result, "Mod13", field, sizeof(field)); PlayerVehicles[playerid][i][pCarMod13] = strval(field);
  1212. db_get_field_assoc(result, "Mod14", field, sizeof(field)); PlayerVehicles[playerid][i][pCarMod14] = strval(field);
  1213. db_get_field_assoc(result, "Mod15", field, sizeof(field)); PlayerVehicles[playerid][i][pCarMod15] = strval(field);
  1214. db_get_field_assoc(result, "Mod16", field, sizeof(field)); PlayerVehicles[playerid][i][pCarMod16] = strval(field);
  1215. db_get_field_assoc(result, "Mod17", field, sizeof(field)); PlayerVehicles[playerid][i][pCarMod17] = strval(field);
  1216. db_get_field_assoc(result, "HasLock", field, sizeof(field)); PlayerVehicles[playerid][i][pCarHasLock] = strval(field);
  1217. db_get_field_assoc(result, "Locked", field, sizeof(field)); PlayerVehicles[playerid][i][pCarLocked] = strval(field);
  1218. db_get_field_assoc(result, "TrunkCash", field, sizeof(field)); PlayerVehicles[playerid][i][pCarTrunkCash] = strval(field);
  1219. db_get_field_assoc(result, "TrunkGun1", field, sizeof(field)); PlayerVehicles[playerid][i][pCarTrunkGun1] = strval(field);
  1220. db_get_field_assoc(result, "TrunkGun2", field, sizeof(field)); PlayerVehicles[playerid][i][pCarTrunkGun2] = strval(field);
  1221. db_get_field_assoc(result, "TrunkGun3", field, sizeof(field)); PlayerVehicles[playerid][i][pCarTrunkGun3] = strval(field);
  1222. db_get_field_assoc(result, "TrunkGun4", field, sizeof(field)); PlayerVehicles[playerid][i][pCarTrunkGun4] = strval(field);
  1223. db_get_field_assoc(result, "TrunkAmmo1", field, sizeof(field)); PlayerVehicles[playerid][i][pCarTrunkAmmo1] = strval(field);
  1224. db_get_field_assoc(result, "TrunkAmmo2", field, sizeof(field)); PlayerVehicles[playerid][i][pCarTrunkAmmo2] = strval(field);
  1225. db_get_field_assoc(result, "TrunkAmmo3", field, sizeof(field)); PlayerVehicles[playerid][i][pCarTrunkAmmo3] = strval(field);
  1226. db_get_field_assoc(result, "TrunkAmmo4", field, sizeof(field)); PlayerVehicles[playerid][i][pCarTrunkAmmo4] = strval(field);
  1227. db_get_field_assoc(result, "Spawned", field, sizeof(field)); PlayerVehicles[playerid][i][pCarSpawned] = strval(field);
  1228. db_get_field_assoc(result, "Owned", field, sizeof(field)); PlayerVehicles[playerid][i][pCarOwned] = strval(field);
  1229. }
  1230. if (PlayerVehicles[playerid][i][pCarOwned])
  1231. {
  1232. if (PlayerVehicles[playerid][i][pCarSpawned])
  1233. {
  1234. PlayerVehicles[playerid][i][pCarID] = CreateVehicle(PlayerVehicles[playerid][i][pCarModel], PlayerVehicles[playerid][i][pCarX], PlayerVehicles[playerid][i][pCarY], PlayerVehicles[playerid][i][pCarZ], PlayerVehicles[playerid][i][pCarRot], PlayerVehicles[playerid][i][pCarColor1], PlayerVehicles[playerid][i][pCarColor2], -1);
  1235. ModifyVehicle(playerid, i);
  1236. }
  1237. }
  1238. db_free_result(result);
  1239. }
  1240. return 1;
  1241. }
  1242.  
  1243. stock SaveDealershipVehicles()
  1244. {
  1245. new query[512], query2[512];
  1246. for (new i = 1; i < MAX_VEHICLES; i += 1)
  1247. {
  1248. if (!DealershipVehicles[i][vForSale]) continue;
  1249.  
  1250. format(query, sizeof(query), "UPDATE `DEALERCARS` SET ");
  1251. format(query2, sizeof(query2), "vID = '%d', vModel = '%d', vX = '%f', vY = '%f', vZ = '%f', vRot = '%f', vForSale = '%d', vPrice = '%d' WHERE `vID` = '%d'",
  1252. DealershipVehicles[i][vSQL_ID],
  1253. DealershipVehicles[i][vModel],
  1254. DealershipVehicles[i][vX],
  1255. DealershipVehicles[i][vY],
  1256. DealershipVehicles[i][vZ],
  1257. DealershipVehicles[i][vRot],
  1258. DealershipVehicles[i][vForSale],
  1259. DealershipVehicles[i][vPrice],
  1260. DealershipVehicles[i][vSQL_ID]);
  1261.  
  1262. strcat(query, query2);
  1263. db_query(DealerVehicleDatabase, query);
  1264. }
  1265. return 1;
  1266. }
  1267.  
  1268. stock LoadDealershipVehicles()
  1269. {
  1270. new DBResult:result;
  1271. new query[128], field[64], string[256];
  1272. for (new i = 1; i < MAX_VEHICLES; i += 1)
  1273. {
  1274. format(query, sizeof(query), "SELECT * FROM `DEALERCARS` WHERE vID = '%d'", i);
  1275. result = db_query(DealerVehicleDatabase, query);
  1276. if (db_num_rows(result))
  1277. {
  1278. new model, Float:x, Float:y, Float:z, Float:rot, forsale, price, vehicleid;
  1279. db_get_field_assoc(result, "vModel", field, sizeof(field)); model = strval(field);
  1280. db_get_field_assoc(result, "vX", field, sizeof(field)); x = strval(field);
  1281. db_get_field_assoc(result, "vY", field, sizeof(field)); y = strval(field);
  1282. db_get_field_assoc(result, "vZ", field, sizeof(field)); z = strval(field);
  1283. db_get_field_assoc(result, "vRot", field, sizeof(field)); rot = strval(field);
  1284. db_get_field_assoc(result, "vForSale", field, sizeof(field)); forsale = strval(field);
  1285. db_get_field_assoc(result, "vPrice", field, sizeof(field)); price = strval(field);
  1286. vehicleid = CreateVehicle(model, x, y, z, rot, 1, 1, 5);
  1287.  
  1288. DealershipVehicles[vehicleid][vModel] = model;
  1289. DealershipVehicles[vehicleid][vX] = x;
  1290. DealershipVehicles[vehicleid][vY] = y;
  1291. DealershipVehicles[vehicleid][vZ] = z;
  1292. DealershipVehicles[vehicleid][vRot] = rot;
  1293. DealershipVehicles[vehicleid][vForSale] = forsale;
  1294. DealershipVehicles[vehicleid][vPrice] = price;
  1295. DealershipVehicles[vehicleid][vID] = vehicleid;
  1296. format(string, sizeof(string), "This {FFFFFF}%s {F5DEB3}is for sale.\nThe cost of this vehicle is {FFFFFF}$%d.\n{F5DEB3}For more information, enter the vehicle.", GetVehicleName(vehicleid), price);
  1297. DealershipVehicles[vehicleid][vLabel] = Create3DTextLabel(string, YELLOW2, x, y, z, 10.0, 0);
  1298. DealershipVehicles[vehicleid][vSQL_ID] = dealershipCars + 1;
  1299. dealershipCars += 1;
  1300. }
  1301. db_free_result(result);
  1302. }
  1303. return 1;
  1304. }
  1305.  
  1306. stock ModifyVehicle(playerid, slot)
  1307. {
  1308. if (!PlayerVehicles[playerid][slot][pCarOwned]) return 1;
  1309. if (!PlayerVehicles[playerid][slot][pCarSpawned]) return 1;
  1310. new vehicleid = PlayerVehicles[playerid][slot][pCarID];
  1311. new comp1 = PlayerVehicles[playerid][slot][pCarMod1];
  1312. new comp2 = PlayerVehicles[playerid][slot][pCarMod2];
  1313. new comp3 = PlayerVehicles[playerid][slot][pCarMod3];
  1314. new comp4 = PlayerVehicles[playerid][slot][pCarMod4];
  1315. new comp5 = PlayerVehicles[playerid][slot][pCarMod5];
  1316. new comp6 = PlayerVehicles[playerid][slot][pCarMod6];
  1317. new comp7 = PlayerVehicles[playerid][slot][pCarMod7];
  1318. new comp8 = PlayerVehicles[playerid][slot][pCarMod8];
  1319. new comp9 = PlayerVehicles[playerid][slot][pCarMod9];
  1320. new comp10 = PlayerVehicles[playerid][slot][pCarMod10];
  1321. new comp11 = PlayerVehicles[playerid][slot][pCarMod11];
  1322. new comp12 = PlayerVehicles[playerid][slot][pCarMod12];
  1323. new comp13 = PlayerVehicles[playerid][slot][pCarMod13];
  1324. new comp14 = PlayerVehicles[playerid][slot][pCarMod14];
  1325. new comp15 = PlayerVehicles[playerid][slot][pCarMod15];
  1326. new comp16 = PlayerVehicles[playerid][slot][pCarMod16];
  1327. new comp17 = PlayerVehicles[playerid][slot][pCarMod17];
  1328. new color1 = PlayerVehicles[playerid][slot][pCarColor1];
  1329. new color2 = PlayerVehicles[playerid][slot][pCarColor2];
  1330. new paintjob = PlayerVehicles[playerid][slot][pCarPaintjob];
  1331.  
  1332. if (comp1 != 0) AddVehicleComponent(vehicleid, comp1);
  1333. if (comp2 != 0) AddVehicleComponent(vehicleid, comp2);
  1334. if (comp3 != 0) AddVehicleComponent(vehicleid, comp3);
  1335. if (comp4 != 0) AddVehicleComponent(vehicleid, comp4);
  1336. if (comp5 != 0) AddVehicleComponent(vehicleid, comp5);
  1337. if (comp6 != 0) AddVehicleComponent(vehicleid, comp6);
  1338. if (comp7 != 0) AddVehicleComponent(vehicleid, comp7);
  1339. if (comp8 != 0) AddVehicleComponent(vehicleid, comp8);
  1340. if (comp9 != 0) AddVehicleComponent(vehicleid, comp9);
  1341. if (comp10 != 0) AddVehicleComponent(vehicleid, comp10);
  1342. if (comp11 != 0) AddVehicleComponent(vehicleid, comp11);
  1343. if (comp12 != 0) AddVehicleComponent(vehicleid, comp12);
  1344. if (comp13 != 0) AddVehicleComponent(vehicleid, comp13);
  1345. if (comp14 != 0) AddVehicleComponent(vehicleid, comp14);
  1346. if (comp15 != 0) AddVehicleComponent(vehicleid, comp15);
  1347. if (comp16 != 0) AddVehicleComponent(vehicleid, comp16);
  1348. if (comp17 != 0) AddVehicleComponent(vehicleid, comp17);
  1349. ChangeVehicleColor(vehicleid, color1, color2);
  1350. if (paintjob != -1) ChangeVehiclePaintjob(vehicleid, paintjob);
  1351.  
  1352. switch (PlayerVehicles[playerid][slot][pCarLocked])
  1353. {
  1354. case 0: UnlockVehicle(PlayerVehicles[playerid][slot][pCarID]);
  1355. case 1: LockVehicle(PlayerVehicles[playerid][slot][pCarID]);
  1356. }
  1357. return 1;
  1358. }
  1359.  
  1360. stock LockVehicle(vehicleid)
  1361. {
  1362. foreach(Player, i)
  1363. {
  1364. SetVehicleParamsForPlayer(vehicleid, i, 0, 1);
  1365. }
  1366. VehicleLocked[vehicleid] = 1;
  1367. return 1;
  1368. }
  1369.  
  1370. stock UnlockVehicle(vehicleid)
  1371. {
  1372. foreach(Player, i)
  1373. {
  1374. SetVehicleParamsForPlayer(vehicleid, i, 0, 0);
  1375. }
  1376. VehicleLocked[vehicleid] = 0;
  1377. return 1;
  1378. }
  1379.  
  1380. stock PlayerOwnsVehicle(playerid, vehicleid)
  1381. {
  1382. for (new i = 1; i < MAX_PLAYER_CARS + 1; i += 1)
  1383. {
  1384. if (PlayerVehicles[playerid][i][pCarID] == vehicleid && PlayerVehicles[playerid][i][pCarSpawned]) return 1;
  1385. }
  1386. return 0;
  1387. }
  1388.  
  1389. stock GetPlayerVehicleSlot(playerid)
  1390. {
  1391. if (IsPlayerInAnyVehicle(playerid))
  1392. {
  1393. for (new i = 1; i < MAX_PLAYER_CARS + 1; i += 1)
  1394. {
  1395. if (PlayerVehicles[playerid][i][pCarID] == GetPlayerVehicleID(playerid) && PlayerVehicles[playerid][i][pCarSpawned])
  1396. {
  1397. return i;
  1398. }
  1399. }
  1400. }
  1401. return 0;
  1402. }
  1403.  
  1404. stock GetPlayerVehicleAmount(playerid)
  1405. {
  1406. new iCars;
  1407. for (new i = 1; i < MAX_PLAYER_CARS + 1; i += 1)
  1408. {
  1409. if (PlayerVehicles[playerid][i][pCarOwned]) ++iCars;
  1410. }
  1411. return iCars;
  1412. }
  1413.  
  1414. stock ParkVehicle(playerid, slot)
  1415. {
  1416. if (IsPlayerInVehicle(playerid, PlayerVehicles[playerid][slot][pCarID]))
  1417. {
  1418. if (GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
  1419. {
  1420. new Float:x, Float:y, Float:z, Float:angle;
  1421. GetVehiclePos(GetPlayerVehicleID(playerid), x, y, z);
  1422. GetVehicleZAngle(GetPlayerVehicleID(playerid), angle);
  1423. PlayerVehicles[playerid][slot][pCarX] = x;
  1424. PlayerVehicles[playerid][slot][pCarY] = y;
  1425. PlayerVehicles[playerid][slot][pCarZ] = z;
  1426. PlayerVehicles[playerid][slot][pCarRot] = angle;
  1427. foreach(Player, i)
  1428. {
  1429. if (i == playerid) continue;
  1430. if (IsPlayerInVehicle(i, PlayerVehicles[playerid][slot][pCarID]))
  1431. {
  1432. SetPVarInt(i, "CarID", PlayerVehicles[playerid][slot][pCarID]);
  1433. SetPVarInt(i, "CarSeat", GetPlayerVehicleSeat(playerid));
  1434. }
  1435. }
  1436. VehicleLocked[GetPlayerVehicleID(playerid)] = 0;
  1437. UnlockVehicle(GetPlayerVehicleID(playerid));
  1438. DestroyVehicle(GetPlayerVehicleID(playerid));
  1439. PlayerVehicles[playerid][slot][pCarID] = CreateVehicle(PlayerVehicles[playerid][slot][pCarModel], x, y, z, angle, PlayerVehicles[playerid][slot][pCarColor1], PlayerVehicles[playerid][slot][pCarColor2], -1);
  1440. PutPlayerInVehicle(playerid, PlayerVehicles[playerid][slot][pCarID], 0);
  1441. foreach(Player, i)
  1442. {
  1443. if (GetPVarInt(i, "CarID") == PlayerVehicles[playerid][slot][pCarID])
  1444. {
  1445. PutPlayerInVehicle(i, PlayerVehicles[playerid][slot][pCarID], GetPVarInt(i, "CarSeat"));
  1446. DeletePVar(i, "CarID");
  1447. DeletePVar(i, "CarSeat");
  1448. }
  1449. }
  1450. ModifyVehicle(playerid, slot);
  1451. return 1;
  1452. }
  1453. return 0;
  1454. }
  1455. return -1;
  1456. }
  1457.  
  1458. public OnVehicleStreamIn(vehicleid, forplayerid)
  1459. {
  1460. if (VehicleLocked[vehicleid]) SetVehicleParamsForPlayer(vehicleid, forplayerid, 0, 1);
  1461. else SetVehicleParamsForPlayer(vehicleid, forplayerid, 0, 0);
  1462. return 1;
  1463. }
  1464.  
  1465. public OnVehicleRespray(playerid, vehicleid, color1, color2)
  1466. {
  1467. foreach(Player, i)
  1468. {
  1469. for (new j = 1; j < MAX_PLAYER_CARS + 1; j += 1)
  1470. {
  1471. if (PlayerVehicles[i][j][pCarSpawned] && PlayerVehicles[i][j][pCarID] == vehicleid)
  1472. {
  1473. PlayerVehicles[i][j][pCarColor1] = color1;
  1474. PlayerVehicles[i][j][pCarColor2] = color2;
  1475. break;
  1476. }
  1477. }
  1478. }
  1479. return 1;
  1480. }
  1481.  
  1482. public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
  1483. {
  1484. foreach(Player, i)
  1485. {
  1486. for (new j = 1; j < MAX_PLAYER_CARS + 1; j += 1)
  1487. {
  1488. if (PlayerVehicles[i][j][pCarSpawned] && PlayerVehicles[i][j][pCarID] == vehicleid)
  1489. {
  1490. PlayerVehicles[i][j][pCarPaintjob] = paintjobid;
  1491. break;
  1492. }
  1493. }
  1494. }
  1495. return 1;
  1496. }
  1497.  
  1498. public OnVehicleMod(playerid, vehicleid, componentid)
  1499. {
  1500. foreach(Player, i)
  1501. {
  1502. for (new j = 1; j < MAX_PLAYER_CARS + 1; j += 1)
  1503. {
  1504. if (PlayerVehicles[i][j][pCarSpawned] && PlayerVehicles[i][j][pCarID] == vehicleid)
  1505. {
  1506. switch (ReturnComponentSlot(componentid))
  1507. {
  1508. case 1: PlayerVehicles[i][j][pCarMod1] = componentid;
  1509. case 2: PlayerVehicles[i][j][pCarMod2] = componentid;
  1510. case 3: PlayerVehicles[i][j][pCarMod3] = componentid;
  1511. case 4: PlayerVehicles[i][j][pCarMod4] = componentid;
  1512. case 5: PlayerVehicles[i][j][pCarMod5] = componentid;
  1513. case 6: PlayerVehicles[i][j][pCarMod6] = componentid;
  1514. case 7: PlayerVehicles[i][j][pCarMod7] = componentid;
  1515. case 8: PlayerVehicles[i][j][pCarMod8] = componentid;
  1516. case 9: PlayerVehicles[i][j][pCarMod9] = componentid;
  1517. case 10: PlayerVehicles[i][j][pCarMod10] = componentid;
  1518. case 11: PlayerVehicles[i][j][pCarMod11] = componentid;
  1519. case 12: PlayerVehicles[i][j][pCarMod12] = componentid;
  1520. case 13: PlayerVehicles[i][j][pCarMod13] = componentid;
  1521. case 14: PlayerVehicles[i][j][pCarMod14] = componentid;
  1522. case 15: PlayerVehicles[i][j][pCarMod15] = componentid;
  1523. case 16: PlayerVehicles[i][j][pCarMod16] = componentid;
  1524. case 17: PlayerVehicles[i][j][pCarMod17] = componentid;
  1525. }
  1526. break;
  1527. }
  1528. }
  1529. }
  1530. return 1;
  1531. }
  1532.  
  1533. public OnFilterScriptInit()
  1534. {
  1535. new query[142];
  1536. DealerVehicleDatabase = db_open("DealershipVehicles.db");
  1537. format(query, sizeof(query), "CREATE TABLE IF NOT EXISTS `DEALERCARS` (`vID`, `vModel`, `vX`, `vY`, `vZ`, `vRot`, `vForSale`, `vPrice`)");
  1538. db_query(DealerVehicleDatabase, query);
  1539. LoadDealershipVehicles();
  1540. foreach(Player, i)
  1541. {
  1542. VehicleConnect(i);
  1543. }
  1544. return 1;
  1545. }
  1546.  
  1547. public OnFilterScriptExit()
  1548. {
  1549. SaveDealershipVehicles();
  1550. db_close(DealerVehicleDatabase);
  1551. foreach(Player, i)
  1552. {
  1553. VehicleDisconnect(i);
  1554. }
  1555. return 1;
  1556. }
  1557.  
  1558. public OnPlayerConnect(playerid)
  1559. {
  1560. VehicleConnect(playerid);
  1561. return 1;
  1562. }
  1563.  
  1564. public OnPlayerDisconnect(playerid)
  1565. {
  1566. VehicleDisconnect(playerid);
  1567. return 1;
  1568. }
  1569.  
  1570. stock VehicleDisconnect(playerid)
  1571. {
  1572. for (new i = 1; i < MAX_PLAYER_CARS + 1; i += 1)
  1573. {
  1574. if (PlayerVehicles[playerid][i][pCarOwned])
  1575. {
  1576. SavePlayerVehicle(playerid, i);
  1577. if (PlayerVehicles[playerid][i][pCarSpawned]) DestroyVehicle(PlayerVehicles[playerid][i][pCarID]);
  1578. }
  1579. }
  1580. db_close(VehicleDatabase[playerid]);
  1581. return 1;
  1582. }
  1583.  
  1584. stock VehicleConnect(playerid)
  1585. {
  1586. new string[64];
  1587. format(string, sizeof(string), "Vehicles/%s.db", PlayerName(playerid));
  1588. VehicleDatabase[playerid] = db_open(string);
  1589. CreateVehicleTables(playerid);
  1590. for (new s = 1; s < MAX_PLAYER_CARS + 1; s += 1)
  1591. {
  1592. PlayerVehicles[playerid][s][pCarModel] = 0;
  1593. PlayerVehicles[playerid][s][pCarX] = 0.0;
  1594. PlayerVehicles[playerid][s][pCarY] = 0.0;
  1595. PlayerVehicles[playerid][s][pCarZ] = 0.0;
  1596. PlayerVehicles[playerid][s][pCarRot] = 0.0;
  1597. PlayerVehicles[playerid][s][pCarColor1] = 0;
  1598. PlayerVehicles[playerid][s][pCarColor2] = 0;
  1599. PlayerVehicles[playerid][s][pCarPaintjob] = -1;
  1600. PlayerVehicles[playerid][s][pCarMod1] = 0;
  1601. PlayerVehicles[playerid][s][pCarMod2] = 0;
  1602. PlayerVehicles[playerid][s][pCarMod3] = 0;
  1603. PlayerVehicles[playerid][s][pCarMod4] = 0;
  1604. PlayerVehicles[playerid][s][pCarMod5] = 0;
  1605. PlayerVehicles[playerid][s][pCarMod6] = 0;
  1606. PlayerVehicles[playerid][s][pCarMod7] = 0;
  1607. PlayerVehicles[playerid][s][pCarMod8] = 0;
  1608. PlayerVehicles[playerid][s][pCarMod9] = 0;
  1609. PlayerVehicles[playerid][s][pCarMod10] = 0;
  1610. PlayerVehicles[playerid][s][pCarMod11] = 0;
  1611. PlayerVehicles[playerid][s][pCarMod12] = 0;
  1612. PlayerVehicles[playerid][s][pCarMod13] = 0;
  1613. PlayerVehicles[playerid][s][pCarMod14] = 0;
  1614. PlayerVehicles[playerid][s][pCarMod15] = 0;
  1615. PlayerVehicles[playerid][s][pCarMod16] = 0;
  1616. PlayerVehicles[playerid][s][pCarMod17] = 0;
  1617. PlayerVehicles[playerid][s][pCarHasLock] = 0;
  1618. PlayerVehicles[playerid][s][pCarLocked] = 0;
  1619. PlayerVehicles[playerid][s][pCarTrunkCash] = 0;
  1620. PlayerVehicles[playerid][s][pCarTrunkGun1] = 0;
  1621. PlayerVehicles[playerid][s][pCarTrunkGun2] = 0;
  1622. PlayerVehicles[playerid][s][pCarTrunkGun3] = 0;
  1623. PlayerVehicles[playerid][s][pCarTrunkGun4] = 0;
  1624. PlayerVehicles[playerid][s][pCarTrunkAmmo1] = 0;
  1625. PlayerVehicles[playerid][s][pCarTrunkAmmo2] = 0;
  1626. PlayerVehicles[playerid][s][pCarTrunkAmmo3] = 0;
  1627. PlayerVehicles[playerid][s][pCarTrunkAmmo4] = 0;
  1628. PlayerVehicles[playerid][s][pCarSpawned] = 0;
  1629. PlayerVehicles[playerid][s][pCarOwned] = 0;
  1630. PlayerVehicles[playerid][s][pCarID] = 0;
  1631. VehicleListitem[playerid][s] = -1;
  1632. }
  1633. SetPVarInt(playerid, "CarOffer", INVALID_PLAYER_ID);
  1634. LoadPlayerVehicles(playerid);
  1635. return 1;
  1636. }
  1637.  
  1638. public OnPlayerStateChange(playerid, newstate, oldstate)
  1639. {
  1640. new string[256];
  1641. if (newstate == PLAYER_STATE_DRIVER && DealershipVehicles[GetPlayerVehicleID(playerid)][vForSale])
  1642. {
  1643. if (GetVehicleModel(GetPlayerVehicleID(playerid)) == DealershipVehicles[GetPlayerVehicleID(playerid)][vModel])
  1644. {
  1645. format(string, sizeof(string), "{D5DEB3}This vehicle is FOR SALE!\n\nVehicle: {FFFFFF}%s{F5DEB3}\nCost: {FFFFFF}$%d{F5DEB3}\n\nWould you like to purchase this vehicle?", GetVehicleName(GetPlayerVehicleID(playerid)), DealershipVehicles[GetPlayerVehicleID(playerid)][vPrice]);
  1646. ShowPlayerDialog(playerid, 9, DIALOG_STYLE_MSGBOX, "Vehicle Dealership", string, "Yes", "No");
  1647. TogglePlayerControllable(playerid, 0);
  1648. }
  1649. }
  1650. return 1;
  1651. }
  1652.  
  1653. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  1654. {
  1655. new string[128];
  1656. if (dialogid == 9)
  1657. {
  1658. if (!response)
  1659. {
  1660. TogglePlayerControllable(playerid, 1);
  1661. return RemovePlayerFromVehicle(playerid);
  1662. }
  1663. else
  1664. {
  1665. if (!IsPlayerInAnyVehicle(playerid))
  1666. {
  1667. SendClientMessage(playerid, GREY, "You are not in a vehicle.");
  1668. TogglePlayerControllable(playerid, 1);
  1669. return RemovePlayerFromVehicle(playerid);
  1670. }
  1671. if (!DealershipVehicles[GetPlayerVehicleID(playerid)][vForSale])
  1672. {
  1673. SendClientMessage(playerid, GREY, "You are not in any vehicle that's for sale.");
  1674. TogglePlayerControllable(playerid, 1);
  1675. return RemovePlayerFromVehicle(playerid);
  1676. }
  1677. if (GetPlayerMoney(playerid) < DealershipVehicles[GetPlayerVehicleID(playerid)][vPrice])
  1678. {
  1679. SendClientMessage(playerid, GREY, "You cannot afford the vehicle.");
  1680. TogglePlayerControllable(playerid, 1);
  1681. return RemovePlayerFromVehicle(playerid);
  1682. }
  1683.  
  1684. new
  1685. iModel = DealershipVehicles[GetPlayerVehicleID(playerid)][vModel],
  1686. Float:fAngle = DealershipVehicles[GetPlayerVehicleID(playerid)][vRot],
  1687. Float:fX = DealershipVehicles[GetPlayerVehicleID(playerid)][vX],
  1688. Float:fY = DealershipVehicles[GetPlayerVehicleID(playerid)][vY],
  1689. Float:fZ = DealershipVehicles[GetPlayerVehicleID(playerid)][vZ];
  1690.  
  1691. switch (iModel)
  1692. {
  1693. case 460, 464, 476, 511, 512, 513, 519, 520, 553, 577, 592, 593, 430, 446, 452, 453,
  1694. 454, 472, 473, 484, 493, 595, 417, 425, 447, 465, 469, 487, 488, 497, 501, 548, 563:
  1695. {
  1696. fX = (fX + (24.0 * floatsin(-fAngle, degrees)));
  1697. fY = (fY + (24.0 * floatcos(fAngle, degrees)));
  1698. }
  1699. default:
  1700. {
  1701. fX = (fX + (6.0 * floatsin(-fAngle, degrees)));
  1702. fY = (fY + (6.0 * floatcos(fAngle, degrees)));
  1703. }
  1704. }
  1705. switch (CreatePlayerVehicle(playerid, iModel, fX, fY, fZ, fAngle))
  1706. {
  1707. case -1:
  1708. {
  1709. SendClientMessage(playerid, GREY, "The vehicle could not be purchased.");
  1710. TogglePlayerControllable(playerid, 1);
  1711. return RemovePlayerFromVehicle(playerid);
  1712. }
  1713. case 0:
  1714. {
  1715. SendClientMessage(playerid, GREY, "You already own the maximum amount of vehicles.");
  1716. TogglePlayerControllable(playerid, 1);
  1717. return RemovePlayerFromVehicle(playerid);
  1718. }
  1719. case 1:
  1720. {
  1721. GivePlayerMoney(playerid, -DealershipVehicles[GetPlayerVehicleID(playerid)][vPrice]);
  1722. format(string, sizeof(string), "You have purchased a %s for $%d, for more help regarding your purchase, type /carhelp.", GetVehicleName(GetPlayerVehicleID(playerid)), DealershipVehicles[GetPlayerVehicleID(playerid)][vPrice]);
  1723. SendClientMessage(playerid, YELLOW, string);
  1724. RemovePlayerFromVehicle(playerid);
  1725. TogglePlayerControllable(playerid, 1);
  1726. return 1;
  1727. }
  1728. }
  1729. }
  1730. }
  1731. if (dialogid == 10 && response)
  1732. {
  1733. for (new i = 1; i < MAX_PLAYER_CARS + 1; i += 1)
  1734. {
  1735. if (VehicleListitem[playerid][i] == listitem)
  1736. {
  1737. if (!PlayerVehicles[playerid][i][pCarOwned]) return SendClientMessage(playerid, GREY, "An error has occurred.");
  1738. PlayerVehicles[playerid][i][pCarSpawned] = !PlayerVehicles[playerid][i][pCarSpawned];
  1739. switch (PlayerVehicles[playerid][i][pCarSpawned])
  1740. {
  1741. case 0:
  1742. {
  1743. UnlockVehicle(PlayerVehicles[playerid][i][pCarID]);
  1744. DestroyVehicle(PlayerVehicles[playerid][i][pCarID]);
  1745. PlayerVehicles[playerid][i][pCarID] = 0;
  1746. format(string, sizeof(string), "You have despawned your %s in slot #%d.", GetVehicleNameByModel(PlayerVehicles[playerid][i][pCarModel]), i);
  1747. SendClientMessage(playerid, WHITE, string);
  1748. }
  1749. case 1:
  1750. {
  1751. PlayerVehicles[playerid][i][pCarID] = CreateVehicle(PlayerVehicles[playerid][i][pCarModel], PlayerVehicles[playerid][i][pCarX], PlayerVehicles[playerid][i][pCarY], PlayerVehicles[playerid][i][pCarZ], PlayerVehicles[playerid][i][pCarRot], PlayerVehicles[playerid][i][pCarColor1], PlayerVehicles[playerid][i][pCarColor2], -1);
  1752. ModifyVehicle(playerid, i);
  1753. format(string, sizeof(string), "You have spawned your %s in slot #%d.", GetVehicleNameByModel(PlayerVehicles[playerid][i][pCarModel]), i);
  1754. SendClientMessage(playerid, WHITE, string);
  1755. }
  1756. }
  1757. VehicleListitem[playerid][i] = -1;
  1758. return 1;
  1759. }
  1760. }
  1761. }
  1762. if (dialogid == 11 && response)
  1763. {
  1764. for (new i = 1; i < MAX_PLAYER_CARS + 1; i += 1)
  1765. {
  1766. if (VehicleListitem[playerid][i] == listitem)
  1767. {
  1768. if (!PlayerVehicles[playerid][i][pCarOwned]) return SendClientMessage(playerid, GREY, "An error has occurred.");
  1769. new iModel = PlayerVehicles[playerid][i][pCarModel];
  1770. if (DeletePlayerVehicle(playerid, i))
  1771. {
  1772. format(string, sizeof(string), "You have deleted your %s in slot #%d.", GetVehicleNameByModel(iModel), i);
  1773. SendClientMessage(playerid, WHITE, string);
  1774. }
  1775. VehicleListitem[playerid][i] = -1;
  1776. return 1;
  1777. }
  1778. }
  1779. }
  1780. if (dialogid == 12 && response)
  1781. {
  1782. for (new i = 1; i < MAX_PLAYER_CARS + 1; i += 1)
  1783. {
  1784. if (VehicleListitem[playerid][i] == listitem)
  1785. {
  1786. if (!PlayerVehicles[playerid][i][pCarOwned]) return SendClientMessage(playerid, GREY, "An error has occurred.");
  1787. SetPVarInt(playerid, "UpgradingVehicle", i);
  1788. ShowPlayerDialog(playerid, 13, DIALOG_STYLE_LIST, "Vehicle Upgrades", "Vehicle Lock ("#LOCK_PRICE")", "Upgrade", "Cancel");
  1789. VehicleListitem[playerid][i] = -1;
  1790. return 1;
  1791. }
  1792. }
  1793. }
  1794. if (dialogid == 13)
  1795. {
  1796. if (response)
  1797. {
  1798. new slot = GetPVarInt(playerid, "UpgradingVehicle");
  1799. if (!slot)
  1800. return SendClientMessage(playerid, GREY, "You must select a vehicle first.");
  1801.  
  1802. if (!PlayerVehicles[playerid][slot][pCarOwned]) return SendClientMessage(playerid, GREY, "An error has occurred."), DeletePVar(playerid, "UpgradingVehicle");
  1803. if (PlayerVehicles[playerid][slot][pCarHasLock]) return SendClientMessage(playerid, GREY, "This vehicle already has a lock installed."), DeletePVar(playerid, "UpgradingVehicle");
  1804.  
  1805. if (GetPlayerMoney(playerid) >= LOCK_PRICE)
  1806. {
  1807. GivePlayerMoney(playerid, -LOCK_PRICE);
  1808. PlayerVehicles[playerid][slot][pCarHasLock] = 1;
  1809. SendClientMessage(playerid, YELLOW, "You have purchased a lock for your vehicle. This costed you $"#LOCK_PRICE".");
  1810. SendClientMessage(playerid, WHITE, "HINT: Type /lock to lock or unlock your vehicle.");
  1811. DeletePVar(playerid, "UpgradingVehicle");
  1812. return 1;
  1813. }
  1814. else
  1815. {
  1816. SendClientMessage(playerid, GREY, "You cannot afford the lock.");
  1817. DeletePVar(playerid, "UpgradingVehicle");
  1818. }
  1819. }
  1820. else return DeletePVar(playerid, "UpgradingVehicle");
  1821. }
  1822. return 1;
  1823. }
  1824.  
  1825. CMD:dealervehicle(playerid, params[])
  1826. {
  1827. if (IsPlayerAdmin(playerid))
  1828. {
  1829. new model, price, string[128];
  1830. if (sscanf(params, "dd", model, price)) return SendClientMessage(playerid, GREY, "USAGE: /dealervehicle [model] [price]");
  1831. if (model < 400 || model > 611) return SendClientMessage(playerid, GREY, "Invalid model.");
  1832. new Float:x, Float:y, Float:z, Float:a;
  1833. GetPlayerPos(playerid, x, y, z);
  1834. GetPlayerFacingAngle(playerid, a);
  1835.  
  1836. new cdv = CreateDealershipVehicle(model, price, x, y, z, a);
  1837. switch (cdv)
  1838. {
  1839. case 0: return SendClientMessage(playerid, GREY, "The vehicle could not be created.");
  1840. case 1:
  1841. {
  1842. SetPlayerPos(playerid, x, y, z + 5);
  1843. format(string, sizeof(string), "Dealership vehicle #%d created (model: %d | price: $%d).", cdv, model, price);
  1844. SendClientMessage(playerid, GREY, string);
  1845. SaveDealershipVehicles();
  1846. }
  1847. }
  1848. return 1;
  1849. }
  1850. else SendClientMessage(playerid, GREY, "You cannot use this command since you're not a high enough administrator level.");
  1851. return 1;
  1852. }
  1853.  
  1854. CMD:deletevehicle(playerid, params[])
  1855. {
  1856. if (IsPlayerAdmin(playerid))
  1857. {
  1858. new vehicleid, string[128], iModel, iSQL;
  1859. if (sscanf(params, "d", vehicleid)) return SendClientMessage(playerid, GREY, "USAGE: /deletevehicle [vehicleid]");
  1860. if (!DealershipVehicles[vehicleid][vForSale]) return SendClientMessage(playerid, GREY, "That is not a dealership vehicle.");
  1861.  
  1862. iModel = DealershipVehicles[vehicleid][vModel];
  1863. iSQL = DealershipVehicles[vehicleid][vSQL_ID];
  1864. if (DeleteDealershipVehicle(vehicleid))
  1865. {
  1866. format(string, sizeof(string), "You have deleted dealership vehicle #%d (SQL ID: %d | Model: %s)", vehicleid, iSQL, GetVehicleNameByModel(iModel));
  1867. SendClientMessage(playerid, WHITE, string);
  1868. SaveDealershipVehicles();
  1869. }
  1870. return 1;
  1871. }
  1872. else SendClientMessage(playerid, GREY, "You cannot use this command since you're not a high enough administrator level.");
  1873. return 1;
  1874. }
  1875.  
  1876. CMD:park(playerid, params[])
  1877. {
  1878. if (!GetPlayerVehicleAmount(playerid)) return SendClientMessage(playerid, GREY, "You don't own any vehicles.");
  1879. if (!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, GREY, "You are not in any vehicle.");
  1880. if (!GetPlayerVehicleSlot(playerid)) return SendClientMessage(playerid, GREY, "You don't own this vehicle.");
  1881. switch (ParkVehicle(playerid, GetPlayerVehicleSlot(playerid)))
  1882. {
  1883. case -1:
  1884. {
  1885. SendClientMessage(playerid, GREY, "You are not in any vehicle.");
  1886. }
  1887. case 0:
  1888. {
  1889. SendClientMessage(playerid, GREY, "You must be the driver.");
  1890. }
  1891. case 1:
  1892. {
  1893. SendClientMessage(playerid, YELLOW, "You have successfully parked your vehicle.");
  1894. }
  1895. }
  1896. return 1;
  1897. }
  1898.  
  1899. CMD:mycars(playerid, params[])
  1900. {
  1901. if (!GetPlayerVehicleAmount(playerid))
  1902. return SendClientMessage(playerid, GREY, "You don't own any vehicles.");
  1903.  
  1904. new szString[128];
  1905. new szStatus[12];
  1906. new szCarString[128 * MAX_PLAYER_CARS];
  1907. for (new i = 1; i < MAX_PLAYER_CARS + 1; i += 1)
  1908. {
  1909. if (PlayerVehicles[playerid][i][pCarOwned] == 0) continue;
  1910. switch (PlayerVehicles[playerid][i][pCarSpawned])
  1911. {
  1912. case 0: szStatus = "Despawned", format(szString, sizeof(szString), "#%d - %s (Status: %s)\n", i, GetVehicleNameByModel(PlayerVehicles[playerid][i][pCarModel]), szStatus);
  1913. case 1: szStatus = "Spawned", format(szString, sizeof(szString), "#%d - %s (ID: %d - Status: %s)\n", i, GetVehicleNameByModel(PlayerVehicles[playerid][i][pCarModel]), PlayerVehicles[playerid][i][pCarID], szStatus);
  1914. }
  1915. strcat(szCarString, szString);
  1916. }
  1917. ShowPlayerDialog(playerid, 0, DIALOG_STYLE_LIST, "My Cars", szCarString, "Close", "");
  1918. return 1;
  1919. }
  1920.  
  1921. CMD:spawncar(playerid, params[])
  1922. {
  1923. if (!GetPlayerVehicleAmount(playerid))
  1924. return SendClientMessage(playerid, GREY, "You don't own any vehicles.");
  1925.  
  1926. new szString[128];
  1927. new szStatus[12];
  1928. new szCarString[128 * MAX_PLAYER_CARS];
  1929. new iListitem = 0;
  1930. for (new i = 1; i < MAX_PLAYER_CARS + 1; i += 1)
  1931. {
  1932. if (PlayerVehicles[playerid][i][pCarOwned] == 0) continue;
  1933. switch (PlayerVehicles[playerid][i][pCarSpawned])
  1934. {
  1935. case 0: szStatus = "Despawned", format(szString, sizeof(szString), "#%d - %s (Status: %s)\n", i, GetVehicleNameByModel(PlayerVehicles[playerid][i][pCarModel]), szStatus);
  1936. case 1: szStatus = "Spawned", format(szString, sizeof(szString), "#%d - %s (ID: %d - Status: %s)\n", i, GetVehicleNameByModel(PlayerVehicles[playerid][i][pCarModel]), PlayerVehicles[playerid][i][pCarID], szStatus);
  1937. }
  1938. strcat(szCarString, szString);
  1939.  
  1940. VehicleListitem[playerid][i] = iListitem ++;
  1941. }
  1942. ShowPlayerDialog(playerid, 10, DIALOG_STYLE_LIST, "Spawn / Despawn Vehicle", szCarString, "Select", "Cancel");
  1943. return 1;
  1944. }
  1945.  
  1946. CMD:deletecar(playerid, params[])
  1947. {
  1948. if (!GetPlayerVehicleAmount(playerid))
  1949. return SendClientMessage(playerid, GREY, "You don't own any vehicles.");
  1950.  
  1951. new szString[128];
  1952. new szStatus[12];
  1953. new szCarString[128 * MAX_PLAYER_CARS];
  1954. new iListitem = 0;
  1955. for (new i = 1; i < MAX_PLAYER_CARS + 1; i += 1)
  1956. {
  1957. if (PlayerVehicles[playerid][i][pCarOwned] == 0) continue;
  1958. switch (PlayerVehicles[playerid][i][pCarSpawned])
  1959. {
  1960. case 0: szStatus = "Despawned", format(szString, sizeof(szString), "#%d - %s (Status: %s)\n", i, GetVehicleNameByModel(PlayerVehicles[playerid][i][pCarModel]), szStatus);
  1961. case 1: szStatus = "Spawned", format(szString, sizeof(szString), "#%d - %s (ID: %d - Status: %s)\n", i, GetVehicleNameByModel(PlayerVehicles[playerid][i][pCarModel]), PlayerVehicles[playerid][i][pCarID], szStatus);
  1962. }
  1963. strcat(szCarString, szString);
  1964.  
  1965. VehicleListitem[playerid][i] = iListitem ++;
  1966. }
  1967. ShowPlayerDialog(playerid, 11, DIALOG_STYLE_LIST, "Delete Vehicle", szCarString, "Select", "Cancel");
  1968. return 1;
  1969. }
  1970.  
  1971. CMD:upgradecar(playerid, params[])
  1972. {
  1973. if (!GetPlayerVehicleAmount(playerid))
  1974. return SendClientMessage(playerid, GREY, "You don't own any vehicles.");
  1975.  
  1976. new szString[128];
  1977. new szStatus[12];
  1978. new szCarString[128 * MAX_PLAYER_CARS];
  1979. new iListitem = 0;
  1980. for (new i = 1; i < MAX_PLAYER_CARS + 1; i += 1)
  1981. {
  1982. if (PlayerVehicles[playerid][i][pCarOwned] == 0) continue;
  1983. switch (PlayerVehicles[playerid][i][pCarSpawned])
  1984. {
  1985. case 0: szStatus = "Despawned", format(szString, sizeof(szString), "#%d - %s (Status: %s)\n", i, GetVehicleNameByModel(PlayerVehicles[playerid][i][pCarModel]), szStatus);
  1986. case 1: szStatus = "Spawned", format(szString, sizeof(szString), "#%d - %s (ID: %d - Status: %s)\n", i, GetVehicleNameByModel(PlayerVehicles[playerid][i][pCarModel]), PlayerVehicles[playerid][i][pCarID], szStatus);
  1987. }
  1988. strcat(szCarString, szString);
  1989.  
  1990. VehicleListitem[playerid][i] = iListitem ++;
  1991. }
  1992. ShowPlayerDialog(playerid, 12, DIALOG_STYLE_LIST, "Upgrade Vehicle", szCarString, "Select", "Cancel");
  1993. return 1;
  1994. }
  1995.  
  1996. CMD:lock(playerid, params[])
  1997. {
  1998. if (!GetPlayerVehicleAmount(playerid))
  1999. return SendClientMessage(playerid, GREY, "You don't own any vehicles.");
  2000.  
  2001. if (IsPlayerInAnyVehicle(playerid))
  2002. {
  2003. new vehicleid = GetPlayerVehicleID(playerid);
  2004. if (!PlayerOwnsVehicle(playerid, vehicleid)) return SendClientMessage(playerid, GREY, "You don't own this vehicle.");
  2005. if (PlayerVehicles[playerid][GetPlayerVehicleSlot(playerid)][pCarHasLock] == 0) return SendClientMessage(playerid, GREY, "This vehicle doesn't have a lock (/upgradecar to buy one).");
  2006. VehicleLocked[vehicleid] = !VehicleLocked[vehicleid];
  2007. switch (VehicleLocked[vehicleid])
  2008. {
  2009. case 0:
  2010. {
  2011. UnlockVehicle(vehicleid);
  2012. PlayerVehicles[playerid][GetPlayerVehicleSlot(playerid)][pCarLocked] = 0;
  2013. GameTextForPlayer(playerid, "~n~~n~~n~~n~~n~~n~~n~~n~~w~Vehicle ~g~Unlocked", 3000, 3);
  2014. }
  2015. case 1:
  2016. {
  2017. LockVehicle(vehicleid);
  2018. PlayerVehicles[playerid][GetPlayerVehicleSlot(playerid)][pCarLocked] = 1;
  2019. GameTextForPlayer(playerid, "~n~~n~~n~~n~~n~~n~~n~~n~~w~Vehicle ~r~Locked", 3000, 3);
  2020. }
  2021. }
  2022. return 1;
  2023. }
  2024. else
  2025. {
  2026. new carcount;
  2027. new vehicleid = -1;
  2028. new slotid = -1;
  2029. new Float:pos[3];
  2030. for (new i = 1; i < MAX_VEHICLES; i += 1)
  2031. {
  2032. GetVehiclePos(i, pos[0], pos[1], pos[2]);
  2033. if (IsPlayerInRangeOfPoint(playerid, 3.5, pos[0], pos[1], pos[2]) && PlayerOwnsVehicle(playerid, i))
  2034. {
  2035. vehicleid = i;
  2036. carcount += 1;
  2037. break;
  2038. }
  2039. }
  2040. if (vehicleid == -1 && !carcount) return SendClientMessage(playerid, GREY, "You are not near any vehicle that you've purchased.");
  2041. if (carcount >= 2) return SendClientMessage(playerid, GREY, "There are too many vehicles in range.");
  2042. else
  2043. {
  2044. for (new i = 1; i < MAX_PLAYER_CARS + 1; i += 1)
  2045. {
  2046. if (PlayerVehicles[playerid][i][pCarID] == vehicleid)
  2047. {
  2048. slotid = i;
  2049. break;
  2050. }
  2051. }
  2052. if (!slotid) return SendClientMessage(playerid, GREY, "You don't own this vehicle.");
  2053. if (PlayerVehicles[playerid][slotid][pCarHasLock] == 0) return SendClientMessage(playerid, GREY, "This vehicle doesn't have a lock (/upgradecar to buy one).");
  2054. VehicleLocked[vehicleid] = !VehicleLocked[vehicleid];
  2055. switch (VehicleLocked[vehicleid])
  2056. {
  2057. case 0:
  2058. {
  2059. UnlockVehicle(vehicleid);
  2060. PlayerVehicles[playerid][slotid][pCarLocked] = 0;
  2061. GameTextForPlayer(playerid, "~n~~n~~n~~n~~n~~n~~n~~n~~w~Vehicle ~g~Unlocked", 3000, 3);
  2062. PlayerPlaySound(playerid, 1145, 0.0, 0.0, 0.0);
  2063. }
  2064. case 1:
  2065. {
  2066. LockVehicle(vehicleid);
  2067. PlayerVehicles[playerid][slotid][pCarLocked] = 1;
  2068. GameTextForPlayer(playerid, "~n~~n~~n~~n~~n~~n~~n~~n~~w~Vehicle ~r~Locked", 3000, 3);
  2069. PlayerPlaySound(playerid, 1145, 0.0, 0.0, 0.0);
  2070. }
  2071. }
  2072. }
  2073. }
  2074. return 1;
  2075. }
  2076.  
  2077. CMD:carhelp(playerid, params[])
  2078. {
  2079. SendClientMessage(playerid, WHITE, "VEHICLE: /park, /mycars, /spawncar, /upgradecar, /deletecar, /lock, /sellcar.");
  2080. SendClientMessage(playerid, WHITE, "VEHICLE: /trunkput, /trunktake, /trunkbalance.");
  2081. return 1;
  2082. }
  2083.  
  2084. CMD:sellcar(playerid, params[])
  2085. {
  2086. if (!GetPlayerVehicleAmount(playerid))
  2087. return SendClientMessage(playerid, GREY, "You don't own any vehicles.");
  2088.  
  2089. if (!IsPlayerInAnyVehicle(playerid))
  2090. return SendClientMessage(playerid, GREY, "You must be inside a vehicle.");
  2091.  
  2092. if (!PlayerOwnsVehicle(playerid, GetPlayerVehicleID(playerid)))
  2093. return SendClientMessage(playerid, GREY, "You don't own this vehicle.");
  2094.  
  2095. new userid, price, string[128];
  2096. if (sscanf(params, "ud", userid, price))
  2097. return SendClientMessage(playerid, GREY, "USAGE: /sellcar [target] [price]");
  2098.  
  2099. if (!IsPlayerConnected(userid))
  2100. return SendClientMessage(playerid, GREY, "The specified player is not connected.");
  2101.  
  2102. if (userid == playerid)
  2103. return SendClientMessage(playerid, GREY, "You can't sell a vehicle to yourself.");
  2104.  
  2105. if (!IsPlayerNearPlayer(playerid, userid, 7.0)) return SendClientMessage(playerid, GREY, "You are not near that player.");
  2106. format(string, sizeof(string), "* %s wants to sell you their %s for $%d (type /acceptcar to accept).", PlayerName(playerid, false), GetVehicleName(GetPlayerVehicleID(playerid)), price);
  2107. SendClientMessage(userid, LIGHTBLUE, string);
  2108.  
  2109. format(string, sizeof(string), "* You've offered %s to buy your %s for $%d.", PlayerName(userid, false), GetVehicleName(GetPlayerVehicleID(playerid)), price);
  2110. SendClientMessage(playerid, LIGHTBLUE, string);
  2111.  
  2112. SetPVarInt(userid, "CarOffer", playerid);
  2113. SetPVarInt(userid, "CarPrice", price);
  2114. SetPVarInt(userid, "CarSlot", GetPlayerVehicleSlot(playerid));
  2115. return 1;
  2116. }
  2117.  
  2118. stock RemovePlayerWeapon(playerid, weaponid)
  2119. {
  2120. new weapons[12] = 0;
  2121. new ammo[12] = 0;
  2122. for (new i = 0; i < 13; i += 1)
  2123. {
  2124. new weapon, ammo2;
  2125. GetPlayerWeaponData(playerid, i, weapon, ammo2);
  2126. if ((weapon != weaponid) && (ammo2 > 0)) GetPlayerWeaponData(playerid, i, weapons[i], ammo[i]);
  2127. }
  2128. ResetPlayerWeapons(playerid);
  2129. for (new i = 0; i < 13; i += 1)
  2130. {
  2131. if(weapons[i] > 0 && ammo[i] != 0) GivePlayerWeapon(playerid, weapons[i], ammo[i]);
  2132. }
  2133. return 1;
  2134. }
  2135.  
  2136. stock GetWeaponNameEx(weaponid, weapon[], len)
  2137. {
  2138. GetWeaponName(weaponid, weapon, len);
  2139. if (weaponid == 0) format(weapon, 24, "None");
  2140. if (weaponid == 18) format(weapon, 24, "Molotov");
  2141. if (weaponid == 44) format(weapon, 24, "Nightvision Goggles");
  2142. if (weaponid == 45) format(weapon, 24, "Infrared Goggles");
  2143. return 1;
  2144. }
  2145.  
  2146. stock IsPlayerNearPlayer(playerid, targetid, Float:radius)
  2147. {
  2148. if (IsPlayerConnected(playerid) && IsPlayerConnected(targetid))
  2149. {
  2150. new Float:x, Float:y, Float:z;
  2151. GetPlayerPos(targetid, x, y, z);
  2152. if (IsPlayerInRangeOfPoint(playerid, radius, x, y, z)) return 1;
  2153. }
  2154. return 0;
  2155. }
  2156.  
  2157. stock IsPlayerNearVehicle(playerid, vehicleid, Float:radius)
  2158. {
  2159. if (IsPlayerConnected(playerid))
  2160. {
  2161. new
  2162. Float:playerFloats[3],
  2163. Float:vehicleFloats[3],
  2164. Float:fCalculation;
  2165.  
  2166. GetPlayerPos(playerid, playerFloats[0], playerFloats[1], playerFloats[2]);
  2167. GetVehiclePos(vehicleid, vehicleFloats[0], vehicleFloats[1], vehicleFloats[2]);
  2168. fCalculation = (vehicleFloats[0] - playerFloats[0]) * (vehicleFloats[0] - playerFloats[0]) + (vehicleFloats[1] - playerFloats[1]) * (vehicleFloats[1] - playerFloats[1]) + (vehicleFloats[2] - playerFloats[2]) * (vehicleFloats[2] - playerFloats[2]);
  2169. if (fCalculation <= (radius * radius))
  2170. {
  2171. if (GetPlayerVirtualWorld(playerid) == GetVehicleVirtualWorld(vehicleid))
  2172. return 1;
  2173. }
  2174. }
  2175. return 0;
  2176. }
  2177.  
  2178. CMD:acceptcar(playerid, params[])
  2179. {
  2180. new string[128];
  2181. if (GetPVarInt(playerid, "CarOffer") != INVALID_PLAYER_ID)
  2182. {
  2183. new query[192];
  2184. if (GetPVarInt(playerid, "CarOffer") != INVALID_PLAYER_ID && IsPlayerConnected(GetPVarInt(playerid, "CarOffer")))
  2185. {
  2186. if (IsPlayerNearPlayer(playerid, GetPVarInt(playerid, "CarOffer"), 7.0))
  2187. {
  2188. if (GetPlayerMoney(playerid) >= GetPVarInt(playerid, "CarPrice"))
  2189. {
  2190. if (GetPlayerVehicleAmount(playerid) < MAX_PLAYER_CARS)
  2191. {
  2192. new slot = GetPVarInt(playerid, "CarSlot");
  2193. if (PlayerVehicles[GetPVarInt(playerid, "CarOffer")][slot][pCarOwned] && PlayerVehicles[GetPVarInt(playerid, "CarOffer")][slot][pCarSpawned])
  2194. {
  2195. new slotid = -1;
  2196. for (new i = 1; i < MAX_PLAYER_CARS + 1; i += 1)
  2197. {
  2198. if (!PlayerVehicles[playerid][i][pCarOwned])
  2199. {
  2200. slotid = i;
  2201. break;
  2202. }
  2203. }
  2204. if (slotid == -1) return SendClientMessage(playerid, GREY, "You already own the maximum amount of vehicles.");
  2205.  
  2206. GivePlayerMoney(playerid, -GetPVarInt(playerid, "CarPrice"));
  2207. GivePlayerMoney(GetPVarInt(playerid, "CarOffer"), GetPVarInt(playerid, "CarPrice"));
  2208.  
  2209. format(string, sizeof(string), "* %s has accepted the offer; you've sold them your %s for $%d.", PlayerName(playerid, false), GetVehicleNameByModel(PlayerVehicles[GetPVarInt(playerid, "CarOffer")][slot][pCarModel]), GetPVarInt(playerid, "CarPrice"));
  2210. SendClientMessage(GetPVarInt(playerid, "CarOffer"), LIGHTBLUE, string);
  2211.  
  2212. format(string, sizeof(string), "* You have bought a %s for $%d from %s.", GetVehicleNameByModel(PlayerVehicles[GetPVarInt(playerid, "CarOffer")][slot][pCarModel]), GetPVarInt(playerid, "CarPrice"), PlayerName(GetPVarInt(playerid, "CarOffer"), false));
  2213. SendClientMessage(playerid, LIGHTBLUE, string);
  2214.  
  2215. PlayerVehicles[playerid][slotid][pCarModel] = PlayerVehicles[GetPVarInt(playerid, "CarOffer")][slot][pCarModel];
  2216. PlayerVehicles[playerid][slotid][pCarX] = PlayerVehicles[GetPVarInt(playerid, "CarOffer")][slot][pCarX];
  2217. PlayerVehicles[playerid][slotid][pCarY] = PlayerVehicles[GetPVarInt(playerid, "CarOffer")][slot][pCarY];
  2218. PlayerVehicles[playerid][slotid][pCarZ] = PlayerVehicles[GetPVarInt(playerid, "CarOffer")][slot][pCarZ];
  2219. PlayerVehicles[playerid][slotid][pCarRot] = PlayerVehicles[GetPVarInt(playerid, "CarOffer")][slot][pCarRot];
  2220. PlayerVehicles[playerid][slotid][pCarColor1] = PlayerVehicles[GetPVarInt(playerid, "CarOffer")][slot][pCarColor1];
  2221. PlayerVehicles[playerid][slotid][pCarColor2] = PlayerVehicles[GetPVarInt(playerid, "CarOffer")][slot][pCarColor2];
  2222. PlayerVehicles[playerid][slotid][pCarPaintjob] = PlayerVehicles[GetPVarInt(playerid, "CarOffer")][slot][pCarPaintjob];
  2223. PlayerVehicles[playerid][slotid][pCarMod1] = PlayerVehicles[GetPVarInt(playerid, "CarOffer")][slot][pCarMod1];
  2224. PlayerVehicles[playerid][slotid][pCarMod2] = PlayerVehicles[GetPVarInt(playerid, "CarOffer")][slot][pCarMod2];
  2225. PlayerVehicles[playerid][slotid][pCarMod3] = PlayerVehicles[GetPVarInt(playerid, "CarOffer")][slot][pCarMod3];
  2226. PlayerVehicles[playerid][slotid][pCarMod4] = PlayerVehicles[GetPVarInt(playerid, "CarOffer")][slot][pCarMod4];
  2227. PlayerVehicles[playerid][slotid][pCarMod5] = PlayerVehicles[GetPVarInt(playerid, "CarOffer")][slot][pCarMod5];
  2228. PlayerVehicles[playerid][slotid][pCarMod6] = PlayerVehicles[GetPVarInt(playerid, "CarOffer")][slot][pCarMod6];
  2229. PlayerVehicles[playerid][slotid][pCarMod7] = PlayerVehicles[GetPVarInt(playerid, "CarOffer")][slot][pCarMod7];
  2230. PlayerVehicles[playerid][slotid][pCarMod8] = PlayerVehicles[GetPVarInt(playerid, "CarOffer")][slot][pCarMod8];
  2231. PlayerVehicles[playerid][slotid][pCarMod9] = PlayerVehicles[GetPVarInt(playerid, "CarOffer")][slot][pCarMod9];
  2232. PlayerVehicles[playerid][slotid][pCarMod10] = PlayerVehicles[GetPVarInt(playerid, "CarOffer")][slot][pCarMod10];
  2233. PlayerVehicles[playerid][slotid][pCarMod11] = PlayerVehicles[GetPVarInt(playerid, "CarOffer")][slot][pCarMod11];
  2234. PlayerVehicles[playerid][slotid][pCarMod12] = PlayerVehicles[GetPVarInt(playerid, "CarOffer")][slot][pCarMod12];
  2235. PlayerVehicles[playerid][slotid][pCarMod13] = PlayerVehicles[GetPVarInt(playerid, "CarOffer")][slot][pCarMod13];
  2236. PlayerVehicles[playerid][slotid][pCarMod14] = PlayerVehicles[GetPVarInt(playerid, "CarOffer")][slot][pCarMod14];
  2237. PlayerVehicles[playerid][slotid][pCarMod15] = PlayerVehicles[GetPVarInt(playerid, "CarOffer")][slot][pCarMod15];
  2238. PlayerVehicles[playerid][slotid][pCarMod16] = PlayerVehicles[GetPVarInt(playerid, "CarOffer")][slot][pCarMod16];
  2239. PlayerVehicles[playerid][slotid][pCarMod17] = PlayerVehicles[GetPVarInt(playerid, "CarOffer")][slot][pCarMod17];
  2240. PlayerVehicles[playerid][slotid][pCarHasLock] = PlayerVehicles[GetPVarInt(playerid, "CarOffer")][slot][pCarHasLock];
  2241. PlayerVehicles[playerid][slotid][pCarLocked] = PlayerVehicles[GetPVarInt(playerid, "CarOffer")][slot][pCarLocked];
  2242. PlayerVehicles[playerid][slotid][pCarTrunkCash] = PlayerVehicles[GetPVarInt(playerid, "CarOffer")][slot][pCarTrunkCash];
  2243. PlayerVehicles[playerid][slotid][pCarTrunkGun1] = PlayerVehicles[GetPVarInt(playerid, "CarOffer")][slot][pCarTrunkGun1];
  2244. PlayerVehicles[playerid][slotid][pCarTrunkGun2] = PlayerVehicles[GetPVarInt(playerid, "CarOffer")][slot][pCarTrunkGun2];
  2245. PlayerVehicles[playerid][slotid][pCarTrunkGun3] = PlayerVehicles[GetPVarInt(playerid, "CarOffer")][slot][pCarTrunkGun3];
  2246. PlayerVehicles[playerid][slotid][pCarTrunkGun4] = PlayerVehicles[GetPVarInt(playerid, "CarOffer")][slot][pCarTrunkGun4];
  2247. PlayerVehicles[playerid][slotid][pCarTrunkAmmo1] = PlayerVehicles[GetPVarInt(playerid, "CarOffer")][slot][pCarTrunkAmmo1];
  2248. PlayerVehicles[playerid][slotid][pCarTrunkAmmo2] = PlayerVehicles[GetPVarInt(playerid, "CarOffer")][slot][pCarTrunkAmmo2];
  2249. PlayerVehicles[playerid][slotid][pCarTrunkAmmo3] = PlayerVehicles[GetPVarInt(playerid, "CarOffer")][slot][pCarTrunkAmmo3];
  2250. PlayerVehicles[playerid][slotid][pCarTrunkAmmo4] = PlayerVehicles[GetPVarInt(playerid, "CarOffer")][slot][pCarTrunkAmmo4];
  2251. PlayerVehicles[playerid][slotid][pCarSpawned] = PlayerVehicles[GetPVarInt(playerid, "CarOffer")][slot][pCarSpawned];
  2252. PlayerVehicles[playerid][slotid][pCarOwned] = PlayerVehicles[GetPVarInt(playerid, "CarOffer")][slot][pCarOwned];
  2253. PlayerVehicles[playerid][slotid][pCarID] = PlayerVehicles[GetPVarInt(playerid, "CarOffer")][slot][pCarID];
  2254.  
  2255. format(query, sizeof(query), "DELETE FROM `VEHICLES` WHERE `Name` = '%s' AND `Slot` = '%d'", PlayerName(GetPVarInt(playerid, "CarOffer")), slot);
  2256. db_query(VehicleDatabase[GetPVarInt(playerid, "CarOffer")], query);
  2257. PlayerVehicles[GetPVarInt(playerid, "CarOffer")][slot][pCarModel] = 0;
  2258. PlayerVehicles[GetPVarInt(playerid, "CarOffer")][slot][pCarX] = 0.0;
  2259. PlayerVehicles[GetPVarInt(playerid, "CarOffer")][slot][pCarY] = 0.0;
  2260. PlayerVehicles[GetPVarInt(playerid, "CarOffer")][slot][pCarZ] = 0.0;
  2261. PlayerVehicles[GetPVarInt(playerid, "CarOffer")][slot][pCarRot] = 0.0;
  2262. PlayerVehicles[GetPVarInt(playerid, "CarOffer")][slot][pCarColor1] = 0;
  2263. PlayerVehicles[GetPVarInt(playerid, "CarOffer")][slot][pCarColor2] = 0;
  2264. PlayerVehicles[GetPVarInt(playerid, "CarOffer")][slot][pCarPaintjob] = -1;
  2265. PlayerVehicles[GetPVarInt(playerid, "CarOffer")][slot][pCarMod1] = 0;
  2266. PlayerVehicles[GetPVarInt(playerid, "CarOffer")][slot][pCarMod2] = 0;
  2267. PlayerVehicles[GetPVarInt(playerid, "CarOffer")][slot][pCarMod3] = 0;
  2268. PlayerVehicles[GetPVarInt(playerid, "CarOffer")][slot][pCarMod4] = 0;
  2269. PlayerVehicles[GetPVarInt(playerid, "CarOffer")][slot][pCarMod5] = 0;
  2270. PlayerVehicles[GetPVarInt(playerid, "CarOffer")][slot][pCarMod6] = 0;
  2271. PlayerVehicles[GetPVarInt(playerid, "CarOffer")][slot][pCarMod7] = 0;
  2272. PlayerVehicles[GetPVarInt(playerid, "CarOffer")][slot][pCarMod8] = 0;
  2273. PlayerVehicles[GetPVarInt(playerid, "CarOffer")][slot][pCarMod9] = 0;
  2274. PlayerVehicles[GetPVarInt(playerid, "CarOffer")][slot][pCarMod10] = 0;
  2275. PlayerVehicles[GetPVarInt(playerid, "CarOffer")][slot][pCarMod11] = 0;
  2276. PlayerVehicles[GetPVarInt(playerid, "CarOffer")][slot][pCarMod12] = 0;
  2277. PlayerVehicles[GetPVarInt(playerid, "CarOffer")][slot][pCarMod13] = 0;
  2278. PlayerVehicles[GetPVarInt(playerid, "CarOffer")][slot][pCarMod14] = 0;
  2279. PlayerVehicles[GetPVarInt(playerid, "CarOffer")][slot][pCarMod15] = 0;
  2280. PlayerVehicles[GetPVarInt(playerid, "CarOffer")][slot][pCarMod16] = 0;
  2281. PlayerVehicles[GetPVarInt(playerid, "CarOffer")][slot][pCarMod17] = 0;
  2282. PlayerVehicles[GetPVarInt(playerid, "CarOffer")][slot][pCarHasLock] = 0;
  2283. PlayerVehicles[GetPVarInt(playerid, "CarOffer")][slot][pCarLocked] = 0;
  2284. PlayerVehicles[GetPVarInt(playerid, "CarOffer")][slot][pCarTrunkCash] = 0;
  2285. PlayerVehicles[GetPVarInt(playerid, "CarOffer")][slot][pCarTrunkGun1] = 0;
  2286. PlayerVehicles[GetPVarInt(playerid, "CarOffer")][slot][pCarTrunkGun2] = 0;
  2287. PlayerVehicles[GetPVarInt(playerid, "CarOffer")][slot][pCarTrunkGun3] = 0;
  2288. PlayerVehicles[GetPVarInt(playerid, "CarOffer")][slot][pCarTrunkGun4] = 0;
  2289. PlayerVehicles[GetPVarInt(playerid, "CarOffer")][slot][pCarTrunkAmmo1] = 0;
  2290. PlayerVehicles[GetPVarInt(playerid, "CarOffer")][slot][pCarTrunkAmmo2] = 0;
  2291. PlayerVehicles[GetPVarInt(playerid, "CarOffer")][slot][pCarTrunkAmmo3] = 0;
  2292. PlayerVehicles[GetPVarInt(playerid, "CarOffer")][slot][pCarTrunkAmmo4] = 0;
  2293. PlayerVehicles[GetPVarInt(playerid, "CarOffer")][slot][pCarSpawned] = 0;
  2294. PlayerVehicles[GetPVarInt(playerid, "CarOffer")][slot][pCarOwned] = 0;
  2295. PlayerVehicles[GetPVarInt(playerid, "CarOffer")][slot][pCarID] = 0;
  2296.  
  2297. SetPVarInt(playerid, "CarOffer", INVALID_PLAYER_ID);
  2298. DeletePVar(playerid, "CarPrice");
  2299. DeletePVar(playerid, "CarSlot");
  2300. return 1;
  2301. }
  2302. }
  2303. else return SendClientMessage(playerid, GREY, "You already own the maximum amount of vehicles.");
  2304. }
  2305. else return SendClientMessage(playerid, GREY, "You can't afford that.");
  2306. }
  2307. else return SendClientMessage(playerid, GREY, "You are not near the player who offered you the car.");
  2308. }
  2309. else return SendClientMessage(playerid, GREY, "Nobody offered you a car.");
  2310. }
  2311. return 1;
  2312. }
  2313.  
  2314. CMD:trunkput(playerid, params[])
  2315. {
  2316. new carcount;
  2317. new slotid = -1;
  2318. new string[128];
  2319. if (IsPlayerInAnyVehicle(playerid))
  2320. return SendClientMessage(playerid, GREY, "You cannot use this command while inside a vehicle.");
  2321. for (new i = 1; i < MAX_PLAYER_CARS + 1; i += 1)
  2322. {
  2323. if (!PlayerVehicles[playerid][i][pCarOwned]) continue;
  2324. if (!PlayerVehicles[playerid][i][pCarSpawned]) continue;
  2325. if (IsPlayerNearVehicle(playerid, PlayerVehicles[playerid][i][pCarID], 3.5))
  2326. {
  2327. slotid = i;
  2328. carcount += 1;
  2329. }
  2330. }
  2331. if (slotid == -1 && !carcount)
  2332. return SendClientMessage(playerid, GREY, "You are not near any vehicle that you've purchased.");
  2333.  
  2334. if (carcount >= 2)
  2335. return SendClientMessage(playerid, GREY, "There are too many vehicles in range.");
  2336.  
  2337. new name[24], value;
  2338. if (sscanf(params, "sd", name, value)) return SendClientMessage(playerid, GREY, "USAGE: /trunkput [name] [value]"), SendClientMessage(playerid, GREY, "Available names: cash, weapon");
  2339. if (strlen(name) > 22) return 1;
  2340. if (strcmp(name, "cash", true) == 0)
  2341. {
  2342. if (GetPlayerMoney(playerid) <= 0)
  2343. return SendClientMessage(playerid, GREY, "You don't have any money.");
  2344.  
  2345. if (value > GetPlayerMoney(playerid) || value < 1)
  2346. return SendClientMessage(playerid, GREY, "You don't have that much.");
  2347.  
  2348. PlayerVehicles[playerid][slotid][pCarTrunkCash] += value;
  2349. GivePlayerMoney(playerid, -value);
  2350. format(string, sizeof(string), "You have stored $%d into your vehicle.", value);
  2351. SendClientMessage(playerid, WHITE, string);
  2352. return 1;
  2353. }
  2354. if (strcmp(name, "weapon", true) == 0)
  2355. {
  2356. if (!GetPlayerWeapon(playerid))
  2357. return SendClientMessage(playerid, GREY, "You must equip the weapon you're storing.");
  2358.  
  2359. if (value < 1 || value > 4) return SendClientMessage(playerid, GREY, "Invalid slot. Slots range from 1-4.");
  2360. if (value == 1 && PlayerVehicles[playerid][slotid][pCarTrunkGun1]) return SendClientMessage(playerid, GREY, "You already have a weapon in that slot.");
  2361. if (value == 2 && PlayerVehicles[playerid][slotid][pCarTrunkGun2]) return SendClientMessage(playerid, GREY, "You already have a weapon in that slot.");
  2362. if (value == 3 && PlayerVehicles[playerid][slotid][pCarTrunkGun3]) return SendClientMessage(playerid, GREY, "You already have a weapon in that slot.");
  2363. if (value == 4 && PlayerVehicles[playerid][slotid][pCarTrunkGun4]) return SendClientMessage(playerid, GREY, "You already have a weapon in that slot.");
  2364.  
  2365. new weapon[24];
  2366. GetWeaponNameEx(GetPlayerWeapon(playerid), weapon, 24);
  2367.  
  2368. switch (value)
  2369. {
  2370. case 1: { PlayerVehicles[playerid][slotid][pCarTrunkGun1] = GetPlayerWeapon(playerid); PlayerVehicles[playerid][slotid][pCarTrunkAmmo1] = GetPlayerAmmo(playerid); }
  2371. case 2: { PlayerVehicles[playerid][slotid][pCarTrunkGun2] = GetPlayerWeapon(playerid); PlayerVehicles[playerid][slotid][pCarTrunkAmmo2] = GetPlayerAmmo(playerid); }
  2372. case 3: { PlayerVehicles[playerid][slotid][pCarTrunkGun3] = GetPlayerWeapon(playerid); PlayerVehicles[playerid][slotid][pCarTrunkAmmo3] = GetPlayerAmmo(playerid); }
  2373. case 4: { PlayerVehicles[playerid][slotid][pCarTrunkGun4] = GetPlayerWeapon(playerid); PlayerVehicles[playerid][slotid][pCarTrunkAmmo4] = GetPlayerAmmo(playerid); }
  2374. }
  2375. RemovePlayerWeapon(playerid, GetPlayerWeapon(playerid));
  2376. format(string, sizeof(string), "You have stored a %s into slot %d of your vehicle.", weapon, value);
  2377. SendClientMessage(playerid, WHITE, string);
  2378. return 1;
  2379. }
  2380. return 1;
  2381. }
  2382.  
  2383. CMD:trunktake(playerid, params[])
  2384. {
  2385. new carcount;
  2386. new slotid = -1;
  2387. new string[128];
  2388. if (IsPlayerInAnyVehicle(playerid))
  2389. return SendClientMessage(playerid, GREY, "You cannot use this command while inside a vehicle.");
  2390. for (new i = 1; i < MAX_PLAYER_CARS + 1; i += 1)
  2391. {
  2392. if (!PlayerVehicles[playerid][i][pCarOwned]) continue;
  2393. if (!PlayerVehicles[playerid][i][pCarSpawned]) continue;
  2394. if (IsPlayerNearVehicle(playerid, PlayerVehicles[playerid][i][pCarID], 3.5))
  2395. {
  2396. slotid = i;
  2397. carcount += 1;
  2398. }
  2399. }
  2400. if (slotid == -1 && !carcount)
  2401. return SendClientMessage(playerid, GREY, "You are not near any vehicle that you've purchased.");
  2402.  
  2403. if (carcount >= 2)
  2404. return SendClientMessage(playerid, GREY, "There are too many vehicles in range.");
  2405.  
  2406. new name[24], value;
  2407. if (sscanf(params, "sd", name, value)) return SendClientMessage(playerid, GREY, "USAGE: /trunktake [name] [value]"), SendClientMessage(playerid, GREY, "Available names: cash, weapon");
  2408. if (strlen(name) > 22) return 1;
  2409. if (strcmp(name, "cash", true) == 0)
  2410. {
  2411. if (PlayerVehicles[playerid][slotid][pCarTrunkCash] <= 0)
  2412. return SendClientMessage(playerid, GREY, "You don't have any money in your trunk.");
  2413.  
  2414. if (value > PlayerVehicles[playerid][slotid][pCarTrunkCash] || value < 1)
  2415. return SendClientMessage(playerid, GREY, "You don't have that much money in your trunk.");
  2416.  
  2417. PlayerVehicles[playerid][slotid][pCarTrunkCash] -= value;
  2418. GivePlayerMoney(playerid, value);
  2419. format(string, sizeof(string), "You have taken $%d from your vehicle.", value);
  2420. SendClientMessage(playerid, WHITE, string);
  2421. return 1;
  2422. }
  2423. if (strcmp(name, "weapon", true) == 0)
  2424. {
  2425. new weaponid, ammo;
  2426. if (value < 1 || value > 4) return SendClientMessage(playerid, GREY, "Invalid slot. Slots range from 1-4.");
  2427. switch (value)
  2428. {
  2429. case 1: { weaponid = PlayerVehicles[playerid][slotid][pCarTrunkGun1]; ammo = PlayerVehicles[playerid][slotid][pCarTrunkAmmo1]; }
  2430. case 2: { weaponid = PlayerVehicles[playerid][slotid][pCarTrunkGun2]; ammo = PlayerVehicles[playerid][slotid][pCarTrunkAmmo2]; }
  2431. case 3: { weaponid = PlayerVehicles[playerid][slotid][pCarTrunkGun3]; ammo = PlayerVehicles[playerid][slotid][pCarTrunkAmmo3]; }
  2432. case 4: { weaponid = PlayerVehicles[playerid][slotid][pCarTrunkGun4]; ammo = PlayerVehicles[playerid][slotid][pCarTrunkAmmo4]; }
  2433. }
  2434. if (!weaponid) return SendClientMessage(playerid, GREY, "You don't have any weapon in that slot.");
  2435.  
  2436. new weapon[24];
  2437. GetWeaponNameEx(weaponid, weapon, 24);
  2438. if (value == 1) PlayerVehicles[playerid][slotid][pCarTrunkGun1] = 0, PlayerVehicles[playerid][slotid][pCarTrunkAmmo1] = 0;
  2439. if (value == 2) PlayerVehicles[playerid][slotid][pCarTrunkGun2] = 0, PlayerVehicles[playerid][slotid][pCarTrunkAmmo2] = 0;
  2440. if (value == 3) PlayerVehicles[playerid][slotid][pCarTrunkGun3] = 0, PlayerVehicles[playerid][slotid][pCarTrunkAmmo3] = 0;
  2441. if (value == 4) PlayerVehicles[playerid][slotid][pCarTrunkGun4] = 0, PlayerVehicles[playerid][slotid][pCarTrunkAmmo4] = 0;
  2442.  
  2443. GivePlayerWeapon(playerid, weaponid, ammo);
  2444. format(string, sizeof(string), "You have taken a %s from slot %d of your vehicle.", weapon, value);
  2445. SendClientMessage(playerid, WHITE, string);
  2446. return 1;
  2447. }
  2448. return 1;
  2449. }
  2450.  
  2451. CMD:trunkbalance(playerid, params[])
  2452. {
  2453. new carcount;
  2454. new slotid = -1;
  2455. new string[128];
  2456. if (IsPlayerInAnyVehicle(playerid))
  2457. return SendClientMessage(playerid, GREY, "You cannot use this command while inside a vehicle.");
  2458. for (new i = 1; i < MAX_PLAYER_CARS + 1; i += 1)
  2459. {
  2460. if (!PlayerVehicles[playerid][i][pCarOwned]) continue;
  2461. if (!PlayerVehicles[playerid][i][pCarSpawned]) continue;
  2462. if (IsPlayerNearVehicle(playerid, PlayerVehicles[playerid][i][pCarID], 3.5))
  2463. {
  2464. slotid = i;
  2465. carcount += 1;
  2466. }
  2467. }
  2468. if (slotid == -1 && !carcount)
  2469. return SendClientMessage(playerid, GREY, "You are not near any vehicle that you've purchased.");
  2470.  
  2471. if (carcount >= 2)
  2472. return SendClientMessage(playerid, GREY, "There are too many vehicles in range.");
  2473.  
  2474. new weapon1[24];
  2475. new weapon2[24];
  2476. new weapon3[24];
  2477. new weapon4[24];
  2478.  
  2479. GetWeaponNameEx(PlayerVehicles[playerid][slotid][pCarTrunkGun1], weapon1, 24);
  2480. GetWeaponNameEx(PlayerVehicles[playerid][slotid][pCarTrunkGun2], weapon2, 24);
  2481. GetWeaponNameEx(PlayerVehicles[playerid][slotid][pCarTrunkGun3], weapon3, 24);
  2482. GetWeaponNameEx(PlayerVehicles[playerid][slotid][pCarTrunkGun4], weapon4, 24);
  2483.  
  2484. SendClientMessage(playerid, GREEN, "_________________________________");
  2485. SendClientMessage(playerid, WHITE, "** Trunk Balance **");
  2486. format(string, sizeof(string), "Cash: $%d", PlayerVehicles[playerid][slotid][pCarTrunkCash]);
  2487. SendClientMessage(playerid, WHITE, string);
  2488. format(string, sizeof(string), "Weapon 1: %s | Ammo: %d", weapon1, PlayerVehicles[playerid][slotid][pCarTrunkAmmo1]);
  2489. SendClientMessage(playerid, WHITE, string);
  2490. format(string, sizeof(string), "Weapon 2: %s | Ammo: %d", weapon2, PlayerVehicles[playerid][slotid][pCarTrunkAmmo2]);
  2491. SendClientMessage(playerid, WHITE, string);
  2492. format(string, sizeof(string), "Weapon 3: %s | Ammo: %d", weapon3, PlayerVehicles[playerid][slotid][pCarTrunkAmmo3]);
  2493. SendClientMessage(playerid, WHITE, string);
  2494. format(string, sizeof(string), "Weapon 4: %s | Ammo: %d", weapon4, PlayerVehicles[playerid][slotid][pCarTrunkAmmo4]);
  2495. SendClientMessage(playerid, WHITE, string);
  2496. SendClientMessage(playerid, GREEN, "_________________________________");
  2497. return 1;
  2498. }
Add Comment
Please, Sign In to add comment