Guest User

e

a guest
Jun 18th, 2012
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 41.99 KB | None | 0 0
  1. //Source for max car speed: http://gta.wikia.com/Vehicle_Stats_in_GTA_San_Andreas
  2. #define FILTERSCRIPT
  3. #include <a_samp>
  4. #include <sscanf2>
  5. #include <YSI/y_ini>
  6. #include <YSI\y_commands>
  7. #pragma tabsize 0
  8.  
  9. #define COORDINATES 1948.0917,1370.3293,9.1094,90//Here you can put your coordinates for car where will be car on list spawn
  10. #define COORDINATES_FOR_BUY 1948.0917,1370.3293,9.1094//Coordinates where player can type /buycar
  11. #define SPAWN_cX 1948.0917//Coordainte X where buyed car will be spawn
  12. #define SPAWN_cY 1375.3293//Coordainte Y where buyed car will be spawn
  13. #define SPAWN_cZ 9.1094//Coordainte Z where buyed car will be spawn
  14. #define SPAWN_cA 90//Angle of spawned cars
  15. #define COLOR_RED 0xCF212D
  16. #define SCM SendClientMessage
  17. #define NUMBER_FOR_LOAD 2
  18. #define MAX_CARS 1000
  19. #define NUMBER_OF_VEHICLES 4
  20. #define Player_File "CoS/Player/%s.ini"
  21. #define CoS_File "CoS/%d.ini"
  22. #define DIALOG_CARS 1390
  23. new bool:False = false, _S_T_R_[128];
  24. #define SendFormatMSG(%0,%1,%2,%3)\
  25. do{\
  26. format(_S_T_R_, sizeof (_S_T_R_), (%2), %3);\
  27. SendClientMessage((%0),(%1), _S_T_R_);\
  28. }\
  29. while (False)
  30.  
  31. #define COL_WHITE "{FFFFFF}"
  32.  
  33. new
  34. VehicleID,
  35. ChoosedCar,
  36. Text:CoSTD0[MAX_PLAYERS],
  37. bool:PlayerSwitchVehicle[MAX_PLAYERS],
  38. bool:PlayerChooseVehicle,
  39. maximalcars,
  40. GPSOn[MAX_PLAYERS],
  41. Seller[MAX_PLAYERS],
  42. Priceo[MAX_PLAYERS],
  43. Text:AlarmTD0[MAX_PLAYERS],
  44. Text:AlarmTD1[MAX_PLAYERS],
  45. AlarmChoose[MAX_PLAYERS],
  46. AlarmChooseID[MAX_PLAYERS];
  47. enum cars
  48. {
  49. Model,
  50. Price,
  51. Level,
  52. Speed
  53. }
  54. new CarModel[NUMBER_OF_VEHICLES][cars];
  55.  
  56. enum data
  57. {
  58. Veh1,
  59. Veh2,
  60. Veh3
  61. }
  62. new Player[MAX_PLAYERS][data];
  63.  
  64. enum cdata
  65. {
  66. Model,
  67. Float:cX,
  68. Float:cY,
  69. Float:cZ,
  70. Float:cA,
  71. Col1,
  72. Col2,
  73. Lock,
  74. Owner[32],
  75. ID,
  76. Money,
  77. Gun1,Ammo1,
  78. Gun2,Ammo2,
  79. Alarm
  80. }
  81. new C_Data[MAX_CARS][cdata];
  82.  
  83. new CarNames[][] =
  84. {
  85. "Landstalker", "Bravura", "Buffalo", "Linerunner", "Perrenial", "Sentinel",
  86. "Dumper", "Firetruck", "Trashmaster", "Stretch", "Manana", "Infernus", "Voodoo",
  87. "Pony", "Mule", "Cheetah", "Ambulance", "Leviathan", "Moonbeam", "Esperanto",
  88. "Taxi", "Washington", "Bobcat", "Whoopee", "BF Injection", "Hunter", "Premier",
  89. "Enforcer", "Securicar", "Banshee", "Predator", "Bus", "Rhino", "Barracks",
  90. "Hotknife", "Trailer 1", "Previon", "Coach", "Cabbie", "Stallion", "Rumpo",
  91. "RC Bandit", "Romero", "Packer", "Monster", "Admiral", "Squalo", "Seasparrow",
  92. "Pizzaboy", "Tram", "Trailer 2", "Turismo", "Speeder", "Reefer", "Tropic", "Flatbed",
  93. "Yankee", "Caddy", "Solair", "Berkley's RC Van", "Skimmer", "PCJ-600", "Faggio",
  94. "Freeway", "RC Baron", "RC Raider", "Glendale", "Oceanic", "Sanchez", "Sparrow",
  95. "Patriot", "Quad", "Coastguard", "Dinghy", "Hermes", "Sabre", "Rustler", "ZR-350",
  96. "Walton", "Regina", "Comet", "BMX", "Burrito", "Camper", "Marquis", "Baggage",
  97. "Dozer", "Maverick", "Chopper", "Rancher", "FBI Rancher", "Virgo", "Greenwood",
  98. "Jetmax", "Hotring", "Sandking", "Blista Compact", "Police Maverick", "Boxvillde",
  99. "Benson", "Mesa", "RC Goblin", "Hotring Racer A", "Hotring Racer B", "Bloodring Banger",
  100. "Rancher", "Super GT", "Elegant", "Journey", "Bike", "Mountain Bike", "Beagle",
  101. "Cropduster", "Stunt", "Tanker", "Roadtrain", "Nebula", "Majestic", "Buccaneer",
  102. "Shamal", "Hydra", "FCR-900", "NRG-500", "HPV1000", "Cement Truck", "Tow Truck",
  103. "Fortune", "Cadrona", "FBI Truck", "Willard", "Forklift", "Tractor", "Combine",
  104. "Feltzer", "Remington", "Slamvan", "Blade", "Freight", "Streak", "Vortex", "Vincent",
  105. "Bullet", "Clover", "Sadler", "Firetruck", "Hustler", "Intruder", "Primo", "Cargobob",
  106. "Tampa", "Sunrise", "Merit", "Utility", "Nevada", "Yosemite", "Windsor", "Monster",
  107. "Monster", "Uranus", "Jester", "Sultan", "Stratum", "Elegy", "Raindance", "RC Tiger",
  108. "Flash", "Tahoma", "Savanna", "Bandito", "Freight Flat", "Streak Carriage", "Kart",
  109. "Mower", "Dune", "Sweeper", "Broadway", "Tornado", "AT-400", "DFT-30", "Huntley",
  110. "Stafford", "BF-400", "News Van", "Tug", "Trailer 3", "Emperor", "Wayfarer", "Euros",
  111. "Hotdog", "Club", "Freight Box", "Trailer", "Andromada", "Dodo", "RC Cam", "Launch",
  112. "LSPD Car", "SFPD Car", "LVPD Car", "Police Ranger", "Picador", "S.W.A.T Tank", "Alpha",
  113. "Phoenix", "Glendale", "Sadler", "Luggage Trailer 1", "Luggage Trailer 2", "Stairs Trailer",
  114. "Boxville", "Utility Trailer 1", "Utility Trailer 2"
  115. };
  116.  
  117. public OnFilterScriptInit()
  118. {
  119. print("\n--------------------------------------");
  120. print(" CoS by Mr.Gagi");
  121. print("--------------------------------------\n");
  122. AddMoreCar(404,5000,150,2);
  123. AddMoreCar(405,9000,165,3);
  124. AddMoreCar(415,19000,230,7);
  125. AddMoreCar(421,10000,180,5);
  126. VehicleID = AddStaticVehicleEx(CarModel[1][Model],COORDINATES,1,1,3600);
  127. new gFile[35];
  128. for(new i = NUMBER_FOR_LOAD; i <= MAX_CARS;i++)
  129. {
  130. format(gFile, 35, CoS_File,i);
  131. INI_ParseFile(gFile, "LoadCar", .bExtra = true, .extra = i);
  132. C_Data[i][ID] = CreateVehicle(C_Data[i][Model], C_Data[i][cX],C_Data[i][cY],C_Data[i][cZ],C_Data[i][cA], C_Data[i][Col1], C_Data[i][Col2], 30000);
  133. }
  134. return 1;
  135. }
  136.  
  137. public OnFilterScriptExit()
  138. {
  139. return 1;
  140. }
  141.  
  142.  
  143. main()
  144. {
  145. print("\n----------------------------------");
  146. print(" CoS by Mr.Gagi");
  147. print("----------------------------------\n");
  148. }
  149.  
  150. public OnGameModeInit()
  151. {
  152. return 1;
  153. }
  154. public OnGameModeExit()
  155. {
  156. return 1;
  157. }
  158.  
  159. public OnPlayerRequestClass(playerid, classid)
  160. {
  161. return 1;
  162. }
  163. stock GetName(playerid)
  164. {
  165. new
  166. pName[MAX_PLAYER_NAME];
  167.  
  168. GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
  169. return pName;
  170. }
  171. public OnPlayerConnect(playerid)
  172. {
  173. CoSTD0[playerid] = TextDrawCreate(270.000000, 371.000000, "~y~Name: ~w~Cheetah ~y~Price: ~g~$5~n~ ~y~Max speed: ~w~200");
  174. TextDrawBackgroundColor(CoSTD0[playerid], 255);
  175. TextDrawFont(CoSTD0[playerid], 2);
  176. TextDrawLetterSize(CoSTD0[playerid], 0.370000, 1.000000);
  177. TextDrawColor(CoSTD0[playerid], -1);
  178. TextDrawSetOutline(CoSTD0[playerid], 1);
  179. TextDrawSetProportional(CoSTD0[playerid], 1);
  180.  
  181. AlarmTD0[playerid] = TextDrawCreate(40.000000, 150.000000, "~n~");
  182. TextDrawBackgroundColor(AlarmTD0[playerid], 255);
  183. TextDrawFont(AlarmTD0[playerid], 1);
  184. TextDrawLetterSize(AlarmTD0[playerid], 0.360000, 3.300000);
  185. TextDrawColor(AlarmTD0[playerid], -1);
  186. TextDrawSetOutline(AlarmTD0[playerid], 0);
  187. TextDrawSetProportional(AlarmTD0[playerid], 1);
  188. TextDrawSetShadow(AlarmTD0[playerid], 1);
  189. TextDrawUseBox(AlarmTD0[playerid], 1);
  190. TextDrawBoxColor(AlarmTD0[playerid], -206);
  191. TextDrawTextSize(AlarmTD0[playerid], 117.000000, 0.000000);
  192.  
  193. AlarmTD1[playerid] = TextDrawCreate(40.000000, 150.000000, "~p~~h~Alarm: ~r~ON~n~~n~~p~~h~Alarm: ~w~OFF");
  194. TextDrawBackgroundColor(AlarmTD1[playerid], 255);
  195. TextDrawFont(AlarmTD1[playerid], 2);
  196. TextDrawLetterSize(AlarmTD1[playerid], 0.290000, 0.899999);
  197. TextDrawColor(AlarmTD1[playerid], -1);
  198. TextDrawSetOutline(AlarmTD1[playerid], 1);
  199. TextDrawSetProportional(AlarmTD1[playerid], 1);
  200. new pFile[48];
  201. format(pFile, 48, Player_File, GetName(playerid));
  202.  
  203. if(!fexist(pFile))
  204. {
  205. new
  206. INI:UserFile = INI_Open(pFile);
  207. INI_WriteInt(UserFile, "Veh1",9999);
  208. INI_WriteInt(UserFile, "Veh2", 9999);
  209. INI_WriteInt(UserFile, "Veh3", 9999);
  210. INI_Close(UserFile);
  211. }
  212. INI_ParseFile(pFile, "LoadPlayerData", .bExtra = true, .extra = playerid);
  213. Priceo[playerid] = 0;
  214. Seller[playerid] = 999;
  215. return 1;
  216. }
  217.  
  218. public OnPlayerDisconnect(playerid, reason)
  219. {
  220. TextDrawDestroy(CoSTD0[playerid]);
  221. TextDrawDestroy(AlarmTD0[playerid]);
  222. TextDrawDestroy(AlarmTD1[playerid]);
  223. new
  224. pFile[35];
  225.  
  226. format(pFile, 35, Player_File, GetName(playerid));
  227. new
  228. INI:UserFile = INI_Open(pFile);
  229. INI_WriteInt(UserFile, "Veh1", Player[playerid][Veh1]);
  230. INI_WriteInt(UserFile, "Veh2", Player[playerid][Veh2]);
  231. INI_WriteInt(UserFile, "Veh3", Player[playerid][Veh3]);
  232. INI_Close(UserFile);
  233. return 1;
  234. }
  235.  
  236. public OnPlayerSpawn(playerid)
  237. {
  238. return 1;
  239. }
  240.  
  241. public OnPlayerDeath(playerid, killerid, reason)
  242. {
  243. return 1;
  244. }
  245.  
  246. public OnVehicleSpawn(vehicleid)
  247. {
  248. return 1;
  249. }
  250.  
  251. public OnVehicleDeath(vehicleid, killerid)
  252. {
  253. return 1;
  254. }
  255.  
  256. public OnPlayerText(playerid, text[])
  257. {
  258. return 1;
  259. }
  260.  
  261.  
  262. public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)//TU STAo
  263. {
  264. new Float:Pos[3],string[128]; GetPlayerPos(playerid,Pos[0],Pos[1],Pos[2]);
  265. if(vehicleid == VehicleID) return SCM(playerid,-1,"You can't enter in this vehicle"),SetPlayerPos(playerid,Pos[0],Pos[1],Pos[2]);
  266. if(C_Data[vehicleid][Lock] == 1) return GameTextForPlayer(playerid,"~r~Car is locked",3000,0),SetPlayerPos(playerid,Pos[0],Pos[1],Pos[2]);
  267. if(C_Data[vehicleid][Alarm] == 1)
  268. {
  269. format(string,128,"*%s has trying to steal vehicle.",GetName(playerid));
  270. ProxDetector(playerid, string, 0xB91BE0, 30);
  271. SetPlayerPos(playerid,Pos[0],Pos[1],Pos[2]);
  272. return 1;
  273. }
  274. return 1;
  275. }
  276.  
  277. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  278. {
  279. if(newkeys == KEY_SECONDARY_ATTACK)
  280. {
  281. if(AlarmChoose[playerid] == 1)
  282. {
  283. AlarmChoose[playerid] = 0;
  284. C_Data[AlarmChooseID[playerid]][Alarm] = 1;
  285. TextDrawHideForPlayer(playerid,AlarmTD0[playerid]);
  286. TextDrawHideForPlayer(playerid,AlarmTD1[playerid]);
  287. SCM(playerid,-1,"Alarm is ON");
  288. CheckCar(AlarmChooseID[playerid]);
  289. RemovePlayerFromVehicle(playerid);
  290. }
  291. if(AlarmChoose[playerid] == 2)
  292. {
  293. AlarmChoose[playerid] = 0;
  294. C_Data[AlarmChooseID[playerid]][Alarm] = 0;
  295. TextDrawHideForPlayer(playerid,AlarmTD0[playerid]);
  296. TextDrawHideForPlayer(playerid,AlarmTD1[playerid]);
  297. SCM(playerid,-1,"Alarm is OFF");
  298. CheckCar(AlarmChooseID[playerid]);
  299. RemovePlayerFromVehicle(playerid);
  300. }
  301. if(PlayerSwitchVehicle[playerid] == true)
  302. {
  303. if(Player[playerid][Veh1] == 9999 || Player[playerid][Veh2] == 9999 || Player[playerid][Veh3] == 9999)
  304. {
  305. if(GetPlayerMoney(playerid) < CarModel[ChoosedCar][Price]) return SCM(playerid,-1,"You don't have engouh money");
  306. if(GetPlayerScore(playerid) < CarModel[ChoosedCar][Level]) return SCM(playerid,-1,"You don't have engouh level");
  307. new i = GetNextFreeID();
  308. SetCameraBehindPlayer(playerid);
  309. SendFormatMSG(playerid,-1,"You are buy vehicle for price $%d",CarModel[ChoosedCar][Price]);
  310. GivePlayerMoney(playerid,-CarModel[ChoosedCar][Price]);
  311. C_Data[i][Model] = CarModel[ChoosedCar][Model];
  312. C_Data[i][cX] = SPAWN_cX;
  313. C_Data[i][cY] = SPAWN_cY;
  314. C_Data[i][cZ] = SPAWN_cZ;
  315. C_Data[i][cA] = SPAWN_cA;
  316. C_Data[i][Col1] = 1;
  317. C_Data[i][Col2] = 1;
  318. C_Data[i][Lock] = 0;
  319. strmid(C_Data[i][Owner], GetName(playerid), 0, strlen(GetName(playerid)), 999);
  320. TogglePlayerControllable(playerid, 1);
  321. C_Data[i][ID] = CreateVehicle(C_Data[i][Model], C_Data[i][cX],C_Data[i][cY],C_Data[i][cZ],C_Data[i][cA], C_Data[i][Col1], C_Data[i][Col2], 30000);
  322. CreateSaveCar(i);
  323. PlayerSwitchVehicle[playerid] = false;
  324. PlayerChooseVehicle = false;
  325. SetCameraBehindPlayer(playerid);
  326. TextDrawHideForPlayer(playerid,CoSTD0[playerid]);
  327. if(Player[playerid][Veh1] == 9999 && Player[playerid][Veh2] == 9999 && Player[playerid][Veh3] == 9999) {Player[playerid][Veh1] = C_Data[i][ID];}
  328. else if(Player[playerid][Veh2] != 9999 && Player[playerid][Veh1] == 9999 && Player[playerid][Veh3] != 9999){Player[playerid][Veh1] = C_Data[i][ID];}
  329. else if(Player[playerid][Veh1] != 9999 && Player[playerid][Veh2] == 9999 && Player[playerid][Veh3] != 9999){Player[playerid][Veh2] = C_Data[i][ID];}
  330. else if(Player[playerid][Veh1] != 9999 && Player[playerid][Veh2] == 9999 && Player[playerid][Veh3] == 9999){Player[playerid][Veh2] = C_Data[i][ID];}
  331. else if(Player[playerid][Veh3] == 9999 && Player[playerid][Veh1] != 9999 && Player[playerid][Veh2] != 9999){Player[playerid][Veh3] = C_Data[i][ID];}
  332. UpdatePlayerInfo(playerid);
  333. }
  334. else
  335. {
  336. SCM(playerid,-1,"You already have 3 vehiceles!");
  337. }
  338. }
  339. }
  340. return 1;
  341. }
  342.  
  343. public OnRconLoginAttempt(ip[], password[], success)
  344. {
  345. return 1;
  346. }
  347.  
  348. public OnPlayerUpdate(playerid)
  349. {
  350. new Keys, ud, lr;
  351. GetPlayerKeys(playerid, Keys, ud, lr);
  352. if(ud > 0)
  353. {
  354. if(AlarmChoose[playerid] == 1)
  355. {
  356. AlarmChoose[playerid] = 2;
  357. TextDrawSetString(AlarmTD1[playerid],"~p~~h~Alarm: ~w~ON~n~~n~~p~~h~Alarm: ~r~OFF");
  358. }
  359. else if(AlarmChoose[playerid] == 2)
  360. {
  361. AlarmChoose[playerid] = 1;
  362. TextDrawSetString(AlarmTD1[playerid],"~p~~h~Alarm: ~r~ON~n~~n~~p~~h~Alarm: ~w~OFF");
  363. }
  364. }
  365. if(PlayerSwitchVehicle[playerid] == true)
  366. {
  367. new string[128];
  368. GetPlayerKeys(playerid, Keys, ud, lr);
  369. if(lr > 0)
  370. {
  371. ChoosedCar++;
  372. if(ChoosedCar > maximalcars) {ChoosedCar = 0;}
  373. DestroyVehicle(VehicleID);
  374. VehicleID = CreateVehicle(CarModel[ChoosedCar][Model], COORDINATES, 1,1, 30000);
  375. format(string,sizeof(string),"~y~Name: ~w~%s ~y~Price: ~g~$%d~n~~y~Level: ~w~%d~y~ Max speed: ~w~%d",CarNames[CarModel[ChoosedCar][Model] - 400],CarModel[ChoosedCar][Price],CarModel[ChoosedCar][Level],CarModel[ChoosedCar][Speed]);
  376. TextDrawSetString(CoSTD0[playerid],string);
  377. }
  378. else if(lr < 0)
  379. {
  380. ChoosedCar--;
  381. if (ChoosedCar < 0) {ChoosedCar = maximalcars;}
  382. DestroyVehicle(VehicleID);
  383. VehicleID = CreateVehicle(CarModel[ChoosedCar][Model], COORDINATES, 1,1, 30000);
  384. format(string,sizeof(string),"~y~Name: ~w~%s ~y~Price: ~g~$%d~n~~y~Level: ~w~%d~y~ Max speed: ~w~%d",CarNames[CarModel[ChoosedCar][Model] - 400],CarModel[ChoosedCar][Price],CarModel[ChoosedCar][Level],CarModel[ChoosedCar][Speed]);
  385. TextDrawSetString(CoSTD0[playerid],string);
  386. }
  387. }
  388. return 1;
  389. }
  390.  
  391. public OnPlayerStreamIn(playerid, forplayerid)
  392. {
  393. return 1;
  394. }
  395.  
  396. public OnPlayerStreamOut(playerid, forplayerid)
  397. {
  398. return 1;
  399. }
  400.  
  401. public OnVehicleStreamIn(vehicleid, forplayerid)
  402. {
  403. return 1;
  404. }
  405.  
  406. public OnVehicleStreamOut(vehicleid, forplayerid)
  407. {
  408. return 1;
  409. }
  410.  
  411. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  412. {
  413. switch(dialogid)
  414. {
  415. case DIALOG_CARS+1:
  416. {
  417. if(!response) return SCM(playerid,-1,"Dialog closed");
  418. new vehicleid = GetPlayerVehicleID(playerid);
  419. switch(listitem)
  420. {
  421. case 0: {
  422. if(!IsPlayerInAnyVehicle(playerid)) return SCM(playerid,COLOR_RED,"You must be in car!");
  423. ShowPlayerDialog(playerid,DIALOG_CARS,DIALOG_STYLE_INPUT,"Color","Price: $200\nType vehicle color (id of color).\n Example: 5 9","Change","Cancel"); }
  424. case 1: {
  425. ShowPlayerDialog(playerid,DIALOG_CARS+5,DIALOG_STYLE_LIST,"Vehicle Control panel","First car\nSecond car\nThird car","Lock","Cancel");
  426. }
  427. case 2: {
  428. ShowPlayerDialog(playerid,DIALOG_CARS+2,DIALOG_STYLE_LIST,"Vehicle Control panel","First car\nSecond car\nThird car","Unlock","Cancel");
  429. }
  430. case 3: {
  431. new string[128];
  432. if(!IsPlayerInAnyVehicle(playerid)) return SCM(playerid,COLOR_RED,"You must be in car");
  433. new price = GetVehiclePrice(GetVehicleModel(vehicleid));
  434. if(Player[playerid][Veh3] == 0 && Player[playerid][Veh2] == 0 && Player[playerid][Veh1] == 0) return SCM(playerid,COLOR_RED,"You don't have car");
  435. GivePlayerMoney(playerid, price/2);
  436. SendFormatMSG(playerid,-1,"You are sell car with price $%d",price/2);
  437. DestroyVehicle(vehicleid);
  438. if(Player[playerid][Veh1] == vehicleid)
  439. {
  440. format(string,sizeof(string),CoS_File,C_Data[vehicleid][ID]);
  441. C_Data[vehicleid][cX] = 0;
  442. C_Data[vehicleid][cY] = 0;
  443. C_Data[vehicleid][cZ] = 0;
  444. C_Data[vehicleid][Model] = 0;
  445. format(C_Data[vehicleid][Owner],128,"Department");
  446. CheckCar(Player[playerid][Veh1]);
  447. Player[playerid][Veh1] = 0;
  448. UpdatePlayerInfo(playerid);
  449. }
  450. else if(Player[playerid][Veh2] == vehicleid)
  451. {
  452. format(string,sizeof(string),CoS_File,C_Data[vehicleid][ID]);
  453. C_Data[vehicleid][cX] = 0;
  454. C_Data[vehicleid][cY] = 0;
  455. C_Data[vehicleid][cZ] = 0;
  456. C_Data[vehicleid][Model] = 0;
  457. format(C_Data[vehicleid][Owner],128,"Department");
  458. CheckCar(Player[playerid][Veh2]);
  459. Player[playerid][Veh2] = 0;
  460. UpdatePlayerInfo(playerid);
  461. }
  462. else if(Player[playerid][Veh3] == vehicleid)
  463. {
  464. format(string,sizeof(string),CoS_File,C_Data[vehicleid][ID]);
  465. C_Data[vehicleid][cX] = 0;
  466. C_Data[vehicleid][cY] = 0;
  467. C_Data[vehicleid][cZ] = 0;
  468. C_Data[vehicleid][Model] = 0;
  469. format(C_Data[vehicleid][Owner],128,"Department");
  470. CheckCar(Player[playerid][Veh3]);
  471. Player[playerid][Veh3] = 0;
  472. UpdatePlayerInfo(playerid);
  473. }
  474. }
  475. case 4: {
  476. if(!IsPlayerInAnyVehicle(playerid)) return SCM(playerid,COLOR_RED,"You'r not in car!");
  477. new Float:Pos[4]; GetPlayerPos(playerid,Pos[0],Pos[1],Pos[2]); GetVehicleZAngle(vehicleid, Pos[3]);
  478. C_Data[vehicleid][cX] = Pos[0];
  479. C_Data[vehicleid][cY] = Pos[1];
  480. C_Data[vehicleid][cZ] = Pos[2];
  481. C_Data[vehicleid][cA] = Pos[3];
  482. SetVehiclePos(vehicleid, C_Data[vehicleid][cX],C_Data[vehicleid][cY],C_Data[vehicleid][cZ]);
  483. SetVehicleZAngle(vehicleid, C_Data[vehicleid][cA]);
  484. SCM(playerid,-1,"Vehicle is parked.");
  485. CheckCar(C_Data[vehicleid][ID]);}
  486. case 5: {
  487. ShowPlayerDialog(playerid,DIALOG_CARS+3,DIALOG_STYLE_LIST,"Vehicle Control panel","First car\nSecond car\nThird car","Unlock","Cancel");
  488. }
  489. case 6: {
  490. ShowPlayerDialog(playerid,DIALOG_CARS+4,DIALOG_STYLE_LIST,"Vehicle Control panel","First car\nSecond car\nThird car","Choose","Cancel");
  491. }
  492. }
  493. }
  494.  
  495. case DIALOG_CARS+4://For alarm
  496. {
  497. if(!response) return 1;
  498. switch(listitem)
  499. {
  500. case 0:
  501. {
  502. new id = Player[playerid][Veh1];
  503. new Float:Pos[3]; GetVehiclePos(id,Pos[0],Pos[1],Pos[2]);
  504. if(id == 999) return SCM(playerid,-1,"You don't have car on this slot");
  505. if(!IsPlayerInRangeOfPoint(playerid,40.0,Pos[0],Pos[1],Pos[2])) return SCM(playerid,-1,"You are not near your car");
  506. AlarmChoose[playerid] = 1;
  507. AlarmChooseID[playerid] = id;
  508. TextDrawShowForPlayer(playerid,AlarmTD0[playerid]);
  509. TextDrawShowForPlayer(playerid,AlarmTD1[playerid]);
  510. TextDrawSetString(AlarmTD1[playerid],"~p~~h~Alarm: ~r~ON~n~~n~~p~~h~Alarm: ~w~OFF");
  511. }
  512. case 1:
  513. {
  514. new id = Player[playerid][Veh2];
  515. new Float:Pos[3]; GetVehiclePos(id,Pos[0],Pos[1],Pos[2]);
  516. if(id == 999) return SCM(playerid,-1,"You don't have car on this slot");
  517. if(!IsPlayerInRangeOfPoint(playerid,40.0,Pos[0],Pos[1],Pos[2])) return SCM(playerid,-1,"You are not near your car");
  518. AlarmChoose[playerid] = 1;
  519. AlarmChooseID[playerid] = id;
  520. TextDrawShowForPlayer(playerid,AlarmTD0[playerid]);
  521. TextDrawShowForPlayer(playerid,AlarmTD1[playerid]);
  522. TextDrawSetString(AlarmTD1[playerid],"~p~~h~Alarm: ~r~ON~n~~n~~p~~h~Alarm: ~w~OFF");
  523. }
  524. case 2:
  525. {
  526. new id = Player[playerid][Veh3];
  527. new Float:Pos[3]; GetVehiclePos(id,Pos[0],Pos[1],Pos[2]);
  528. if(id == 999) return SCM(playerid,-1,"You don't have car on this slot");
  529. if(!IsPlayerInRangeOfPoint(playerid,40.0,Pos[0],Pos[1],Pos[2])) return SCM(playerid,-1,"You are not near your car");
  530. AlarmChoose[playerid] = 1;
  531. AlarmChooseID[playerid] = id;
  532. TextDrawShowForPlayer(playerid,AlarmTD0[playerid]);
  533. TextDrawShowForPlayer(playerid,AlarmTD1[playerid]);
  534. TextDrawSetString(AlarmTD1[playerid],"~p~~h~Alarm: ~r~ON~n~~n~~p~~h~Alarm: ~w~OFF");
  535. }
  536. }
  537. }
  538.  
  539. case DIALOG_CARS+2:
  540. {
  541. switch(listitem)
  542. {
  543. case 0: {
  544. if(Player[playerid][Veh1] != 9999) { C_Data[Player[playerid][Veh1]][Lock] = 0; CheckCar(Player[playerid][Veh1]); } }
  545. case 1: {
  546. if(Player[playerid][Veh2] != 9999) { C_Data[Player[playerid][Veh2]][Lock] = 0; CheckCar(Player[playerid][Veh2]); } }
  547. case 2: {
  548. if(Player[playerid][Veh3] != 9999) { C_Data[Player[playerid][Veh3]][Lock] = 0; CheckCar(Player[playerid][Veh3]); } }
  549. }
  550. }
  551. case DIALOG_CARS+3://Dialog for locate
  552. {
  553. switch(listitem)
  554. {
  555. case 0: {
  556. if(Player[playerid][Veh1] != 9999) {new Float:Postition[3]; GPSOn[playerid] = true; GetVehiclePos(Player[playerid][Veh1],Postition[0],Postition[1],Postition[2]); SetPlayerCheckpoint(playerid,Postition[0],Postition[1],Postition[2],5.0); SCM(playerid,-1,"Vehicle is located for turn of GPS type /gpsoff");} }
  557. case 1: {
  558. if(Player[playerid][Veh2] != 9999) {new Float:Postition[3]; GPSOn[playerid] = true; GetVehiclePos(Player[playerid][Veh2],Postition[0],Postition[1],Postition[2]); SetPlayerCheckpoint(playerid,Postition[0],Postition[1],Postition[2],5.0); SCM(playerid,-1,"Vehicle is located for turn of GPS type /gpsoff");} }
  559. case 2: {
  560. if(Player[playerid][Veh3] != 9999) {new Float:Postition[3]; GPSOn[playerid] = true; GetVehiclePos(Player[playerid][Veh3],Postition[0],Postition[1],Postition[2]); SetPlayerCheckpoint(playerid,Postition[0],Postition[1],Postition[2],5.0); SCM(playerid,-1,"Vehicle is located for turn of GPS type /gpsoff");} }
  561. }
  562. }
  563. case DIALOG_CARS://For color
  564. {
  565. new vehicleid = GetPlayerVehicleID(playerid),col[2];
  566. if(sscanf(inputtext,"ii",col[0],col[1])) return ShowPlayerDialog(playerid,DIALOG_CARS,DIALOG_STYLE_INPUT,"Color","Type vehicle color (id of color).\n Example: 5 9","Change","Cancel");
  567. C_Data[vehicleid][Col1] = col[0];
  568. C_Data[vehicleid][Col2] = col[1];
  569. GivePlayerMoney(playerid,-200);
  570. ChangeVehicleColor(vehicleid,col[0],col[1]);
  571. CheckCar(vehicleid);
  572. }
  573. case DIALOG_CARS+5://For lock
  574. {
  575. switch(listitem)
  576. {
  577. case 0: {
  578. if(Player[playerid][Veh1] != 9999) { C_Data[Player[playerid][Veh1]][Lock] = 1; CheckCar(Player[playerid][Veh1]); } }
  579. case 1: {
  580. if(Player[playerid][Veh2] != 9999) { C_Data[Player[playerid][Veh2]][Lock] = 1; CheckCar(Player[playerid][Veh2]); } }
  581. case 2: {
  582. if(Player[playerid][Veh3] != 9999) { C_Data[Player[playerid][Veh3]][Lock] = 1; CheckCar(Player[playerid][Veh3]); } }
  583. }
  584. }
  585. }
  586. return 1;
  587. }
  588.  
  589. public OnPlayerClickPlayer(playerid, clickedplayerid, source)
  590. {
  591. return 1;
  592. }
  593. forward LoadPlayerData(playerid, name[], value[]);
  594. public LoadPlayerData(playerid, name[], value[])
  595. {
  596. INI_Int("Veh1", Player[playerid][Veh1]);
  597. INI_Int("Veh2", Player[playerid][Veh2]);
  598. INI_Int("Veh3", Player[playerid][Veh3]);
  599. return 1;
  600. }
  601. //Commands
  602. YCMD:buycar(playerid,params[],help)
  603. {
  604. #pragma unused params
  605. #pragma unused help
  606. if(PlayerChooseVehicle) return SCM(playerid,COLOR_RED,"EROR: "COL_WHITE"Somebody already buying vehicle");
  607. if(!IsPlayerInRangeOfPoint(playerid,20.0,COORDINATES_FOR_BUY)) return SCM(playerid,COLOR_RED,"EROR: "COL_WHITE"You are not on place for buy car");
  608. PlayerChooseVehicle = true;
  609. PlayerSwitchVehicle[playerid] = true;
  610. ChoosedCar = 0;
  611. SCM(playerid,-1,"Use arrow left and right for choose car");
  612. SCM(playerid,-1,"When you choose you car press 'ENTER'");
  613. SCM(playerid,-1,"If you want to exit type /stopbuying");
  614. TogglePlayerControllable(playerid,false);
  615. DestroyVehicle(VehicleID);
  616. VehicleID = AddStaticVehicleEx(CarModel[ChoosedCar][Model],COORDINATES,1,1,3600);
  617. TextDrawShowForPlayer(playerid,CoSTD0[playerid]);
  618. return 1;
  619. }
  620. YCMD:stopbuying(playerid,params[],help)
  621. {
  622. #pragma unused params
  623. #pragma unused help
  624. if(!PlayerSwitchVehicle[playerid]) return SCM(playerid,COLOR_RED,"EROR: "COL_WHITE"You are not buying vehicle.");
  625. PlayerChooseVehicle = false;
  626. PlayerSwitchVehicle[playerid] = false;
  627. TogglePlayerControllable(playerid,true);
  628. ChoosedCar = 0;
  629. SCM(playerid,-1,"You are stop choosing car");
  630. TextDrawHideForPlayer(playerid,CoSTD0[playerid]);
  631. return 1;
  632. }
  633. YCMD:v(playerid, params[], help)
  634. {
  635. #pragma unused help
  636. #pragma unused params
  637. new vehicleid = GetPlayerVehicleID(playerid);
  638. if(Player[playerid][Veh3] == 9999 && Player[playerid][Veh2] == 9999 && Player[playerid][Veh1] == 9999) return SCM(playerid,COLOR_RED,"You don't have vehicle!");
  639. if(strcmp(C_Data[vehicleid][Owner],GetName(playerid), false ) == 0)
  640. {
  641. ShowPlayerDialog(playerid,DIALOG_CARS+1,DIALOG_STYLE_LIST,"Vehicle control panel","Color\nLock car\nUnlock car\nSell\nPark\nLocate\nAlarm","Do it","Cancel");
  642. }
  643. return 1;
  644. }
  645. YCMD:gpsoff(playerid, params[], help)
  646. {
  647. #pragma unused help
  648. #pragma unused params
  649. if(!GPSOn[playerid]) return SCM(playerid,COLOR_RED,"EROR: "COL_WHITE"Your GPS is already off");
  650. DisablePlayerCheckpoint(playerid);
  651. GPSOn[playerid] = false;
  652. return 1;
  653. }
  654. YCMD:cwithdraw(playerid, params[], help)
  655. {
  656. #pragma unused help
  657. #pragma unused params
  658. new string[128],money;
  659. if(!IsPlayerInAnyVehicle(playerid)) return SCM(playerid,COLOR_RED,"You must be in car!");
  660. new id = GetPlayerVehicleID(playerid);
  661. if(Player[playerid][Veh3] == 9999 && Player[playerid][Veh2] == 9999 && Player[playerid][Veh1] == 9999) return SCM(playerid,COLOR_RED,"You don't have vehicle!");
  662. if(Player[playerid][Veh3] == id || Player[playerid][Veh2] == id || Player[playerid][Veh1] == id)
  663. {
  664. new Float:Pos[3]; GetVehiclePos(C_Data[id][ID],Pos[0],Pos[1],Pos[2]);
  665. if(!IsPlayerInRangeOfPoint(playerid,10.0,Pos[0],Pos[1],Pos[2])) return SCM(playerid,COLOR_RED,"EROR: "COL_WHITE"You are not near near your car");
  666. if(sscanf(params, "i",money)) return SCM(playerid, COLOR_RED, "Usage: /cwithdraw [Money]");
  667. if(money > GetPlayerMoney(playerid)) return SCM(playerid, COLOR_RED, "You don't have that money");
  668. if(money < 1) return SCM(playerid, COLOR_RED, "Money can't be less then 1");
  669. C_Data[id][Money] += money;
  670. GivePlayerMoney(playerid, -money);
  671. format(string,sizeof(string),"{E0BC1B}You are put in car $%d.Now you have in car $%d",money,C_Data[id][Money]);
  672. SCM(playerid,-1,string);
  673. CheckCar(id);
  674. }
  675. return 1;
  676. }
  677. YCMD:cdeposit(playerid, params[], help)
  678. {
  679. #pragma unused help
  680. #pragma unused params
  681. new string[128],money;
  682. if(!IsPlayerInAnyVehicle(playerid)) return SCM(playerid,COLOR_RED,"You must be in car!");
  683. new id = GetPlayerVehicleID(playerid);
  684. if(Player[playerid][Veh3] == 9999 && Player[playerid][Veh2] == 9999 && Player[playerid][Veh1] == 9999) return SCM(playerid,COLOR_RED,"You don't have vehicle!");
  685. if(Player[playerid][Veh3] == id || Player[playerid][Veh2] == id || Player[playerid][Veh1] == id)
  686. {
  687. new Float:Pos[3]; GetVehiclePos(C_Data[id][ID],Pos[0],Pos[1],Pos[2]);
  688. if(sscanf(params, "i",money)) return SCM(playerid, COLOR_RED, "Usage: /cdeposit [Money]");
  689. if(money > C_Data[id][Money]) return SCM(playerid, COLOR_RED, "There is that money in car");
  690. if(money < 1) return SCM(playerid, COLOR_RED, "Money can't be less then 1");
  691. C_Data[id][Money] -= money;
  692. GivePlayerMoney(playerid, money);
  693. format(string,sizeof(string),"{E0BC1B}You are take from car $%d.Now you have in car $%d",money,C_Data[id][Money]);
  694. SCM(playerid,-1,string);
  695. CheckCar(id);
  696. }
  697. return 1;
  698. }
  699. YCMD:cputgun(playerid, params[], help)
  700. {
  701. #pragma unused help
  702. new string[128];
  703. if(!IsPlayerInAnyVehicle(playerid)) return SCM(playerid,COLOR_RED,"You must be in car!");
  704. new id = GetPlayerVehicleID(playerid);
  705. if(Player[playerid][Veh3] == 9999 && Player[playerid][Veh2] == 9999 && Player[playerid][Veh1] == 9999) return SCM(playerid,COLOR_RED,"You don't have vehicle!");
  706. if(Player[playerid][Veh3] == id || Player[playerid][Veh2] == id || Player[playerid][Veh1] == id)
  707. {
  708. new Float:Pos[3]; GetVehiclePos(id,Pos[0],Pos[1],Pos[2]);
  709. new slot,ammo;
  710. if(sscanf(params, "ii",slot,ammo)) return SCM(playerid, COLOR_RED, "Usage: /cputgun [Slot 1/2] [Ammo]");
  711. if(ammo > GetPlayerAmmo(playerid)) return SCM(playerid, COLOR_RED, "You don't have that so much ammo");
  712. if(ammo < 1) return SCM(playerid, COLOR_RED, "Ammo can't be less then 1");
  713. if(slot == 1)
  714. {
  715. if(C_Data[id][Gun1] != 0) return SCM(playerid,COLOR_RED,"EROR: "COL_WHITE"There is already gun on this slot.");
  716. C_Data[id][Gun1] = GetPlayerWeapon(playerid);
  717. C_Data[id][Ammo1] = ammo;
  718. SetPlayerAmmo(playerid,GetPlayerWeapon(playerid),GetPlayerAmmo(playerid)-ammo);
  719. format(string,sizeof(string),"{E0BC1B}You are put gun on slot 1.With %d ammo",ammo);
  720. SCM(playerid,-1,string);
  721. CheckCar(id);
  722. }
  723. if(slot == 2)
  724. {
  725. if(C_Data[id][Gun2] != 0) return SCM(playerid,COLOR_RED,"EROR: "COL_WHITE"There is already gun on this slot.");
  726. C_Data[id][Gun2] = GetPlayerWeapon(playerid);
  727. C_Data[id][Ammo2] = ammo;
  728. SetPlayerAmmo(playerid,GetPlayerWeapon(playerid),GetPlayerAmmo(playerid)-ammo);
  729. format(string,sizeof(string),"{E0BC1B}You are put gun on slot 2.With %d ammo",ammo);
  730. SCM(playerid,-1,string);
  731. CheckCar(id);
  732. }
  733. }
  734. return 1;
  735. }
  736. YCMD:ctakegun(playerid, params[], help)
  737. {
  738. #pragma unused help
  739. new string[128];
  740. if(!IsPlayerInAnyVehicle(playerid)) return SCM(playerid,COLOR_RED,"You must be in car!");
  741. new id = GetPlayerVehicleID(playerid);
  742. if(Player[playerid][Veh3] == 9999 && Player[playerid][Veh2] == 9999 && Player[playerid][Veh1] == 9999) return SCM(playerid,COLOR_RED,"You don't have vehicle!");
  743. if(Player[playerid][Veh3] == id || Player[playerid][Veh2] == id || Player[playerid][Veh1] == id)
  744. {
  745. new Float:Pos[3]; GetVehiclePos(id,Pos[0],Pos[1],Pos[2]);
  746. new slot,ammo;
  747. if(sscanf(params, "ii",slot,ammo)) return SCM(playerid, COLOR_RED, "Usage: /ctakegun [Slot 1/2] [Ammo]");
  748. if(ammo < 1) return SCM(playerid, COLOR_RED, "Ammo can't be less then 1");
  749. if(slot == 1)
  750. {
  751. if(C_Data[id][Gun1] != 0) return SCM(playerid,COLOR_RED,"EROR: "COL_WHITE"There is already gun on this slot.");
  752. if(ammo > C_Data[id][Ammo1]) return SCM(playerid, COLOR_RED, "EROR:"COL_WHITE" In car dosen't have that so much ammo");
  753. GivePlayerWeapon(playerid,C_Data[id][Gun1],ammo);
  754. C_Data[id][Ammo1] -= ammo;
  755. if(C_Data[id][Ammo1] == 0) {C_Data[id][Gun1] = 0;}
  756. format(string,sizeof(string),"{E0BC1B}You are take gun from slot 1.With %d ammo",ammo);
  757. SCM(playerid,-1,string);
  758. CheckCar(id);
  759. }
  760. if(slot == 2)
  761. {
  762. if(C_Data[id][Gun2] != 0) return SCM(playerid,COLOR_RED,"EROR: "COL_WHITE"There is already gun on this slot.");
  763. if(ammo > C_Data[id][Ammo2]) return SCM(playerid, COLOR_RED, "EROR:"COL_WHITE" In car dosen't have that so much ammo");
  764. GivePlayerWeapon(playerid,C_Data[id][Gun2],ammo);
  765. C_Data[id][Ammo2] -= ammo;
  766. if(C_Data[id][Ammo2] == 0) {C_Data[id][Gun2] = 0;}
  767. format(string,sizeof(string),"{E0BC2B}You are take gun from slot 2.With %d ammo",ammo);
  768. SCM(playerid,-2,string);
  769. CheckCar(id);
  770. }
  771. }
  772. return 1;
  773. }
  774. YCMD:sellto(playerid, params[], help)
  775. {
  776. #pragma unused help
  777. if(!IsPlayerInAnyVehicle(playerid)) return SCM(playerid,COLOR_RED,"EROR: "COL_WHITE"You must be in vehicle");
  778. new pplayerid,price;
  779. if(sscanf(params,"ui",pplayerid,price)) return SCM(playerid,COLOR_RED,"Usage: "COL_WHITE"/sellto [Player ID/Part of Name] [Price]");
  780. if(GetPlayerMoney(pplayerid) < price) return SCM(playerid,COLOR_RED,"EROR: "COL_WHITE"Player don't have engouh money");
  781. if(price < 1) return SCM(playerid,COLOR_RED,"EROR: "COL_WHITE"Price can't be less then 1");
  782. new Float:Pos[3]; GetPlayerPos(pplayerid,Pos[0],Pos[1],Pos[2]);
  783. if(!IsPlayerInRangeOfPoint(playerid,10.0,Pos[0],Pos[1],Pos[2])) return SCM(playerid,COLOR_RED,"EROR: "COL_WHITE"You'r not near that player");
  784. if(Player[playerid][Veh3] == 9999 && Player[playerid][Veh2] == 9999 && Player[playerid][Veh1] == 9999) return SCM(playerid,COLOR_RED,"You don't have vehicle!");
  785. if(Player[pplayerid][Veh3] != 9999 && Player[pplayerid][Veh2] != 9999 && Player[pplayerid][Veh1] != 9999) return SCM(playerid,COLOR_RED,"Player already have three vehicles!");
  786. Seller[pplayerid] = playerid;
  787. Priceo[pplayerid] = price;
  788. SendFormatMSG(pplayerid,-1,"Player %s has offer u for vehicle for price %d. Type /accept sell",Priceo[playerid]);
  789. SCM(playerid,-1,"Wait for answer");
  790. return 1;
  791. }
  792. YCMD:refusesell(playerid, params[], help)
  793. {
  794. #pragma unused help
  795. #pragma unused params
  796. if(Seller[playerid] == 999) return SCM(playerid,COLOR_RED,"EROR: "COL_WHITE"You dont have ofer for buy vehicle.");
  797. SCM(playerid,-1,"You are refuse offer.");
  798. SCM(Seller[playerid],-1,"Player is refuse offer.");
  799. Priceo[playerid] = 0;
  800. Seller[playerid] = 999;
  801. return 1;
  802. }
  803. YCMD:acceptsell(playerid, params[], help)
  804. {
  805. #pragma unused help
  806. #pragma unused params
  807. new id = GetPlayerVehicleID(playerid);
  808. if(Seller[playerid] == 999) return SCM(playerid,COLOR_RED,"EROR: "COL_WHITE"You dont have ofer for buy vehicle.");
  809. if(!IsPlayerInAnyVehicle(Seller[playerid])) return SCM(playerid,COLOR_RED,"EROR: "COL_WHITE"Player is not in car");
  810. if(Player[Seller[playerid]][Veh3] == id)
  811. {
  812. if(Player[playerid][Veh1] == 9999 && Player[playerid][Veh2] == 9999 && Player[playerid][Veh3] == 9999) {Player[playerid][Veh1] = Player[Seller[playerid]][Veh3];}
  813. else if(Player[playerid][Veh2] != 9999 && Player[playerid][Veh1] == 9999 && Player[playerid][Veh3] != 9999){Player[playerid][Veh1] = Player[Seller[playerid]][Veh3];}
  814. else if(Player[playerid][Veh1] != 9999 && Player[playerid][Veh2] == 9999 && Player[playerid][Veh3] != 9999){Player[playerid][Veh2] = Player[Seller[playerid]][Veh3];}
  815. else if(Player[playerid][Veh1] != 9999 && Player[playerid][Veh2] == 9999 && Player[playerid][Veh3] == 9999){Player[playerid][Veh2] = Player[Seller[playerid]][Veh3];}
  816. else if(Player[playerid][Veh3] == 9999 && Player[playerid][Veh1] != 9999 && Player[playerid][Veh2] != 9999){Player[playerid][Veh3] = Player[Seller[playerid]][Veh3];}
  817. strmid(C_Data[id][Owner], GetName(playerid), 0, strlen(GetName(playerid)), 999);
  818. GivePlayerMoney(Seller[playerid],Priceo[playerid]);
  819. GivePlayerMoney(playerid,-Priceo[playerid]);
  820. SendFormatMSG(playerid,-1,"You are buy vehicle for price %d",Priceo[playerid]);
  821. SendFormatMSG(Seller[playerid],-1,"You are sell vehicle for price %d",Priceo[playerid]);
  822. CheckCar(id);
  823. RemovePlayerFromVehicle(Seller[playerid]);
  824. Priceo[playerid] = 0;
  825. Seller[playerid] = 999;
  826. }
  827. if(Player[Seller[playerid]][Veh2] == id)
  828. {
  829. if(Player[playerid][Veh1] == 9999 && Player[playerid][Veh2] == 9999 && Player[playerid][Veh3] == 9999) {Player[playerid][Veh1] = Player[Seller[playerid]][Veh2];}
  830. else if(Player[playerid][Veh2] != 9999 && Player[playerid][Veh1] == 9999 && Player[playerid][Veh3] != 9999){Player[playerid][Veh1] = Player[Seller[playerid]][Veh2];}
  831. else if(Player[playerid][Veh1] != 9999 && Player[playerid][Veh2] == 9999 && Player[playerid][Veh3] != 9999){Player[playerid][Veh2] = Player[Seller[playerid]][Veh2];}
  832. else if(Player[playerid][Veh1] != 9999 && Player[playerid][Veh2] == 9999 && Player[playerid][Veh3] == 9999){Player[playerid][Veh2] = Player[Seller[playerid]][Veh2];}
  833. else if(Player[playerid][Veh3] == 9999 && Player[playerid][Veh1] != 9999 && Player[playerid][Veh2] != 9999){Player[playerid][Veh3] = Player[Seller[playerid]][Veh2];}
  834. strmid(C_Data[id][Owner], GetName(playerid), 0, strlen(GetName(playerid)), 999);
  835. GivePlayerMoney(Seller[playerid],Priceo[playerid]);
  836. GivePlayerMoney(playerid,-Priceo[playerid]);
  837. SendFormatMSG(playerid,-1,"You are buy vehicle for price %d",Priceo[playerid]);
  838. SendFormatMSG(playerid,-1,"You are sell vehicle for price %d",Priceo[playerid]);
  839. CheckCar(id);
  840. RemovePlayerFromVehicle(Seller[playerid]);
  841. Priceo[playerid] = 0;
  842. Seller[playerid] = 999;
  843. }
  844. if(Player[Seller[playerid]][Veh1] == id)
  845. {
  846. if(Player[playerid][Veh1] == 9999 && Player[playerid][Veh2] == 9999 && Player[playerid][Veh3] == 9999) {Player[playerid][Veh1] = Player[Seller[playerid]][Veh1];}
  847. else if(Player[playerid][Veh2] != 9999 && Player[playerid][Veh1] == 9999 && Player[playerid][Veh3] != 9999){Player[playerid][Veh1] = Player[Seller[playerid]][Veh1];}
  848. else if(Player[playerid][Veh1] != 9999 && Player[playerid][Veh2] == 9999 && Player[playerid][Veh3] != 9999){Player[playerid][Veh2] = Player[Seller[playerid]][Veh1];}
  849. else if(Player[playerid][Veh1] != 9999 && Player[playerid][Veh2] == 9999 && Player[playerid][Veh3] == 9999){Player[playerid][Veh2] = Player[Seller[playerid]][Veh1];}
  850. else if(Player[playerid][Veh3] == 9999 && Player[playerid][Veh1] != 9999 && Player[playerid][Veh2] != 9999){Player[playerid][Veh3] = Player[Seller[playerid]][Veh1];}
  851. strmid(C_Data[id][Owner], GetName(playerid), 0, strlen(GetName(playerid)), 999);
  852. GivePlayerMoney(Seller[playerid],Priceo[playerid]);
  853. GivePlayerMoney(playerid,-Priceo[playerid]);
  854. SendFormatMSG(playerid,-1,"You are buy vehicle for price %d",Priceo[playerid]);
  855. SendFormatMSG(playerid,-1,"You are sell vehicle for price %d",Priceo[playerid]);
  856. CheckCar(id);
  857. RemovePlayerFromVehicle(Seller[playerid]);
  858. Priceo[playerid] = 0;
  859. Seller[playerid] = 999;
  860. }
  861. return 1;
  862. }
  863. //Stock
  864. stock AddMoreCar(model,price,speed,level)
  865. {
  866. CarModel[maximalcars][Model] = model;
  867. CarModel[maximalcars][Price] = price;
  868. CarModel[maximalcars][Speed] = speed;
  869. CarModel[maximalcars][Level] = level;
  870. maximalcars++;
  871. }
  872. stock CreateSaveCar(id)
  873. {
  874. new dFile[32];
  875. format(dFile, 35, CoS_File, id);
  876.  
  877. new
  878. INI:File = INI_Open(dFile);
  879.  
  880. INI_WriteFloat(File, "X", C_Data[id][cX]);
  881. INI_WriteFloat(File, "Y", C_Data[id][cY]);
  882. INI_WriteFloat(File, "Z", C_Data[id][cZ]);
  883. INI_WriteFloat(File, "A", C_Data[id][cA]);
  884. INI_WriteInt(File, "Model", C_Data[id][Model]);
  885. INI_WriteInt(File, "Lock", C_Data[id][Lock]);
  886. INI_WriteString(File, "Owner", C_Data[id][Owner]);
  887. INI_WriteInt(File, "Col1", C_Data[id][Col1]);
  888. INI_WriteInt(File, "Col2", C_Data[id][Col2]);
  889. INI_WriteInt(File, "Money", C_Data[id][Col2]);
  890. INI_WriteInt(File, "Gun1", C_Data[id][Gun1]);
  891. INI_WriteInt(File, "Ammo1", C_Data[id][Ammo1]);
  892. INI_WriteInt(File, "Gun2", C_Data[id][Gun2]);
  893. INI_WriteInt(File, "Ammo2", C_Data[id][Ammo2]);
  894. INI_WriteInt(File, "Alarm", C_Data[id][Alarm]);
  895.  
  896. INI_Close(File);
  897. }
  898. stock CheckCar(id)
  899. {
  900. new dFile[32];
  901. format(dFile, 35, CoS_File, id);
  902.  
  903. new
  904. INI:File = INI_Open(dFile);
  905.  
  906. INI_WriteFloat(File, "X", C_Data[id][cX]);
  907. INI_WriteFloat(File, "Y", C_Data[id][cY]);
  908. INI_WriteFloat(File, "Z", C_Data[id][cZ]);
  909. INI_WriteFloat(File, "A", C_Data[id][cA]);
  910. INI_WriteInt(File, "Model", C_Data[id][Model]);
  911. INI_WriteInt(File, "Lock", C_Data[id][Lock]);
  912. INI_WriteString(File, "Owner", C_Data[id][Owner]);
  913. INI_WriteInt(File, "Col1", C_Data[id][Col1]);
  914. INI_WriteInt(File, "Col2", C_Data[id][Col2]);
  915. INI_WriteInt(File, "Money", C_Data[id][Col2]);
  916. INI_WriteInt(File, "Gun1", C_Data[id][Gun1]);
  917. INI_WriteInt(File, "Ammo1", C_Data[id][Ammo1]);
  918. INI_WriteInt(File, "Gun2", C_Data[id][Gun2]);
  919. INI_WriteInt(File, "Ammo2", C_Data[id][Ammo2]);
  920. INI_WriteInt(File, "Alarm", C_Data[id][Alarm]);
  921.  
  922. INI_Close(File);
  923. }
  924. stock GetNextFreeID()
  925. {
  926. new string[32];
  927. for(new i = NUMBER_FOR_LOAD; i <= MAX_CARS;i++)
  928. {
  929. format(string,32,CoS_File,i);
  930. if(!fexist(string)) return i;
  931. }
  932. return 1;
  933. }
  934. stock GetVehiclePrice(model)
  935. {
  936. for(new id = 0; id <= maximalcars;id++)
  937. {
  938. if(CarModel[id][Model] == model) return CarModel[id][Price];
  939. }
  940. return 1;
  941. }
  942. stock UpdatePlayerInfo(playerid)
  943. {
  944. new
  945. pFile[35];
  946.  
  947. format(pFile, 35, Player_File, GetName(playerid));
  948. new
  949. INI:UserFile = INI_Open(pFile);
  950. INI_WriteInt(UserFile, "Veh1", Player[playerid][Veh1]);
  951. INI_WriteInt(UserFile, "Veh2", Player[playerid][Veh2]);
  952. INI_WriteInt(UserFile, "Veh3", Player[playerid][Veh3]);
  953. INI_Close(UserFile);
  954. }
  955. stock ProxDetector(playerid, const msg [], color, maxdistance = 50)
  956. {
  957. new
  958. Float: x1,
  959. Float: y1,
  960. Float: z1,
  961. distance,
  962. string [128];
  963.  
  964. if (GetPlayerName (playerid, string, sizeof string))
  965. {
  966. format (string, sizeof string, "%s", msg);
  967. GetPlayerPos (playerid, x1, y1, z1);
  968. for (new i = 0; i < MAX_PLAYERS; ++i)
  969. {
  970. if (IsPlayerConnected (i) && !IsPlayerNPC (i))
  971. {
  972. if (i == playerid)
  973. SCM (i, color, string);
  974. else
  975. {
  976. distance = floatround (GetPlayerDistanceFromPoint (i, x1, y1, z1));
  977. if (distance <= maxdistance)
  978. SCM (i, ColorFade (color, distance, maxdistance), string);
  979. }
  980. }
  981. }
  982. return 1;
  983. }
  984. return 0;
  985. }
  986. stock ColorFade (color, value, maxvalue)
  987. {
  988. if (0 <= value <= maxvalue)
  989. {
  990. new
  991. Float: ratio = float (value) / float (maxvalue);
  992. new
  993. r = max (0, min (255, floatround (float ((color >> 24) & 0xFF) * ratio))),
  994. g = max (0, min (255, floatround (float ((color >> 16) & 0xFF) * ratio))),
  995. b = max (0, min (255, floatround (float ((color >> 8) & 0xFF) * ratio)));
  996. return (r << 24) | (g << 16) | (b << 8) | (value & 0xFF);
  997. }
  998. return 0;
  999. }
  1000. //public function
  1001. forward LoadCar(id, name[], value[]);
  1002. public LoadCar(id, name[], value[])
  1003. {
  1004. INI_Float("X", C_Data[id][cX]);
  1005. INI_Float("Y", C_Data[id][cY]);
  1006. INI_Float("Z", C_Data[id][cZ]);
  1007. INI_Float("A", C_Data[id][cA]);
  1008. INI_Int("Model", C_Data[id][Model]);
  1009. INI_Int("Lock", C_Data[id][Lock]);
  1010. INI_String("Owner", C_Data[id][Owner],32);
  1011. INI_Int("Col1", C_Data[id][Col1]);
  1012. INI_Int("Col2", C_Data[id][Col2]);
  1013. INI_Int("Money", C_Data[id][Money]);
  1014. INI_Int("Gun1", C_Data[id][Gun1]);
  1015. INI_Int("Ammo1", C_Data[id][Ammo1]);
  1016. INI_Int("Gun2", C_Data[id][Gun2]);
  1017. INI_Int("Ammo2", C_Data[id][Ammo2]);
  1018. INI_Int("Alarm", C_Data[id][Alarm]);
  1019. return 1;
  1020. }
Advertisement
Add Comment
Please, Sign In to add comment