Guest User

Untitled

a guest
Jan 5th, 2011
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 39.19 KB | None | 0 0
  1. #include <a_samp>
  2. #include <float>
  3.  
  4. // comment out if you do not want to use the /resetcars function
  5. #define RESETCARS
  6.  
  7. // comment out if you do not want to use the /pcarsell function
  8. #define CARSELL
  9.  
  10. #if defined CARSELL
  11. #include <utils>
  12. #endif
  13.  
  14. #define COLOR_GRAD1 0xB4B5B7FF
  15. #define COLOR_GRAD2 0xBFC0C2FF
  16. #define COLOR_GRAD3 0xCBCCCEFF
  17. #define COLOR_GRAD4 0xD8D8D8FF
  18. #define COLOR_GRAD5 0xE3E3E3FF
  19. #define COLOR_GRAD6 0xF0F0F0FF
  20. #define COLOR_GREY 0xAFAFAFAA
  21. #define COLOR_GREEN 0x33AA33AA
  22. #define COLOR_RED 0xAA3333AA
  23. #define COLOR_LIGHTRED 0xFF6347AA
  24. #define COLOR_LIGHTBLUE 0x33CCFFAA
  25. #define COLOR_LIGHTGREEN 0x9ACD32AA
  26. #define COLOR_YELLOW 0xFFFF00AA
  27. #define COLOR_YELLOW2 0xF5DEB3AA
  28. #define COLOR_WHITE 0xFFFFFFAA
  29.  
  30. forward SetVehicleParamsForAll(carid,objective,doorslocked);
  31. forward CreateTunedCar(playerid);
  32. forward DelayDestroyCar(playerid);
  33. forward DelaySetVehicleParams(playerid);
  34. forward ResetAutohausSpawns();
  35.  
  36. enum ahCar
  37. {
  38. Typ,
  39. Float:X,
  40. Float:Y,
  41. Float:Z,
  42. Float:Rotation,
  43. Status,
  44. Lock,
  45. Carid,
  46. Paintjob,
  47. Color1,
  48. Color2,
  49. mod1,
  50. mod2,
  51. mod3,
  52. mod4,
  53. mod5,
  54. mod6,
  55. mod7,
  56. mod8,
  57. mod9,
  58. mod10,
  59. mod11,
  60. mod12,
  61. mod13,
  62. mod14,
  63. mod15,
  64. mod16,
  65. mod17,
  66. };
  67. new Carlist[MAX_PLAYERS][ahCar];
  68.  
  69. enum ahSpawn
  70. {
  71. Float:X,
  72. Float:Y,
  73. Float:Z,
  74. Float:Rotation,
  75. };
  76. new Carspawns[2][ahSpawn] = {
  77. {739.7457,-1343.8668,13.2828,270.2592},
  78. {-1639.3599,1198.1665,6.9527,269.9673}
  79. };
  80.  
  81. enum ahModel
  82. {
  83. Name[128],
  84. Autohaus,
  85. Modelid,
  86. Carid,
  87. Price,
  88. Repair,
  89. Float:X,
  90. Float:Y,
  91. Float:Z,
  92. Float:Rotation,
  93. };
  94. new Buylist[34][ahModel] = {
  95. {"Stallion",0,439,-1,750000,5000,783.0,-1335.0,13.2,121.1},
  96. {"Feltzer",0,533,-1,500000,3000,783.0,-1340.0,13.2,121.1},
  97. {"Windsor",0,555,-1,450000,3400,783.0,-1345.0,13.2,121.1},
  98. {"Blade",0,536,-1,350000,3000,783.0,-1350.0,13.2,121.1},
  99. {"Remington",0,534,-1,500000,3000,783.0,-1355.0,13.2,121.1},
  100. {"Savanna",0,567,-1,350000,3000,783.0,-1360.0,13.2,121.1},
  101. {"Slamvan",0,535,-1,500000,3000,783.0,-1365.0,13.2,121.1},
  102. {"Voodoo",0,412,-1,500000,3000,783.0,-1370.0,13.2,121.1},
  103. {"Huntley",0,579,-1,200000,1000,783.0,-1375.0,13.2,121.1},
  104. {"Buccaneer",0,518,-1,120000,1000,783.0,-1380.0,13.2,121.1},
  105. {"Clover",0,542,-1,35000,500,765.0,-1360.0,13.4,301.1},
  106. {"Elegant",0,507,-1,40000,650,765.0,-1365.0,13.4,301.1},
  107. {"Elegy",0,562,-1,1500000,10000,765.0,-1370.0,13.4,301.1},
  108. {"Esperanto",0,419,-1,65000,650,765.0,-1375.0,13.4,301.1},
  109. {"Fortune",0,526,-1,35000,500,765.0,-1380.0,13.4,301.1},
  110. {"Sultan",0,560,-1,1500000,10000,766.0,-1333.0,13.3,211.1},
  111. {"Sunrise",0,550,-1,300000,2000,761.0,-1333.0,13.3,211.1},
  112. {"Vincent",0,540,-1,280000,2000,756.0,-1333.0,13.3,211.1},
  113. {"Alpha",0,602,-1,230000,2000,751.0,-1333.0,13.3,211.1},
  114. {"Banshee",0,429,-1,1000000,5500,746.0,-1333.0,13.3,211.1},
  115. {"Blista Compact",1,496,-1,350000,2500,-1668.6447,1207.0372,7.0249,309.5959},
  116. {"Buffalo",1,402,-1,500000,3000,-1663.6709,1215.2883,7.0234,274.9868},
  117. {"Bullet",1,541,-1,7500000,17500,-1651.3892,1210.3469,7.0208,281.3321},
  118. {"Cheetah",1,415,-1,4000000,10000,-1677.3560,1207.8099,13.4461,208.2602},
  119. {"Club",1,589,-1,70000,750,-1665.7789,1222.4406,13.4485,279.6459},
  120. {"Euros",1,587,-1,650000,7000,-1660.7256,1217.6407,13.4444,283.1553},
  121. {"Infernus",1,411,-1,1500000,7000,-1653.2462,1210.7842,13.4460,266.7211},
  122. {"Jester",1,559,-1,1500000,10000,-1676.0128,1207.1641,20.9248,261.5029},
  123. {"Phoenix",1,603,-1,600000,4000,-1664.4386,1206.8241,20.9289,332.5978},
  124. {"Super GT",1,506,-1,12500000,20000,-1651.6372,1208.2538,20.9231,305.1015},
  125. {"Turismo",1,451,-1,13000000,20000,-1665.1248,1222.7113,20.9265,267.4103},
  126. {"Uranus",1,558,-1,850000,10000,-1661.1943,1217.9629,20.9268,286.1662},
  127. {"ZR-350",1,477,-1,6500000,7000,-1654.3116,1214.8097,20.9267,173.5712},
  128. {"Faggio",0,462,-1,10000,500,750.7272,-1358.3872,13.0996,273.7736}
  129. };
  130.  
  131. new Spectating[MAX_PLAYERS][1];
  132.  
  133. // begin of tuning component list
  134. new spoiler[20][0] = {
  135. {1000},
  136. {1001},
  137. {1002},
  138. {1003},
  139. {1014},
  140. {1015},
  141. {1016},
  142. {1023},
  143. {1058},
  144. {1060},
  145. {1049},
  146. {1050},
  147. {1138},
  148. {1139},
  149. {1146},
  150. {1147},
  151. {1158},
  152. {1162},
  153. {1163},
  154. {1164}
  155. };
  156.  
  157. new nitro[3][0] = {
  158. {1008},
  159. {1009},
  160. {1010}
  161. };
  162.  
  163. new fbumper[23][0] = {
  164. {1117},
  165. {1152},
  166. {1153},
  167. {1155},
  168. {1157},
  169. {1160},
  170. {1165},
  171. {1167},
  172. {1169},
  173. {1170},
  174. {1171},
  175. {1172},
  176. {1173},
  177. {1174},
  178. {1175},
  179. {1179},
  180. {1181},
  181. {1182},
  182. {1185},
  183. {1188},
  184. {1189},
  185. {1192},
  186. {1193}
  187. };
  188.  
  189. new rbumper[22][0] = {
  190. {1140},
  191. {1141},
  192. {1148},
  193. {1149},
  194. {1150},
  195. {1151},
  196. {1154},
  197. {1156},
  198. {1159},
  199. {1161},
  200. {1166},
  201. {1168},
  202. {1176},
  203. {1177},
  204. {1178},
  205. {1180},
  206. {1183},
  207. {1184},
  208. {1186},
  209. {1187},
  210. {1190},
  211. {1191}
  212. };
  213.  
  214. new exhaust[28][0] = {
  215. {1018},
  216. {1019},
  217. {1020},
  218. {1021},
  219. {1022},
  220. {1028},
  221. {1029},
  222. {1037},
  223. {1043},
  224. {1044},
  225. {1045},
  226. {1046},
  227. {1059},
  228. {1064},
  229. {1065},
  230. {1066},
  231. {1089},
  232. {1092},
  233. {1104},
  234. {1105},
  235. {1113},
  236. {1114},
  237. {1126},
  238. {1127},
  239. {1129},
  240. {1132},
  241. {1135},
  242. {1136}
  243. };
  244.  
  245. new bventr[2][0] = {
  246. {1042},
  247. {1044}
  248. };
  249.  
  250. new bventl[2][0] = {
  251. {1043},
  252. {1045}
  253. };
  254.  
  255. new bscoop[4][0] = {
  256. {1004},
  257. {1005},
  258. {1011},
  259. {1012}
  260. };
  261.  
  262. new rscoop[13][0] = {
  263. {1006},
  264. {1032},
  265. {1033},
  266. {1035},
  267. {1038},
  268. {1053},
  269. {1054},
  270. {1055},
  271. {1061},
  272. {1067},
  273. {1068},
  274. {1088},
  275. {1091}
  276. };
  277.  
  278. new lskirt[21][0] = {
  279. {1007},
  280. {1026},
  281. {1031},
  282. {1036},
  283. {1039},
  284. {1042},
  285. {1047},
  286. {1048},
  287. {1056},
  288. {1057},
  289. {1069},
  290. {1070},
  291. {1090},
  292. {1093},
  293. {1106},
  294. {1108},
  295. {1118},
  296. {1119},
  297. {1133},
  298. {1122},
  299. {1134}
  300. };
  301.  
  302. new rskirt[21][0] = {
  303. {1017},
  304. {1027},
  305. {1030},
  306. {1040},
  307. {1041},
  308. {1051},
  309. {1052},
  310. {1062},
  311. {1063},
  312. {1071},
  313. {1072},
  314. {1094},
  315. {1095},
  316. {1099},
  317. {1101},
  318. {1102},
  319. {1107},
  320. {1120},
  321. {1121},
  322. {1124},
  323. {1137}
  324. };
  325.  
  326. new hydraulics[1][0] = {
  327. {1087}
  328. };
  329.  
  330. new base[1][0] = {
  331. {1086}
  332. };
  333.  
  334. new rbbars[2][0] = {
  335. {1109},
  336. {1110}
  337. };
  338.  
  339. new fbbars[2][0] = {
  340. {1115},
  341. {1116}
  342. };
  343.  
  344. new wheels[17][0] = {
  345. {1025},
  346. {1073},
  347. {1074},
  348. {1075},
  349. {1076},
  350. {1077},
  351. {1078},
  352. {1079},
  353. {1080},
  354. {1081},
  355. {1082},
  356. {1083},
  357. {1084},
  358. {1085},
  359. {1096},
  360. {1097},
  361. {1098}
  362. };
  363.  
  364. new lights[2][0] = {
  365. {1013},
  366. {1024}
  367. };
  368. // end of tuning component list
  369.  
  370. #if defined CARSELL
  371. new offerCar[MAX_PLAYERS][2];
  372. #endif
  373.  
  374. ini_GetKey( line[] )
  375. {
  376. new keyRes[256];
  377. keyRes[0] = 0;
  378. if ( strfind( line , "=" , true ) == -1 ) return keyRes;
  379. strmid( keyRes , line , 0 , strfind( line , "=" , true ) , sizeof( keyRes) );
  380. return keyRes;
  381. }
  382.  
  383. ini_GetValue( line[] )
  384. {
  385. new valRes[256];
  386. valRes[0]=0;
  387. if ( strfind( line , "=" , true ) == -1 ) return valRes;
  388. strmid( valRes , line , strfind( line , "=" , true )+1 , strlen( line ) , sizeof( valRes ) );
  389. return valRes;
  390. }
  391.  
  392. strtok(const string[], &index)
  393. {
  394. new length = strlen(string);
  395. while ((index < length) && (string[index] <= ' '))
  396. {
  397. index++;
  398. }
  399.  
  400. new offset = index;
  401. new result[20];
  402. while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
  403. {
  404. result[index - offset] = string[index];
  405. index++;
  406. }
  407. result[index - offset] = EOS;
  408. return result;
  409. }
  410.  
  411. IsAutohausCar(carid)
  412. {
  413. new i;
  414. for(i=0; i<sizeof(Buylist); i++)
  415. {
  416. if(Buylist[i][Carid]==carid) { return i; }
  417. }
  418. return -1;
  419. }
  420.  
  421. GetPlayerFromCarlistCar(carid)
  422. {
  423. new i;
  424. for(i=0; i<sizeof(Carlist); i++)
  425. {
  426. if(Carlist[i][Carid]==carid) { return i; }
  427. }
  428. return -1;
  429. }
  430.  
  431. GetModType(componentid)
  432. {
  433. new i;
  434. for(i=0; i<20; i++)
  435. {
  436. if(spoiler[i][0]==componentid) { return 1; }
  437. }
  438. for(i=0; i<3; i++)
  439. {
  440. if(nitro[i][0]==componentid) { return 2; }
  441. }
  442. for(i=0; i<23; i++)
  443. {
  444. if(fbumper[i][0]==componentid) { return 3; }
  445. }
  446. for(i=0; i<22; i++)
  447. {
  448. if(rbumper[i][0]==componentid) { return 4; }
  449. }
  450. for(i=0; i<28; i++)
  451. {
  452. if(exhaust[i][0]==componentid) { return 5; }
  453. }
  454. for(i=0; i<2; i++)
  455. {
  456. if(bventr[i][0]==componentid) { return 6; }
  457. }
  458. for(i=0; i<2; i++)
  459. {
  460. if(bventl[i][0]==componentid) { return 7; }
  461. }
  462. for(i=0; i<4; i++)
  463. {
  464. if(bscoop[i][0]==componentid) { return 8; }
  465. }
  466. for(i=0; i<13; i++)
  467. {
  468. if(rscoop[i][0]==componentid) { return 9; }
  469. }
  470. for(i=0; i<21; i++)
  471. {
  472. if(lskirt[i][0]==componentid) { return 10; }
  473. }
  474. for(i=0; i<21; i++)
  475. {
  476. if(rskirt[i][0]==componentid) { return 11; }
  477. }
  478. if(hydraulics[0][0]==componentid) { return 12; }
  479. if(base[0][0]==componentid) { return 13; }
  480. for(i=0; i<2; i++)
  481. {
  482. if(rbbars[i][0]==componentid) { return 14; }
  483. }
  484. for(i=0; i<2; i++)
  485. {
  486. if(fbbars[i][0]==componentid) { return 15; }
  487. }
  488. for(i=0; i<17; i++)
  489. {
  490. if(wheels[i][0]==componentid) { return 16; }
  491. }
  492. for(i=0; i<2; i++)
  493. {
  494. if(lights[i][0]==componentid) { return 17; }
  495. }
  496. return 0;
  497. }
  498.  
  499. public OnFilterScriptInit()
  500. {
  501. print("----------------------------------");
  502. print(" ~*~ Most wanted CarDealership v1.0 ~*~");
  503. print(" ~*~ (c) 2010 by Wezley ~*~");
  504. print("----------------------------------\n");
  505.  
  506. new i;
  507. for(i=0; i<sizeof(Buylist); i++)
  508. {
  509. Buylist[i][Carid]=CreateVehicle(Buylist[i][Modelid],Buylist[i][X],Buylist[i][Y],Buylist[i][Z],Buylist[i][Rotation],-1,-1,-1);
  510. }
  511. for(i=0; i<MAX_PLAYERS; i++)
  512. {
  513. Spectating[i][0]=-1;
  514. }
  515. return 1;
  516. }
  517.  
  518. public OnPlayerConnect(playerid)
  519. {
  520. new dateiname[MAX_PLAYER_NAME+4];
  521. new playername[MAX_PLAYER_NAME];
  522. Carlist[playerid][Typ]=-1; Carlist[playerid][X]=0.0; Carlist[playerid][Y]=0.0; Carlist[playerid][Z]=0.0;
  523. Carlist[playerid][Rotation]=0.0; Carlist[playerid][Status]=0; Carlist[playerid][Lock]=0; Carlist[playerid][Carid]=-1;
  524. Carlist[playerid][Color1]=-1; Carlist[playerid][Color2]=-1; Carlist[playerid][mod1]=-1; Carlist[playerid][mod2]=-1;
  525. Carlist[playerid][mod3]=-1; Carlist[playerid][mod4]=-1; Carlist[playerid][mod5]=-1; Carlist[playerid][mod6]=-1;
  526. Carlist[playerid][mod7]=-1; Carlist[playerid][mod8]=-1; Carlist[playerid][mod9]=-1; Carlist[playerid][mod10]=-1;
  527. Carlist[playerid][mod11]=-1; Carlist[playerid][mod12]=-1; Carlist[playerid][mod13]=-1; Carlist[playerid][mod14]=-1;
  528. Carlist[playerid][mod15]=-1; Carlist[playerid][mod16]=-1; Carlist[playerid][mod17]=-1; Carlist[playerid][Paintjob]=-1;
  529. Spectating[playerid][0]=-1;
  530. #if defined CARSELL
  531. offerCar[playerid]={-1,0};
  532. #endif
  533. GetPlayerName(playerid, playername, sizeof(playername));
  534. format(dateiname, sizeof(dateiname), "%s.car", playername);
  535. if (fexist(dateiname))
  536. {
  537. new File: CarFile = fopen(dateiname, io_read);
  538. if ( CarFile )
  539. {
  540. new key[ 256 ];
  541. new Data[ 256 ];
  542. while ( fread( CarFile , Data , sizeof( Data ) ) )
  543. {
  544. key = ini_GetKey(Data);
  545. if(strcmp(key,"AH_Typ",true)==0) { Carlist[playerid][Typ]=strval(ini_GetValue(Data)); }
  546. else if(strcmp(key,"AH_X",true)==0) { Carlist[playerid][X]=floatstr(ini_GetValue(Data)); }
  547. else if(strcmp(key,"AH_Y",true)==0) { Carlist[playerid][Y]=floatstr(ini_GetValue(Data)); }
  548. else if(strcmp(key,"AH_Z",true)==0) { Carlist[playerid][Z]=floatstr(ini_GetValue(Data)); }
  549. else if(strcmp(key,"AH_Rot",true)==0) { Carlist[playerid][Rotation]=floatstr(ini_GetValue(Data)); }
  550. else if(strcmp(key,"AH_Status",true)==0) { Carlist[playerid][Status]=strval(ini_GetValue(Data)); }
  551. else if(strcmp(key,"AH_Lock",true)==0) { Carlist[playerid][Lock]=strval(ini_GetValue(Data)); }
  552. else if(strcmp(key,"AH_Paintjob",true)==0) { Carlist[playerid][Paintjob]=strval(ini_GetValue(Data)); }
  553. else if(strcmp(key,"AH_Color1",true)==0) { Carlist[playerid][Color1]=strval(ini_GetValue(Data)); }
  554. else if(strcmp(key,"AH_Color2",true)==0) { Carlist[playerid][Color2]=strval(ini_GetValue(Data)); }
  555. else if(strcmp(key,"AH_mod1",true)==0) { Carlist[playerid][mod1]=strval(ini_GetValue(Data)); }
  556. else if(strcmp(key,"AH_mod2",true)==0) { Carlist[playerid][mod2]=strval(ini_GetValue(Data)); }
  557. else if(strcmp(key,"AH_mod3",true)==0) { Carlist[playerid][mod3]=strval(ini_GetValue(Data)); }
  558. else if(strcmp(key,"AH_mod4",true)==0) { Carlist[playerid][mod4]=strval(ini_GetValue(Data)); }
  559. else if(strcmp(key,"AH_mod5",true)==0) { Carlist[playerid][mod5]=strval(ini_GetValue(Data)); }
  560. else if(strcmp(key,"AH_mod6",true)==0) { Carlist[playerid][mod6]=strval(ini_GetValue(Data)); }
  561. else if(strcmp(key,"AH_mod7",true)==0) { Carlist[playerid][mod7]=strval(ini_GetValue(Data)); }
  562. else if(strcmp(key,"AH_mod8",true)==0) { Carlist[playerid][mod8]=strval(ini_GetValue(Data)); }
  563. else if(strcmp(key,"AH_mod9",true)==0) { Carlist[playerid][mod9]=strval(ini_GetValue(Data)); }
  564. else if(strcmp(key,"AH_mod10",true)==0) { Carlist[playerid][mod10]=strval(ini_GetValue(Data)); }
  565. else if(strcmp(key,"AH_mod11",true)==0) { Carlist[playerid][mod11]=strval(ini_GetValue(Data)); }
  566. else if(strcmp(key,"AH_mod12",true)==0) { Carlist[playerid][mod12]=strval(ini_GetValue(Data)); }
  567. else if(strcmp(key,"AH_mod13",true)==0) { Carlist[playerid][mod13]=strval(ini_GetValue(Data)); }
  568. else if(strcmp(key,"AH_mod14",true)==0) { Carlist[playerid][mod14]=strval(ini_GetValue(Data)); }
  569. else if(strcmp(key,"AH_mod15",true)==0) { Carlist[playerid][mod15]=strval(ini_GetValue(Data)); }
  570. else if(strcmp(key,"AH_mod16",true)==0) { Carlist[playerid][mod16]=strval(ini_GetValue(Data)); }
  571. else if(strcmp(key,"AH_mod17",true)==0) { Carlist[playerid][mod17]=strval(ini_GetValue(Data)); }
  572. }
  573. }
  574. fclose(CarFile);
  575. if(Carlist[playerid][Typ]!=-1 && Carlist[playerid][Status]==1)
  576. {
  577. Carlist[playerid][Carid]=CreateTunedCar(playerid);
  578. }
  579. }
  580. SetTimerEx("DelaySetVehicleParams",10000,0,"i",playerid);
  581. return 1;
  582. }
  583.  
  584. public OnPlayerDisconnect(playerid)
  585. {
  586. new dateiname[MAX_PLAYER_NAME+4];
  587. new playername[MAX_PLAYER_NAME];
  588. new var[256];
  589. GetPlayerName(playerid, playername, sizeof(playername));
  590. format(dateiname, sizeof(dateiname), "%s.car", playername);
  591. new File: CarFile = fopen(dateiname, io_write);
  592. format(var, 256, "AH_Typ=%i\n", Carlist[playerid][Typ]); fwrite(CarFile, var);
  593. format(var, 256, "AH_X=%f\n", Carlist[playerid][X]); fwrite(CarFile, var);
  594. format(var, 256, "AH_Y=%f\n", Carlist[playerid][Y]); fwrite(CarFile, var);
  595. format(var, 256, "AH_Z=%f\n", Carlist[playerid][Z]); fwrite(CarFile, var);
  596. format(var, 256, "AH_Rot=%f\n", Carlist[playerid][Rotation]); fwrite(CarFile, var);
  597. format(var, 256, "AH_Status=%i\n", Carlist[playerid][Status]); fwrite(CarFile, var);
  598. format(var, 256, "AH_Lock=%i\n", Carlist[playerid][Lock]); fwrite(CarFile, var);
  599. format(var, 256, "AH_Paintjob=%i\n", Carlist[playerid][Paintjob]); fwrite(CarFile, var);
  600. format(var, 256, "AH_Color1=%i\n", Carlist[playerid][Color1]); fwrite(CarFile, var);
  601. format(var, 256, "AH_Color2=%i\n", Carlist[playerid][Color2]); fwrite(CarFile, var);
  602. format(var, 256, "AH_mod1=%i\n", Carlist[playerid][mod1]); fwrite(CarFile, var);
  603. format(var, 256, "AH_mod2=%i\n", Carlist[playerid][mod2]); fwrite(CarFile, var);
  604. format(var, 256, "AH_mod3=%i\n", Carlist[playerid][mod3]); fwrite(CarFile, var);
  605. format(var, 256, "AH_mod4=%i\n", Carlist[playerid][mod4]); fwrite(CarFile, var);
  606. format(var, 256, "AH_mod5=%i\n", Carlist[playerid][mod5]); fwrite(CarFile, var);
  607. format(var, 256, "AH_mod6=%i\n", Carlist[playerid][mod6]); fwrite(CarFile, var);
  608. format(var, 256, "AH_mod7=%i\n", Carlist[playerid][mod7]); fwrite(CarFile, var);
  609. format(var, 256, "AH_mod8=%i\n", Carlist[playerid][mod8]); fwrite(CarFile, var);
  610. format(var, 256, "AH_mod9=%i\n", Carlist[playerid][mod9]); fwrite(CarFile, var);
  611. format(var, 256, "AH_mod10=%i\n", Carlist[playerid][mod10]); fwrite(CarFile, var);
  612. format(var, 256, "AH_mod11=%i\n", Carlist[playerid][mod11]); fwrite(CarFile, var);
  613. format(var, 256, "AH_mod12=%i\n", Carlist[playerid][mod12]); fwrite(CarFile, var);
  614. format(var, 256, "AH_mod13=%i\n", Carlist[playerid][mod13]); fwrite(CarFile, var);
  615. format(var, 256, "AH_mod14=%i\n", Carlist[playerid][mod14]); fwrite(CarFile, var);
  616. format(var, 256, "AH_mod15=%i\n", Carlist[playerid][mod15]); fwrite(CarFile, var);
  617. format(var, 256, "AH_mod16=%i\n", Carlist[playerid][mod16]); fwrite(CarFile, var);
  618. format(var, 256, "AH_mod17=%i\n", Carlist[playerid][mod17]); fwrite(CarFile, var);
  619. fclose(CarFile);
  620. if(Carlist[playerid][Carid]!=-1)
  621. {
  622. SetVehicleParamsForAll(Carlist[playerid][Carid],0,0);
  623. DestroyVehicle(Carlist[playerid][Carid]);
  624. Carlist[playerid][Carid]=-1;
  625. }
  626. if (Spectating[playerid][0]!=-1)
  627. {
  628. SetVehicleParamsForAll(Buylist[Spectating[playerid][0]][Carid],0,0);
  629. Spectating[playerid][0]=-1;
  630. }
  631. return 1;
  632. }
  633.  
  634. public OnVehicleDeath(vehicleid, killerid)
  635. {
  636. new i;
  637. for(i=0; i<MAX_PLAYERS; i++)
  638. {
  639. if(Carlist[i][Carid]==vehicleid)
  640. {
  641. SetTimerEx("DelayDestroyCar",3000,0,"i",i);
  642. return 1;
  643. }
  644. }
  645. return 1;
  646. }
  647.  
  648. public OnPlayerCommandText(playerid, cmdtext[])
  649. {
  650. new cmd[128], idx, string[128];
  651. #if defined CARSELL
  652. new tmp[128];
  653. #endif
  654. cmd = strtok(cmdtext, idx);
  655.  
  656. if (strcmp("/carhelp", cmd, true, 10) == 0)
  657. {
  658. if(IsPlayerConnected(playerid))
  659. {
  660. SendClientMessage(playerid, COLOR_GREEN,"_______________________________________");
  661. SendClientMessage(playerid, COLOR_WHITE,"*** CAR HELP *** type the command for more help");
  662. SendClientMessage(playerid, COLOR_GRAD3,"*** CAR *** /park /fixcar /carlock /respraycar");
  663. SendClientMessage(playerid, COLOR_GRAD3,"*** CAR *** /repaintcar /buycar /carsell /exitcar");
  664. #if defined CARSELL
  665. SendClientMessage(playerid, COLOR_GRAD3,"*** CAR *** /pcarsell /cancelsell /acceptsell");
  666. #endif
  667. }
  668. return 1;
  669. }
  670. else if (strcmp("/park", cmd, true, 10) == 0)
  671. {
  672. if (IsPlayerInVehicle(playerid,Carlist[playerid][Carid]))
  673. {
  674. GetVehiclePos(Carlist[playerid][Carid],Carlist[playerid][X],Carlist[playerid][Y],Carlist[playerid][Z]);
  675. GetVehicleZAngle(Carlist[playerid][Carid],Carlist[playerid][Rotation]);
  676. SendClientMessage(playerid, COLOR_GREEN, "Saved car position!");
  677. }
  678. else { SendClientMessage(playerid, COLOR_GREY, "That is not your car!"); }
  679. return 1;
  680. }
  681. else if (strcmp("/fixcar", cmd, true, 10) == 0)
  682. {
  683. if (Carlist[playerid][Typ]!=-1)
  684. {
  685. if (Carlist[playerid][Status]==0)
  686. {
  687. new reparatur = Buylist[Carlist[playerid][Typ]][Repair];
  688. if (reparatur <= GetPlayerMoney(playerid))
  689. {
  690. Carlist[playerid][Status]=1;
  691. Carlist[playerid][Carid]=CreateTunedCar(playerid);
  692. GivePlayerMoney(playerid, - reparatur);
  693. format(string, 128, "You repaired your car for $%i! It is ready where you parked it.", reparatur);
  694. SendClientMessage(playerid, COLOR_RED, string);
  695. }
  696. else { format(string, 128, "Insufficent money for the repair (need: $%i)!", reparatur); SendClientMessage(playerid, COLOR_LIGHTRED, string); }
  697. }
  698. else { SendClientMessage(playerid, COLOR_GREY, "Your car does not need a repair!"); }
  699. }
  700. else { SendClientMessage(playerid, COLOR_GREY, "You do not have a car!"); }
  701. return 1;
  702. }
  703. else if (strcmp("/carlock", cmd, true, 10) == 0)
  704. {
  705. if (Carlist[playerid][Typ]!=-1)
  706. {
  707. if (Carlist[playerid][Carid]!=-1)
  708. {
  709. if (Carlist[playerid][Lock]==0)
  710. {
  711. Carlist[playerid][Lock]=1;
  712. SetVehicleParamsForAll(Carlist[playerid][Carid],0,1);
  713. SetVehicleParamsForPlayer(Carlist[playerid][Carid],playerid,0,0);
  714. SendClientMessage(playerid, COLOR_RED, "You locked your car for other players!");
  715. }
  716. else
  717. {
  718. Carlist[playerid][Lock]=0;
  719. SetVehicleParamsForAll(Carlist[playerid][Carid],0,0);
  720. SendClientMessage(playerid, COLOR_RED, "You unlocked your car for other players!");
  721. }
  722. }
  723. else { SendClientMessage(playerid, COLOR_GREY, "Your car is broken. You have to repair it!"); }
  724. }
  725. else { SendClientMessage(playerid, COLOR_GREY, "You do not have a car!"); }
  726. return 1;
  727. }
  728. else if (strcmp("/respraycar", cmd, true, 10) == 0)
  729. {
  730. if (Carlist[playerid][Typ]!=-1)
  731. {
  732. if (Carlist[playerid][Carid]!=-1)
  733. {
  734. ChangeVehicleColor(Carlist[playerid][Carid],Carlist[playerid][Color1],Carlist[playerid][Color2]);
  735. SendClientMessage(playerid, COLOR_RED, "You resprayed your car!");
  736. }
  737. else { SendClientMessage(playerid, COLOR_GREY, "Your car is broken. You have to repair it!"); }
  738. }
  739. else { SendClientMessage(playerid, COLOR_GREY, "You do not have a car!"); }
  740. return 1;
  741. }
  742. else if (strcmp("/repaintcar", cmd, true, 10) == 0)
  743. {
  744. if (Carlist[playerid][Typ]!=-1)
  745. {
  746. if (Carlist[playerid][Carid]!=-1)
  747. {
  748. if (Carlist[playerid][Paintjob]!=-1)
  749. {
  750. ChangeVehiclePaintjob(Carlist[playerid][Carid],Carlist[playerid][Paintjob]);
  751. SendClientMessage(playerid, COLOR_RED, "You repainted your car!");
  752. }
  753. else { SendClientMessage(playerid, COLOR_GREY, "Your car does not have a paintjob yet!"); }
  754. }
  755. else { SendClientMessage(playerid, COLOR_GREY, "Your car is broken. You have to repair it!"); }
  756. }
  757. else { SendClientMessage(playerid, COLOR_GREY, "You do not have a car!"); }
  758. return 1;
  759. }
  760. else if (strcmp("/exitcar", cmd, true, 10) == 0)
  761. {
  762. if (Spectating[playerid][0]!=-1)
  763. {
  764. TogglePlayerControllable(playerid,1);
  765. SetVehicleParamsForAll(Buylist[Spectating[playerid][0]][Carid],0,0);
  766. Spectating[playerid][0]=-1;
  767. RemovePlayerFromVehicle(playerid);
  768. }
  769. else { SendClientMessage(playerid, COLOR_GREY, "You are now in a car thats for sale!"); }
  770. return 1;
  771. }
  772. else if (strcmp("/buycar", cmd, true, 10) == 0)
  773. {
  774. if (Spectating[playerid][0]!=-1)
  775. {
  776. if (Carlist[playerid][Typ]==-1)
  777. {
  778. new price = Buylist[Spectating[playerid][0]][Price];
  779. if (price <= GetPlayerMoney(playerid))
  780. {
  781. new autohaus=Buylist[Spectating[playerid][0]][Autohaus];
  782. GivePlayerMoney(playerid, - price);
  783. Carlist[playerid][Typ]=Spectating[playerid][0]; Carlist[playerid][X]=Carspawns[autohaus][X]; Carlist[playerid][Y]=Carspawns[autohaus][Y];
  784. Carlist[playerid][Z]=Carspawns[autohaus][Z]; Carlist[playerid][Rotation]=Carspawns[autohaus][Rotation]; Carlist[playerid][Status]=1; Carlist[playerid][Lock]=0;
  785. Carlist[playerid][Carid]=CreateVehicle(Buylist[Spectating[playerid][0]][Modelid],Carlist[playerid][X],Carlist[playerid][Y],Carlist[playerid][Z],Carlist[playerid][Rotation],-1,-1,-1);
  786. SetVehicleParamsForAll(Buylist[Spectating[playerid][0]][Carid],0,0);
  787. TogglePlayerControllable(playerid,1);
  788. Spectating[playerid][0]=-1;
  789. RemovePlayerFromVehicle(playerid);
  790. format(string,128,"Congratulations! You bought yourself a/an $%s for %i!",Buylist[Carlist[playerid][Typ]][Name],price);
  791. SendClientMessage(playerid, COLOR_RED, string);
  792. SendClientMessage(playerid, COLOR_GREEN, "If your car is broken, type /fixcar to fix it.");
  793. SendClientMessage(playerid, COLOR_GREEN, "You can lock/unlock your car for other players with /lock.");
  794. SendClientMessage(playerid, COLOR_GREEN, "Look for more commands with /carhelp.");
  795. SendClientMessage(playerid, COLOR_YELLOW, "Your car is ready at the release point. Have fun!");
  796. }
  797. else { format(string, 128, "Insufficent money to buy the car (need: $%i)!", price); SendClientMessage(playerid, COLOR_LIGHTRED, string); }
  798. }
  799. else { SendClientMessage(playerid, COLOR_GREY, "You already have a car!"); }
  800. }
  801. else { SendClientMessage(playerid, COLOR_GREY, "You are not visiting a demonstration car!"); }
  802. return 1;
  803. }
  804. else if (strcmp("/carsell", cmd, true, 10) == 0)
  805. {
  806. if (Carlist[playerid][Typ]!=-1)
  807. {
  808. new price = (Buylist[Carlist[playerid][Typ]][Price]/5)*4;
  809. if (IsPlayerInVehicle(playerid,Carlist[playerid][Carid])) { RemovePlayerFromVehicle(playerid); }
  810. GivePlayerMoney(playerid, price);
  811. DestroyVehicle(Carlist[playerid][Carid]);
  812. Carlist[playerid][Typ]=-1; Carlist[playerid][X]=0.0; Carlist[playerid][Y]=0.0; Carlist[playerid][Z]=0.0;
  813. Carlist[playerid][Rotation]=0.0; Carlist[playerid][Status]=0; Carlist[playerid][Lock]=0; Carlist[playerid][Carid]=-1;
  814. Carlist[playerid][Color1]=-1; Carlist[playerid][Color2]=-1; Carlist[playerid][mod1]=-1; Carlist[playerid][mod2]=-1;
  815. Carlist[playerid][mod3]=-1; Carlist[playerid][mod4]=-1; Carlist[playerid][mod5]=-1; Carlist[playerid][mod6]=-1;
  816. Carlist[playerid][mod7]=-1; Carlist[playerid][mod8]=-1; Carlist[playerid][mod9]=-1; Carlist[playerid][mod10]=-1;
  817. Carlist[playerid][mod11]=-1; Carlist[playerid][mod12]=-1; Carlist[playerid][mod13]=-1; Carlist[playerid][mod14]=-1;
  818. Carlist[playerid][mod15]=-1; Carlist[playerid][mod16]=-1; Carlist[playerid][mod17]=-1; Carlist[playerid][Paintjob]=-1;
  819. format(string,128,"You sold successfully your car for $%i!",price);
  820. SendClientMessage(playerid, COLOR_RED, string);
  821. }
  822. else { SendClientMessage(playerid, COLOR_GREY, "You do not have a car!"); }
  823. return 1;
  824. }
  825. #if defined RESETCARS
  826. else if (strcmp("/resetcars", cmd, true, 10) == 0)
  827. {
  828. if(CallRemoteFunction("IsAdmin","i",playerid)) { ResetAutohausSpawns(); }
  829. return 1;
  830. }
  831. #endif
  832. #if defined CARSELL
  833. else if (strcmp("/pcarsell", cmd, true, 10) == 0)
  834. {
  835. tmp = strtok(cmdtext, idx);
  836. if (!strlen(tmp))
  837. {
  838. SendClientMessage(playerid, COLOR_GREY, "Usage: /pcarsell [playerid] [price]");
  839. return 1;
  840. }
  841. new sellplayerid = ReturnUser(tmp);
  842. tmp = strtok(cmdtext, idx);
  843. if (!strlen(tmp))
  844. {
  845. SendClientMessage(playerid, COLOR_GREY, "Usage: /pcarsell [playerid] [price]");
  846. return 1;
  847. }
  848. new price = strval(tmp);
  849. if (price<0)
  850. {
  851. SendClientMessage(playerid, COLOR_GREY, "The price has to be bigger than $0.");
  852. return 1;
  853. }
  854. if (Carlist[playerid][Typ]==-1)
  855. {
  856. SendClientMessage(playerid, COLOR_GREY, "You do not have a car!");
  857. return 1;
  858. }
  859. if (!IsPlayerConnected(sellplayerid))
  860. {
  861. SendClientMessage(playerid, COLOR_GREY, "This player is offline.");
  862. return 1;
  863. }
  864. offerCar[sellplayerid][0]=playerid;
  865. offerCar[sellplayerid][1]=price;
  866. new playername[MAX_PLAYER_NAME];
  867. new sellplayername[MAX_PLAYER_NAME];
  868. GetPlayerName(playerid,playername,sizeof(playername));
  869. GetPlayerName(sellplayerid,sellplayername,sizeof(sellplayername));
  870. format(string,128,"You are offering %s your car for $%i!",sellplayername,price);
  871. SendClientMessage(playerid, COLOR_RED, string);
  872. SendClientMessage(playerid, COLOR_YELLOW, "Cancel the deal with /cancelsell.");
  873. format(string,128,"%s offers his %s for $%i.",playername,Buylist[Carlist[playerid][Typ]][Name],price);
  874. SendClientMessage(sellplayerid, COLOR_RED, string);
  875. SendClientMessage(sellplayerid, COLOR_YELLOW, "Accept the deal with /acceptsell.");
  876. return 1;
  877. }
  878. else if (strcmp("/cancelsell", cmd, true, 10) == 0)
  879. {
  880. for (new i=0; i<MAX_PLAYERS; i++)
  881. {
  882. if (offerCar[i][0]==playerid)
  883. {
  884. offerCar[i]={-1,0};
  885. SendClientMessage(playerid, COLOR_RED, "You cancelled the deal.");
  886. if (IsPlayerConnected(i))
  887. {
  888. new playername[MAX_PLAYER_NAME];
  889. GetPlayerName(playerid,playername,sizeof(playername));
  890. format(string,128,"%s cancelled the deal.",playername);
  891. SendClientMessage(i, COLOR_GREEN, string);
  892. }
  893. return 1;
  894. }
  895. }
  896. SendClientMessage(playerid, COLOR_GREY, "You are not offering your car!");
  897. return 1;
  898. }
  899. else if (strcmp("/acceptsell", cmd, true, 10) == 0)
  900. {
  901. if (offerCar[playerid][0]!=-1)
  902. {
  903. if (IsPlayerConnected(offerCar[playerid][0]))
  904. {
  905. if (Carlist[playerid][Typ]==-1)
  906. {
  907. if (Carlist[offerCar[playerid][0]][Typ]!=-1)
  908. {
  909. if (GetPlayerMoney(playerid)>=offerCar[playerid][1])
  910. {
  911. new sellerid=offerCar[playerid][0];
  912. new price=offerCar[playerid][1];
  913. offerCar[playerid]={-1,0};
  914. GivePlayerMoney(playerid, - price);
  915. GivePlayerMoney(sellerid, price);
  916. Carlist[playerid][Typ]=Carlist[sellerid][Typ];
  917. Carlist[playerid][X]=Carlist[sellerid][X];
  918. Carlist[playerid][Y]=Carlist[sellerid][Y];
  919. Carlist[playerid][Z]=Carlist[sellerid][Z];
  920. Carlist[playerid][Rotation]=Carlist[sellerid][Rotation];
  921. Carlist[playerid][Status]=Carlist[sellerid][Status];
  922. Carlist[playerid][Lock]=Carlist[sellerid][Lock];
  923. Carlist[playerid][Carid]=Carlist[sellerid][Carid];
  924. Carlist[playerid][Color1]=Carlist[sellerid][Color1];
  925. Carlist[playerid][Color2]=Carlist[sellerid][Color2];
  926. Carlist[playerid][mod1]=Carlist[sellerid][mod1];
  927. Carlist[playerid][mod2]=Carlist[sellerid][mod2];
  928. Carlist[playerid][mod3]=Carlist[sellerid][mod3];
  929. Carlist[playerid][mod4]=Carlist[sellerid][mod4];
  930. Carlist[playerid][mod5]=Carlist[sellerid][mod5];
  931. Carlist[playerid][mod6]=Carlist[sellerid][mod6];
  932. Carlist[playerid][mod7]=Carlist[sellerid][mod7];
  933. Carlist[playerid][mod8]=Carlist[sellerid][mod8];
  934. Carlist[playerid][mod9]=Carlist[sellerid][mod9];
  935. Carlist[playerid][mod10]=Carlist[sellerid][mod10];
  936. Carlist[playerid][mod11]=Carlist[sellerid][mod11];
  937. Carlist[playerid][mod12]=Carlist[sellerid][mod12];
  938. Carlist[playerid][mod13]=Carlist[sellerid][mod13];
  939. Carlist[playerid][mod14]=Carlist[sellerid][mod14];
  940. Carlist[playerid][mod15]=Carlist[sellerid][mod15];
  941. Carlist[playerid][mod16]=Carlist[sellerid][mod16];
  942. Carlist[playerid][mod17]=Carlist[sellerid][mod17];
  943. Carlist[playerid][Paintjob]=Carlist[sellerid][Paintjob];
  944. Carlist[sellerid][Typ]=-1; Carlist[sellerid][X]=0.0; Carlist[sellerid][Y]=0.0; Carlist[sellerid][Z]=0.0;
  945. Carlist[sellerid][Rotation]=0.0; Carlist[sellerid][Status]=0; Carlist[sellerid][Lock]=0; Carlist[sellerid][Carid]=-1;
  946. Carlist[sellerid][Color1]=-1; Carlist[sellerid][Color2]=-1; Carlist[sellerid][mod1]=-1; Carlist[sellerid][mod2]=-1;
  947. Carlist[sellerid][mod3]=-1; Carlist[sellerid][mod4]=-1; Carlist[sellerid][mod5]=-1; Carlist[sellerid][mod6]=-1;
  948. Carlist[sellerid][mod7]=-1; Carlist[sellerid][mod8]=-1; Carlist[sellerid][mod9]=-1; Carlist[sellerid][mod10]=-1;
  949. Carlist[sellerid][mod11]=-1; Carlist[sellerid][mod12]=-1; Carlist[sellerid][mod13]=-1; Carlist[sellerid][mod14]=-1;
  950. Carlist[sellerid][mod15]=-1; Carlist[sellerid][mod16]=-1; Carlist[sellerid][mod17]=-1; Carlist[sellerid][Paintjob]=-1;
  951. if (Carlist[playerid][Status]==1)
  952. {
  953. SetVehicleParamsForAll(Carlist[playerid][Carid],0,Carlist[playerid][Lock]);
  954. SetVehicleParamsForPlayer(Carlist[playerid][Carid],playerid,0,0);
  955. }
  956. format(string,128,"Congratulations! You bought yourself a/an $%s for %i!",Buylist[Carlist[playerid][Typ]][Name],price);
  957. SendClientMessage(playerid, COLOR_RED, string);
  958. SendClientMessage(playerid, COLOR_GREEN, "If your car is broken, type /fixcar to fix it.");
  959. SendClientMessage(playerid, COLOR_GREEN, "You can lock/unlock your car for other players with /lock.");
  960. SendClientMessage(playerid, COLOR_GREEN, "Look for more commands with /carhelp.");
  961. SendClientMessage(playerid, COLOR_YELLOW, "The car is now yours. Have fun with it!");
  962. new playername[MAX_PLAYER_NAME];
  963. GetPlayerName(playerid,playername,sizeof(playername));
  964. format(string,128,"You sold %s your car for $%i!",playername, price);
  965. SendClientMessage(sellerid, COLOR_RED, string);
  966. }
  967. else
  968. {
  969. format(string, 128, "Insufficent money to buy the car (need: $%i)!", offerCar[playerid][1]);
  970. SendClientMessage(playerid, COLOR_GREY, string);
  971. }
  972. }
  973. else
  974. {
  975. offerCar[playerid]={-1,0};
  976. SendClientMessage(playerid, COLOR_GREY, "The seller does not have a car!.");
  977. }
  978. }
  979. else
  980. {
  981. SendClientMessage(playerid, COLOR_GREY, "You already have a car!");
  982. }
  983. }
  984. else
  985. {
  986. offerCar[playerid]={-1,0};
  987. SendClientMessage(playerid, COLOR_GREY, "The seller is offline.");
  988. }
  989. }
  990. else
  991. {
  992. SendClientMessage(playerid, COLOR_GREY, "There is no car on offer.");
  993. }
  994. return 1;
  995. }
  996. #endif
  997. return 0;
  998. }
  999.  
  1000. public OnPlayerStateChange(playerid, newstate, oldstate)
  1001. {
  1002. if(newstate == PLAYER_STATE_DRIVER)
  1003. {
  1004. new vehicleid = GetPlayerVehicleID(playerid);
  1005. new typ;
  1006. typ=IsAutohausCar(vehicleid);
  1007. if(typ!=-1)
  1008. {
  1009. new string[128];
  1010. TogglePlayerControllable(playerid,0);
  1011. Spectating[playerid][0]=typ;
  1012. SetVehicleParamsForAll(vehicleid,0,1);
  1013. SendClientMessage(playerid, COLOR_YELLOW, "~*~ Car Dealership ~*~");
  1014. format(string,128,"Name: %s",Buylist[typ][Name]);
  1015. SendClientMessage(playerid, COLOR_YELLOW, string);
  1016. format(string,128,"Price: $%i",Buylist[typ][Price]);
  1017. SendClientMessage(playerid, COLOR_YELLOW, string);
  1018. format(string,128,"Cost of repair: $%i",Buylist[typ][Repair]);
  1019. SendClientMessage(playerid, COLOR_YELLOW, string);
  1020. SendClientMessage(playerid, COLOR_GREEN, "This car is for sell. To buy it, type: /buycar");
  1021. SendClientMessage(playerid, COLOR_GREEN, "If you want to leave the car, type: /exitcar");
  1022. }
  1023. }
  1024. return 1;
  1025. }
  1026.  
  1027. public OnVehicleMod(playerid,vehicleid,componentid)
  1028. {
  1029. if (playerid!=GetPlayerFromCarlistCar(vehicleid)) {return 1;}
  1030. if(playerid!=-1)
  1031. {
  1032. new mod=GetModType(componentid);
  1033. switch (mod)
  1034. {
  1035. case 1: { Carlist[playerid][mod1]=componentid; }
  1036. case 2: { Carlist[playerid][mod2]=componentid; }
  1037. case 3: { Carlist[playerid][mod3]=componentid; }
  1038. case 4: { Carlist[playerid][mod4]=componentid; }
  1039. case 5: { Carlist[playerid][mod5]=componentid; }
  1040. case 6: { Carlist[playerid][mod6]=componentid; }
  1041. case 7: { Carlist[playerid][mod7]=componentid; }
  1042. case 8: { Carlist[playerid][mod8]=componentid; }
  1043. case 9: { Carlist[playerid][mod9]=componentid; }
  1044. case 10: { Carlist[playerid][mod10]=componentid; }
  1045. case 11: { Carlist[playerid][mod11]=componentid; }
  1046. case 12: { Carlist[playerid][mod12]=componentid; }
  1047. case 13: { Carlist[playerid][mod13]=componentid; }
  1048. case 14: { Carlist[playerid][mod14]=componentid; }
  1049. case 15: { Carlist[playerid][mod15]=componentid; }
  1050. case 16: { Carlist[playerid][mod16]=componentid; }
  1051. case 17: { Carlist[playerid][mod17]=componentid; }
  1052. default: { new string[128]; format(string,128,"Unknown component id: %i",componentid); print(string); }
  1053. }
  1054. }
  1055. return 1;
  1056. }
  1057.  
  1058. public OnVehiclePaintjob(playerid,vehicleid, paintjobid)
  1059. {
  1060. if (playerid!=GetPlayerFromCarlistCar(vehicleid)) {return 1;}
  1061. if(playerid!=-1)
  1062. {
  1063. Carlist[playerid][Paintjob]=paintjobid;
  1064. }
  1065. return 1;
  1066. }
  1067.  
  1068. public OnVehicleRespray(playerid,vehicleid, color1, color2)
  1069. {
  1070. if (playerid!=GetPlayerFromCarlistCar(vehicleid)) {return 1;}
  1071. if(playerid!=-1)
  1072. {
  1073. Carlist[playerid][Color1]=color1;
  1074. Carlist[playerid][Color2]=color2;
  1075. }
  1076. return 1;
  1077. }
  1078.  
  1079. public SetVehicleParamsForAll(carid,objective,doorslocked)
  1080. {
  1081. new i;
  1082. for(i=0; i<MAX_PLAYERS; i++) { SetVehicleParamsForPlayer(carid,i,objective,doorslocked); }
  1083. }
  1084.  
  1085. public CreateTunedCar(playerid)
  1086. {
  1087. if(IsPlayerConnected(playerid) && Carlist[playerid][Typ]!=-1)
  1088. {
  1089. new carid=CreateVehicle(Buylist[Carlist[playerid][Typ]][Modelid],Carlist[playerid][X],Carlist[playerid][Y],Carlist[playerid][Z],Carlist[playerid][Rotation],-1,-1,-1);
  1090. if(Carlist[playerid][Lock]==1)
  1091. {
  1092. SetVehicleParamsForAll(carid,0,1);
  1093. SetVehicleParamsForPlayer(carid,playerid,0,0);
  1094. }
  1095. if(Carlist[playerid][mod1]!=-1) { AddVehicleComponent(carid,Carlist[playerid][mod1]); }
  1096. if(Carlist[playerid][mod2]!=-1) { AddVehicleComponent(carid,Carlist[playerid][mod2]); }
  1097. if(Carlist[playerid][mod3]!=-1) { AddVehicleComponent(carid,Carlist[playerid][mod3]); }
  1098. if(Carlist[playerid][mod4]!=-1) { AddVehicleComponent(carid,Carlist[playerid][mod4]); }
  1099. if(Carlist[playerid][mod5]!=-1) { AddVehicleComponent(carid,Carlist[playerid][mod5]); }
  1100. if(Carlist[playerid][mod6]!=-1) { AddVehicleComponent(carid,Carlist[playerid][mod6]); }
  1101. if(Carlist[playerid][mod7]!=-1) { AddVehicleComponent(carid,Carlist[playerid][mod7]); }
  1102. if(Carlist[playerid][mod8]!=-1) { AddVehicleComponent(carid,Carlist[playerid][mod8]); }
  1103. if(Carlist[playerid][mod9]!=-1) { AddVehicleComponent(carid,Carlist[playerid][mod9]); }
  1104. if(Carlist[playerid][mod10]!=-1) { AddVehicleComponent(carid,Carlist[playerid][mod10]); }
  1105. if(Carlist[playerid][mod11]!=-1) { AddVehicleComponent(carid,Carlist[playerid][mod11]); }
  1106. if(Carlist[playerid][mod12]!=-1) { AddVehicleComponent(carid,Carlist[playerid][mod12]); }
  1107. if(Carlist[playerid][mod13]!=-1) { AddVehicleComponent(carid,Carlist[playerid][mod13]); }
  1108. if(Carlist[playerid][mod14]!=-1) { AddVehicleComponent(carid,Carlist[playerid][mod14]); }
  1109. if(Carlist[playerid][mod15]!=-1) { AddVehicleComponent(carid,Carlist[playerid][mod15]); }
  1110. if(Carlist[playerid][mod16]!=-1) { AddVehicleComponent(carid,Carlist[playerid][mod16]); }
  1111. if(Carlist[playerid][mod17]!=-1) { AddVehicleComponent(carid,Carlist[playerid][mod17]); }
  1112. if(Carlist[playerid][Paintjob]!=-1) { ChangeVehiclePaintjob(carid,Carlist[playerid][Paintjob]); }
  1113. if(Carlist[playerid][Color1]!=-1) { ChangeVehicleColor(carid,Carlist[playerid][Color1],Carlist[playerid][Color2]); }
  1114. return carid;
  1115. }
  1116. return -1;
  1117. }
  1118.  
  1119. public DelayDestroyCar(playerid)
  1120. {
  1121. SetVehicleParamsForAll(Carlist[playerid][Carid],0,0);
  1122. DestroyVehicle(Carlist[playerid][Carid]);
  1123. Carlist[playerid][Status]=0;
  1124. Carlist[playerid][Carid]=-1;
  1125. return 1;
  1126. }
  1127.  
  1128. public DelaySetVehicleParams(playerid)
  1129. {
  1130. if(!IsPlayerConnected(playerid)) { return 0; }
  1131. new i;
  1132. for(i=0; i<MAX_PLAYERS; i++)
  1133.  
  1134. {
  1135. if(Carlist[i][Carid]!=-1 && Carlist[i][Lock]==1) { SetVehicleParamsForPlayer(Carlist[i][Carid],playerid,0,1); }
  1136. if(Spectating[i][0]!=-1) { SetVehicleParamsForPlayer(Buylist[Spectating[i][0]][Carid],playerid,0,1); }
  1137. }
  1138. return 1;
  1139. }
  1140.  
  1141. public ResetAutohausSpawns()
  1142. {
  1143. new i;
  1144. for(i=0; i<sizeof(Buylist); i++) { SetVehicleToRespawn(Buylist[i][Carid]); }
  1145. }
Advertisement
Add Comment
Please, Sign In to add comment