Guest User

Sistem Car

a guest
Dec 31st, 2012
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 40.39 KB | None | 0 0
  1. ////////////////////////////////////////////////////////////////////////////////
  2. ////////////////////////////////////////////////////////////////////////////////
  3. ////////////////////////////////////////////////////////////////////////////////
  4. //----------------------PERSONAL CAR SYSTEM FOR GODFATHER-----------------------
  5. //=================================by SoundLike ================================
  6. ////////////////////////////////////////////////////////////////////////////////
  7. ////////////////////////////////////////////////////////////////////////////////
  8. ////////////////////////////////////////////////////////////////////////////////
  9. //////////////////////////////////Clock And Date TD/////////////////////////////
  10.  
  11. //===========================Section: Includes==================================
  12. #include <a_samp>
  13. #include <utils>
  14. #include <JunkBuster>
  15. #include <vehicle_library>
  16. //===========================Section: Definations===============================
  17. #define COLOR_GRAD1 0xB4B5B7FF
  18. #define COLOR_GRAD2 0xBFC0C2FF
  19. #define COLOR_GRAD3 0xCBCCCEFF
  20. #define COLOR_GRAD4 0xD8D8D8FF
  21. #define COLOR_GRAD5 0xE3E3E3FF
  22. #define COLOR_GRAD6 0xF0F0F0FF
  23. #define COLOR_GREEN 0x33AA33AA
  24. #define COLOR_GREY 0xAFAFAFAA
  25. #define COLOR_WHITE 0xFFFFFFAA
  26. #define COLOR_YELLOW 0xFFFF00AA
  27. #define COLOR_YELLOW2 0xF5DEB3AA
  28. #define COLOR_BLUE 0x2641FEAA
  29.  
  30.  
  31. #pragma tabsize 0
  32. //===========================Section: Forwards==================================
  33. forward split(const strsrc[], strdest[][], delimiter);
  34. forward LoadCar();
  35. forward SaveCarCoords();
  36. forward OnPropUpdate();
  37. forward IsAnOwnableCar(vehicleid);
  38. forward CarKeys(playerid);
  39. forward SavePlayerData(playerid);
  40. forward ini_GetKey( line[] );
  41. forward ini_GetValue( line[] );
  42. forward OnPlayerKeyStateChange(playerid, newkeys, oldkeys);
  43.  
  44. new carsonserver = 301;
  45.  
  46. new vehName[][] = {
  47. "Landstalker",
  48. "Bravura",
  49. "Buffalo",
  50. "Linerunner",
  51. "Perrenial",
  52. "Sentinel",
  53. "Dumper",
  54. "Firetruck",
  55. "Trashmaster",
  56. "Stretch",
  57. "Manana",
  58. "Infernus",
  59. "Voodoo",
  60. "Pony",
  61. "Mule",
  62. "Cheetah",
  63. "Ambulance",
  64. "Leviathan",
  65. "Moonbeam",
  66. "Esperanto",
  67. "Taxi",
  68. "Washington",
  69. "Bobcat",
  70. "Whoopee",
  71. "BF Injection",
  72. "Hunter",
  73. "Premier",
  74. "Enforcer",
  75. "Securicar",
  76. "Banshee",
  77. "Predator",
  78. "Bus",
  79. "Rhino",
  80. "Barracks",
  81. "Hotknife",
  82. "Trailer",
  83. "Previon",
  84. "Coach",
  85. "Cabbie",
  86. "Stallion",
  87. "Rumpo",
  88. "RC Bandit",
  89. "Romero",
  90. "Packer",
  91. "Monster",
  92. "Admiral",
  93. "Squalo",
  94. "Seasparrow",
  95. "Pizzaboy",
  96. "Tram",
  97. "Trailer",
  98. "Turismo",
  99. "Speeder",
  100. "Reefer",
  101. "Tropic",
  102. "Flatbed",
  103. "Yankee",
  104. "Caddy",
  105. "Solair",
  106. "Berkley's RC Van",
  107. "Skimmer",
  108. "PCJ-600",
  109. "Faggio",
  110. "Freeway",
  111. "RC Baron",
  112. "RC Raider",
  113. "Glendale",
  114. "Oceanic",
  115. "Sanchez",
  116. "Sparrow",
  117. "Patriot",
  118. "ATV",
  119. "Coastguard",
  120. "Dinghy",
  121. "Hermes",
  122. "Sabre",
  123. "Rustler",
  124. "ZR-350",
  125. "Walton",
  126. "Regina",
  127. "Comet",
  128. "BMX",
  129. "Burrito",
  130. "Camper",
  131. "Marquis",
  132. "Baggage",
  133. "Dozer",
  134. "Maverick",
  135. "News Chopper",
  136. "Rancher",
  137. "FBI Rancher",
  138. "Virgo",
  139. "Greenwood",
  140. "Jetmax",
  141. "Hotring",
  142. "Sandking",
  143. "Blista Compact",
  144. "Police Maverick",
  145. "Boxvillde",
  146. "Benson",
  147. "Mesa",
  148. "RC Goblin",
  149. "Hotring Racer A",
  150. "Hotring Racer B",
  151. "Bloodring Banger",
  152. "Rancher",
  153. "Super GT",
  154. "Elegant",
  155. "Journey",
  156. "Bike",
  157. "Mountain Bike",
  158. "Beagle",
  159. "Cropduster",
  160. "Stunt",
  161. "Tanker",
  162. "Roadtrain",
  163. "Nebula",
  164. "Majestic",
  165. "Buccaneer",
  166. "Shamal",
  167. "Hydra",
  168. "FCR-900",
  169. "NRG-500",
  170. "HPV1000",
  171. "Cement Truck",
  172. "Tow Truck",
  173. "Fortune",
  174. "Cadrona",
  175. "FBI Truck",
  176. "Willard",
  177. "Forklift",
  178. "Tractor",
  179. "Combine",
  180. "Feltzer",
  181. "Remington",
  182. "Slamvan",
  183. "Blade",
  184. "Freight",
  185. "Streak",
  186. "Vortex",
  187. "Vincent",
  188. "Bullet",
  189. "Clover",
  190. "Sadler",
  191. "Firetruck",
  192. "Hustler",
  193. "Intruder",
  194. "Primo",
  195. "Cargobob",
  196. "Tampa",
  197. "Sunrise",
  198. "Merit",
  199. "Utility",
  200. "Nevada",
  201. "Jeep",
  202. "Windsor",
  203. "Monster",
  204. "Monster",
  205. "Uranus",
  206. "Jester",
  207. "Sultan",
  208. "Stratum",
  209. "Elegy",
  210. "Raindance",
  211. "RC Tiger",
  212. "Flash",
  213. "Tahoma",
  214. "Savanna",
  215. "Bandito",
  216. "Freight Flat",
  217. "Streak Carriage",
  218. "Kart",
  219. "Mower",
  220. "Dune",
  221. "Sweeper",
  222. "Broadway",
  223. "Tornado",
  224. "AT-400",
  225. "DFT-30",
  226. "Huntley",
  227. "Stafford",
  228. "BF-400",
  229. "News Van",
  230. "Tug",
  231. "Trailer",
  232. "Emperor",
  233. "Wayfarer",
  234. "Euros",
  235. "Hotdog",
  236. "Club",
  237. "Freight Box",
  238. "Trailer",
  239. "Andromada",
  240. "Dodo",
  241. "RC Cam",
  242. "Launch",
  243. "Police Car LSPD",
  244. "Police Car SFPD",
  245. "Police Car LVPD",
  246. "Police Ranger",
  247. "Picador",
  248. "S.W.A.T",
  249. "Alpha",
  250. "Phoenix",
  251. "Glendale",
  252. "Sadler",
  253. "Luggage",
  254. "Luggage",
  255. "Stairs",
  256. "Boxville",
  257. "Tiller",
  258. "Utility Trailer"
  259. };
  260. //===========================Section: Variables=================================
  261.  
  262. enum pInfo
  263. {
  264. pPcarkey,
  265. pPcarkey2,
  266. }
  267. new PlayerInfo[256][pInfo];
  268.  
  269. enum cInfo
  270. {
  271. cModel,
  272. Float:cLocationx,
  273. Float:cLocationy,
  274. Float:cLocationz,
  275. Float:cAngle,
  276. cColorOne,
  277. cColorTwo,
  278. cOwner[MAX_PLAYER_NAME],
  279. cDescription[12],
  280. cOwned,
  281. cLock,
  282. };
  283.  
  284. new CarInfo[650][cInfo];
  285.  
  286. //===========================Section: strtok & split============================
  287. strtok(const string[], &index)
  288. {
  289. new length = strlen(string);
  290. while ((index < length) && (string[index] <= ' '))
  291. {
  292. index++;
  293. }
  294.  
  295. new offset = index;
  296. new result[20];
  297. while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
  298. {
  299. result[index - offset] = string[index];
  300. index++;
  301. }
  302. result[index - offset] = EOS;
  303. return result;
  304. }
  305.  
  306. public split(const strsrc[], strdest[][], delimiter)
  307. {
  308. new i, li;
  309. new aNum;
  310. new len;
  311. while(i <= strlen(strsrc)){
  312. if(strsrc[i]==delimiter || i==strlen(strsrc)){
  313. len = strmid(strdest[aNum], strsrc, li, i, 128);
  314. strdest[aNum][len] = 0;
  315. li = i+1;
  316. aNum++;
  317. }
  318. i++;
  319. }
  320. return 1;
  321. }
  322. //===========================Section: Callbacks & Functions=====================
  323. public OnFilterScriptInit()
  324. {
  325. LoadCar();
  326. for(new h = carsonserver; h < sizeof(CarInfo); h++)
  327. {
  328. AddStaticVehicleEx(CarInfo[h][cModel],CarInfo[h][cLocationx],CarInfo[h][cLocationy],CarInfo[h][cLocationz]+1.0,CarInfo[h][cAngle],CarInfo[h][cColorOne],CarInfo[h][cColorTwo],60000);
  329. }
  330. return 1;
  331. }
  332.  
  333. public OnFilterScriptExit()
  334. { return 1; }
  335.  
  336. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  337. {
  338. new carid = GetPlayerVehicleID(playerid);
  339. if ((newkeys & KEY_SECONDARY_ATTACK))
  340. {
  341. if(IsAnOwnableCar(carid) && CarInfo[carid][cOwned] == 0)
  342. {
  343. TogglePlayerControllable(playerid, 1);
  344. RemovePlayerFromVehicle(playerid);
  345. }
  346. }
  347. }
  348.  
  349. public SavePlayerData(playerid)
  350. {
  351. if(IsPlayerConnected(playerid))
  352. {
  353. new string3[32];
  354. new playername3[MAX_PLAYER_NAME];
  355. GetPlayerName(playerid, playername3, sizeof(playername3));
  356. format(string3, sizeof(string3), "carkeys/%s.ini", playername3);
  357. new File: hFile = fopen(string3, io_write);
  358. if (hFile)
  359. {
  360. new var[32];
  361. format(var, 32, "CarKey=%d\n",PlayerInfo[playerid][pPcarkey]);fwrite(hFile, var);
  362. format(var, 32, "CarKey2=%d\n",PlayerInfo[playerid][pPcarkey2]);fwrite(hFile, var);
  363. fclose(hFile);
  364. }
  365. }
  366. return 1;
  367. }
  368.  
  369. public CarKeys(playerid)
  370. {
  371. new string2[64];
  372. new playername2[MAX_PLAYER_NAME];
  373. GetPlayerName(playerid, playername2, sizeof(playername2));
  374. format(string2, sizeof(string2), "carkeys/%s.ini", playername2);
  375. new File: UserFile = fopen(string2, io_read);
  376. if ( UserFile )
  377. {
  378. new key[ 256 ] , val[ 256 ];
  379. new Data[ 256 ];
  380. while ( fread( UserFile , Data , sizeof( Data ) ) )
  381. {
  382. key = ini_GetKey( Data );
  383. if( strcmp( key , "CarKey" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pPcarkey] = strval( val ); }
  384. if( strcmp( key , "CarKey2" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pPcarkey2] = strval( val ); }
  385. }
  386. fclose(UserFile);
  387. }
  388. return 1;
  389. }
  390.  
  391. public OnPropUpdate()
  392. {
  393. new idx;
  394. new File: file2;
  395. idx = carsonserver;
  396. while (idx < sizeof(CarInfo))
  397. {
  398. new coordsstring[256];
  399. format(coordsstring, sizeof(coordsstring), "%d,%f,%f,%f,%f,%d,%d,%s,%s,%d,%d\n",
  400. CarInfo[idx][cModel],
  401. CarInfo[idx][cLocationx],
  402. CarInfo[idx][cLocationy],
  403. CarInfo[idx][cLocationz],
  404. CarInfo[idx][cAngle],
  405. CarInfo[idx][cColorOne],
  406. CarInfo[idx][cColorTwo],
  407. CarInfo[idx][cOwner],
  408. CarInfo[idx][cDescription],
  409. CarInfo[idx][cOwned],
  410. CarInfo[idx][cLock]);
  411. if(idx == carsonserver)
  412. {
  413. file2 = fopen("pcars.cfg", io_write);
  414. }
  415. else
  416. {
  417. file2 = fopen("pcars.cfg", io_append);
  418. }
  419. fwrite(file2, coordsstring);
  420. idx++;
  421. fclose(file2);
  422. }
  423. return 1;
  424. }
  425.  
  426. public IsAnOwnableCar(vehicleid)
  427. {
  428. if(vehicleid >= carsonserver && vehicleid <= 650) { return 1; }
  429. return 0;
  430. }
  431.  
  432. //---------------------------<[ OnDialogResponse ]>--------------------------------------------------------
  433.  
  434. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  435. {
  436. new string[256];
  437. new sendername[MAX_PLAYER_NAME];
  438. new giveplayerid;
  439. new idcar = GetPlayerVehicleID(playerid);
  440. if(dialogid==1234)
  441. {
  442. if(response)
  443. {
  444. if(strmatch("xEnOx", PlayerName(playerid))|| strmatch("xEnOn", PlayerName(playerid)))
  445. {
  446. if(IsPlayerInVehicle(playerid,idcar))
  447. {
  448. if(IsAnOwnableCar(idcar))
  449. {
  450. if(strlen(inputtext))
  451. {
  452. giveplayerid = ReturnUser(inputtext);
  453. if(PlayerInfo[giveplayerid][pPcarkey] == -1) { }
  454. else if(PlayerInfo[giveplayerid][pPcarkey2] == -1) { }
  455. else { SendClientMessage(playerid, COLOR_GREY, " That player allready have 2 cars"); return 1; }
  456. if(CarInfo[idcar][cOwned]==1)
  457. {
  458. SendClientMessage(playerid, COLOR_GREY, "Someone already owns this car");
  459. return 1;
  460. }
  461. if(PlayerInfo[giveplayerid][pPcarkey] == -1) { PlayerInfo[giveplayerid][pPcarkey] = idcar; }
  462. else if(PlayerInfo[giveplayerid][pPcarkey2] == -1) { PlayerInfo[giveplayerid][pPcarkey2] = idcar; }
  463. else { return 1; }
  464. CarInfo[idcar][cOwned] = 1;
  465. GetPlayerName(giveplayerid, sendername, sizeof(sendername));
  466. strmid(CarInfo[idcar][cOwner], sendername, 0, strlen(sendername), 999);
  467. SavePlayerData(giveplayerid);
  468. OnPropUpdate();
  469. format(string,128, " Personal car set to %s",sendername);
  470. SendClientMessage(playerid, COLOR_GREEN, string);
  471. RemovePlayerFromVehicle(playerid);
  472. }
  473. }
  474. else SendClientMessage(playerid, COLOR_GREY, " ERROR. That car is not a ownable car");
  475. }
  476. else SendClientMessage(playerid, COLOR_GREY, " You must be in ownable vehicle to set a personal car");
  477. }
  478. else SendClientMessage(playerid, COLOR_GREY, " You are not authorized to use that command");
  479. }
  480. }
  481. return 1;
  482. }
  483.  
  484. public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
  485. {
  486. if(IsAnOwnableCar(vehicleid) && CarInfo[vehicleid][cLock] == 1 && CarInfo[vehicleid][cOwned] == 1)
  487. {
  488. if(strmatch("xEnOx", PlayerName(playerid))|| strmatch("xEnOn", PlayerName(playerid))) { }
  489. else
  490. {
  491. new Float:cx, Float:cy, Float:cz;
  492. GetPlayerPos(playerid, cx, cy, cz);
  493. SetPlayerPos(playerid, cx, cy, cz);
  494. }
  495. }
  496. return 1;
  497. }
  498.  
  499. public OnVehicleSpawn(vehicleid)
  500. {
  501. return 1;
  502. }
  503.  
  504. public OnPlayerSpawn(playerid)
  505. {
  506. CarKeys(playerid);
  507. return 1;
  508. }
  509.  
  510. public OnPlayerConnect(playerid)
  511. {
  512. PlayerInfo[playerid][pPcarkey] = -1;
  513. PlayerInfo[playerid][pPcarkey2] = -1;
  514. for(new h = carsonserver; h < sizeof(CarInfo); h++)
  515. {
  516. SetVehicleParamsForPlayer(h,playerid,0,CarInfo[h][cLock]);
  517. }
  518. return 1;
  519. }
  520.  
  521. public OnPlayerDisconnect(playerid, reason)
  522. {
  523. return 1;
  524. }
  525.  
  526. public OnPlayerCommandText(playerid, cmdtext[])
  527. {
  528. new idx;
  529. new string[256];
  530. new cmd[256];
  531. new tmp[256];
  532. new playername[MAX_PLAYER_NAME];
  533. new idcar = GetPlayerVehicleID(playerid);
  534. new sendername[MAX_PLAYER_NAME];
  535. new giveplayerid;
  536. cmd = strtok(cmdtext, idx);
  537. new vehid;
  538. vehid = GetPlayerVehicleID(playerid);
  539.  
  540. if(strcmp(cmd, "/chelp", true) == 0)
  541. {
  542. if(strmatch("xEnOx", PlayerName(playerid))|| strmatch("xEnOn", PlayerName(playerid)))
  543. {
  544. SendClientMessage(playerid, COLOR_GRAD1, " ** Personal Cars Comands ** - /apark /upgradecars /asetkey /asetowner /acreatecar /adeletecar /checkcars ");
  545. }
  546. }
  547. if(strcmp(cmd, "/apark", true) == 0)
  548. {
  549. if(IsPlayerConnected(playerid))
  550. {
  551. new Float:x,Float:y,Float:z;
  552. new Float:a;
  553. new carid;
  554. carid = GetPlayerVehicleID(playerid);
  555. GetPlayerName(playerid, playername, sizeof(playername));
  556. GetVehiclePos(carid, x, y, z);
  557. GetVehicleZAngle(carid, a);
  558. if(strmatch("xEnOx", PlayerName(playerid))|| strmatch("xEnOn", PlayerName(playerid)))
  559. {
  560. CarInfo[carid][cLocationx] = x;
  561. CarInfo[carid][cLocationy] = y;
  562. CarInfo[carid][cLocationz] = z;
  563. CarInfo[carid][cAngle] = a;
  564. format(string, sizeof(string), "New position saved ( by admin %s)", playername);
  565. OnPropUpdate(); SavePlayerData(playerid);
  566. DestroyVehicle(carid);
  567. new thatcar = CreateVehicle(CarInfo[carid][cModel],CarInfo[carid][cLocationx],CarInfo[carid][cLocationy],CarInfo[carid][cLocationz]+1.0,CarInfo[carid][cAngle],CarInfo[carid][cColorOne],CarInfo[carid][cColorTwo],999999);
  568. PutPlayerInVehicle(playerid,thatcar,0);
  569. return 1;
  570. }
  571. else
  572. {
  573. SendClientMessage(playerid, COLOR_GREY, " You are not authorized to use that command !");
  574. return 1;
  575. }
  576. }
  577. return 1;
  578. }
  579. if(strcmp(cmd, "/asetowner",true) == 0)
  580. {
  581. if(IsPlayerConnected(playerid))
  582. {
  583. tmp = strtok(cmdtext, idx);
  584. if(!strlen(tmp))
  585. {
  586. SendClientMessage(playerid, COLOR_GRAD1, "USAGE: /asetowner [playerid/PartOfName]");
  587. return 1;
  588. }
  589. giveplayerid = ReturnUser(tmp);
  590. if(strmatch("xEnOx", PlayerName(playerid))|| strmatch("xEnOn", PlayerName(playerid)))
  591. {
  592. if(IsPlayerInVehicle(playerid, idcar) && IsAnOwnableCar(idcar))
  593. {
  594. if(PlayerInfo[giveplayerid][pPcarkey] == -1) { }
  595. else if(PlayerInfo[giveplayerid][pPcarkey2] == -1) { }
  596. else { SendClientMessage(playerid, COLOR_GREY, " That player allready have 2 cars"); return 1; }
  597. if(PlayerInfo[giveplayerid][pPcarkey] == -1) { PlayerInfo[giveplayerid][pPcarkey] = idcar; }
  598. else if(PlayerInfo[giveplayerid][pPcarkey2] == -1) { PlayerInfo[giveplayerid][pPcarkey2] = idcar; }
  599. else { return 1; }
  600. if(CarInfo[idcar][cOwned] == 0)
  601. {
  602. CarInfo[idcar][cOwned] = 1;
  603. }
  604. GetPlayerName(giveplayerid, sendername, sizeof(sendername));
  605. format(string, 128, " Masina lui %s i-a fost data lui %s ", CarInfo[idcar][cOwner], sendername);
  606. SendClientMessage(playerid,COLOR_GREEN, string);
  607. strmid(CarInfo[idcar][cOwner], sendername, 0, strlen(sendername), 999);
  608. SavePlayerData(giveplayerid);
  609. OnPropUpdate();
  610. RemovePlayerFromVehicle(playerid);
  611. }
  612. else SendClientMessage(playerid, COLOR_GRAD1, " You must be in the personal car");
  613. }
  614. }
  615. }
  616. if(strcmp(cmd, "/checkcars",true) == 0)
  617. {
  618. if(IsPlayerConnected(playerid))
  619. {
  620. tmp = strtok(cmdtext, idx);
  621. if(!strlen(tmp))
  622. {
  623. SendClientMessage(playerid, COLOR_GRAD1, "USAGE: /checkcars [playerid/PartOfName]");
  624. return 1;
  625. }
  626. giveplayerid = ReturnUser(tmp);
  627. if(strmatch("xEnOx", PlayerName(playerid))|| strmatch("xEnOn", PlayerName(playerid)))
  628. {
  629. if(IsPlayerConnected(giveplayerid))
  630. {
  631. new carkey = PlayerInfo[giveplayerid][pPcarkey];
  632. new carkey2 = PlayerInfo[giveplayerid][pPcarkey2];
  633. GetPlayerName(giveplayerid,sendername,38);
  634. if (PlayerInfo[giveplayerid][pPcarkey] != -1)
  635. {
  636. format(string, 128, " *** [%s 's vehicle stats] ***",sendername);
  637. SendClientMessage(playerid, COLOR_GREEN, string);
  638. format(string, sizeof(string), "{00C8FF}Slot:[1] ** VehModel:[%s] ** VehCol1:[%d] ** VehCol2:[%d] ** OldVehID[%d]", CarInfo[carkey][cDescription], CarInfo[carkey][cColorOne], CarInfo[carkey][cColorTwo], CarInfo[carkey][cLock],PlayerInfo[giveplayerid][pPcarkey]);
  639. SendClientMessage(playerid, COLOR_GRAD5,string);
  640. }
  641. if (PlayerInfo[playerid][pPcarkey2] != -1)
  642. {
  643. format(string, sizeof(string), "{007BFF}Slot:[2] ** VehModel:[%s] ** VehCol1:[%d] ** VehCol2:[%d] ** OldVehID[%d]", CarInfo[carkey2][cDescription], CarInfo[carkey2][cColorOne], CarInfo[carkey2][cColorTwo], CarInfo[carkey2][cLock],PlayerInfo[giveplayerid][pPcarkey2]);
  644. SendClientMessage(playerid, COLOR_GRAD5,string);
  645. }
  646. if(PlayerInfo[giveplayerid][pPcarkey] == -1 && PlayerInfo[giveplayerid][pPcarkey2] == -1)
  647. {
  648. SendClientMessage(playerid,COLOR_GRAD5, " That player haven't a personal vehicle");
  649. }
  650. }
  651. else SendClientMessage(playerid,COLOR_GRAD1, " Wrong player ID");
  652. }
  653. else SendClientMessage(playerid, COLOR_GRAD1, " You are not authorized to use that commad");
  654. }
  655. }
  656. /* if(strcmp(cmd,"/upgradecars",true) == 0)
  657. {
  658. if(strmatch("xEnOn", PlayerName(playerid))|| strmatch("xEnOn", PlayerName(playerid)))
  659. {
  660. for(new i=carsonserver; i<sizeof(CarInfo); i++)
  661. {
  662. DestroyVehicle(i);
  663. }
  664. LoadCar();
  665. for(new h = carsonserver; h < sizeof(CarInfo); h++)
  666. {
  667. AddStaticVehicleEx(CarInfo[h][cModel],CarInfo[h][cLocationx],CarInfo[h][cLocationy],CarInfo[h][cLocationz]+1.0,CarInfo[h][cAngle],CarInfo[h][cColorOne],CarInfo[h][cColorTwo],60000);
  668. }
  669. SendClientMessageToAll(-1," {DB3737}* {AEFF00}All personal cars has been updated! .");
  670. }
  671. else SendClientMessage(playerid, COLOR_GRAD1, " You are not authorized to use that commad");
  672. }*/
  673. if(strcmp(cmd, "/asetkey", true) == 0)
  674. {
  675. if(IsPlayerConnected(playerid))
  676. {
  677. tmp = strtok(cmdtext, idx);
  678. if(!strlen(tmp))
  679. {
  680. SendClientMessage(playerid, COLOR_GRAD1, "USAGE: /asetkey [playerid/PartOfName] [carkey] [amount]");
  681. SendClientMessage(playerid, COLOR_GRAD4, "|1 CarKey |2 CarKey2 |3 CarKey3");
  682. return 1;
  683. }
  684. giveplayerid = ReturnUser(tmp);
  685. if(strmatch("xEnOn", PlayerName(playerid))|| strmatch("xEnOn", PlayerName(playerid)))
  686. {
  687. if(giveplayerid != INVALID_PLAYER_ID)
  688. {
  689. tmp = strtok(cmdtext, idx);
  690. if(!strlen(tmp))
  691. {
  692. SendClientMessage(playerid, COLOR_GRAD1, "USAGE: /asetkey [playerid/PartOfName] [carkey] [amount]");
  693. SendClientMessage(playerid, COLOR_GRAD4, "|1 CarKey |2 CarKey2 |3 CarKey3");
  694. return 1;
  695. }
  696. new stat;
  697. stat = strval(tmp);
  698. tmp = strtok(cmdtext, idx);
  699. if(!strlen(tmp))
  700. {
  701. SendClientMessage(playerid, COLOR_GRAD1, "USAGE: /asetkey [playerid/PartOfName] [carkey] [amount]");
  702. SendClientMessage(playerid, COLOR_GRAD4, "|1 CarKey |2 CarKey2 |3 CarKey3");
  703. return 1;
  704. }
  705. new amount;
  706. amount = strval(tmp);
  707. switch (stat)
  708. {
  709. case 1:
  710. {
  711. PlayerInfo[giveplayerid][pPcarkey] = amount;
  712. format(string, sizeof(string), " The Player Car Key Was Set To %d", amount);
  713. SavePlayerData(playerid);
  714. }
  715. case 2:
  716. {
  717. PlayerInfo[giveplayerid][pPcarkey2] = amount;
  718. format(string, sizeof(string), " The Player Car Key 2 Was Set To %d", amount);
  719. SavePlayerData(playerid);
  720. }
  721. default:
  722. {
  723. format(string, sizeof(string), " Invalid Car Key Code", amount);
  724. }
  725. }
  726. SendClientMessage(playerid, COLOR_GRAD1, string);
  727. }
  728. }
  729. else
  730. {
  731. SendClientMessage(playerid, COLOR_GRAD1, " Doar adminii pot folosi aceasta comanda!");
  732. return 1;
  733. }
  734. }
  735. return 1;
  736. }
  737. /*if(strcmp(cmd, "/adeletecar", true) == 0)
  738. {
  739. if(strmatch("xEnOn", PlayerName(playerid))|| strmatch("xEnOn", PlayerName(playerid)))
  740. {
  741. CarInfo[idcar][cOwned] = 0; CarInfo[idcar][cModel] = 0; CarInfo[idcar][cColorOne] = 0; CarInfo[idcar][cColorTwo] = 0;
  742. CarInfo[idcar][cLocationx] = 0; CarInfo[idcar][cLocationy] = 0; CarInfo[idcar][cLocationz] = 0; CarInfo[idcar][cAngle] = 0;
  743. CarInfo[idcar][cLock] = 0;
  744. strmid(CarInfo[idcar][cOwner], "No-one", 0, strlen("No-one"), 999);
  745. format(CarInfo[idcar][cDescription], 32, "0");
  746. DestroyVehicle(idcar);
  747. OnPropUpdate(); SavePlayerData(playerid);
  748. }
  749. }*/
  750. if(strcmp(cmd, "/acreatecar", true) == 0)
  751. {
  752. if(strmatch("xEnOn", PlayerName(playerid))|| strmatch("xEnOn", PlayerName(playerid)))
  753. {
  754.  
  755. tmp = strtok(cmdtext, idx);
  756. if(!strlen(tmp))
  757. {
  758. SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /acreatecar [carid] [culoare1] [culoare2]");
  759. return 1;
  760. }
  761. new car;
  762. car = strval(tmp);
  763. if(car < 400 || car > 611) { SendClientMessage(playerid, COLOR_WHITE, " Vehicle Number can't be below 400 or above 611 !"); return 1; }
  764. tmp = strtok(cmdtext, idx);
  765. if(!strlen(tmp))
  766. {
  767. SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /acreatecar [carid] [culoare1] [culoare2]");
  768. return 1;
  769. }
  770. new color1;
  771. color1 = strval(tmp);
  772. if(color1 < 0 || color1 > 252) { SendClientMessage(playerid, COLOR_WHITE, " Color Number can't be below 0 or above 252 !"); return 1; }
  773. tmp = strtok(cmdtext, idx);
  774. if(!strlen(tmp))
  775. {
  776. SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /acreatecar [carid] [culoare1] [culoare2]");
  777. return 1;
  778. }
  779. new color2;
  780. color2 = strval(tmp);
  781. if(color2 < 0 || color2 > 252) { SendClientMessage(playerid, COLOR_WHITE, " Color Number can't be below 0 or above 252 !"); return 1; }
  782. new Float:X,Float:Y,Float:Z; GetPlayerPos(playerid, X,Y,Z);
  783. new thiscar = CreateVehicle(car,X,Y,Z,1,color1,color2,99999999);
  784. CarInfo[thiscar][cOwned] = 0; CarInfo[thiscar][cModel] = car; CarInfo[thiscar][cColorOne] = color1; CarInfo[thiscar][cColorTwo] = color2;
  785. CarInfo[thiscar][cLocationx] = X; CarInfo[thiscar][cLocationy] = Y; CarInfo[thiscar][cLocationz] = Z; CarInfo[thiscar][cAngle] = 1;
  786. CarInfo[thiscar][cLock] = 0;
  787. PutPlayerInVehicle(playerid,thiscar,0);
  788. strmid(CarInfo[vehid][cOwner], "No-one", 0, strlen("No-one"), 999);
  789. format(CarInfo[thiscar][cDescription], 32, "%s",vehName[GetVehicleModel(GetPlayerVehicleID(playerid))-400]);
  790. format(string, sizeof(string), "The car %s [%d] has been created",CarInfo[thiscar][cDescription],thiscar);
  791. SendClientMessage(playerid, COLOR_BLUE, string);
  792. ShowPlayerDialog(playerid,1234,DIALOG_STYLE_INPUT,"{E0941B}Vehicle owner","Write playerid/PartOfName \nto make owner this car:","Enter","Close");
  793. }
  794. else
  795. {
  796. SendClientMessage(playerid, COLOR_GRAD1, " you are not authorized to use that command!");
  797. return 1;
  798. }
  799. }
  800. if(strcmp(cmd, "/v", true) == 0 || strcmp(cmd, "/vehicle", true) == 0)
  801. {
  802. if(IsPlayerConnected(playerid))
  803. {
  804. new x_nr[64];
  805. x_nr = strtok(cmdtext, idx);
  806. if(!strlen(x_nr))
  807. {
  808. SendClientMessage(playerid, COLOR_WHITE," ___________[Personal vehicle comands]__________");
  809. SendClientMessage(playerid, COLOR_WHITE, " ** {7ED43D}(/v)ehicle {3DBBD4}[name]");
  810. SendClientMessage(playerid, COLOR_WHITE, " ** save, model, color, lock(1-2), tow(1-2), fix(1-2), list");
  811. return 1;
  812. }
  813. else if(strcmp(x_nr,"list",true) == 0)
  814. {
  815. if(IsPlayerConnected(playerid))
  816. {
  817. new carkey = PlayerInfo[playerid][pPcarkey];
  818. new carkey2 = PlayerInfo[playerid][pPcarkey2];
  819. if (PlayerInfo[playerid][pPcarkey] != -1)
  820. {
  821. format(string, sizeof(string), "1| VehModel:[%s] VehColor1:[%d] VehColor2:[%d] VehLocked:[%d] VehOldID[%d]", CarInfo[carkey][cDescription], CarInfo[carkey][cColorOne], CarInfo[carkey][cColorTwo], CarInfo[carkey][cLock], carkey);
  822. SendClientMessage(playerid, COLOR_GRAD5,string);
  823. }
  824. if (PlayerInfo[playerid][pPcarkey2] != -1)
  825. {
  826. format(string, sizeof(string), "2| VehModel:[%s] VehColor1:[%d] VehColor2:[%d] VehLocked:[%d] VehOldID[%d]", CarInfo[carkey2][cDescription], CarInfo[carkey2][cColorOne], CarInfo[carkey2][cColorTwo], CarInfo[carkey2][cLock], carkey2);
  827. SendClientMessage(playerid, COLOR_GRAD5,string);
  828. }
  829. }
  830. }
  831. else if(strcmp(x_nr,"model",true) == 0)
  832. {
  833. new carid;
  834. new getcarid;
  835. if(GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pPcarkey]) { carid = PlayerInfo[playerid][pPcarkey]; }
  836. else if(GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pPcarkey2]) { carid = PlayerInfo[playerid][pPcarkey2]; }
  837. else { return 1; }
  838. getcarid = GetPlayerVehicleID(playerid);
  839. GetPlayerName(playerid, playername, sizeof(playername));
  840. if(IsPlayerInVehicle(playerid,carid) && CarInfo[carid][cOwned] == 1)
  841. {
  842. if(PlayerInfo[playerid][pPcarkey] == -1 && PlayerInfo[playerid][pPcarkey2] == -1)
  843. {
  844. SendClientMessage(playerid, COLOR_GREY, " You don't have a personal car.");
  845. return 1;
  846. }
  847. if(getcarid == carid)
  848. {
  849. if(PlayerInfo[playerid][pPcarkey] != -1 && PlayerInfo[playerid][pPcarkey2] != -1)
  850. {
  851. tmp = strtok(cmdtext, idx);
  852. if(!strlen(tmp))
  853. {
  854. SendClientMessage(playerid, COLOR_WHITE, "USAGE: /v model [vehicleid]");
  855. return 1;
  856. }
  857. new model;
  858. model = strval(tmp);
  859. if(model < 400 && model > 611)
  860. {
  861. SendClientMessage(playerid, COLOR_GREY, " Wrong model id!");
  862. return 1;
  863. }
  864. CarInfo[carid][cModel] = model;
  865. format(CarInfo[carid][cDescription], 32, "%s",vehName[model-400]);
  866. format(string, sizeof(string), " [Veh Info]: {3D9AD4}New vehicle model saved.");
  867. SendClientMessage(playerid, COLOR_YELLOW, string);
  868. OnPropUpdate(); SavePlayerData(playerid);
  869. DestroyVehicle(carid);
  870. new thatcar = CreateVehicle(CarInfo[carid][cModel],CarInfo[carid][cLocationx],CarInfo[carid][cLocationy],CarInfo[carid][cLocationz]+1.0,CarInfo[carid][cAngle],CarInfo[carid][cColorOne],CarInfo[carid][cColorTwo],999999);
  871. PutPlayerInVehicle(playerid,thatcar,0);
  872. TogglePlayerControllable(playerid, 1);
  873. return 1;
  874. }
  875. else SendClientMessage(playerid, COLOR_GREY, " ");
  876. }
  877. }
  878. else SendClientMessage(playerid, COLOR_GREY, " You are not in personal car");
  879. }
  880. else if(strcmp(x_nr,"save",true) == 0)
  881. {
  882. new Float:x,Float:y,Float:z;
  883. new Float:a;
  884. new carid;
  885. new getcarid;
  886. if(GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pPcarkey]) { carid = PlayerInfo[playerid][pPcarkey]; }
  887. else if(GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pPcarkey2]) { carid = PlayerInfo[playerid][pPcarkey2]; }
  888. else { return 1; }
  889. getcarid = GetPlayerVehicleID(playerid);
  890. GetPlayerName(playerid, playername, sizeof(playername));
  891. GetVehiclePos(carid, x, y, z);
  892. GetVehicleZAngle(carid, a);
  893. if(IsPlayerInVehicle(playerid,carid) && CarInfo[carid][cOwned] == 1)
  894. {
  895. if(PlayerInfo[playerid][pPcarkey] == -1 && PlayerInfo[playerid][pPcarkey2] == -1)
  896. {
  897. SendClientMessage(playerid, COLOR_GREY, " You don't have a personal car.");
  898. return 1;
  899. }
  900. if(getcarid == carid)
  901. {
  902. CarInfo[carid][cLocationx] = x;
  903. CarInfo[carid][cLocationy] = y;
  904. CarInfo[carid][cLocationz] = z;
  905. CarInfo[carid][cAngle] = a;
  906. format(string, sizeof(string), " [Veh Info]: {3D9AD4}New position saved.");
  907. SendClientMessage(playerid, COLOR_YELLOW, string);
  908. OnPropUpdate(); SavePlayerData(playerid);
  909. DestroyVehicle(carid);
  910. new thatcar = CreateVehicle(CarInfo[carid][cModel],CarInfo[carid][cLocationx],CarInfo[carid][cLocationy],CarInfo[carid][cLocationz]+1.0,CarInfo[carid][cAngle],CarInfo[carid][cColorOne],CarInfo[carid][cColorTwo],999999);
  911. PutPlayerInVehicle(playerid,thatcar,0);
  912. TogglePlayerControllable(playerid, 1);
  913. return 1;
  914. }
  915. }
  916. else SendClientMessage(playerid, COLOR_GREY, " You are not in personal car");
  917. }
  918. else if(strcmp(x_nr,"lock1",true) == 0)
  919. {
  920. new keycar = PlayerInfo[playerid][pPcarkey];
  921. if(keycar != -1)
  922. {
  923. new locked[256];
  924. locked = strtok(cmdtext, idx);
  925. if(CarInfo[keycar][cLock] == 1)
  926. {
  927. for(new i = 0; i < MAX_PLAYERS; i++)
  928. {
  929. if (IsPlayerConnected(i))
  930. {
  931. SetVehicleParamsForPlayer(keycar,i,0,0);
  932. }
  933. }
  934. format(string, sizeof(string), " [Veh Info]: {3BE8FF}Vehicle {08FC00}Unlocked");
  935. SendClientMessage(playerid, COLOR_YELLOW, string);
  936. CarInfo[keycar][cLock] = 0;
  937. OnPropUpdate(); SavePlayerData(playerid);
  938. return 1;
  939. }
  940. else if(CarInfo[keycar][cLock] == 0)
  941. {
  942. for(new i = 0; i < MAX_PLAYERS; i++)
  943. {
  944. if (IsPlayerConnected(i))
  945. {
  946. SetVehicleParamsForPlayer(keycar,i,0,1);
  947. }
  948. }
  949. format(string, sizeof(string), " [Veh Info]: {3BE8FF}Vehicle {FC0000}Locked");
  950. SendClientMessage(playerid, COLOR_YELLOW, string);
  951. CarInfo[keycar][cLock] = 1;
  952. OnPropUpdate(); SavePlayerData(playerid);
  953. return 1;
  954. }
  955. }
  956. else
  957. {
  958. SendClientMessage(playerid, COLOR_GREY, " You don't have a vehicle at slot 1");
  959. return 1;
  960. }
  961. }
  962. else if(strcmp(x_nr,"lock2",true) == 0)
  963. {
  964. new keycar = PlayerInfo[playerid][pPcarkey2];
  965. if(keycar != -1)
  966. {
  967. new locked[256];
  968. locked = strtok(cmdtext, idx);
  969. if(CarInfo[keycar][cLock] == 1)
  970. {
  971. for(new i = 0; i < MAX_PLAYERS; i++)
  972. {
  973. if (IsPlayerConnected(i))
  974. {
  975. SetVehicleParamsForPlayer(keycar,i,0,0);
  976. }
  977. }
  978. format(string, sizeof(string), " [Veh Info]: {3BE8FF}Vehicle {08FC00}Unlocked");
  979. SendClientMessage(playerid, COLOR_YELLOW, string);
  980. CarInfo[keycar][cLock] = 0;
  981. OnPropUpdate(); SavePlayerData(playerid);
  982. return 1;
  983. }
  984. else if(CarInfo[keycar][cLock] == 0)
  985. {
  986. for(new i = 0; i < MAX_PLAYERS; i++)
  987. {
  988. if (IsPlayerConnected(i))
  989. {
  990. SetVehicleParamsForPlayer(keycar,i,0,1);
  991. }
  992. }
  993. format(string, sizeof(string), " [Veh Info]: {3BE8FF}Vehicle {FC0000}Locked");
  994. SendClientMessage(playerid, COLOR_YELLOW, string);
  995. CarInfo[keycar][cLock] = 1;
  996. OnPropUpdate(); SavePlayerData(playerid);
  997. return 1;
  998. }
  999. }
  1000. else
  1001. {
  1002. SendClientMessage(playerid, COLOR_GREY, " You don't have a vehicle at slot 2");
  1003. return 1;
  1004. }
  1005. }
  1006. else if(strcmp(x_nr,"color",true) == 0)
  1007. {
  1008. if(PlayerInfo[playerid][pPcarkey] == -1 && PlayerInfo[playerid][pPcarkey2] == -1)
  1009. {
  1010. SendClientMessage(playerid, COLOR_GREY," You don't have a vehicle to respray.");
  1011. return 1;
  1012. }
  1013. tmp = strtok(cmdtext, idx);
  1014. if(!strlen(tmp))
  1015. {
  1016. SendClientMessage(playerid, COLOR_WHITE, "USAGE: /v color [ColorOneID] [ColorTwoID]");
  1017. return 1;
  1018. }
  1019. new color1;
  1020. color1 = strval(tmp);
  1021. if(color1 < 0 && color1 > 252)
  1022. {
  1023. SendClientMessage(playerid, COLOR_GREY, " Wrong color id!");
  1024. return 1;
  1025. }
  1026. tmp = strtok(cmdtext, idx);
  1027. if(!strlen(tmp))
  1028. {
  1029. SendClientMessage(playerid, COLOR_WHITE, "USAGE: /v color [ColorOneID] [ColorTwoID]");
  1030. return 1;
  1031. }
  1032. new color2;
  1033. color2 = strval(tmp);
  1034. if(color2 < 0 && color2 > 252)
  1035. {
  1036. SendClientMessage(playerid, COLOR_GREY, " Wrong color id!");
  1037. return 1;
  1038. }
  1039.  
  1040. if(GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pPcarkey]) { vehid = PlayerInfo[playerid][pPcarkey]; }
  1041. else if(GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pPcarkey2]) { vehid = PlayerInfo[playerid][pPcarkey2]; }
  1042. else { return 1; }
  1043.  
  1044. if(IsPlayerInVehicle(playerid, vehid))
  1045. {
  1046. new carid;
  1047. CarInfo[vehid][cColorOne] = color1;
  1048. CarInfo[vehid][cColorTwo] = color2;
  1049. format(string, sizeof(string), " [Veh Info]: {3BE8FF}Vehicle color: Color1- %d , Color2- %d", color1,color2);
  1050. SendClientMessage(playerid,COLOR_YELLOW,string);
  1051. OnPropUpdate(); SavePlayerData(playerid);
  1052. DestroyVehicle(carid);
  1053. new thatcar = CreateVehicle(CarInfo[carid][cModel],CarInfo[carid][cLocationx],CarInfo[carid][cLocationy],CarInfo[carid][cLocationz]+1.0,CarInfo[carid][cAngle],CarInfo[carid][cColorOne],CarInfo[carid][cColorTwo],999999);
  1054. PutPlayerInVehicle(playerid,thatcar,0);
  1055. return 1;
  1056. }
  1057. else
  1058. {
  1059. SendClientMessage(playerid, COLOR_GREY," You are not in your vehicle.");
  1060. return 1;
  1061. }
  1062. }
  1063. else if(strcmp(x_nr,"fix1",true) == 0)
  1064. {
  1065. if(IsPlayerConnected(playerid))
  1066. {
  1067. new car = PlayerInfo[playerid][pPcarkey];
  1068. GetPlayerName(playerid, playername, sizeof(playername));
  1069. if (car != -1 && strcmp(playername, CarInfo[PlayerInfo[playerid][pPcarkey]][cOwner], true) == 0)
  1070. {
  1071. format(string, sizeof(string), " [Veh Info]: {3BE8FF}Your vehicle %s was respawned", CarInfo[car][cDescription]);
  1072. SendClientMessage(playerid, COLOR_YELLOW, string);
  1073. SetVehicleToRespawn(car);
  1074. PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
  1075. }
  1076. else
  1077. {
  1078. SendClientMessage(playerid, COLOR_GREY, " You don't have a personal car");
  1079. }
  1080. }
  1081. }
  1082. else if(strcmp(x_nr,"fix2",true) == 0)
  1083. {
  1084. if(IsPlayerConnected(playerid))
  1085. {
  1086. new car = PlayerInfo[playerid][pPcarkey2];
  1087. GetPlayerName(playerid, playername, sizeof(playername));
  1088. if (car != -1 && strcmp(playername, CarInfo[PlayerInfo[playerid][pPcarkey2]][cOwner], true) == 0)
  1089. {
  1090. format(string, sizeof(string), " [Veh Info]: {3BE8FF}Your vehicle %s was respawned", CarInfo[car][cDescription]);
  1091. SendClientMessage(playerid, COLOR_YELLOW, string);
  1092. SetVehicleToRespawn(car);
  1093. PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
  1094. }
  1095. else
  1096. {
  1097. SendClientMessage(playerid, COLOR_GREY, " You don't have a personal car");
  1098. }
  1099. }
  1100. }
  1101. else if(strcmp(x_nr,"tow1",true) == 0)
  1102. {
  1103. if(IsPlayerConnected(playerid))
  1104. {
  1105. new car = PlayerInfo[playerid][pPcarkey];
  1106. GetPlayerName(playerid, playername, sizeof(playername));
  1107. if (car != -1 && strcmp(playername, CarInfo[PlayerInfo[playerid][pPcarkey]][cOwner], true) == 0)
  1108. {
  1109. format(string, sizeof(string), " [Veh Info]: {3BE8FF}Your vehicle %s was towed", CarInfo[car][cDescription]);
  1110. SendClientMessage(playerid, COLOR_YELLOW, string);
  1111. SetVehiclePos(car,CarInfo[car][cLocationx],CarInfo[car][cLocationy],CarInfo[car][cLocationz]);
  1112. SetVehicleZAngle(car, CarInfo[car][cAngle]);
  1113. PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
  1114. }
  1115. else
  1116. {
  1117. SendClientMessage(playerid, COLOR_GREY, " You don't have a personal car");
  1118. }
  1119. }
  1120. }
  1121. else if(strcmp(x_nr,"tow2",true) == 0)
  1122. {
  1123. if(IsPlayerConnected(playerid))
  1124. {
  1125. new car = PlayerInfo[playerid][pPcarkey2];
  1126. GetPlayerName(playerid, playername, sizeof(playername));
  1127. if (car != -1 && strcmp(playername, CarInfo[PlayerInfo[playerid][pPcarkey2]][cOwner], true) == 0)
  1128. {
  1129. format(string, sizeof(string), " [Veh Info]: {3BE8FF}Your vehicle %s was towed", CarInfo[car][cDescription]);
  1130. SendClientMessage(playerid, COLOR_YELLOW, string);
  1131. SetVehiclePos(car,CarInfo[car][cLocationx],CarInfo[car][cLocationy],CarInfo[car][cLocationz]);
  1132. SetVehicleZAngle(car, CarInfo[car][cAngle]);
  1133. PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
  1134. }
  1135. else
  1136. {
  1137. SendClientMessage(playerid, COLOR_GREY, " You don't have a personal car");
  1138. }
  1139. }
  1140. }
  1141. else
  1142. {
  1143. SendClientMessage(playerid, COLOR_WHITE," ___________[Personal vehicle comands]__________");
  1144. SendClientMessage(playerid, COLOR_WHITE, " ** {7ED43D}(/v)ehicle {3DBBD4}[name]");
  1145. SendClientMessage(playerid, COLOR_WHITE, " ** save, model, color, lock(1-2), tow(1-2), fix(1-2), list");
  1146. return 1;
  1147. }
  1148. }
  1149. return 1;
  1150. }
  1151. return 0;
  1152. }
  1153.  
  1154. public OnPlayerEnterCheckpoint(playerid)
  1155. {
  1156. DisablePlayerCheckpoint(playerid);
  1157. return 1;
  1158. }
  1159. /*----------Car Save Functions----------*/
  1160.  
  1161. public LoadCar()
  1162. {
  1163. new arrCoords[31][64];
  1164. new strFromFile2[256];
  1165. new File: file = fopen("pcars.cfg", io_read);
  1166. if (file)
  1167. {
  1168. new idx = carsonserver;
  1169. while (idx < sizeof(CarInfo))
  1170. {
  1171. fread(file, strFromFile2);
  1172. split(strFromFile2, arrCoords, ',');
  1173. CarInfo[idx][cModel] = strval(arrCoords[0]);
  1174. CarInfo[idx][cLocationx] = floatstr(arrCoords[1]);
  1175. CarInfo[idx][cLocationy] = floatstr(arrCoords[2]);
  1176. CarInfo[idx][cLocationz] = floatstr(arrCoords[3]);
  1177. CarInfo[idx][cAngle] = floatstr(arrCoords[4]);
  1178. CarInfo[idx][cColorOne] = strval(arrCoords[5]);
  1179. CarInfo[idx][cColorTwo] = strval(arrCoords[6]);
  1180. strmid(CarInfo[idx][cOwner], arrCoords[7], 0, strlen(arrCoords[7]), 255);
  1181. strmid(CarInfo[idx][cDescription], arrCoords[8], 0, strlen(arrCoords[8]), 255);
  1182. CarInfo[idx][cOwned] = strval(arrCoords[9]);
  1183. CarInfo[idx][cLock] = strval(arrCoords[10]);
  1184. printf("CarInfo: %d Owner:%s Discription: %s",idx,CarInfo[idx][cOwner],CarInfo[idx][cDescription]);
  1185. idx++;
  1186. }
  1187. }
  1188. return 1;
  1189. }
  1190.  
  1191. public SaveCarCoords()
  1192. {
  1193. new idx;
  1194. new File: file2;
  1195. while (idx < sizeof(CarInfo))
  1196. {
  1197. new coordsstring[256];
  1198. format(coordsstring, sizeof(coordsstring), "%d|%f|%f|%f|%f|%d|%d\n",
  1199. CarInfo[idx][cModel],
  1200. CarInfo[idx][cLocationx],
  1201. CarInfo[idx][cLocationy],
  1202. CarInfo[idx][cLocationz],
  1203. CarInfo[idx][cAngle],
  1204. CarInfo[idx][cColorOne],
  1205. CarInfo[idx][cColorTwo]);
  1206. if(idx == carsonserver)
  1207. {
  1208. file2 = fopen("pcars.cfg", io_write);
  1209. }
  1210. else
  1211. {
  1212. file2 = fopen("pcars.cfg", io_append);
  1213. }
  1214. fwrite(file2, coordsstring);
  1215. idx++;
  1216. fclose(file2);
  1217. }
  1218. return 1;
  1219. }
  1220.  
  1221. public OnPlayerStateChange(playerid, newstate, oldstate)
  1222. {
  1223. new string[128];
  1224. new vehicle = GetPlayerVehicleID(playerid);
  1225. new newcar = GetPlayerVehicleID(playerid);
  1226. new name[MAX_PLAYER_NAME], Float:x,Float:y,Float:z;
  1227. GetPlayerPos(playerid,x,y,z);
  1228. GetPlayerName(playerid,name,sizeof(name));
  1229. if(newstate == PLAYER_STATE_DRIVER)
  1230. {
  1231. if(IsAnOwnableCar(newcar))
  1232. {
  1233. if(CarInfo[newcar][cOwned]==1)
  1234. {
  1235. if(strcmp(name,CarInfo[newcar][cOwner], true) == 0)
  1236. {
  1237. format(string,sizeof(string)," * Vehiculul tau, %s",CarInfo[newcar][cOwner]);
  1238. SendClientMessage(playerid, COLOR_BLUE, string);
  1239. if(PlayerInfo[playerid][pPcarkey] == vehicle) { }
  1240. else if(PlayerInfo[playerid][pPcarkey2] == vehicle) { }
  1241. }
  1242. else
  1243. {
  1244. if(strmatch("xEnOn", PlayerName(playerid))|| strmatch("xEnOn", PlayerName(playerid)))
  1245. {
  1246. SendClientMessage(playerid, COLOR_GREY, " You can drive this car because you are xEnOx");
  1247. }
  1248. else
  1249. {
  1250. SetPlayerPos(playerid,x,y,z+2);
  1251. }
  1252. format(string, sizeof(string), " * Aceast vehicul apartine lui: %s",CarInfo[newcar][cOwner]);
  1253. SendClientMessage(playerid, COLOR_GREY, string);
  1254. }
  1255. }
  1256. }
  1257. }
  1258. return 1;
  1259. }
  1260.  
  1261. stock ini_GetKey( line[] )
  1262. {
  1263. new keyRes[256];
  1264. keyRes[0] = 0;
  1265. if ( strfind( line , "=" , true ) == -1 ) return keyRes;
  1266. strmid( keyRes , line , 0 , strfind( line , "=" , true ) , sizeof( keyRes) );
  1267. return keyRes;
  1268. }
  1269.  
  1270. stock ini_GetValue( line[] )
  1271. {
  1272. new valRes[256];
  1273. valRes[0]=0;
  1274. if ( strfind( line , "=" , true ) == -1 ) return valRes;
  1275. strmid( valRes , line , strfind( line , "=" , true )+1 , strlen( line ) , sizeof( valRes ) );
  1276. return valRes;
  1277. }
  1278.  
  1279. stock strmatch(const String1[], const String2[])
  1280. {
  1281. if((strcmp(String1, String2, true, strlen(String2)) == 0) && (strlen(String2) == strlen(String1)))
  1282. {
  1283. return true;
  1284. }
  1285. else
  1286. {
  1287. return false;
  1288. }
  1289. }
  1290.  
  1291. stock PlayerName(playerid)
  1292. {
  1293. new name[MAX_PLAYER_NAME];
  1294. GetPlayerName(playerid, name, sizeof(name));
  1295. return name;
  1296. }
Advertisement
Add Comment
Please, Sign In to add comment