Guest User

SaveTuning By Baily

a guest
Oct 29th, 2011
3,056
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.12 KB | None | 0 0
  1. #include <a_samp>
  2. #include <dini>
  3. /* TUNING SAVER BY Baily */
  4. forward TuneThisCar(vehicleid);
  5. forward LoadModsForAll(vehicleid);
  6. forward SaveModsForAll(vehicleid);
  7. new spoiler[20][0] = {
  8. {1000},
  9. {1001},
  10. {1002},
  11. {1003},
  12. {1014},
  13. {1015},
  14. {1016},
  15. {1023},
  16. {1058},
  17. {1060},
  18. {1049},
  19. {1050},
  20. {1138},
  21. {1139},
  22. {1146},
  23. {1147},
  24. {1158},
  25. {1162},
  26. {1163},
  27. {1164}
  28. };
  29.  
  30. new nitro[3][0] = {
  31. {1008},
  32. {1009},
  33. {1010}
  34. };
  35.  
  36. new fbumper[23][0] = {
  37. {1117},
  38. {1152},
  39. {1153},
  40. {1155},
  41. {1157},
  42. {1160},
  43. {1165},
  44. {1167},
  45. {1169},
  46. {1170},
  47. {1171},
  48. {1172},
  49. {1173},
  50. {1174},
  51. {1175},
  52. {1179},
  53. {1181},
  54. {1182},
  55. {1185},
  56. {1188},
  57. {1189},
  58. {1192},
  59. {1193}
  60. };
  61.  
  62. new rbumper[22][0] = {
  63. {1140},
  64. {1141},
  65. {1148},
  66. {1149},
  67. {1150},
  68. {1151},
  69. {1154},
  70. {1156},
  71. {1159},
  72. {1161},
  73. {1166},
  74. {1168},
  75. {1176},
  76. {1177},
  77. {1178},
  78. {1180},
  79. {1183},
  80. {1184},
  81. {1186},
  82. {1187},
  83. {1190},
  84. {1191}
  85. };
  86.  
  87. new exhaust[28][0] = {
  88. {1018},
  89. {1019},
  90. {1020},
  91. {1021},
  92. {1022},
  93. {1028},
  94. {1029},
  95. {1037},
  96. {1043},
  97. {1044},
  98. {1045},
  99. {1046},
  100. {1059},
  101. {1064},
  102. {1065},
  103. {1066},
  104. {1089},
  105. {1092},
  106. {1104},
  107. {1105},
  108. {1113},
  109. {1114},
  110. {1126},
  111. {1127},
  112. {1129},
  113. {1132},
  114. {1135},
  115. {1136}
  116. };
  117.  
  118. new bventr[2][0] = {
  119. {1042},
  120. {1044}
  121. };
  122.  
  123. new bventl[2][0] = {
  124. {1043},
  125. {1045}
  126. };
  127.  
  128. new bscoop[4][0] = {
  129. {1004},
  130. {1005},
  131. {1011},
  132. {1012}
  133. };
  134.  
  135. new rscoop[13][0] = {
  136. {1006},
  137. {1032},
  138. {1033},
  139. {1035},
  140. {1038},
  141. {1053},
  142. {1054},
  143. {1055},
  144. {1061},
  145. {1067},
  146. {1068},
  147. {1088},
  148. {1091}
  149. };
  150.  
  151. new lskirt[21][0] = {
  152. {1007},
  153. {1026},
  154. {1031},
  155. {1036},
  156. {1039},
  157. {1042},
  158. {1047},
  159. {1048},
  160. {1056},
  161. {1057},
  162. {1069},
  163. {1070},
  164. {1090},
  165. {1093},
  166. {1106},
  167. {1108},
  168. {1118},
  169. {1119},
  170. {1133},
  171. {1122},
  172. {1134}
  173. };
  174.  
  175. new rskirt[21][0] = {
  176. {1017},
  177. {1027},
  178. {1030},
  179. {1040},
  180. {1041},
  181. {1051},
  182. {1052},
  183. {1062},
  184. {1063},
  185. {1071},
  186. {1072},
  187. {1094},
  188. {1095},
  189. {1099},
  190. {1101},
  191. {1102},
  192. {1107},
  193. {1120},
  194. {1121},
  195. {1124},
  196. {1137}
  197. };
  198.  
  199. new hydraulics[1][0] = {
  200. {1087}
  201. };
  202.  
  203. new base[1][0] = {
  204. {1086}
  205. };
  206.  
  207. new rbbars[2][0] = {
  208. {1109},
  209. {1110}
  210. };
  211.  
  212. new fbbars[2][0] = {
  213. {1115},
  214. {1116}
  215. };
  216.  
  217. new wheels[17][0] = {
  218. {1025},
  219. {1073},
  220. {1074},
  221. {1075},
  222. {1076},
  223. {1077},
  224. {1078},
  225. {1079},
  226. {1080},
  227. {1081},
  228. {1082},
  229. {1083},
  230. {1084},
  231. {1085},
  232. {1096},
  233. {1097},
  234. {1098}
  235. };
  236.  
  237. new lights[2][0] = {
  238. {1013},
  239. {1024}
  240. };
  241. //
  242. enum tInfo
  243. {
  244. mod1,
  245. mod2,
  246. mod3,
  247. mod4,
  248. mod5,
  249. mod6,
  250. mod7,
  251. mod8,
  252. mod9,
  253. mod10,
  254. mod11,
  255. mod12,
  256. mod13,
  257. mod14,
  258. mod15,
  259. mod16,
  260. mod17,
  261. paintjob,
  262. colorA,
  263. colorB,
  264. }
  265. new TuneCar[MAX_VEHICLES][tInfo];
  266.  
  267. #define FILTERSCRIPT
  268.  
  269. #if defined FILTERSCRIPT
  270.  
  271. public OnFilterScriptInit()
  272. {
  273. print("\n--------------------------------------");
  274. print(" Tuning SaVe by Baily");
  275. print("--------------------------------------\n");
  276. return 1;
  277. }
  278.  
  279. public OnFilterScriptExit()
  280. {
  281. return 1;
  282. }
  283.  
  284. #else
  285.  
  286. main()
  287. {
  288. }
  289.  
  290. #endif
  291.  
  292.  
  293. public OnGameModeExit()
  294. {
  295. return 1;
  296. }
  297.  
  298. public OnPlayerRequestClass(playerid, classid)
  299. {
  300. return 1;
  301. }
  302.  
  303. public OnPlayerRequestSpawn(playerid)
  304. {
  305. return 1;
  306. }
  307.  
  308. public OnPlayerConnect(playerid)
  309. {
  310. return 1;
  311. }
  312.  
  313. public OnPlayerDisconnect(playerid, reason)
  314. {
  315. return 1;
  316. }
  317.  
  318. public OnPlayerSpawn(playerid)
  319. {
  320. return 1;
  321. }
  322.  
  323. public OnPlayerDeath(playerid, killerid, reason)
  324. {
  325. return 1;
  326. }
  327.  
  328. public OnVehicleSpawn(vehicleid)
  329. {
  330. LoadModsForAll(vehicleid);
  331. TuneThisCar(vehicleid);
  332. return 1;
  333. }
  334.  
  335. public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
  336. {
  337. LoadModsForAll(vehicleid);
  338. TuneThisCar(vehicleid);
  339. return 1;
  340. }
  341.  
  342. public OnPlayerExitVehicle(playerid, vehicleid)
  343. {
  344. SaveModsForAll(vehicleid);
  345. return 1;
  346. }
  347.  
  348. public OnPlayerStateChange(playerid, newstate, oldstate)
  349. {
  350. return 1;
  351. }
  352.  
  353. public OnPlayerEnterCheckpoint(playerid)
  354. {
  355. return 1;
  356. }
  357.  
  358. public OnPlayerLeaveCheckpoint(playerid)
  359. {
  360. return 1;
  361. }
  362.  
  363. public OnPlayerEnterRaceCheckpoint(playerid)
  364. {
  365. return 1;
  366. }
  367.  
  368. public OnPlayerLeaveRaceCheckpoint(playerid)
  369. {
  370. return 1;
  371. }
  372.  
  373. public OnRconCommand(cmd[])
  374. {
  375. return 1;
  376. }
  377.  
  378. public OnObjectMoved(objectid)
  379. {
  380. return 1;
  381. }
  382.  
  383. public OnPlayerObjectMoved(playerid, objectid)
  384. {
  385. return 1;
  386. }
  387.  
  388. public OnPlayerPickUpPickup(playerid, pickupid)
  389. {
  390. return 1;
  391. }
  392.  
  393. public OnPlayerSelectedMenuRow(playerid, row)
  394. {
  395. return 1;
  396. }
  397.  
  398. public OnPlayerExitedMenu(playerid)
  399. {
  400. return 1;
  401. }
  402. //
  403. public TuneThisCar(vehicleid)
  404. {
  405. if(TuneCar[vehicleid][mod1]!=0) { AddVehicleComponent(vehicleid,TuneCar[vehicleid][mod1]); }
  406. if(TuneCar[vehicleid][mod2]!=0) { AddVehicleComponent(vehicleid,TuneCar[vehicleid][mod2]); }
  407. if(TuneCar[vehicleid][mod3]!=0) { AddVehicleComponent(vehicleid,TuneCar[vehicleid][mod3]); }
  408. if(TuneCar[vehicleid][mod4]!=0) { AddVehicleComponent(vehicleid,TuneCar[vehicleid][mod4]); }
  409. if(TuneCar[vehicleid][mod5]!=0) { AddVehicleComponent(vehicleid,TuneCar[vehicleid][mod5]); }
  410. if(TuneCar[vehicleid][mod6]!=0) { AddVehicleComponent(vehicleid,TuneCar[vehicleid][mod6]); }
  411. if(TuneCar[vehicleid][mod7]!=0) { AddVehicleComponent(vehicleid,TuneCar[vehicleid][mod7]); }
  412. if(TuneCar[vehicleid][mod8]!=0) { AddVehicleComponent(vehicleid,TuneCar[vehicleid][mod8]); }
  413. if(TuneCar[vehicleid][mod9]!=0) { AddVehicleComponent(vehicleid,TuneCar[vehicleid][mod9]); }
  414. if(TuneCar[vehicleid][mod10]!=0) { AddVehicleComponent(vehicleid,TuneCar[vehicleid][mod10]); }
  415. if(TuneCar[vehicleid][mod11]!=0) { AddVehicleComponent(vehicleid,TuneCar[vehicleid][mod11]); }
  416. if(TuneCar[vehicleid][mod12]!=0) { AddVehicleComponent(vehicleid,TuneCar[vehicleid][mod12]); }
  417. if(TuneCar[vehicleid][mod13]!=0) { AddVehicleComponent(vehicleid,TuneCar[vehicleid][mod13]); }
  418. if(TuneCar[vehicleid][mod14]!=0) { AddVehicleComponent(vehicleid,TuneCar[vehicleid][mod14]); }
  419. if(TuneCar[vehicleid][mod15]!=0) { AddVehicleComponent(vehicleid,TuneCar[vehicleid][mod15]); }
  420. if(TuneCar[vehicleid][mod16]!=0) { AddVehicleComponent(vehicleid,TuneCar[vehicleid][mod16]); }
  421. if(TuneCar[vehicleid][mod17]!=0) { AddVehicleComponent(vehicleid,TuneCar[vehicleid][mod17]); }
  422. if(TuneCar[vehicleid][colorA]!=0 || TuneCar[vehicleid][colorB]!=0)
  423. {
  424. ChangeVehicleColor(vehicleid,TuneCar[vehicleid][colorA],TuneCar[vehicleid][colorB]);
  425. }
  426. if(TuneCar[vehicleid][paintjob]!=0) { ChangeVehiclePaintjob(vehicleid,TuneCar[vehicleid][paintjob]); }
  427. return 1;
  428. }
  429. InitComponents(componentid)
  430. {
  431. new i;
  432. for(i=0; i<20; i++)
  433. {
  434. if(spoiler[i][0]==componentid) { return 1; }
  435. }
  436. for(i=0; i<3; i++)
  437. {
  438. if(nitro[i][0]==componentid) { return 2; }
  439. }
  440. for(i=0; i<23; i++)
  441. {
  442. if(fbumper[i][0]==componentid) { return 3; }
  443. }
  444. for(i=0; i<22; i++)
  445. {
  446. if(rbumper[i][0]==componentid) { return 4; }
  447. }
  448. for(i=0; i<28; i++)
  449. {
  450. if(exhaust[i][0]==componentid) { return 5; }
  451. }
  452. for(i=0; i<2; i++)
  453. {
  454. if(bventr[i][0]==componentid) { return 6; }
  455. }
  456. for(i=0; i<2; i++)
  457. {
  458. if(bventl[i][0]==componentid) { return 7; }
  459. }
  460. for(i=0; i<4; i++)
  461. {
  462. if(bscoop[i][0]==componentid) { return 8; }
  463. }
  464. for(i=0; i<13; i++)
  465. {
  466. if(rscoop[i][0]==componentid) { return 9; }
  467. }
  468. for(i=0; i<21; i++)
  469. {
  470. if(lskirt[i][0]==componentid) { return 10; }
  471. }
  472. for(i=0; i<21; i++)
  473. {
  474. if(rskirt[i][0]==componentid) { return 11; }
  475. }
  476. if(hydraulics[0][0]==componentid) { return 12; }
  477. if(base[0][0]==componentid) { return 13; }
  478. for(i=0; i<2; i++)
  479. {
  480. if(rbbars[i][0]==componentid) { return 14; }
  481. }
  482. for(i=0; i<2; i++)
  483. {
  484. if(fbbars[i][0]==componentid) { return 15; }
  485. }
  486. for(i=0; i<17; i++)
  487. {
  488. if(wheels[i][0]==componentid) { return 16; }
  489. }
  490. for(i=0; i<2; i++)
  491. {
  492. if(lights[i][0]==componentid) { return 17; }
  493. }
  494. return 0;
  495. }
  496. //
  497. public OnVehicleMod(playerid,vehicleid,componentid)
  498. {
  499. new Varz=InitComponents(componentid);
  500. switch (Varz)
  501. {
  502. case 1: { TuneCar[vehicleid][mod1]=componentid; }
  503. case 2: { TuneCar[vehicleid][mod2]=componentid; }
  504. case 3: { TuneCar[vehicleid][mod3]=componentid; }
  505. case 4: { TuneCar[vehicleid][mod4]=componentid; }
  506. case 5: { TuneCar[vehicleid][mod5]=componentid; }
  507. case 6: { TuneCar[vehicleid][mod6]=componentid; }
  508. case 7: { TuneCar[vehicleid][mod7]=componentid; }
  509. case 8: { TuneCar[vehicleid][mod8]=componentid; }
  510. case 9: { TuneCar[vehicleid][mod9]=componentid; }
  511. case 10: { TuneCar[vehicleid][mod10]=componentid; }
  512. case 11: { TuneCar[vehicleid][mod11]=componentid; }
  513. case 12: { TuneCar[vehicleid][mod12]=componentid; }
  514. case 13: { TuneCar[vehicleid][mod13]=componentid; }
  515. case 14: { TuneCar[vehicleid][mod14]=componentid; }
  516. case 15: { TuneCar[vehicleid][mod15]=componentid; }
  517. case 16: { TuneCar[vehicleid][mod16]=componentid; }
  518. case 17: { TuneCar[vehicleid][mod17]=componentid; }
  519. }
  520. printf("Component Added: %d",componentid);
  521. SaveModsForAll(vehicleid);
  522. return 1;
  523. }
  524.  
  525. public OnVehiclePaintjob(playerid,vehicleid, paintjobid)
  526. {
  527. TuneCar[vehicleid][paintjob]=paintjobid;
  528. return 1;
  529. }
  530. //
  531.  
  532. public LoadModsForAll(vehicleid)
  533. {
  534. new formatLD[256];
  535. format(formatLD,sizeof(formatLD),"Baily_Carlist/%d.mods",vehicleid);
  536. if(dini_Exists(formatLD))
  537. {
  538. TuneCar[vehicleid][mod1] = dini_Int(formatLD, "mod1");
  539. TuneCar[vehicleid][mod2] = dini_Int(formatLD, "mod2");
  540. TuneCar[vehicleid][mod3] = dini_Int(formatLD, "mod3");
  541. TuneCar[vehicleid][mod4] = dini_Int(formatLD, "mod4");
  542. TuneCar[vehicleid][mod5] = dini_Int(formatLD, "mod5");
  543.  
  544. TuneCar[vehicleid][mod6] = dini_Int(formatLD, "mod6");
  545. TuneCar[vehicleid][mod7] = dini_Int(formatLD, "mod7");
  546. TuneCar[vehicleid][mod8] = dini_Int(formatLD, "mod8");
  547. TuneCar[vehicleid][mod9] = dini_Int(formatLD, "mod9");
  548. TuneCar[vehicleid][mod10] = dini_Int(formatLD, "mod10");
  549.  
  550. TuneCar[vehicleid][mod11] = dini_Int(formatLD, "mod11");
  551. TuneCar[vehicleid][mod12] = dini_Int(formatLD, "mod12");
  552. TuneCar[vehicleid][mod13] = dini_Int(formatLD, "mod13");
  553. TuneCar[vehicleid][mod14] = dini_Int(formatLD, "mod14");
  554. TuneCar[vehicleid][mod15] = dini_Int(formatLD, "mod15");
  555.  
  556. TuneCar[vehicleid][mod16] = dini_Int(formatLD, "mod16");
  557. TuneCar[vehicleid][mod17] = dini_Int(formatLD, "mod17");
  558. TuneCar[vehicleid][paintjob] = dini_Int(formatLD, "paintjob");
  559. TuneCar[vehicleid][colorA] = dini_Int(formatLD, "color1");
  560. TuneCar[vehicleid][colorB] = dini_Int(formatLD, "color2");
  561. }
  562. else
  563. {
  564. dini_Create(formatLD);
  565. }
  566. return 0;
  567. }
  568. public SaveModsForAll(vehicleid)
  569. {
  570. new formatLD[256];
  571. format(formatLD,sizeof(formatLD),"Baily_Carlist/%d.mods",vehicleid);
  572. if(dini_Exists(formatLD))
  573. {
  574. dini_IntSet(formatLD,"mod1",TuneCar[vehicleid][mod1]);
  575. dini_IntSet(formatLD,"mod2",TuneCar[vehicleid][mod2]);
  576. dini_IntSet(formatLD,"mod3",TuneCar[vehicleid][mod3]);
  577. dini_IntSet(formatLD,"mod4",TuneCar[vehicleid][mod4]);
  578. dini_IntSet(formatLD,"mod5",TuneCar[vehicleid][mod5]);
  579. dini_IntSet(formatLD,"mod6",TuneCar[vehicleid][mod6]);
  580. dini_IntSet(formatLD,"mod7",TuneCar[vehicleid][mod8]);
  581. dini_IntSet(formatLD,"mod9",TuneCar[vehicleid][mod9]);
  582. dini_IntSet(formatLD,"mod10",TuneCar[vehicleid][mod10]);
  583. dini_IntSet(formatLD,"mod11",TuneCar[vehicleid][mod11]);
  584. dini_IntSet(formatLD,"mod12",TuneCar[vehicleid][mod12]);
  585. dini_IntSet(formatLD,"mod13",TuneCar[vehicleid][mod13]);
  586. dini_IntSet(formatLD,"mod14",TuneCar[vehicleid][mod14]);
  587. dini_IntSet(formatLD,"mod15",TuneCar[vehicleid][mod15]);
  588. dini_IntSet(formatLD,"mod16",TuneCar[vehicleid][mod16]);
  589. dini_IntSet(formatLD,"mod17",TuneCar[vehicleid][mod17]);
  590. dini_IntSet(formatLD,"paintjob",TuneCar[vehicleid][paintjob]);
  591. dini_IntSet(formatLD,"color1",TuneCar[vehicleid][colorA]);
  592. dini_IntSet(formatLD,"color2",TuneCar[vehicleid][colorB]);
  593. }
  594. else
  595. {
  596. dini_Create(formatLD);
  597. dini_IntSet(formatLD,"mod1",TuneCar[vehicleid][mod1]);
  598. dini_IntSet(formatLD,"mod2",TuneCar[vehicleid][mod2]);
  599. dini_IntSet(formatLD,"mod3",TuneCar[vehicleid][mod3]);
  600. dini_IntSet(formatLD,"mod4",TuneCar[vehicleid][mod4]);
  601. dini_IntSet(formatLD,"mod5",TuneCar[vehicleid][mod5]);
  602. dini_IntSet(formatLD,"mod6",TuneCar[vehicleid][mod6]);
  603. dini_IntSet(formatLD,"mod7",TuneCar[vehicleid][mod8]);
  604. dini_IntSet(formatLD,"mod9",TuneCar[vehicleid][mod9]);
  605. dini_IntSet(formatLD,"mod10",TuneCar[vehicleid][mod10]);
  606. dini_IntSet(formatLD,"mod11",TuneCar[vehicleid][mod11]);
  607. dini_IntSet(formatLD,"mod12",TuneCar[vehicleid][mod12]);
  608. dini_IntSet(formatLD,"mod13",TuneCar[vehicleid][mod13]);
  609. dini_IntSet(formatLD,"mod14",TuneCar[vehicleid][mod14]);
  610. dini_IntSet(formatLD,"mod15",TuneCar[vehicleid][mod15]);
  611. dini_IntSet(formatLD,"mod16",TuneCar[vehicleid][mod16]);
  612. dini_IntSet(formatLD,"mod17",TuneCar[vehicleid][mod17]);
  613. dini_IntSet(formatLD,"paintjob",TuneCar[vehicleid][paintjob]);
  614. dini_IntSet(formatLD,"color1",TuneCar[vehicleid][colorA]);
  615. dini_IntSet(formatLD,"color2",TuneCar[vehicleid][colorB]);
  616. }
  617. return 0;
  618. }
  619. public OnVehicleRespray(playerid,vehicleid, color1, color2)
  620. {
  621. TuneCar[vehicleid][colorA] = color1;
  622. TuneCar[vehicleid][colorB] = color2;
  623. return 1;
  624. }
  625.  
Advertisement
Add Comment
Please, Sign In to add comment