Advertisement
Guest User

Untitled

a guest
Dec 15th, 2011
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 29.45 KB | None | 0 0
  1. //===========================Section: Includes==================================
  2. #include <a_samp>
  3. #include <utils>
  4. //===========================Section: Definations===============================
  5. #define COLOR_GRAD1 0xB4B5B7FF
  6. #define COLOR_GRAD2 0xBFC0C2FF
  7. #define COLOR_GRAD3 0xCBCCCEFF
  8. #define COLOR_GRAD4 0xD8D8D8FF
  9. #define COLOR_GRAD5 0xE3E3E3FF
  10. #define COLOR_GRAD6 0xF0F0F0FF
  11. #define COLOR_GREEN 0x33AA33AA
  12. #define COLOR_GREY 0xAFAFAFAA
  13. #define COLOR_WHITE 0xFFFFFFAA
  14. #define COLOR_YELLOW 0xFFFF00AA
  15. #define COLOR_YELLOW2 0xF5DEB3AA
  16. #define COLOR_BLUE 0x2641FEAA
  17.  
  18. #pragma tabsize 0
  19.  
  20.  
  21. //===========================Section: Forwards==================================
  22.  
  23. forward LoadCar();
  24. forward SaveCarCoords();
  25. forward OnPropUpdate();
  26. forward IsAnOwnableCar(vehicleid);
  27. forward CarKeys(playerid);
  28. forward SavePlayerData(playerid);
  29.  
  30.  
  31.  
  32. new carsonserver = 290;
  33.  
  34. new OwnableCarID[MAX_PLAYERS];
  35.  
  36.  
  37. new vehName[][] = {
  38. "Landstalker",
  39. "Bravura",
  40. "Buffalo",
  41. "Linerunner",
  42. "Perrenial",
  43. "Sentinel",
  44. "Dumper",
  45. "Firetruck",
  46. "Trashmaster",
  47. "Stretch",
  48. "Manana",
  49. "Infernus",
  50. "Voodoo",
  51. "Pony",
  52. "Mule",
  53. "Cheetah",
  54. "Ambulance",
  55. "Leviathan",
  56. "Moonbeam",
  57. "Esperanto",
  58. "Taxi",
  59. "Washington",
  60. "Bobcat",
  61. "Whoopee",
  62. "BF Injection",
  63. "Hunter",
  64. "Premier",
  65. "Enforcer",
  66. "Securicar",
  67. "Banshee",
  68. "Predator",
  69. "Bus",
  70. "Rhino",
  71. "Barracks",
  72. "Hotknife",
  73. "Trailer",
  74. "Previon",
  75. "Coach",
  76. "Cabbie",
  77. "Stallion",
  78. "Rumpo",
  79. "RC Bandit",
  80. "Romero",
  81. "Packer",
  82. "Monster",
  83. "Admiral",
  84. "Squalo",
  85. "Seasparrow",
  86. "Pizzaboy",
  87. "Tram",
  88. "Trailer",
  89. "Turismo",
  90. "Speeder",
  91. "Reefer",
  92. "Tropic",
  93. "Flatbed",
  94. "Yankee",
  95. "Caddy",
  96. "Solair",
  97. "Berkley's RC Van",
  98. "Skimmer",
  99. "PCJ-600",
  100. "Faggio",
  101. "Freeway",
  102. "RC Baron",
  103. "RC Raider",
  104. "Glendale",
  105. "Oceanic",
  106. "Sanchez",
  107. "Sparrow",
  108. "Patriot",
  109. "ATV",
  110. "Coastguard",
  111. "Dinghy",
  112. "Hermes",
  113. "Sabre",
  114. "Rustler",
  115. "ZR-350",
  116. "Walton",
  117. "Regina",
  118. "Comet",
  119. "BMX",
  120. "Burrito",
  121. "Camper",
  122. "Marquis",
  123. "Baggage",
  124. "Dozer",
  125. "Maverick",
  126. "News Chopper",
  127. "Rancher",
  128. "FBI Rancher",
  129. "Virgo",
  130. "Greenwood",
  131. "Jetmax",
  132. "Hotring",
  133. "Sandking",
  134. "Blista Compact",
  135. "Police Maverick",
  136. "Boxvillde",
  137. "Benson",
  138. "Mesa",
  139. "RC Goblin",
  140. "Hotring Racer A",
  141. "Hotring Racer B",
  142. "Bloodring Banger",
  143. "Rancher",
  144. "Super GT",
  145. "Elegant",
  146. "Journey",
  147. "Bike",
  148. "Mountain Bike",
  149. "Beagle",
  150. "Cropduster",
  151. "Stunt",
  152. "Tanker",
  153. "Roadtrain",
  154. "Nebula",
  155. "Majestic",
  156. "Buccaneer",
  157. "Shamal",
  158. "Hydra",
  159. "FCR-900",
  160. "NRG-500",
  161. "HPV1000",
  162. "Cement Truck",
  163. "Tow Truck",
  164. "Fortune",
  165. "Cadrona",
  166. "FBI Truck",
  167. "Willard",
  168. "Forklift",
  169. "Tractor",
  170. "Combine",
  171. "Feltzer",
  172. "Remington",
  173. "Slamvan",
  174. "Blade",
  175. "Freight",
  176. "Streak",
  177. "Vortex",
  178. "Vincent",
  179. "Bullet",
  180. "Clover",
  181. "Sadler",
  182. "Firetruck",
  183. "Hustler",
  184. "Intruder",
  185. "Primo",
  186. "Cargobob",
  187. "Tampa",
  188. "Sunrise",
  189. "Merit",
  190. "Utility",
  191. "Nevada",
  192. "Jeep",
  193. "Windsor",
  194. "Monster",
  195. "Monster",
  196. "Uranus",
  197. "Jester",
  198. "Sultan",
  199. "Stratum",
  200. "Elegy",
  201. "Raindance",
  202. "RC Tiger",
  203. "Flash",
  204. "Tahoma",
  205. "Savanna",
  206. "Bandito",
  207. "Freight Flat",
  208. "Streak Carriage",
  209. "Kart",
  210. "Mower",
  211. "Dune",
  212. "Sweeper",
  213. "Broadway",
  214. "Tornado",
  215. "AT-400",
  216. "DFT-30",
  217. "Huntley",
  218. "Stafford",
  219. "BF-400",
  220. "News Van",
  221. "Tug",
  222. "Trailer",
  223. "Emperor",
  224. "Wayfarer",
  225. "Euros",
  226. "Hotdog",
  227. "Club",
  228. "Freight Box",
  229. "Trailer",
  230. "Andromada",
  231. "Dodo",
  232. "RC Cam",
  233. "Launch",
  234. "Police Car LSPD",
  235. "Police Car SFPD",
  236. "Police Car LVPD",
  237. "Police Ranger",
  238. "Picador",
  239. "S.W.A.T",
  240. "Alpha",
  241. "Phoenix",
  242. "Glendale",
  243. "Sadler",
  244. "Luggage",
  245. "Luggage",
  246. "Stairs",
  247. "Boxville",
  248. "Tiller",
  249. "Utility Trailer"
  250. };
  251. //===========================Section: Variables=================================
  252.  
  253. enum pInfo
  254. {
  255. pPcarkey,
  256. pPcarkey2,
  257. pPcarkey3,
  258. }
  259. new PlayerInfo[256][pInfo];
  260.  
  261. enum cInfo
  262. {
  263. cModel,
  264. Float:cLocationx,
  265. Float:cLocationy,
  266. Float:cLocationz,
  267. Float:cAngle,
  268. cColorOne,
  269. cColorTwo,
  270. cOwner[MAX_PLAYER_NAME],
  271. cDescription[12],
  272. cOwned,
  273. cLock
  274. };
  275. new CarInfo[1000][cInfo];
  276.  
  277.  
  278.  
  279. //===========================Section: Callbacks & Functions=====================
  280. public OnFilterScriptInit()
  281. {
  282.  
  283.  
  284. for(new h = carsonserver; h < sizeof(CarInfo); h++)
  285. {
  286. 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);
  287.  
  288. }
  289. return 1;
  290. }
  291.  
  292.  
  293. public SavePlayerData(playerid)
  294. {
  295. if(IsPlayerConnected(playerid))
  296. {
  297. new string3[32];
  298. new playername3[MAX_PLAYER_NAME];
  299. GetPlayerName(playerid, playername3, sizeof(playername3));
  300. format(string3, sizeof(string3), "carkeys/%s.ini", playername3);
  301. new File: hFile = fopen(string3, io_write);
  302. if (hFile)
  303. {
  304. new var[32];
  305. format(var, 32, "CarKey=%d\n",PlayerInfo[playerid][pPcarkey]);fwrite(hFile, var);
  306. format(var, 32, "CarKey2=%d\n",PlayerInfo[playerid][pPcarkey2]);fwrite(hFile, var);
  307. format(var, 32, "CarKey3=%d\n",PlayerInfo[playerid][pPcarkey3]);fwrite(hFile, var);
  308. fclose(hFile);
  309. }
  310. }
  311. return 1;
  312. }
  313. public OnPropUpdate()
  314. {
  315. new idx;
  316. new File: file2;
  317. idx = carsonserver;
  318. while (idx < sizeof(CarInfo))
  319. {
  320. new coordsstring[256];
  321. format(coordsstring, sizeof(coordsstring), "%d,%f,%f,%f,%f,%d,%d,%s,%s,%d,%s\n",
  322. CarInfo[idx][cModel],
  323. CarInfo[idx][cLocationx],
  324. CarInfo[idx][cLocationy],
  325. CarInfo[idx][cLocationz],
  326. CarInfo[idx][cAngle],
  327. CarInfo[idx][cColorOne],
  328. CarInfo[idx][cColorTwo],
  329. CarInfo[idx][cOwner],
  330. CarInfo[idx][cDescription],
  331. CarInfo[idx][cOwned],
  332. CarInfo[idx][cLock],
  333. if(idx == carsonserver)
  334. {
  335. file2 = fopen("masini.cfg", io_write);
  336. }
  337. else
  338. {
  339. file2 = fopen("masini.cfg", io_append);
  340. }
  341. fwrite(file2, coordsstring);
  342. idx++;
  343. fclose(file2);
  344. }
  345. return 0;
  346. }
  347.  
  348. public IsAnOwnableCar(vehicleid)
  349. {
  350. if(vehicleid >= carsonserver && vehicleid <= 1000) { return 1; }
  351. return 0;
  352. }
  353.  
  354.  
  355. public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
  356. {
  357. if(IsAnOwnableCar(vehicleid) && CarInfo[vehicleid][cLock] == 1 && CarInfo[vehicleid][cOwned] == 1)
  358. {
  359. if(IsPlayerAdmin(playerid)) { }
  360. else
  361. {
  362. new Float:cx, Float:cy, Float:cz;
  363. GetPlayerPos(playerid, cx, cy, cz);
  364. SetPlayerPos(playerid, cx, cy, cz);
  365. }
  366. }
  367. return 1;
  368. }
  369.  
  370.  
  371.  
  372.  
  373.  
  374. public OnPlayerSpawn(playerid)
  375. {
  376. CarKeys(playerid);
  377. return 1;
  378. }
  379.  
  380. public OnPlayerConnect(playerid)
  381. {
  382. PlayerInfo[playerid][pPcarkey] = -1;
  383. PlayerInfo[playerid][pPcarkey2] = -1;
  384. PlayerInfo[playerid][pPcarkey3] = -1;
  385. for(new h = carsonserver; h < sizeof(CarInfo); h++)
  386. {
  387. SetVehicleParamsForPlayer(h,playerid,0,CarInfo[h][cLock]);
  388. }
  389. return 1;
  390. }
  391.  
  392. public OnPlayerCommandText(playerid, cmdtext[])
  393. {
  394. new idx;
  395. new string[256];
  396. new cmd[256];
  397. new tmp[256];
  398. new sendername[MAX_PLAYER_NAME];
  399. new playername[MAX_PLAYER_NAME];
  400. new giveplayer[MAX_PLAYER_NAME];
  401. new giveplayerid;
  402. new idcar = GetPlayerVehicleID(playerid);
  403. cmd = strtok(cmdtext, idx);
  404. new vehid;
  405. vehid = GetPlayerVehicleID(playerid);
  406.  
  407.  
  408.  
  409. if (strcmp(cmd, "/mycars", true) == 0)
  410. {
  411. if(IsPlayerConnected(playerid))
  412. {
  413. new carkey = PlayerInfo[playerid][pPcarkey];
  414. new carkey2 = PlayerInfo[playerid][pPcarkey2];
  415. new carkey3 = PlayerInfo[playerid][pPcarkey3];
  416. if (PlayerInfo[playerid][pPcarkey] != -1)
  417. {
  418. format(string, sizeof(string), "1| VehModel:[%s] VehValue:[%d] VehColor1:[%d] VehColor2:[%d] VehLocked:[%d]", CarInfo[carkey][cDescription], CarInfo[carkey][cColorOne], CarInfo[carkey][cColorTwo], CarInfo[carkey][cLock]);
  419. SendClientMessage(playerid, COLOR_GRAD5,string);
  420. }
  421. if (PlayerInfo[playerid][pPcarkey2] != -1)
  422. {
  423. format(string, sizeof(string), "2| VehModel:[%s] VehValue:[%d] VehColor1:[%d] VehColor2:[%d] VehLocked:[%d]", CarInfo[carkey2][cDescription], CarInfo[carkey2][cColorOne], CarInfo[carkey2][cColorTwo], CarInfo[carkey2][cLock]);
  424. SendClientMessage(playerid, COLOR_GRAD5,string);
  425. }
  426. if (PlayerInfo[playerid][pPcarkey3] != -1)
  427. {
  428. format(string, sizeof(string), "3| VehModel:[%s] VehValue:[%d] VehColor1:[%d] VehColor2:[%d] VehLocked:[%d]", CarInfo[carkey3][cDescription], CarInfo[carkey3][cColorOne], CarInfo[carkey3][cColorTwo], CarInfo[carkey3][cLock]);
  429. SendClientMessage(playerid, COLOR_GRAD5,string);
  430. }
  431. }
  432. return 1;
  433. }
  434.  
  435. if(strcmp(cmd, "/apark", true) == 0)
  436. {
  437. if(IsPlayerConnected(playerid))
  438. {
  439. new Float:x,Float:y,Float:z;
  440. new Float:a;
  441. new carid;
  442. carid = GetPlayerVehicleID(playerid);
  443. GetPlayerName(playerid, playername, sizeof(playername));
  444. GetVehiclePos(carid, x, y, z);
  445. GetVehicleZAngle(carid, a);
  446. if(IsPlayerAdmin(playerid))
  447. {
  448. CarInfo[carid][cLocationx] = x;
  449. CarInfo[carid][cLocationy] = y;
  450. CarInfo[carid][cLocationz] = z;
  451. CarInfo[carid][cAngle] = a;
  452. format(string, sizeof(string), "~n~ You have parked your car in this location. ~n~");
  453. GameTextForPlayer(playerid, "You have parked this car in this position. It will respawn here.", 10000, 3);
  454. OnPropUpdate(); SavePlayerData(playerid);
  455. DestroyVehicle(carid);
  456. new thiscar = CreateVehicle(CarInfo[carid][cModel],CarInfo[carid][cLocationx],CarInfo[carid][cLocationy],CarInfo[carid][cLocationz]+1.0,CarInfo[carid][cAngle],CarInfo[carid][cColorOne],CarInfo[carid][cColorTwo],60000);
  457.  
  458. return 1;
  459. }
  460. else
  461. {
  462. SendClientMessage(playerid, COLOR_GREY, " You are not authorized to use that command !");
  463. return 1;
  464. }
  465. }
  466. return 1;
  467. }
  468.  
  469.  
  470.  
  471. if(strcmp(cmd, "/acreatecar", true) == 0)
  472. {
  473. if(IsPlayerAdmin(playerid))
  474. {
  475. tmp = strtok(cmdtext, idx);
  476. if(!strlen(tmp))
  477. {
  478. SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /acreatecar [carid] [culoare1] [culoare2] ");
  479. return 1;
  480. }
  481. new car;
  482. car = strval(tmp);
  483. if(car < 400 || car > 611) { SendClientMessage(playerid, COLOR_WHITE, " Vehicle Number can't be below 400 or above 611 !"); return 1; }
  484. tmp = strtok(cmdtext, idx);
  485. if(!strlen(tmp))
  486. {
  487. SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /acreatecar [carid] [culoare1] [culoare2] ");
  488. return 1;
  489. }
  490. new color1;
  491. color1 = strval(tmp);
  492. if(color1 < 0 || color1 > 126) { SendClientMessage(playerid, COLOR_WHITE, " Color Number can't be below 0 or above 126 !"); return 1; }
  493. tmp = strtok(cmdtext, idx);
  494. if(!strlen(tmp))
  495. {
  496. SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /acreatecar [carid] [culoare1] [culoare2]");
  497. return 1;
  498. }
  499. new color2;
  500. color2 = strval(tmp);
  501. if(color2 < 0 || color2 > 126) { SendClientMessage(playerid, COLOR_WHITE, " Color Number can't be below 0 or above 126 !"); return 1; }
  502. tmp = strtok(cmdtext, idx);
  503. if(!strlen(tmp))
  504. {
  505. SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /acreatecar [carid] [culoare1] [culoare2] ");
  506. return 1;
  507. }
  508. new value;
  509. value = strval(tmp);
  510. new Float:X,Float:Y,Float:Z; GetPlayerPos(playerid, X,Y,Z);
  511. new thiscar = CreateVehicle(car,X,Y,Z,1,color1,color2,99999999);
  512. CarInfo[thiscar][cOwned] = 0; CarInfo[thiscar][cModel] = car; CarInfo[thiscar][cColorOne] = color1; CarInfo[thiscar][cColorTwo] = color2;
  513. CarInfo[thiscar][cLocationx] = X; CarInfo[thiscar][cLocationy] = Y; CarInfo[thiscar][cLocationz] = Z; CarInfo[thiscar][cAngle] = 1;
  514. PutPlayerInVehicle(playerid,thiscar,0);
  515. strmid(CarInfo[vehid][cOwner], "Dealership", 0, strlen("Dealership"), 999);
  516. format(CarInfo[thiscar][cDescription], 32, "%s",vehName[GetVehicleModel(GetPlayerVehicleID(playerid))-400]);
  517. format(string, sizeof(string), " Masina %d a fost creata cu succes!.", thiscar);
  518. SendClientMessage(playerid, COLOR_BLUE, string);
  519. }
  520. else
  521. {
  522. SendClientMessage(playerid, COLOR_GRAD1, " you are not authorized to use that command!");
  523. return 1;
  524. }
  525. }
  526.  
  527.  
  528.  
  529.  
  530.  
  531. if(strcmp(cmd, "/v", true) == 0 || strcmp(cmd, "/vehicle", true) == 0)
  532. {
  533. if(IsPlayerConnected(playerid))
  534. {
  535. new x_nr[64];
  536. x_nr = strtok(cmdtext, idx);
  537. if(!strlen(x_nr))
  538. {
  539. SendClientMessage(playerid, COLOR_WHITE, "HINT: (/v)ehicle [name]");
  540. SendClientMessage(playerid, COLOR_WHITE, "Available names: park, lock(1-3), color, locate(1-3), tow(1-3)");
  541. return 1;
  542. }
  543.  
  544. else if(strcmp(x_nr,"buy",true) == 0)
  545. {
  546. if(IsAnOwnableCar(idcar))
  547. {
  548. if(PlayerInfo[playerid][pPcarkey] == -1) { }
  549. else if(PlayerInfo[playerid][pPcarkey2] == -1) { }
  550. else if(PlayerInfo[playerid][pPcarkey3] == -1) { }
  551. else { SendClientMessage(playerid, COLOR_GREY, " Ai deja 3 masini!!"); return 1; }
  552. if(CarInfo[idcar][cOwned]==1)
  553. {
  554. SendClientMessage(playerid, COLOR_GREY, "Someone already owns this car");
  555. return 1;
  556. }
  557. if(GetPlayerMoney(playerid) >= CarInfo[idcar][cValue])
  558. {
  559. if(PlayerInfo[playerid][pPcarkey] == -1) { PlayerInfo[playerid][pPcarkey] = idcar; }
  560. else if(PlayerInfo[playerid][pPcarkey2] == -1) { PlayerInfo[playerid][pPcarkey2] = idcar; }
  561. else if(PlayerInfo[playerid][pPcarkey3] == -1) { PlayerInfo[playerid][pPcarkey3] = idcar; }
  562. else { return 1; }
  563. CarInfo[idcar][cOwned] = 1;
  564. GetPlayerName(playerid, sendername, sizeof(sendername));
  565. strmid(CarInfo[idcar][cOwner], sendername, 0, strlen(sendername), 999);
  566. PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
  567. GameTextForPlayer(playerid, "~w~Felicitari~n~Nu uita sa o parchezi cu /v park!", 5000, 3);
  568. SendClientMessage(playerid, COLOR_GRAD2, "Felicitari ti-ai cumparat o masina noua!");
  569. TogglePlayerControllable(playerid, 1);
  570. OnPropUpdate(); SavePlayerData(playerid);
  571. return 1;
  572. }
  573. else
  574.  
  575. }
  576. }
  577.  
  578. else if(strcmp(x_nr,"park",true) == 0)
  579. {
  580. new Float:x,Float:y,Float:z;
  581. new Float:a;
  582. new carid;
  583. new getcarid;
  584. if(GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pPcarkey]) { carid = PlayerInfo[playerid][pPcarkey]; }
  585. else if(GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pPcarkey2]) { carid = PlayerInfo[playerid][pPcarkey2]; }
  586. else if(GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pPcarkey3]) { carid = PlayerInfo[playerid][pPcarkey3]; }
  587. else { return 1; }
  588. getcarid = GetPlayerVehicleID(playerid);
  589. GetPlayerName(playerid, playername, sizeof(playername));
  590. GetVehiclePos(carid, x, y, z);
  591. GetVehicleZAngle(carid, a);
  592. if(IsPlayerInVehicle(playerid,carid) && CarInfo[carid][cOwned] == 1)
  593. {
  594. if(PlayerInfo[playerid][pPcarkey] == -1 && PlayerInfo[playerid][pPcarkey2] == -1 && PlayerInfo[playerid][pPcarkey3] == -1)
  595. {
  596. SendClientMessage(playerid, COLOR_GREY, "You don't own a car.");
  597. return 1;
  598. }
  599. if(getcarid == carid)
  600. {
  601. new Float:CarHP, Float:OldCarHP; new panels,doors,lights,tires;
  602. CarInfo[carid][cLocationx] = x;
  603. CarInfo[carid][cLocationy] = y;
  604. CarInfo[carid][cLocationz] = z;
  605. CarInfo[carid][cAngle] = a;
  606. GetVehicleDamageStatus(carid,panels,doors,lights,tires);
  607. GetVehicleHealth(carid, CarHP); OldCarHP = CarHP;
  608. format(string, sizeof(string), "~n~ You have parked your vehicle in this location. ~n~");
  609. GameTextForPlayer(playerid, "You have parked your vehicle in this position. It will respawn here.", 10000, 3);
  610. OnPropUpdate(); SavePlayerData(playerid); DestroyVehicle(carid);
  611. CreateVehicle(CarInfo[carid][cModel],CarInfo[carid][cLocationx],CarInfo[carid][cLocationy],CarInfo[carid][cLocationz]+1.0,CarInfo[carid][cAngle],CarInfo[carid][cColorOne],CarInfo[carid][cColorTwo],60000);
  612.  
  613. PutPlayerInVehicle(playerid,carid,0); SetVehicleHealth(carid, OldCarHP);
  614. UpdateVehicleDamageStatus(carid,panels,doors,lights,tires);
  615. TogglePlayerControllable(playerid, 1);
  616. return 1;
  617. }
  618. }
  619. }
  620.  
  621. else if(strcmp(x_nr,"lock1",true) == 0)
  622. {
  623. new keycar = PlayerInfo[playerid][pPcarkey];
  624. if(keycar != -1)
  625. {
  626. new locked[256];
  627. locked = strtok(cmdtext, idx);
  628. if(CarInfo[keycar][cLock] == 1)
  629. {
  630. for(new i = 0; i < MAX_PLAYERS; i++)
  631. {
  632. if (IsPlayerConnected(i))
  633. {
  634. SetVehicleParamsForPlayer(keycar,i,0,0);
  635. }
  636. }
  637. format(string, sizeof(string), "~w~Vehicle~n~~g~Unlocked");
  638. GameTextForPlayer(playerid, string, 4000, 3);
  639. CarInfo[keycar][cLock] = 0;
  640. OnPropUpdate(); SavePlayerData(playerid);
  641. return 1;
  642. }
  643. else if(CarInfo[keycar][cLock] == 0)
  644. {
  645. for(new i = 0; i < MAX_PLAYERS; i++)
  646. {
  647. if (IsPlayerConnected(i))
  648. {
  649. SetVehicleParamsForPlayer(keycar,i,0,1);
  650. }
  651. }
  652. format(string, sizeof(string), "~w~Vehicle~n~~r~Locked");
  653. GameTextForPlayer(playerid, string, 4000, 3);
  654. CarInfo[keycar][cLock] = 1;
  655. OnPropUpdate(); SavePlayerData(playerid);
  656. return 1;
  657. }
  658. }
  659. else
  660. {
  661. SendClientMessage(playerid, COLOR_GREY, " You don't have a vehicle at slot 1");
  662. return 1;
  663. }
  664. }
  665. else if(strcmp(x_nr,"lock2",true) == 0)
  666. {
  667. new keycar = PlayerInfo[playerid][pPcarkey2];
  668. if(keycar != -1)
  669. {
  670. new locked[256];
  671. locked = strtok(cmdtext, idx);
  672. if(CarInfo[keycar][cLock] == 1)
  673. {
  674. for(new i = 0; i < MAX_PLAYERS; i++)
  675. {
  676. if (IsPlayerConnected(i))
  677. {
  678. SetVehicleParamsForPlayer(keycar,i,0,0);
  679. }
  680. }
  681. format(string, sizeof(string), "~w~Vehicle~n~~g~Unlocked");
  682. GameTextForPlayer(playerid, string, 4000, 3);
  683. CarInfo[keycar][cLock] = 0;
  684. OnPropUpdate(); SavePlayerData(playerid);
  685. return 1;
  686. }
  687. else if(CarInfo[keycar][cLock] == 0)
  688. {
  689. for(new i = 0; i < MAX_PLAYERS; i++)
  690. {
  691. if (IsPlayerConnected(i))
  692. {
  693. SetVehicleParamsForPlayer(keycar,i,0,1);
  694. }
  695. }
  696. format(string, sizeof(string), "~w~Vehicle~n~~r~Locked");
  697. GameTextForPlayer(playerid, string, 4000, 3);
  698. CarInfo[keycar][cLock] = 1;
  699. OnPropUpdate(); SavePlayerData(playerid);
  700. return 1;
  701. }
  702. }
  703. else
  704. {
  705. SendClientMessage(playerid, COLOR_GREY, " You don't have a vehicle at slot 2");
  706. return 1;
  707. }
  708. }
  709. else if(strcmp(x_nr,"lock3",true) == 0)
  710. {
  711. new keycar = PlayerInfo[playerid][pPcarkey3];
  712. if(keycar != -1)
  713. {
  714. new locked[256];
  715. locked = strtok(cmdtext, idx);
  716. if(CarInfo[keycar][cLock] == 1)
  717. {
  718. for(new i = 0; i < MAX_PLAYERS; i++)
  719. {
  720. if (IsPlayerConnected(i))
  721. {
  722. SetVehicleParamsForPlayer(keycar,i,0,0);
  723. }
  724. }
  725. format(string, sizeof(string), "~w~Vehicle~n~~g~Unlocked");
  726. GameTextForPlayer(playerid, string, 4000, 3);
  727. CarInfo[keycar][cLock] = 0;
  728. OnPropUpdate(); SavePlayerData(playerid);
  729. return 1;
  730. }
  731. else if(CarInfo[keycar][cLock] == 0)
  732. {
  733. for(new i = 0; i < MAX_PLAYERS; i++)
  734. {
  735. if (IsPlayerConnected(i))
  736. {
  737. SetVehicleParamsForPlayer(keycar,i,0,1);
  738. }
  739. }
  740. format(string, sizeof(string), "~w~Vehicle~n~~r~Locked");
  741. GameTextForPlayer(playerid, string, 4000, 3);
  742. CarInfo[keycar][cLock] = 1;
  743. OnPropUpdate(); SavePlayerData(playerid);
  744. return 1;
  745. }
  746. }
  747. else
  748. {
  749. SendClientMessage(playerid, COLOR_GREY, " You don't have a vehicle at slot 3");
  750. return 1;
  751. }
  752. }
  753. else if(strcmp(x_nr,"color",true) == 0)
  754. {
  755. if(PlayerInfo[playerid][pPcarkey] == -1 && PlayerInfo[playerid][pPcarkey2] == -1 && PlayerInfo[playerid][pPcarkey3] == -1)
  756. {
  757. SendClientMessage(playerid, COLOR_GREY," You don't have a vehicle to respray.");
  758. return 1;
  759. }
  760. if(GetPlayerMoney(playerid) < 1000)
  761. {
  762. SendClientMessage(playerid, COLOR_GREY," You don't have enough money for vehicle respray.");
  763. return 1;
  764. }
  765. tmp = strtok(cmdtext, idx);
  766. if(!strlen(tmp))
  767. {
  768. SendClientMessage(playerid, COLOR_WHITE, "USAGE: /v color [ColorOneID] [ColorTwoID]");
  769. return 1;
  770. }
  771. new color1;
  772. color1 = strval(tmp);
  773. if(color1 < 0 && color1 > 126)
  774. {
  775. SendClientMessage(playerid, COLOR_GREY, " Wrong color id!");
  776. return 1;
  777. }
  778. tmp = strtok(cmdtext, idx);
  779. if(!strlen(tmp))
  780. {
  781. SendClientMessage(playerid, COLOR_WHITE, "USAGE: /v color [ColorOneID] [ColorTwoID]");
  782. return 1;
  783. }
  784. new color2;
  785. color2 = strval(tmp);
  786. if(color2 < 0 && color2 > 126)
  787. {
  788. SendClientMessage(playerid, COLOR_GREY, " Wrong color id!");
  789. return 1;
  790. }
  791.  
  792. if(GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pPcarkey]) { vehid = PlayerInfo[playerid][pPcarkey]; }
  793. else if(GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pPcarkey2]) { vehid = PlayerInfo[playerid][pPcarkey2]; }
  794. else if(GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pPcarkey3]) { vehid = PlayerInfo[playerid][pPcarkey3]; }
  795. else { return 1; }
  796.  
  797. if(IsPlayerInVehicle(playerid, vehid))
  798. {
  799. CarInfo[vehid][cColorOne] = color1;
  800. CarInfo[vehid][cColorTwo] = color2;
  801. GivePlayerMoney(playerid, -1000);
  802. GameTextForPlayer(playerid, "~w~Bill for a Paint Respray~n~~r~-$1000", 5000, 1);
  803. ChangeVehicleColor(vehid, color1, color2);
  804. OnPropUpdate(); SavePlayerData(playerid);
  805. return 1;
  806. }
  807. else
  808. {
  809. SendClientMessage(playerid, COLOR_GREY," You are not in your vehicle.");
  810. return 1;
  811. }
  812. }
  813. else if(strcmp(x_nr,"locate1",true) == 0)
  814. {
  815. if(!IsPlayerConnected(playerid)) { return 1; }
  816. new Float:x,Float:y,Float:z;
  817. new car = PlayerInfo[playerid][pPcarkey];
  818. if(PlayerInfo[playerid][pPcarkey]==-1) { GameTextForPlayer(playerid, "~w~Nu ai o masina pentru a putea fi localizata", 2500, 3); return 1; }
  819. SendClientMessage(playerid,COLOR_WHITE,"Locatia masinii a fost gasita.");
  820. GetVehiclePos(car, x, y, z);
  821. SetPlayerCheckpoint(playerid, x, y, z, 6);
  822. return 1;
  823. }
  824. else if(strcmp(x_nr,"locate2",true) == 0)
  825. {
  826. if(!IsPlayerConnected(playerid)) { return 1; }
  827. new Float:x,Float:y,Float:z;
  828. new car = PlayerInfo[playerid][pPcarkey2];
  829. if(PlayerInfo[playerid][pPcarkey]==-1) { GameTextForPlayer(playerid, "~w~Nu ai o masina pentru a putea fi localizata", 2500, 3); return 1; }
  830. SendClientMessage(playerid,COLOR_WHITE,"Locatia masinii a fost gasita.");
  831. GetVehiclePos(car, x, y, z);
  832. SetPlayerCheckpoint(playerid, x, y, z, 6);
  833. return 1;
  834. }
  835. else if(strcmp(x_nr,"locate3",true) == 0)
  836. {
  837. if(!IsPlayerConnected(playerid)) { return 1; }
  838. new Float:x,Float:y,Float:z;
  839. new car = PlayerInfo[playerid][pPcarkey3];
  840. if(PlayerInfo[playerid][pPcarkey]==-1) { GameTextForPlayer(playerid, "~w~Nu ai o masina pentru a putea fi localizata", 2500, 3); return 1; }
  841. SendClientMessage(playerid,COLOR_WHITE,"Locatia masinii a fost gasita.");
  842. GetVehiclePos(car, x, y, z);
  843. SetPlayerCheckpoint(playerid, x, y, z, 6);
  844. return 1;
  845. }
  846. else if(strcmp(x_nr,"tow1",true) == 0)
  847. {
  848. if(IsPlayerConnected(playerid))
  849. {
  850. new car = PlayerInfo[playerid][pPcarkey];
  851. GetPlayerName(playerid, playername, sizeof(playername));
  852. if (car != -1 && strcmp(playername, CarInfo[PlayerInfo[playerid][pPcarkey]][cOwner], true) == 0)
  853. {
  854. GameTextForPlayer(playerid, "~w~Masina a fost~n~~g~Tractata cu succes~n~~r~$-1500", 5000, 1);
  855. GivePlayerMoney(playerid,-1500);
  856. SetVehicleToRespawn(car);
  857. PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
  858. }
  859. else
  860. {
  861. GameTextForPlayer(playerid, "~w~Nu detii o masina personala.", 5000, 1);
  862. }
  863. }
  864. }
  865. else if(strcmp(x_nr,"tow2",true) == 0)
  866. {
  867. if(IsPlayerConnected(playerid))
  868. {
  869. new car = PlayerInfo[playerid][pPcarkey2];
  870. GetPlayerName(playerid, playername, sizeof(playername));
  871. if (car != -1 && strcmp(playername, CarInfo[PlayerInfo[playerid][pPcarkey2]][cOwner], true) == 0)
  872. {
  873. GameTextForPlayer(playerid, "~w~Masina a fost~n~~g~Tractata cu succes~n~~r~$-1500", 5000, 1);
  874. GivePlayerMoney(playerid,-1500);
  875. SetVehicleToRespawn(car);
  876. PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
  877. }
  878. else
  879. {
  880. GameTextForPlayer(playerid, "~w~Nu detii o masina personala.", 5000, 1);
  881. }
  882. }
  883. }
  884. else if(strcmp(x_nr,"tow3",true) == 0)
  885. {
  886. if(IsPlayerConnected(playerid))
  887. {
  888. new car = PlayerInfo[playerid][pPcarkey3];
  889. GetPlayerName(playerid, playername, sizeof(playername));
  890. if (car != -1 && strcmp(playername, CarInfo[PlayerInfo[playerid][pPcarkey3]][cOwner], true) == 0)
  891. {
  892. GameTextForPlayer(playerid, "~w~Masina a fost~n~~g~Tractata cu succes~n~~r~$-1500", 5000, 1);
  893. GivePlayerMoney(playerid,-1500);
  894. SetVehicleToRespawn(car);
  895. PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
  896. }
  897. else
  898. {
  899. GameTextForPlayer(playerid, "~w~Nu detii o masina personala.", 5000, 1);
  900. }
  901. }
  902. }
  903. else
  904. {
  905. SendClientMessage(playerid, COLOR_WHITE, "HINT: (/v)ehicle [name]");
  906. SendClientMessage(playerid, COLOR_WHITE, "Available names: park, lock(1-3) color, locate(1-3), tow(1-3)");
  907. return 1;
  908. }
  909. }
  910. return 1;
  911. }
  912. return 0;
  913. }
  914.  
  915. public OnPlayerEnterCheckpoint(playerid)
  916. {
  917. DisablePlayerCheckpoint(playerid);
  918. return 1;
  919. }
  920. /*----------Car Save Functions----------*/
  921. public LoadCar()
  922. {
  923. new arrCoords[31][64];
  924. new strFromFile2[256];
  925. new File: file = fopen("masini.cfg", io_read);
  926. if (file)
  927. {
  928. new idx = carsonserver;
  929. while (idx < sizeof(CarInfo))
  930. {
  931. fread(file, strFromFile2);
  932. CarInfo[idx][cModel] = strval(arrCoords[0]);
  933. CarInfo[idx][cLocationx] = floatstr(arrCoords[1]);
  934. CarInfo[idx][cLocationy] = floatstr(arrCoords[2]);
  935. CarInfo[idx][cLocationz] = floatstr(arrCoords[3]);
  936. CarInfo[idx][cAngle] = floatstr(arrCoords[4]);
  937. CarInfo[idx][cColorOne] = strval(arrCoords[5]);
  938. CarInfo[idx][cColorTwo] = strval(arrCoords[6]);
  939. strmid(CarInfo[idx][cOwner], arrCoords[7], 0, strlen(arrCoords[7]), 255);
  940. strmid(CarInfo[idx][cDescription], arrCoords[8], 0, strlen(arrCoords[8]), 255);
  941. CarInfo[idx][cOwned] = strval(arrCoords[11]);
  942. CarInfo[idx][cLock] = strval(arrCoords[12]);
  943. idx++;
  944. }
  945. }
  946. return 1;
  947. }
  948.  
  949. public SaveCarCoords()
  950. {
  951. new idx;
  952. new File: file2;
  953. while (idx < sizeof(CarInfo))
  954. {
  955. new coordsstring[256];
  956. format(coordsstring, sizeof(coordsstring), "%d|%f|%f|%f|%f|%d|%d\n",
  957. CarInfo[idx][cModel],
  958. CarInfo[idx][cLocationx],
  959. CarInfo[idx][cLocationy],
  960. CarInfo[idx][cLocationz],
  961. CarInfo[idx][cAngle],
  962. CarInfo[idx][cColorOne],
  963. CarInfo[idx][cColorTwo],
  964. if(idx == carsonserver)
  965. {
  966. file2 = fopen("masini.cfg", io_write);
  967. }
  968. else
  969. {
  970. file2 = fopen("masini.cfg", io_append);
  971. }
  972. fwrite(file2, coordsstring);
  973. idx++;
  974. fclose(file2);
  975. }
  976. return 1;
  977. }
  978. public OnPlayerStateChange(playerid, newstate, oldstate)
  979. {
  980. new string[128];
  981. new vehicle = GetPlayerVehicleID(playerid);
  982. new newcar = GetPlayerVehicleID(playerid);
  983. if(newstate == PLAYER_STATE_DRIVER)
  984. {
  985. if(IsAnOwnableCar(newcar))
  986. {
  987. if(CarInfo[newcar][cOwned]==0)
  988. {
  989. TogglePlayerControllable(playerid, 0);
  990. format(string,sizeof(string),"%s Price: %d /v buy to buy this vehicle",CarInfo[newcar][cDescription]);
  991. SendClientMessage(playerid, COLOR_BLUE, string);
  992. SendClientMessage(playerid, COLOR_BLUE, "or press Enter to exit this vehicle");
  993. }
  994. if(CarInfo[newcar][cOwned]==1)
  995. {
  996. format(string,sizeof(string),"Vehicle registered to %s",CarInfo[newcar][cOwner]);
  997. SendClientMessage(playerid, COLOR_BLUE, string);
  998. if(PlayerInfo[playerid][pPcarkey] == vehicle) { }
  999. else if(PlayerInfo[playerid][pPcarkey2] == vehicle) { }
  1000. else if(PlayerInfo[playerid][pPcarkey3] == vehicle) { }
  1001. else
  1002. {
  1003. if(IsPlayerAdmin(playerid))
  1004. {
  1005. SendClientMessage(playerid, COLOR_GREY, " You can drive this car because you are admin");
  1006. }
  1007. else
  1008. {
  1009. RemovePlayerFromVehicle(playerid);
  1010. SendClientMessage(playerid, COLOR_GREY, "You don't have a key of this vehicle");
  1011. }
  1012. }
  1013. }
  1014. }
  1015. }
  1016. return 1;
  1017. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement