Guest User

Untitled

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