/*
*	Created:			06.03.09
*	Author:				009
*	Last Modifed:		11.03.10
*	Description:		Функции упрощения работы с транспортом
*
*	11.03.10:
*	1.Добавлена функция GetModeVehiclesCount()
*	2.Добавлена функция bool:IsModeVehicleActive(vehicleid)
*
*	10.03.10:
*	1.Добавлены функции радио
*
*	30.01.10:
*	1.Глобальное обновление под новую структуру мода
*
*	03.11.09:
*	1.Изменена система сохранения данных
*	2.Машина привязана к ключу
*
*	20.09.09:
*	1.MAX_PLAYERS в циклах заменён на GetMaxPlayer()
*	2.Замена SendMessage на ModeMessage
*/

#if defined _mode_vehicles_included
  #endinput
#endif

#define _mode_vehicles_included
#pragma library mode_vehicles

// --------------------------------------------------
// includes
// --------------------------------------------------
#include "speedometers\analog"
#include "speedometers\electro"
#include "mode_core"
#include "mode_debug"
#include "mode_mysql"
#include "mode_property"

// --------------------------------------------------
// defines
// --------------------------------------------------
#define NEVER 999_999_999
#define INVALID_MODE_VEHICLE_ID -1
#define MAX_VEHICLE_NAME 40
#define KEY_EXIT_VEHICLE 16
#define MODE_VEHICLES_LUGGAGE_RANGE 1.5
#define GetModeVehiclesCount() ModeVehiclesCounter

// --------------------------------------------------
// enums
// --------------------------------------------------
enum ModeVehiclesInfo {
	bool:vActive,
	vSpeedoType,
	vSpeedoSubtype,
	vSpeedoId,
	Float:vFuel,
	bool:vEngineState
};
enum ModeVehiclesPlayerInfo {
	bool:pSpeedoShowed,
	Float:pLastPos[3],
	Float:pLastVelocity
};
enum VehiclesInfo {
	vName[MAX_VEHICLE_NAME],
	vType,
	vSubtype,
	Float:vMaxFuel,
	Float:vLenght,
	Float:vWidth,
	Float:vExpense,
	vLuggageType,
	Float:vMaxLuggage
};
enum {
	LUGGAGE_NONE,
	LUGGAGE_SMALL,
	LUGGAGE_BIG
};
enum {
	VEHICLE_TYPE_CAR,
	VEHICLE_TYPE_BIKE,
	VEHICLE_TYPE_SEA,
	VEHICLE_TYPE_AIR,
	VEHICLE_TYPE_HEAVY,
	VEHICLE_TYPE_RC,
	VEHICLE_TYPE_TRAIN
};
enum {
	// car
	VEHICLE_SUBTYPE_4WD,
	VEHICLE_SUBTYPE_2DOOR,
	VEHICLE_SUBTYPE_4DOOR,
	VEHICLE_SUBTYPE_SPORT,
	VEHICLE_SUBTYPE_INDUSTRIAL,
	VEHICLE_SUBTYPE_GOVERMENT,
	VEHICLE_SUBTYPE_SERVICE,
	VEHICLE_SUBTYPE_VAN,
	VEHICLE_SUBTYPE_LOWRIDER,
	VEHICLE_SUBTYPE_UNIQUE,
	// air
	VEHICLE_SUBTYPE_HELI,
	VEHICLE_SUBTYPE_PLANE,
	// sea
	VEHICLE_SUBTYPE_BOAT,
	// heavy
	VEHICLE_SUBTYPE_TRAILER,
	VEHICLE_SUBTYPE_TRAM,
	// rc
	VEHICLE_SUBTYPE_RCCAR,
	VEHICLE_SUBTYPE_RCBIKE,
	VEHICLE_SUBTYPE_RCPLANE,
	VEHICLE_SUBTYPE_RCHELI,
	// bike
	VEHICLE_SUBTYPE_MOPED,
	VEHICLE_SUBTYPE_MOTO,
	VEHICLE_SUBTYPE_BIKE,
	VEHICLE_SUBTYPE_QUAD,
	// train
	VEHICLE_SUBTYPE_CARGO,
	VEHICLE_SUBTYPE_PASSANGER,
	VEHICLE_SUBTYPE_CARGO_T,
	VEHICLE_SUBTYPE_PASSANGER_T
};
enum {
	SPEEDOMETER_ANALOG,
	SPEEDOMETER_ELECTRO
};

// --------------------------------------------------
// news
// --------------------------------------------------
new ModeVehiclesCounter;

// --------------------------------------------------
// statics
// --------------------------------------------------
static
	ModeVehicles[MAX_VEHICLES][ModeVehiclesInfo],
	ModeVehicles_Player[MAX_PLAYERS][ModeVehiclesPlayerInfo],
	Vehicles[][VehiclesInfo] = {
		{"Landstalker",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_4WD,85.0,2.4,1.1,16.0,LUGGAGE_SMALL,30.0},// 400
		{"Bravura",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_2DOOR,45.0,2.7,1.1,10.0,LUGGAGE_SMALL,10.0},// 401
		{"Buffalo",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_SPORT,40.0,2.7,1.2,12.0,LUGGAGE_SMALL,10.0},// 402
		{"Linerunner",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_INDUSTRIAL,298.0,4.4,1.5,30.0,LUGGAGE_NONE,0.0},// 403
		{"Pereniel",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_4DOOR,40.0,2.7,1.0,13.1,LUGGAGE_SMALL,30.0},// 404
		{"Sentinel",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_4DOOR,40.0,2.5,1.1,11.1,LUGGAGE_SMALL,10.0},// 405
		{"Dumper",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_INDUSTRIAL,200.0,5.0,2.2,40.0,LUGGAGE_NONE,0.0},// 406
		{"Firetruck",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_GOVERMENT,80.0,4.3,1.2,25.0,LUGGAGE_NONE,0.0},// 407
		{"Trashmaster",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_SERVICE,60.0,5.0,1.5,25.0,LUGGAGE_NONE,0.0},// 408
		{"Stretch",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_4DOOR,40.0,4.0,1.1,15.0,LUGGAGE_SMALL,15.0},// 409
		{"Manana",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_2DOOR,40.0,2.2,1.0,10.0,LUGGAGE_SMALL,10.0},// 410
		{"Infernus",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_SPORT,40.0,-2.7,1.1,20.0,LUGGAGE_SMALL,5.0},// 411
		{"Voodoo",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_LOWRIDER,40.0,3.5,1.2,15.0,LUGGAGE_SMALL,15.0},// 412
		{"Pony",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_VAN,45.0,2.7,1.0,20.0,LUGGAGE_SMALL,45.0},// 413
		{"Mule",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_INDUSTRIAL,45.0,3.4,1.2,25.0,LUGGAGE_BIG,70.0},// 414
		{"Cheetah",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_SPORT,40.0,-2.5,1.1,17.5,LUGGAGE_SMALL,5.0},// 415
		{"Ambulance",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_GOVERMENT,70.0,3.5,1.2,15.0,LUGGAGE_NONE,0.0},// 416
		{"Leviathan",VEHICLE_TYPE_AIR,VEHICLE_SUBTYPE_HELI,100.0,5.0,1.2,30.0,LUGGAGE_NONE,0.0},// 417
		{"Moonbeam",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_VAN,45.0,2.5,1.2,18.0,LUGGAGE_SMALL,40.0},// 418
		{"Esperanto",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_2DOOR,40.0,3.0,1.2,15.0,LUGGAGE_SMALL,10.0},// 419
		{"Taxi",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_SERVICE,40.0,2.7,1.2,12.5,LUGGAGE_SMALL,15.0},// 420
		{"Washington",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_4DOOR,40.0,3.0,1.0,13.0,LUGGAGE_SMALL,15.0},// 421
		{"Bobcat",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_4WD,45.0,2.5,1.2,18.0,LUGGAGE_NONE,0.0},// 422
		{"Mr Whoopee",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_VAN,45.0,2.2,1.2,10.0,LUGGAGE_NONE,0.0},// 423
		{"BF Injection",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_4WD,20.0,1.7,1.0,20.0,LUGGAGE_NONE,0.0},// 424
		{"Hunter",VEHICLE_TYPE_AIR,VEHICLE_SUBTYPE_HELI,200.0,5.3,1.0,45.5,LUGGAGE_NONE,0.0},// 425
		{"Premier",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_4DOOR,40.0,2.5,1.1,12.5,LUGGAGE_SMALL,15.0},// 426
		{"Enforcer",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_GOVERMENT,70.0,3.7,1.2,20.0,LUGGAGE_NONE,0.0},// 427
		{"Securicar",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_VAN,70.0,3.0,1.2,20.0,LUGGAGE_SMALL,50.0},// 428
		{"Banshee",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_SPORT,40.0,2.5,1.0,20.0,LUGGAGE_SMALL,10.0},// 429
		{"Predator",VEHICLE_TYPE_SEA,VEHICLE_SUBTYPE_BOAT,45.0,7.8,1.7,30.0,LUGGAGE_SMALL,10.0},// 430
		{"Bus",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_SERVICE,60.0,5.8,1.2,20.0,LUGGAGE_NONE,0.0},// 431
		{"Rhino",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_GOVERMENT,90.0,4.4,2.0,45.0,LUGGAGE_NONE,0.0},// 432
		{"Barracks",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_GOVERMENT,100.0,4.0,1.5,30.0,LUGGAGE_NONE,0.0},// 433
		{"Hotknife",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_SPORT,35.0,2.0,1.0,15.0,LUGGAGE_SMALL,5.0},// 434
		{"Trailer",VEHICLE_TYPE_HEAVY,VEHICLE_SUBTYPE_TRAILER,0.0,4.0,1.5,0.0,LUGGAGE_BIG,100.0},// 435
		{"Previon",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_2DOOR,40.0,2.4,1.0,15.0,LUGGAGE_SMALL,10.0},// 436
		{"Coach",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_SERVICE,50.0,5.4,1.2,20.0,LUGGAGE_NONE,0.0},// 437
		{"Cabbie",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_SERVICE,40.0,2.7,1.1,10.0,LUGGAGE_SMALL,15.0},// 438
		{"Stallion",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_2DOOR,40.0,2.7,1.2,15.0,LUGGAGE_SMALL,10.0},// 439
		{"Rumpo",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_VAN,45.0,2.5,1.1,20.0,LUGGAGE_SMALL,40.0},// 440
		{"RC Bandit",VEHICLE_TYPE_RC,VEHICLE_SUBTYPE_RCCAR,0.0,0.8,0.5,0.0,LUGGAGE_NONE,0.0},// 441
		{"Romero",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_4DOOR,40.0,3.2,1.2,15.0,LUGGAGE_SMALL,25.0},// 442
		{"Packer",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_INDUSTRIAL,50.0,6.0,1.6,30.0,LUGGAGE_NONE,0.0},// 443
		{"Monster",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_4WD,65.0,2.9,1.2,30.0,LUGGAGE_SMALL,15.0},// 444
		{"Admiral",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_4DOOR,65.0,2.9,1.1,20.0,LUGGAGE_SMALL,20.0},// 445
		{"Squalo",VEHICLE_TYPE_SEA,VEHICLE_SUBTYPE_BOAT,35.0,4.5,1.7,20.0,LUGGAGE_NONE,0.0},// 446
		{"Seasparrow",VEHICLE_TYPE_AIR,VEHICLE_SUBTYPE_HELI,90.0,2.4,1.2,30.0,LUGGAGE_NONE,0.0},// 447
		{"Pizzaboy",VEHICLE_TYPE_BIKE,VEHICLE_SUBTYPE_MOPED,20.0,1.1,0.5,5.0,LUGGAGE_NONE,0.0},// 448
		{"Tram",VEHICLE_TYPE_HEAVY,VEHICLE_SUBTYPE_TRAM,0.0,4.0,1.2,0.0,LUGGAGE_NONE,0.0},// 449
		{"Trailer",VEHICLE_TYPE_HEAVY,VEHICLE_SUBTYPE_TRAILER,0.0,3.9,1.5,0.0,LUGGAGE_BIG,90.0},// 450
		{"Turismo",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_SPORT,40.0,-2.5,1.1,20.0,LUGGAGE_SMALL,7.5},// 451
		{"Speeder",VEHICLE_TYPE_SEA,VEHICLE_SUBTYPE_BOAT,20.0,4.5,1.2,10.0,LUGGAGE_NONE,0.0},// 452
		{"Reefer",VEHICLE_TYPE_SEA,VEHICLE_SUBTYPE_BOAT,20.0,1.5,2.0,10.0,LUGGAGE_NONE,0.0},// 453
		{"Tropic",VEHICLE_TYPE_SEA,VEHICLE_SUBTYPE_BOAT,20.0,3.0,1.5,10.0,LUGGAGE_NONE,0.0},// 454
		{"Flatbed",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_INDUSTRIAL,60.0,4.5,1.6,20.0,LUGGAGE_NONE,0.0},// 455
		{"Yankee",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_INDUSTRIAL,50.0,3.7,1.6,20.0,LUGGAGE_BIG,80.0},// 456
		{"Caddy",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_UNIQUE,20.0,1.5,0.8,5.0,LUGGAGE_NONE,0.0},// 457
		{"Solair",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_4DOOR,40.0,2.5,1.2,10.0,LUGGAGE_SMALL,30.0},// 458
		{"Berkley's RC Van",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_VAN,45.0,2.7,1.1,15.0,LUGGAGE_SMALL,45.0},// 459
		{"Skimmer",VEHICLE_TYPE_AIR,VEHICLE_SUBTYPE_PLANE,90.0,0.0,0.0,30.0,LUGGAGE_NONE,0.0},// 460
		{"PCJ-600",VEHICLE_TYPE_BIKE,VEHICLE_SUBTYPE_MOTO,30.0,0.8,0.5,10.0,LUGGAGE_NONE,0.0},// 461
		{"Faggio",VEHICLE_TYPE_BIKE,VEHICLE_SUBTYPE_MOPED,20.0,0.8,0.5,5.0,LUGGAGE_NONE,0.0},// 462
		{"Freeway",VEHICLE_TYPE_BIKE,VEHICLE_SUBTYPE_MOTO,35.0,1.2,0.4,15.0,LUGGAGE_NONE,0.0},// 463
		{"RC Baron",VEHICLE_TYPE_RC,VEHICLE_SUBTYPE_RCPLANE,0.0,0.0,0.0,0.0,LUGGAGE_NONE,0.0},// 464
		{"RC Raider",VEHICLE_TYPE_RC,VEHICLE_SUBTYPE_RCHELI,0.0,0.0,0.0,0.0,LUGGAGE_NONE,0.0},// 465
		{"Glendale",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_4DOOR,40.0,3.0,1.2,20.0,LUGGAGE_SMALL,15.0},// 466
		{"Oceanic",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_2DOOR,40.0,2.7,1.1,20.0,LUGGAGE_SMALL,20.0},// 467
		{"Sanchez",VEHICLE_TYPE_BIKE,VEHICLE_SUBTYPE_2DOOR,20.0,1.2,0.5,10.0,LUGGAGE_NONE,0.0},// 468
		{"Sparrow",VEHICLE_TYPE_AIR,VEHICLE_SUBTYPE_HELI,90.0,2.4,0.8,30.0,LUGGAGE_NONE,0.0},// 469
		{"Patriot",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_4WD,90.0,2.5,1.2,40.0,LUGGAGE_SMALL,30.0},// 470
		{"Quad",VEHICLE_TYPE_BIKE,VEHICLE_SUBTYPE_QUAD,20.0,0.8,0.6,7.5,LUGGAGE_NONE,0.0},// 471
		{"Coastguard",VEHICLE_TYPE_SEA,VEHICLE_SUBTYPE_BOAT,20.0,4.0,1.2,10.0,LUGGAGE_NONE,0.0},// 472
		{"Dinghy",VEHICLE_TYPE_SEA,VEHICLE_SUBTYPE_BOAT,20.0,0.0,0.0,10.0,LUGGAGE_NONE,0.0},// 473
		{"Hermes",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_2DOOR,40.0,3.0,1.2,15.0,LUGGAGE_SMALL,15.0},// 474
		{"Sabre",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_2DOOR,40.0,2.7,1.1,20.0,LUGGAGE_SMALL,15.0},// 475
		{"Rustler",VEHICLE_TYPE_AIR,VEHICLE_SUBTYPE_PLANE,40.0,3.4,1.1,15.0,LUGGAGE_NONE,0.0},// 476
		{"ZR-350",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_SPORT,40.0,2.7,1.2,25.0,LUGGAGE_SMALL,5.0},// 477
		{"Walton",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_INDUSTRIAL,40.0,2.2,1.1,15.0,LUGGAGE_SMALL,35.0},// 478
		{"Regina",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_4DOOR,45.0,2.5,1.2,25.0,LUGGAGE_SMALL,25.0},// 479
		{"Comet",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_SPORT,40.0,-2.5,1.1,30.0,LUGGAGE_SMALL,10.0},// 480
		{"BMX",VEHICLE_TYPE_BIKE,VEHICLE_SUBTYPE_BIKE,0.0,1.0,0.3,0.0,LUGGAGE_NONE,0.0},// 481
		{"Burrito",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_VAN,45.0,2.5,1.0,20.0,LUGGAGE_SMALL,45.0},// 482
		{"Camper",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_UNIQUE,45.0,2.9,1.0,15.0,LUGGAGE_SMALL,25.0},// 483
		{"Marquis",VEHICLE_TYPE_SEA,VEHICLE_SUBTYPE_BOAT,20.0,0.0,0.0,7.5,LUGGAGE_NONE,0.0},// 484
		{"Baggage",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_UNIQUE,0.0,1.7,1.0,0.0,LUGGAGE_NONE,0.0},// 485
		{"Dozer",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_INDUSTRIAL,30.0,3.2,1.1,30.0,LUGGAGE_NONE,0.0},// 486
		{"Maverick",VEHICLE_TYPE_AIR,VEHICLE_SUBTYPE_HELI,90.0,3.2,1.0,30.0,LUGGAGE_NONE,0.0},// 487
		{"News Chopper",VEHICLE_TYPE_AIR,VEHICLE_SUBTYPE_HELI,90.0,2.7,1.1,30.0,LUGGAGE_NONE,0.0},// 488
		{"Rancher",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_4WD,70.0,2.7,1.2,30.0,LUGGAGE_SMALL,30.0},// 489
		{"FBI Rancher",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_GOVERMENT,70.0,3.2,1.2,35.0,LUGGAGE_SMALL,35.0},// 490
		{"Virgo",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_2DOOR,40.0,3.0,1.1,10.0,LUGGAGE_SMALL,10.0},// 491
		{"Greenwood",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_4DOOR,40.0,2.5,1.1,15.0,LUGGAGE_SMALL,20.0},// 492
		{"Jetmax",VEHICLE_TYPE_SEA,VEHICLE_SUBTYPE_BOAT,20.0,0.0,0.0,10.0,LUGGAGE_NONE,0.0},// 493
		{"Hotring",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_SPORT,40.0,3.2,1.1,40.0,LUGGAGE_SMALL,5.0},// 494
		{"Sandking",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_4WD,45.0,2.5,1.2,50.0,LUGGAGE_SMALL,10.0},// 495
		{"Blista Compact",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_SPORT,40.0,2.4,1.1,20.0,LUGGAGE_SMALL,12.5},// 496
		{"Police Maverick",VEHICLE_TYPE_AIR,VEHICLE_SUBTYPE_HELI,90.0,3.4,1.0,30.0,LUGGAGE_NONE,0.0},// 497
		{"Boxville",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_INDUSTRIAL,50.0,3.0,1.2,20.0,LUGGAGE_BIG,60.0},// 498
		{"Benson",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_INDUSTRIAL,50.0,2.7,1.1,20.0,LUGGAGE_BIG,55.0},// 499
		{"Mesa",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_4WD,40.0,2.0,1.1,30.0,LUGGAGE_SMALL,15.0},// 500
		{"RC Goblin",VEHICLE_TYPE_RC,VEHICLE_SUBTYPE_RCHELI,0.0,0.6,0.3,0.0,LUGGAGE_NONE,0.0},// 501
		{"Hotring Racer",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_SPORT,40.0,3.2,1.1,40.0,LUGGAGE_SMALL,5.0},// 502
		{"Hotring Racer",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_SPORT,40.0,3.2,1.1,40.0,LUGGAGE_SMALL,5.0},// 503
		{"Bloodring Banger",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_SPORT,40.0,2.7,1.2,20.0,LUGGAGE_SMALL,5.0},// 504
		{"Rancher",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_4WD,70.0,2.7,1.2,30.0,LUGGAGE_SMALL,30.0},// 505
		{"Super GT",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_SPORT,40.0,-2.4,1.0,25.0,LUGGAGE_SMALL,12.5},// 506
		{"Elegant",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_4DOOR,40.0,3.2,1.2,17.5,LUGGAGE_SMALL,20.0},// 507
		{"Journey",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_2DOOR,50.0,3.2,1.2,35.0,LUGGAGE_SMALL,45.0},// 508
		{"Bike",VEHICLE_TYPE_BIKE,VEHICLE_SUBTYPE_BIKE,0.0,1.0,0.4,0.0,LUGGAGE_NONE,0.0},// 509
		{"Mountain Bike",VEHICLE_TYPE_BIKE,VEHICLE_SUBTYPE_BIKE,0.0,1.1,0.4,0.0,LUGGAGE_NONE,0.0},// 510
		{"Beagle",VEHICLE_TYPE_AIR,VEHICLE_SUBTYPE_PLANE,90.0,0.0,0.0,25.0,LUGGAGE_NONE,0.0},// 511
		{"Cropdust",VEHICLE_TYPE_AIR,VEHICLE_SUBTYPE_PLANE,90.0,0.0,0.0,30.0,LUGGAGE_NONE,0.0},// 512
		{"Stunt",VEHICLE_TYPE_AIR,VEHICLE_SUBTYPE_PLANE,90.0,0.0,0.0,40.0,LUGGAGE_NONE,0.0},// 513
		{"Tanker",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_INDUSTRIAL,298.0,4.5,1.2,60.0,LUGGAGE_NONE,0.0},// 514
		{"RoadTrain",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_INDUSTRIAL,298.0,4.5,1.2,60.0,LUGGAGE_NONE,0.0},// 515
		{"Nebula",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_4DOOR,40.0,2.9,1.1,20.0,LUGGAGE_SMALL,20.0},// 516
		{"Majestic",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_2DOOR,40.0,3.0,1.2,15.0,LUGGAGE_SMALL,17.5},// 517
		{"Buccaneer",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_2DOOR,40.0,2.9,1.2,20.0,LUGGAGE_SMALL,15.0},// 518
		{"Shamal",VEHICLE_TYPE_AIR,VEHICLE_SUBTYPE_PLANE,400.0,0.0,0.0,80.0,LUGGAGE_NONE,0.0},// 519
		{"Hydra",VEHICLE_TYPE_AIR,VEHICLE_SUBTYPE_PLANE,400.0,0.0,0.0,80.0,LUGGAGE_NONE,0.0},// 520
		{"FCR-900",VEHICLE_TYPE_BIKE,VEHICLE_SUBTYPE_MOTO,30.0,1.1,0.5,15.0,LUGGAGE_NONE,0.0},// 521
		{"NRG-500",VEHICLE_TYPE_BIKE,VEHICLE_SUBTYPE_MOTO,30.0,1.2,0.5,15.0,LUGGAGE_NONE,0.0},// 522
		{"HPV1000",VEHICLE_TYPE_BIKE,VEHICLE_SUBTYPE_GOVERMENT,30.0,1.2,0.4,10.0,LUGGAGE_NONE,0.0},// 523
		{"Cement Truck",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_INDUSTRIAL,50.0,4.0,1.5,20.0,LUGGAGE_NONE,0.0},// 524
		{"Tow Truck",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_UNIQUE,50.0,3.0,1.5,30.0,LUGGAGE_NONE,0.0},// 525
		{"Fortune",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_2DOOR,40.0,2.5,1.1,20.0,LUGGAGE_SMALL,20.0},// 526
		{"Cadrona",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_2DOOR,40.0,2.5,1.1,23.0,LUGGAGE_SMALL,15.0},// 527
		{"FBI Truck",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_GOVERMENT,50.0,2.5,1.2,30.0,LUGGAGE_SMALL,35.0},// 528
		{"Willard",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_4DOOR,40.0,2.5,1.1,15.0,LUGGAGE_SMALL,15.0},// 529
		{"Forklift",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_UNIQUE,20.0,1.2,0.8,5.0,LUGGAGE_NONE,0.0},// 530
		{"Tractor",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_UNIQUE,20.0,1.7,0.6,20.0,LUGGAGE_NONE,0.0},// 531
		{"Combine",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_UNIQUE,60.0,2.2,1.7,20.0,LUGGAGE_NONE,0.0},// 532
		{"Feltzer",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_2DOOR,40.0,2.7,1.1,15.0,LUGGAGE_SMALL,25.0},// 533
		{"Remington",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_LOWRIDER,40.0,2.9,1.1,20.0,LUGGAGE_SMALL,25.0},// 534
		{"Slamvan",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_LOWRIDER,40.0,2.5,1.1,20.0,LUGGAGE_SMALL,35.0},// 535
		{"Blade",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_LOWRIDER,40.0,2.9,1.2,20.0,LUGGAGE_SMALL,25.0},// 536
		{"Freight",VEHICLE_TYPE_TRAIN,VEHICLE_SUBTYPE_CARGO,0.0,0.0,0.0,0.0,LUGGAGE_NONE,0.0},// 537
		{"Streak",VEHICLE_TYPE_TRAIN,VEHICLE_SUBTYPE_PASSANGER,0.0,0.0,0.0,0.0,LUGGAGE_NONE,0.0},// 538
		{"Vortex",VEHICLE_TYPE_HEAVY,VEHICLE_SUBTYPE_UNIQUE,20.0,2.0,1.2,15.0,LUGGAGE_NONE,0.0},// 539
		{"Vincent",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_4DOOR,40.0,2.9,1.2,20.0,LUGGAGE_SMALL,15.0},// 540
		{"Bullet",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_SPORT,40.0,2.4,1.1,30.0,LUGGAGE_SMALL,5.0},// 541
		{"Clover",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_2DOOR,40.0,3.0,1.1,40.0,LUGGAGE_SMALL,10.0},// 542
		{"Sadler",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_INDUSTRIAL,50.0,2.5,1.2,20.0,LUGGAGE_SMALL,30.0},// 543
		{"Firetruck",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_GOVERMENT,70.0,4.0,1.2,25.0,LUGGAGE_NONE,0.0},// 544
		{"Hustler",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_2DOOR,40.0,2.0,1.0,30.0,LUGGAGE_SMALL,10.0},// 545
		{"Intruder",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_4DOOR,40.0,2.7,1.2,20.0,LUGGAGE_SMALL,15.0},// 546
		{"Primo",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_4DOOR,40.0,2.7,1.1,15.0,LUGGAGE_SMALL,15.0},// 547
		{"Cargobob",VEHICLE_TYPE_AIR,VEHICLE_SUBTYPE_HELI,90.0,0.0,0.0,30.0,LUGGAGE_NONE,0.0},// 548
		{"Tampa",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_2DOOR,40.0,2.5,1.1,40.0,LUGGAGE_SMALL,20.0},// 549
		{"Sunrise",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_4DOOR,40.0,2.7,1.2,20.0,LUGGAGE_SMALL,17.5},// 550
		{"Merit",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_4DOOR,40.0,3.0,1.2,25.0,LUGGAGE_SMALL,17.5},// 551
		{"Utility",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_INDUSTRIAL,40.0,3.2,1.2,30.0,LUGGAGE_NONE,0.0},// 552
		{"Nevada",VEHICLE_TYPE_AIR,VEHICLE_SUBTYPE_PLANE,300.0,6.0,1.5,60.0,LUGGAGE_NONE,0.0},// 553
		{"Yosemite",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_4WD,50.0,2.9,1.2,30.0,LUGGAGE_SMALL,30.0},// 554
		{"Windsor",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_2DOOR,40.0,2.4,0.8,20.0,LUGGAGE_SMALL,15.0},// 555
		{"Monster",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_4WD,65.0,2.9,1.2,30.0,LUGGAGE_SMALL,15.0},// 556
		{"Monster",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_4WD,65.0,3.0,1.2,30.0,LUGGAGE_SMALL,15.0},// 557
		{"Uranus",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_SPORT,40.0,2.4,1.1,30.0,LUGGAGE_SMALL,15.0},// 558
		{"Jester",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_SPORT,40.0,2.4,1.2,30.0,LUGGAGE_SMALL,10.0},// 559
		{"Sultan",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_4DOOR,40.0,2.5,1.1,25.0,LUGGAGE_SMALL,20.0},// 560
		{"Stratum",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_4DOOR,40.0,2.7,1.2,20.0,LUGGAGE_SMALL,30.0},// 561
		{"Elegy",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_SPORT,40.0,2.4,1.0,25.0,LUGGAGE_SMALL,20.0},// 562
		{"Raindance",VEHICLE_TYPE_AIR,VEHICLE_SUBTYPE_HELI,90.0,4.5,1.2,30.0,LUGGAGE_NONE,0.0},// 563
		{"RC Tiger",VEHICLE_TYPE_RC,VEHICLE_SUBTYPE_RCCAR,0.0,0.8,0.4,0.0,LUGGAGE_NONE,0.0},// 564
		{"Flash",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_SPORT,40.0,2.2,1.0,20.0,LUGGAGE_SMALL,35.0},// 565
		{"Tahoma",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_LOWRIDER,45.0,3.0,1.2,20.0,LUGGAGE_SMALL,20.0},// 566
		{"Savanna",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_LOWRIDER,45.0,2.9,1.2,20.0,LUGGAGE_SMALL,25.0},// 567
		{"Bandito",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_4WD,20.0,2.2,0.8,15.0,LUGGAGE_NONE,0.0},// 568
		{"Freight",VEHICLE_TYPE_TRAIN,VEHICLE_SUBTYPE_CARGO_T,0.0,0.0,0.0,0.0,LUGGAGE_BIG,500.0},// 569
		{"Trailer",VEHICLE_TYPE_TRAIN,VEHICLE_SUBTYPE_PASSANGER_T,0.0,0.0,0.0,0.0,LUGGAGE_NONE,0.0},// 570
		{"Kart",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_UNIQUE,10.0,1.1,0.6,10.0,LUGGAGE_NONE,0.0},// 571
		{"Mower",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_UNIQUE,20.0,1.1,0.6,10.0,LUGGAGE_NONE,0.0},// 572
		{"Duneride",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_4WD,50.0,3.5,1.2,40.0,LUGGAGE_SMALL,30.0},// 573
		{"Sweeper",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_UNIQUE,20.0,1.7,0.8,5.0,LUGGAGE_NONE,0.0},// 574
		{"Broadway",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_LOWRIDER,40.0,2.9,1.1,20.0,LUGGAGE_SMALL,20.0},// 575
		{"Tornado",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_LOWRIDER,40.0,2.5,1.2,20.0,LUGGAGE_SMALL,20.0},// 576
		{"AT-400",VEHICLE_TYPE_AIR,VEHICLE_SUBTYPE_PLANE,300.0,0.0,0.0,70.0,LUGGAGE_NONE,0.0},// 577
		{"DFT-30",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_INDUSTRIAL,50.0,5.5,1.6,20.0,LUGGAGE_SMALL,80.0},// 578
		{"Huntley",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_4WD,50.0,2.7,1.2,20.0,LUGGAGE_SMALL,35.0},// 579
		{"Stafford",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_4DOOR,40.0,2.9,1.2,15.0,LUGGAGE_SMALL,20.0},// 580
		{"BF-400",VEHICLE_TYPE_BIKE,VEHICLE_SUBTYPE_MOTO,30.0,1.2,0.4,15.0,LUGGAGE_NONE,0.0},// 581
		{"Newsvan",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_VAN,50.0,2.5,1.1,20.0,LUGGAGE_SMALL,30.0},// 582
		{"Tug",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_UNIQUE,20.0,1.6,0.8,10.0,LUGGAGE_NONE,0.0},// 583
		{"Trailer",VEHICLE_TYPE_HEAVY,VEHICLE_SUBTYPE_TRAILER,0.0,4.4,1.3,0.0,LUGGAGE_BIG,100.0},// 584
		{"Emperor",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_4DOOR,40.0,2.9,1.1,25.0,LUGGAGE_SMALL,25.0},// 585
		{"Wayfarer",VEHICLE_TYPE_BIKE,VEHICLE_SUBTYPE_MOTO,30.0,1.3,0.6,10.0,LUGGAGE_NONE,0.0},// 586
		{"Euros",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_SPORT,40.0,2.5,1.2,30.0,LUGGAGE_SMALL,10.0},// 587
		{"Hotdog",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_UNIQUE,50.0,4.0,1.3,20.0,LUGGAGE_SMALL,20.0},// 588
		{"Club",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_SPORT,40.0,2.4,1.0,30.0,LUGGAGE_SMALL,20.0},// 589
		{"Trailer",VEHICLE_TYPE_TRAIN,VEHICLE_SUBTYPE_CARGO_T,0.0,0.0,0.0,0.0,LUGGAGE_BIG,500.0},// 590
		{"Trailer",VEHICLE_TYPE_HEAVY,VEHICLE_SUBTYPE_TRAILER,0.0,3.9,1.5,0.0,LUGGAGE_BIG,100.0},// 591
		{"Andromada",VEHICLE_TYPE_AIR,VEHICLE_SUBTYPE_PLANE,300.0,14.3,2.4,70.0,LUGGAGE_BIG,100.0},// 592
		{"Dodo",VEHICLE_TYPE_AIR,VEHICLE_SUBTYPE_PLANE,200.0,3.4,0.8,60.0,LUGGAGE_NONE,0.0},// 593
		{"RC Cam",VEHICLE_TYPE_RC,VEHICLE_SUBTYPE_RCCAR,0.0,0.0,0.0,0.0,LUGGAGE_NONE,0.0},// 594
		{"Launch",VEHICLE_TYPE_SEA,VEHICLE_SUBTYPE_BOAT,20.0,0.0,0.0,10.0,LUGGAGE_NONE,0.0},// 595
		{"Police Car (LSPD)",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_GOVERMENT,40.0,2.7,1.2,20.0,LUGGAGE_SMALL,20.0},// 596
		{"Police Car (SFPD)",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_GOVERMENT,40.0,2.4,1.2,20.0,LUGGAGE_SMALL,20.0},// 597
		{"Police Car (LVPD)",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_GOVERMENT,40.0,2.7,1.2,20.0,LUGGAGE_SMALL,20.0},// 598
		{"Police Ranger",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_GOVERMENT,50.0,2.7,1.2,30.0,LUGGAGE_SMALL,40.0},// 599
		{"Picador",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_2DOOR,40.0,2.7,1.2,20.0,LUGGAGE_SMALL,20.0},// 600
		{"S.W.A.T. Van",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_GOVERMENT,60.0,3.0,1.3,40.0,LUGGAGE_NONE,0.0},// 601
		{"Alpha",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_SPORT,40.0,2.5,1.1,20.0,LUGGAGE_SMALL,20.0},// 602
		{"Phoenix",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_SPORT,40.0,2.7,1.2,20.0,LUGGAGE_SMALL,20.0},// 603
		{"Glendale",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_UNIQUE,40.0,3.0,1.1,20.0,LUGGAGE_SMALL,20.0},// 604
		{"Sadler",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_UNIQUE,45.0,2.5,1.1,30.0,LUGGAGE_SMALL,30.0},// 605
		{"Luggage Trailer",VEHICLE_TYPE_HEAVY,VEHICLE_SUBTYPE_TRAILER,0.0,0.0,0.0,0.0,LUGGAGE_SMALL,20.0},// 606
		{"Luggage Trailer",VEHICLE_TYPE_HEAVY,VEHICLE_SUBTYPE_TRAILER,0.0,0.0,0.0,0.0,LUGGAGE_SMALL,20.0},// 607
		{"Stair Trailer",VEHICLE_TYPE_HEAVY,VEHICLE_SUBTYPE_TRAILER,0.0,0.0,0.0,0.0,LUGGAGE_SMALL,20.0},// 608
		{"Boxville",VEHICLE_TYPE_CAR,VEHICLE_SUBTYPE_INDUSTRIAL,50.0,3.0,1.2,30.0,LUGGAGE_BIG,70.0},// 609
		{"Farm Plow",VEHICLE_TYPE_HEAVY,VEHICLE_SUBTYPE_TRAILER,0.0,0.0,0.0,0.0,LUGGAGE_NONE,0.0},// 610
		{"Utility Trailer",VEHICLE_TYPE_HEAVY,VEHICLE_SUBTYPE_TRAILER,0.0,0.0,0.0,0.0,LUGGAGE_NONE,0.0}// 611
	};

// --------------------------------------------------
// natives list (for pawno functions list)
// --------------------------------------------------
/*
native CreateModeVehicle(model,Float:posx,Float:posy,Float:posz,Float:angle,color1,color2,key,stype,ssubtype,sid);
native DestroyModeVehicle(vehicleid);
native GetModeVehiclePos(vehicleid,&Float:X,&Float:Y,&Float:Z);
native SetModeVehiclePos(vehicleid,Float:X,Float:Y,Float:Z);
native GetModeVehicleAngle(vehicleid,&Float:A);
native SetModeVehicleAngle(vehicleid,Float:A);
native GetModeVehicleColor(vehicleid,&color1,&color2);
native SetModeVehicleColor(vehicleid,color1,color2);
native GetModeVehicleKeysize(vehicleid);
native SetModeVehicleKeysize(vehicleid,key);
native GetModeVehicleSpeedoInfo(vehicleid,&stype,&ssubtype,&sid);
native SetModeVehicleSpeedoInfo(vehicleid,stype,ssubtype,sid);
native GetModeVehicleDoorStatus(vehicleid);
native SetModeVehicleDoorStatus(vehicleid,status);
native GetModeVehicleRadioStation(vehicleid);
native SetModeVehicleRadioStation(vehicleid,requency);
native Float:GetModeVehicleFuel(vehicleid);
native SetModeVehicleFuel(vehicleid,Float:fuel);
native bool:GetModeVehicleEngineState(vehicleid);
native SetModeVehicleEngineState(vehicleid,bool:state);
native Float:GetModeVehicleMaxLuggage(vehicleid);
native GetModeVehicleLuggageType(vehicleid);
native GetPlayerClosestModeVehicle(playerid);
native IsPlayerAroundLuggageModeVehicl(playerid,vehicleid);
native IsPlayerAroundDoorModeVehicle(playerid,vehicleid);
native GetModeVehicleType(model);
native GetModeVehicleSubType(model);
native GetModeVehiclesCount();
native bool:IsModeVehicleActive(vehicleid);
native Float:GetModeVehicleMaxFuel(model);
*/

// --------------------------------------------------
// stocks
// --------------------------------------------------
stock CreateModeVehicle(model,Float:posx,Float:posy,Float:posz,Float:angle,color1,color2,key,stype,ssubtype,sid)
{
	Debug(DEBUG_START,"CreateModeVehicle(%d,%f,%f,%f,%f,%d,%d,%d,%d)",model,posx,posy,posz,angle,color1,color2,key,speedometer);
	if(color1 == -1) color1 = random(128);
	if(color2 == -1) color2 = random(128);
	Debug(DEBUG_ACTION,"create vehicle");
	new vehicleid = CreateVehicle(model,posx,posy,posz,angle,color1,color2,NEVER);
	Debug(DEBUG_ACTION,"vehicle id = %d",vehicleid);
	if(vehicleid == INVALID_VEHICLE_ID)
	{
		Debug(DEBUG_END,"CreateModeVehicle(reason: error)");
		print("[WARNING] Mode vehicles -> CreateModeVehicle (all slots used)");
		return INVALID_MODE_VEHICLE_ID;
	}
	Debug(DEBUG_ACTION,"set data");
	ModeVehicles[vehicleid][vActive] = true;
	ModeVehicles[vehicleid][vFuel] = Vehicles[model - 400][vMaxFuel];
	ModeVehicles[vehicleid][vSpeedoType] = stype;
	ModeVehicles[vehicleid][vSpeedoSubtype] = ssubtype;
	ModeVehicles[vehicleid][vSpeedoId] = sid;
	ModeVehicles[vehicleid][vEngineState] = false;
	Debug(DEBUG_ACTION,"add in base");
	new bid = MySQL_GetMinimalFreeSlot("id","Vehicles") + 1;
	switch(Vehicles[model - 400][vSubtype])
	{
		case 
			VEHICLE_SUBTYPE_UNIQUE,
			VEHICLE_SUBTYPE_TRAILER,
			VEHICLE_SUBTYPE_RCCAR,
			VEHICLE_SUBTYPE_RCBIKE,
			VEHICLE_SUBTYPE_RCPLANE,
			VEHICLE_SUBTYPE_RCHELI,
			VEHICLE_SUBTYPE_MOPED,
			VEHICLE_SUBTYPE_MOTO,
			VEHICLE_SUBTYPE_BIKE,
			VEHICLE_SUBTYPE_QUAD,
			VEHICLE_SUBTYPE_CARGO_T,
			VEHICLE_SUBTYPE_PASSANGER_T: format(query,sizeof(query),"INSERT INTO `Vehicles` (`id`,`Model`,`X`,`Y`,`Z`,`Angle`,`Color1`,`Color2`,`Key`,`Fuel`,`SpeedoType`,`SpeedoSubType`,`SpeedoId`,`Health`) VALUES (%d,%d,%f,%f,%f,%f,%d,%d,%d,%f,%d,%d,%d,1000.0)",bid,model,posx,posy,posz,angle,color1,color2,key,Vehicles[model - 400][vMaxFuel],stype,ssubtype,sid);
		default: format(query,sizeof(query),"INSERT INTO `Vehicles` (`id`,`Model`,`X`,`Y`,`Z`,`Angle`,`Color1`,`Color2`,`Key`,`Fuel`,`SpeedoType`,`SpeedoSubType`,`SpeedoId`,`Health`,`Door`) VALUES (%d,%d,%f,%f,%f,%f,%d,%d,%d,%f,%d,%d,%d,1000.0,0)",bid,model,posx,posy,posz,angle,color1,color2,key,Vehicles[model - 400][vMaxFuel],stype,ssubtype,sid);
	}
	samp_mysql_query(query);
	SetModePropertyInt(MODE_PROPERTY_VEHICLES_BID,vehicleid,0,bid);
	if(ModeVehiclesCounter < vehicleid) ModeVehiclesCounter = vehicleid;
	Debug(DEBUG_END,"CreateModeVehicle(reason: complete)");
	return vehicleid;
}

stock DestroyModeVehicle(vehicleid)
{
	Debug(DEBUG_START,"DestroyModeVehicle(%d)",vehicleid);
	if(ModeVehicles[vehicleid][vActive] == false)
	{
		Debug(DEBUG_END,"DestroyModeVehicle(reason: error)");
		printf("[WARNING] Mode vehicles -> DestroyModeVehicle (vehicle not created, id = %d)",vehicleid);
		return 0;
	}
	Debug(DEBUG_ACTION,"destroy vehicle");
	DestroyVehicle(vehicleid);
	Debug(DEBUG_ACTION,"reset data");
	ModeVehicles[vehicleid][vActive] = false;
	ModeVehicles[vehicleid][vFuel] = 0.0;
	ModeVehicles[vehicleid][vSpeedoType] = 0;
	ModeVehicles[vehicleid][vSpeedoSubtype] = 0;
	ModeVehicles[vehicleid][vSpeedoId] = 0;
	ModeVehicles[vehicleid][vEngineState] = false;
	Debug(DEBUG_ACTION,"update base");
	format(query,sizeof(query),"DELETE FROM `Vehicles` WHERE `id`=%d",GetModePropertyInt(MODE_PROPERTY_VEHICLES_BID,vehicleid,0));
	samp_mysql_query(query);
	DeleteModeProperty(MODE_PROPERTY_VEHICLES_BID,vehicleid,0);
	if(ModeVehiclesCounter == vehicleid) 
	{
		do ModeVehiclesCounter--;
		while(!ModeVehicles[ModeVehiclesCounter][vActive]);
	}
	Debug(DEBUG_END,"DestroyModeVehicle(reason: complete)");
	return 1;
}

stock GetModeVehiclePos(vehicleid,&Float:X,&Float:Y,&Float:Z)
{
	Debug(DEBUG_START,"GetModeVehiclePos(%d)",vehicleid);
	if(ModeVehicles[vehicleid][vActive] == false)
	{
		Debug(DEBUG_END,"GetModeVehiclePos(reason: error)");
		printf("[WARNING] Mode vehicles -> GetModeVehiclePos (vehicle not created, id = %d)",vehicleid);
		return 0;
	}
	GetVehiclePos(vehicleid,X,Y,Z);
	Debug(DEBUG_END,"GetModeVehiclePos(reason: complete)");
	return 1;
}

stock SetModeVehiclePos(vehicleid,Float:X,Float:Y,Float:Z)
{
	Debug(DEBUG_START,"SetModeVehiclePos(%d,%f,%f,%f)",vehicleid,X,Y,Z);
	if(ModeVehicles[vehicleid][vActive] == false)
	{
		Debug(DEBUG_END,"SetModeVehiclePos(reason: error)");
		printf("[WARNING] Mode vehicles -> SetModeVehiclePos (vehicle not created, id = %d)",vehicleid);
		return 0;
	}
	SetVehiclePos(vehicleid,X,Y,Z);
	Debug(DEBUG_ACTION,"update base");
	format(query,sizeof(query),"UPDATE `Vehicles` (`X`,`Y`,`Z`) VALUES (%f,%f,%f) WHERE `id`=%d",X,Y,Z,GetModePropertyInt(MODE_PROPERTY_VEHICLES_BID,vehicleid,0));
	samp_mysql_query(query);
	Debug(DEBUG_END,"SetModeVehiclePos(reason: complete)");
	return 1;
}

stock GetModeVehicleAngle(vehicleid,&Float:A)
{
	Debug(DEBUG_START,"GetModeVehicleAngle(%d)",vehicleid);
	if(ModeVehicles[vehicleid][vActive] == false)
	{
		Debug(DEBUG_END,"GetModeVehicleAngle(reason: error)");
		printf("[WARNING] Mode vehicles -> GetModeVehicleAngle (vehicle not created, id = %d)",vehicleid);
		return 0;
	}
	GetVehicleZAngle(vehicleid,A);
	Debug(DEBUG_END,"GetModeVehicleAngle(reason: complete)");
	return 1;
}

stock SetModeVehicleAngle(vehicleid,Float:A)
{
	Debug(DEBUG_START,"SetModeVehicleAngle(%d,%f)",vehicleid,A);
	if(ModeVehicles[vehicleid][vActive] == false)
	{
		Debug(DEBUG_END,"SetModeVehicleAngle(reason: error)");
		printf("[WARNING] Mode vehicles -> SetModeVehicleAngle (vehicle not created, id = %d)",vehicleid);
		return 0;
	}
	SetVehicleZAngle(vehicleid,A);
	Debug(DEBUG_ACTION,"update base");
	format(query,sizeof(query),"UPDATE `Vehicles` (`Angle`) VALUES (%f) WHERE `id`=%d",A,GetModePropertyInt(MODE_PROPERTY_VEHICLES_BID,vehicleid,0));
	samp_mysql_query(query);
	Debug(DEBUG_END,"SetModeVehicleAngle(reason: complete)");
	return 1;
}

stock GetModeVehicleColor(vehicleid,&color1,&color2)
{
	Debug(DEBUG_START,"GetModeVehicleColor(%d)",vehicleid);
	if(ModeVehicles[vehicleid][vActive] == false)
	{
		Debug(DEBUG_END,"GetModeVehicleColor(reason: error)");
		printf("[WARNING] Mode vehicles -> GetModeVehicleColor (vehicle not created, id = %d)",vehicleid);
		return 0;
	}
	Debug(DEBUG_ACTION,"select query");
	format(query,sizeof(query),"SELECT `Color1`,`Color2` FROM `Vehicles` WHERE `id`=%d",GetModePropertyInt(MODE_PROPERTY_VEHICLES_BID,vehicleid,0));
	samp_mysql_query(query);
	samp_mysql_store_result();
	samp_mysql_fetch_row(result);
	Debug(DEBUG_ACTION,"get colors from result");
	new tmp[11];
	samp_mysql_get_field("Color1",tmp);
	color1 = strval(tmp);
	samp_mysql_get_field("Color2",tmp);
	color2 = strval(tmp);
	Debug(DEBUG_END,"GetModeVehicleColor(reason: complete)");
	return 1;
}

stock SetModeVehicleColor(vehicleid,color1,color2)
{
	Debug(DEBUG_START,"SetModeVehicleColor(%d,%d,%d)",vehicleid,color1,color2);
	if(ModeVehicles[vehicleid][vActive] == false)
	{
		Debug(DEBUG_END,"SetModeVehicleColor(reason: error)");
		printf("[WARNING] Mode vehicles -> SetModeVehicleColor (vehicle not created, id = %d)",vehicleid);
		return 0;
	}
	ChangeVehicleColor(vehicleid,color1,color2);
	Debug(DEBUG_ACTION,"update base");
	format(query,sizeof(query),"UPDATE `Vehicles` (`Color1`,`Color2`) VALUES (%d,%d) WHERE `id`=%d",color1,color2,GetModePropertyInt(MODE_PROPERTY_VEHICLES_BID,vehicleid,0));
	samp_mysql_query(query);
	Debug(DEBUG_END,"SetModeVehicleColor(reason: complete)");
	return 1;
}

stock GetModeVehicleKeysize(vehicleid)
{
	Debug(DEBUG_START,"GetModeVehicleKeysize(%d)",vehicleid);
	if(ModeVehicles[vehicleid][vActive] == false)
	{
		Debug(DEBUG_END,"GetModeVehicleKeysize(reason: error)");
		printf("[WARNING] Mode vehicles -> GetModeVehicleKeysize (vehicle not created, id = %d)",vehicleid);
		return 0;
	}
	Debug(DEBUG_ACTION,"select query");
	format(query,sizeof(query),"SELECT `Key` FROM `Vehicles` WHERE `id`=%d",GetModePropertyInt(MODE_PROPERTY_VEHICLES_BID,vehicleid,0));
	samp_mysql_query(query);
	samp_mysql_store_result();
	samp_mysql_fetch_row(result);
	Debug(DEBUG_END,"GetModeVehicleKeysize(reason: complete)");
	return strval(result);
}

stock SetModeVehicleKeysize(vehicleid,key)
{
	Debug(DEBUG_START,"SetModeVehicleKeysize(%d,%d)",vehicleid,key);
	if(ModeVehicles[vehicleid][vActive] == false)
	{
		Debug(DEBUG_END,"SetModeVehicleKeysize(reason: error)");
		printf("[WARNING] Mode vehicles -> SetModeVehicleKeysize (vehicle not created, id = %d)",vehicleid);
		return 0;
	}
	Debug(DEBUG_ACTION,"update base");
	format(query,sizeof(query),"UPDATE `Vehicles` (`Key`) VALUES (%d) WHERE `id`=%d",key,GetModePropertyInt(MODE_PROPERTY_VEHICLES_BID,vehicleid,0));
	samp_mysql_query(query);
	Debug(DEBUG_END,"SetModeVehicleKeysize(reason: complete)");
	return 1;
}

stock GetModeVehicleSpeedoInfo(vehicleid,&stype,&ssubtype,&sid)
{
	Debug(DEBUG_START,"GetModeVehicleSpeedoInfo(%d)",vehicleid);
	if(ModeVehicles[vehicleid][vActive] == false)
	{
		Debug(DEBUG_END,"GetModeVehicleSpeedoInfo(reason: error)");
		printf("[WARNING] Mode vehicles -> GetModeVehicleSpeedoInfo (vehicle not created, id = %d)",vehicleid);
		return 0;
	}
	Debug(DEBUG_ACTION,"write data");
	stype = ModeVehicles[vehicleid][vSpeedoType];
	ssubtype = ModeVehicles[vehicleid][vSpeedoSubtype];
	sid = ModeVehicles[vehicleid][vSpeedoId];
	Debug(DEBUG_END,"GetModeVehicleSpeedoInfo(reason: complete)");
	return 1;
}

stock SetModeVehicleSpeedoInfo(vehicleid,stype,ssubtype,sid)
{
	Debug(DEBUG_START,"SetModeVehicleSpeedoInfo(%d,%d,%d,%d)",vehicleid,stype,ssubtype,sid);
	if(ModeVehicles[vehicleid][vActive] == false)
	{
		Debug(DEBUG_END,"SetModeVehicleSpeedoInfo(reason: error)");
		printf("[WARNING] Mode vehicles -> SetModeVehicleSpeedoInfo (vehicle not created, id = %d)",vehicleid);
		return 0;
	}
	Debug(DEBUG_ACTION,"write data");
	ModeVehicles[vehicleid][vSpeedoType] = stype;
	ModeVehicles[vehicleid][vSpeedoSubtype] = ssubtype;
	ModeVehicles[vehicleid][vSpeedoId] = sid;
	Debug(DEBUG_ACTION,"update base");
	format(query,sizeof(query),"UPDATE `Vehicles` (`SpeedoType`,`SpeedoSubType`,`SpeedoId`) VALUES (%d,%d,%d) WHERE `id`=%d",stype,ssubtype,sid,GetModePropertyInt(MODE_PROPERTY_VEHICLES_BID,vehicleid,0));
	samp_mysql_query(query);
	Debug(DEBUG_END,"SetModeVehicleSpeedoInfo(reason: complete)");
	return 1;
}

stock GetModeVehicleDoorStatus(vehicleid)
{
	Debug(DEBUG_START,"GetModeVehicleDoorStatus(%d)",vehicleid);
	if(ModeVehicles[vehicleid][vActive] == false)
	{
		Debug(DEBUG_END,"GetModeVehicleDoorStatus(reason: error)");
		printf("[WARNING] Mode vehicles -> GetModeVehicleDoorStatus (vehicle not created, id = %d)",vehicleid);
		return 0;
	}
	Debug(DEBUG_ACTION,"select query");
	format(query,sizeof(query),"SELECT `Door` FROM `Vehicles` WHERE `id`=%d",GetModePropertyInt(MODE_PROPERTY_VEHICLES_BID,vehicleid,0));
	samp_mysql_query(query);
	samp_mysql_store_result();
	samp_mysql_fetch_row(result);
	Debug(DEBUG_END,"GetModeVehicleDoorStatus(reason: complete)");
	return strval(result);
}

stock SetModeVehicleDoorStatus(vehicleid,status)
{
	Debug(DEBUG_START,"SetModeVehicleDoorStatus(%d,%d)",vehicleid,status);
	if(ModeVehicles[vehicleid][vActive] == false)
	{
		Debug(DEBUG_END,"SetModeVehicleDoorStatus(reason: error)");
		printf("[WARNING] Mode vehicles -> SetModeVehicleDoorStatus (vehicle not created, id = %d)",vehicleid);
		return 0;
	}
	Debug(DEBUG_ACTION,"update base");
	format(query,sizeof(query),"UPDATE `Vehicles` (`Door`) VALUES (%d) WHERE `id`=%d",status,GetModePropertyInt(MODE_PROPERTY_VEHICLES_BID,vehicleid,0));
	samp_mysql_query(query);
	Debug(DEBUG_END,"SetModeVehicleDoorStatus(reason: complete)");
	return 1;
}

stock GetModeVehicleRadioStation(vehicleid)
{
	Debug(DEBUG_START,"GetModeVehicleRadioStation(%d)",vehicleid);
	if(ModeVehicles[vehicleid][vActive] == false)
	{
		Debug(DEBUG_END,"GetModeVehicleRadioStation(reason: error)");
		printf("[WARNING] Mode vehicles -> GetModeVehicleRadioStation (vehicle not created, id = %d)",vehicleid);
		return 0;
	}
	Debug(DEBUG_ACTION,"select query");
	format(query,sizeof(query),"SELECT `Radio` FROM `Vehicles` WHERE `id`=%d",GetModePropertyInt(MODE_PROPERTY_VEHICLES_BID,vehicleid,0));
	samp_mysql_query(query);
	samp_mysql_store_result();
	samp_mysql_fetch_row(result);
	Debug(DEBUG_END,"GetModeVehicleRadioStation(reason: complete)");
	return strval(result);
}

stock SetModeVehicleRadioStation(vehicleid,requency)
{
	Debug(DEBUG_START,"SetModeVehicleRadioStation(%d,%d)",vehicleid,requency);
	if(ModeVehicles[vehicleid][vActive] == false)
	{
		Debug(DEBUG_END,"SetModeVehicleRadioStation(reason: error)");
		printf("[WARNING] Mode vehicles -> SetModeVehicleRadioStation (vehicle not created, id = %d)",vehicleid);
		return 0;
	}
	Debug(DEBUG_ACTION,"select query");
	format(query,sizeof(query),"UPDATE `Vehicles` SET `Radio`=%d WHERE `id`=%d",requency,GetModePropertyInt(MODE_PROPERTY_VEHICLES_BID,vehicleid,0));
	samp_mysql_query(query);
	samp_mysql_store_result();
	samp_mysql_fetch_row(result);
	Debug(DEBUG_END,"SetModeVehicleRadioStation(reason: complete)");
	return 1;
}

stock Float:GetModeVehicleFuel(vehicleid)
{
	Debug(DEBUG_START,"GetModeVehicleFuel(%d)",vehicleid);
	if(ModeVehicles[vehicleid][vActive] == false)
	{
		Debug(DEBUG_END,"GetModeVehicleFuel(reason: error)");
		printf("[WARNING] Mode vehicles -> GetModeVehicleFuel (vehicle not created, id = %d)",vehicleid);
		return 0;
	}
	Debug(DEBUG_END,"GetModeVehicleFuel(reason: complete)");
	return ModeVehicles[vehicleid][vFuel];
}

stock SetModeVehicleFuel(vehicleid,Float:fuel)
{
	Debug(DEBUG_START,"SetModeVehicleFuel(%d,%f)",vehicleid,fuel);
	if(ModeVehicles[vehicleid][vActive] == false)
	{
		Debug(DEBUG_END,"SetModeVehicleFuel(reason: error)");
		printf("[WARNING] Mode vehicles -> SetModeVehicleFuel (vehicle not created, id = %d)",vehicleid);
		return 0;
	}
	if(fuel > Vehicles[GetVehicleModel(vehicleid) - 400][vMaxFuel])
	{
		Debug(DEBUG_END,"SetModeVehicleFuel(reason: error)");
		printf("[WARNING] Mode vehicles -> SetModeVehicleFuel (invalid fuel amount for vehicle %d(max = %f) ,try fuel = %f)",vehicleid,Vehicles[GetVehicleModel(vehicleid) - 400][vMaxFuel],fuel);
		return 0;
	}
	Debug(DEBUG_ACTION,"set data");
	ModeVehicles[vehicleid][vFuel] = fuel;
	format(query,sizeof(query),"UPDATE `Vehicles` (`Fuel`) VALUES (%f) WHERE `id`=%d",ModeVehicles[vehicleid][vFuel],GetModePropertyInt(MODE_PROPERTY_VEHICLES_BID,vehicleid,0));
	samp_mysql_query(query);
	Debug(DEBUG_END,"SetModeVehicleFuel(reason: complete)");
	return 1;
}

stock bool:GetModeVehicleEngineState(vehicleid)
{
	Debug(DEBUG_START,"GetModeVehicleEngineState(%d)",vehicleid);
	if(ModeVehicles[vehicleid][vActive] == false)
	{
		Debug(DEBUG_END,"GetModeVehicleEngineState(reason: error)");
		printf("[WARNING] Mode vehicles -> GetModeVehicleEngineState (vehicle not created, id = %d)",vehicleid);
		return 0;
	}
	Debug(DEBUG_END,"GetModeVehicleEngineState(reason: complete)");
	return ModeVehicles[vehicleid][vEngineState];
}

stock SetModeVehicleEngineState(vehicleid,bool:state)
{
	Debug(DEBUG_START,"SetModeVehicleEngineState(%d,%b)",vehicleid,state);
	if(ModeVehicles[vehicleid][vActive] == false)
	{
		Debug(DEBUG_END,"SetModeVehicleEngineState(reason: error)");
		printf("[WARNING] Mode vehicles -> SetModeVehicleEngineState (vehicle not created, id = %d)",vehicleid);
		return 0;
	}
	ModeVehicles[vehicleid][vEngineState] = state;
	Debug(DEBUG_END,"SetModeVehicleEngineState(reason: complete)");
	return 1;
}

stock Float:GetModeVehicleMaxLuggage(vehicleid)
{
	Debug(DEBUG_START,"GetModeVehicleMaxLuggage(%d)",vehicleid);
	if(ModeVehicles[vehicleid][vActive] == false)
	{
		Debug(DEBUG_END,"GetModeVehicleMaxLuggage(reason: error)");
		printf("[WARNING] Mode vehicles -> GetModeVehicleMaxLuggage (vehicle not created, id = %d)",vehicleid);
		return 0.0;
	}
	Debug(DEBUG_END,"GetModeVehicleMaxLuggage(reason: complete)");
	return ModeVehicles[vehicleid][vMaxLuggage];
}

stock GetModeVehicleLuggageType(vehicleid)
{
	Debug(DEBUG_START,"GetModeVehicleLuggageType(%d)",vehicleid);
	if(ModeVehicles[vehicleid][vActive] == false)
	{
		Debug(DEBUG_END,"GetModeVehicleLuggageType(reason: error)");
		printf("[WARNING] Mode vehicles -> GetModeVehicleLuggageType (vehicle not created, id = %d)",vehicleid);
		return 0;
	}
	Debug(DEBUG_END,"GetModeVehicleLuggageType(reason: complete)");
	return ModeVehicles[vehicleid][vLuggageType];
}

stock GetPlayerClosestModeVehicle(playerid)
{
	Debug(DEBUG_START,"GetPlayerClosestModeVehicle(%d)",playerid);
	if(!IsPlayerConnected(playerid))
	{
		Debug(DEBUG_END,"GetPlayerClosestModeVehicle(reason: error)");
		printf("[ERROR] Mode vehicles -> GetPlayerClosestModeVehicle (invalid player - %d)",playerid);
		return INVALID_MODE_VEHICLE_ID;
	}
	new vehicleid = INVALID_MODE_VEHICLE_ID,
		Float:distance = 69000.0,
		Float:tmp[7];
	GetPlayerPos(playerid,tmp[0],tmp[1],tmp[2]);
	for(new i = 0;i < MAX_VEHICLES;i++)
	{
		if(!ModeVehicles[i][vActive]) continue;
		if(!IsVehicleStreamedIn(i,playerid)) continue;
		GetVehiclePos(i,tmp[3],tmp[4],tmp[5]);
		tmp[6] = GetDistanceBetweenCoords(tmp[0],tmp[1],tmp[2],tmp[3],tmp[4],tmp[5]);
		if(distance < tmp[6]) continue;
		distance = tmp[6];
		vehicleid = i;
	}
	Debug(DEBUG_END,"GetPlayerClosestModeVehicle(reason: complete)");
	return vehicleid;
}

stock IsPlayerAroundLuggageModeVehicl(playerid,vehicleid)
{
	Debug(DEBUG_START,"IsPlayerAroundLuggageModeVehicl(%d)",playerid);
	if(!IsPlayerConnected(playerid))
	{
		Debug(DEBUG_END,"IsPlayerAroundLuggageModeVehicl(reason: error)");
		printf("[ERROR] Mode vehicles -> IsPlayerAroundLuggageModeVehicl (invalid player - %d)",playerid);
		return 0;
	}
	if(ModeVehicles[vehicleid][vActive] == false)
	{
		Debug(DEBUG_END,"IsPlayerAroundLuggageModeVehicl(reason: error)");
		printf("[WARNING] Mode vehicles -> IsPlayerAroundLuggageModeVehicl (vehicle not created, id = %d)",vehicleid);
		return 0;
	}
	new Float:tmp[4];
	GetVehiclePos(vehicleid,tmp[0],tmp[1],tmp[2]);
	GetVehicleZAngle(vehicleid,tmp[3]);
	new model_ex = GetVehicleModel(vehicleid) - 400;
	MoveCoordsOnAngleByDistance(tmp[0],tmp[1],tmp[3],-Vehicles[model_ex][vLenght]);
	Debug(DEBUG_END,"IsPlayerAroundLuggageModeVehicl(reason: complete)");
	return IsPlayerInRangeOfPoint(playerid,MODE_VEHICLES_LUGGAGE_RANGE,tmp[0],tmp[1],tmp[2]);
}

stock IsPlayerAroundDoorModeVehicle(playerid,vehicleid)
{
	Debug(DEBUG_START,"IsPlayerAroundDoorModeVehicle(%d)",playerid);
	if(!IsPlayerConnected(playerid))
	{
		Debug(DEBUG_END,"IsPlayerAroundDoorModeVehicle(reason: error)");
		printf("[ERROR] Mode vehicles -> IsPlayerAroundDoorModeVehicle (invalid player - %d)",playerid);
		return 0;
	}
	if(ModeVehicles[vehicleid][vActive] == false)
	{
		Debug(DEBUG_END,"IsPlayerAroundDoorModeVehicle(reason: error)");
		printf("[WARNING] Mode vehicles -> IsPlayerAroundDoorModeVehicle (vehicle not created, id = %d)",vehicleid);
		return 0;
	}
	new Float:tmp[4];
	GetVehiclePos(vehicleid,tmp[0],tmp[1],tmp[2]);
	GetVehicleZAngle(vehicleid,tmp[3]);
	new model_ex = GetVehicleModel(vehicleid) - 400;
	tmp[3] -= 90.0;
	MoveCoordsOnAngleByDistance(tmp[0],tmp[1],tmp[3],-Vehicles[model_ex][vWidth]);
	if(IsPlayerInRangeOfPoint(playerid,MODE_VEHICLES_DOOR_RANGE,tmp[0],tmp[1],tmp[2]))
	{
		Debug(DEBUG_END,"IsPlayerAroundDoorModeVehicle(reason: complete)");
		return 1;
	}
	MoveCoordsOnAngleByDistance(tmp[0],tmp[1],tmp[3],(Vehicles[model_ex][vWidth]*2));
	if(IsPlayerInRangeOfPoint(playerid,MODE_VEHICLES_DOOR_RANGE,tmp[0],tmp[1],tmp[2]))
	{
		Debug(DEBUG_END,"IsPlayerAroundDoorModeVehicle(reason: complete)");
		return 1;
	}
	Debug(DEBUG_END,"IsPlayerAroundDoorModeVehicle(reason: complete)");
	return 0;
}

stock GetModeVehicleType(model)
{
	return Vehicles[model - 400][vType];
}

stock GetModeVehicleSubType(model)
{
	return Vehicles[model - 400][vSubtype];
}

stock bool:IsModeVehicleActive(vehicleid)
{
	return ModeVehicles[vehicleid][vActive];
}

stock Float:GetModeVehicleMaxFuel(model)
{
	return Vehicles[model - 400][vMaxFuel];	
}

// --------------------------------------------------
// Obligatory functions
// --------------------------------------------------
ModeVehicles_OnGameModeInit()
{
	Debug(DEBUG_START,"ModeVehicles_OnGameModeInit()");
	SpeedometerAnalogLoad();
	SpeedometerElectroLoad();
	Debug(DEBUG_ACTION,"load vehicles from base");
	new baseid,
		vehicleid,
		model,
		Float:X,
		Float:Y,
		Float:Z,
		Float:A,
		color[2],
		tmp[5];
	samp_mysql_query("SELECT * FROM `Vehicles`");
	samp_mysql_store_result();
	while(samp_mysql_fetch_row(result))
	{
		samp_mysql_get_field("id",tmp);
		baseid = strval(tmp);
		samp_mysql_get_field("Model",tmp);
		model = strval(tmp);
		samp_mysql_get_field("X",tmp);
		X = floatstr(tmp);
		samp_mysql_get_field("Y",tmp);
		Y = floatstr(tmp);
		samp_mysql_get_field("Z",tmp);
		Z = floatstr(tmp);
		samp_mysql_get_field("Angle",tmp);
		A = floatstr(tmp);
		samp_mysql_get_field("Color1",tmp);
		color[0] = strval(tmp);
		samp_mysql_get_field("Color2",tmp);
		color[1] = strval(tmp);
		
		vehicleid = CreateVehicle(model,X,Y,Z,A,color[0],color[1],NEVER);
		ModeVehicles[vehicleid][vActive] = true;
		samp_mysql_get_field("Fuel",tmp);
		ModeVehicles[vehicleid][vFuel] = floatstr(tmp);
		samp_mysql_get_field("SpeedoType",tmp);
		ModeVehicles[vehicleid][vSpeedoType] = strval(tmp);
		samp_mysql_get_field("SpeedoSubType",tmp);
		ModeVehicles[vehicleid][vSpeedoSubtype] = strval(tmp);
		samp_mysql_get_field("SpeedoId",tmp);
		ModeVehicles[vehicleid][vSpeedoId] = strval(tmp);
		for(new i = 0;i <= 13;i++)
		{
			format(tmp,sizeof(tmp),"Mod_%d",i);
			samp_mysql_get_field("Color1",tmp);
			AddVehicleComponent(vehicleid,strval(tmp));
		}
		samp_mysql_get_field("PaintJob",tmp);
		ChangeVehiclePaintjob(vehicleid,strval(tmp));
		SetModePropertyInt(MODE_PROPERTY_VEHICLES_BID,vehicleid,0,baseid);
		Debug(DEBUG_ACTION,"Created vehicle: %d,%d,%f,%f,%f,%f,%d,%d,%f,%d,%d,%d",baseid,model,X,Y,Z,A,color[0],color[1],ModeVehicles[vehicleid][vFuel],ModeVehicles[vehicleid][vSpeedoType],ModeVehicles[vehicleid][vSpeedoSubType],ModeVehicles[vehicleid][vSpeedoId]);
	}
	print("Mode vehicles system loaded.");
	Debug(DEBUG_END,"ModeVehicles_OnGameModeInit(reason: complete)");
}

ModeVehicles_OnVehicleMod(vehicleid,componentid)
{
	Debug(DEBUG_START,"ModeVehicles_OnVehicleMod(%d,%d)",vehicleid,componentid);
	format(query,sizeof(query),"UPDATE `Vehicles` SET (`Mod_%d`) VALUES (%d) WHERE `id`=%d",GetVehicleComponentType(componentid),componentid,GetModePropertyInt(MODE_PROPERTY_VEHICLES_BID,vehicleid,0));
	samp_mysql_query(query);
	Debug(DEBUG_END,"ModeVehicles_OnVehicleMod(reason: complete)");
}

ModeVehicles_OnVehiclePaintjob(vehicleid,paintjobid)
{
	Debug(DEBUG_START,"ModeVehicles_OnVehiclePaintjob(%d,%d)",vehicleid,paintjobid);
	format(query,sizeof(query),"UPDATE `Vehicles` SET (`PaintJob`) VALUES (%d) WHERE `id`=%d",paintjobid,GetModePropertyInt(MODE_PROPERTY_VEHICLES_BID,vehicleid,0));
	samp_mysql_query(query);
	Debug(DEBUG_END,"ModeVehicles_OnVehiclePaintjob(reason: complete)");
}

ModeVehicles_OnVehicleRespray(vehicleid,color1,color2)
{
	Debug(DEBUG_START,"ModeVehicles_OnVehicleRespray(%d,%d,%d)",vehicleid,color1,color2);
	format(query,sizeof(query),"UPDATE `Vehicles` (`Color1`,`Color2`) VALUES (%d,%d) WHERE `id`=%d",color1,color2,GetModePropertyInt(MODE_PROPERTY_VEHICLES_BID,vehicleid,0));
	samp_mysql_query(query);
	Debug(DEBUG_END,"ModeVehicles_OnVehicleRespray(reason: complete)");
}

ModeVehicles_OnVehicleSpawn(vehicleid)
{
	Debug(DEBUG_START,"ModeVehicles_OnVehicleSpawn(%d)",vehicleid);
	DestroyModeVehicle(vehicleid);
	Debug(DEBUG_END,"ModeVehicles_OnVehicleSpawn(reason: complete)");
}

ModeVehicles_OnVehicleStreamIn(vehicleid,forplayerid)
{
	Debug(DEBUG_START,"ModeVehicles_OnVehicleStreamIn(%d,%d)",vehicleid,forplayerid);
	if(GetModeVehicleDoorStatus(vehicleid) == 0) SetVehicleParamsForPlayer(vehicleid,forplayerid,0,0);
	else SetVehicleParamsForPlayer(vehicleid,forplayerid,0,1);
	Debug(DEBUG_END,"ModeVehicles_OnVehicleStreamIn(reason: complete)");
}

ModeVehicles_OnPlayerStateChang(playerid,newstate,oldstate)
{
	Debug(DEBUG_START,"ModeVehicles_OnPlayerStateChang(%d,%d,%d)",playerid,newstate,oldstate);
	if(newstate == PLAYER_STATE_DRIVER)
	{
		new vehicleid = GetPlayerVehicleID(playerid);
		switch(ModeVehicles[vehicleid][vSpeedoType])
		{
			case SPEEDOMETER_ANALOG: SpeedometerAnalogShow(playerid,ModeVehicles[vehicleid][vSpeedoSubtype],ModeVehicles[vehicleid][vSpeedoId]);
			case SPEEDOMETER_ELECTRO: SpeedometerElectroShow(playerid,ModeVehicles[vehicleid][vSpeedoSubtype],ModeVehicles[vehicleid][vSpeedoId]);
		}
		if(ModeVehicles[vehicleid][vEngineState] == false) TogglePlayerControllableEx(playerid,false);
	}
	if(oldstate == PLAYER_STATE_DRIVER)
	{
		new vehicleid = GetPlayerVehicleID(playerid),
			Float:Pos[4],
			Float:Health;
		switch(ModeVehicles[vehicleid][vSpeedoType])
		{
			case SPEEDOMETER_ANALOG: SpeedometerAnalogHide(playerid,ModeVehicles[vehicleid][vSpeedoSubtype],ModeVehicles[vehicleid][vSpeedoId]);
			case SPEEDOMETER_ELECTRO: SpeedometerElectroHide(playerid,ModeVehicles[vehicleid][vSpeedoSubtype],ModeVehicles[vehicleid][vSpeedoId]);
		}
		GetVehiclePos(vehicleid,Pos[0],Pos[1],Pos[2]);
		GetVehicleZAngle(vehicleid,Pos[3]);
		GetVehicleHealth(vehicleid,Health);
		format(query,sizeof(query),"UPDATE `Vehicles` (`X`,`Y`,`Z`,`Angle`,`Health`,`Fuel`) VALUES (%f,%f,%f,%f,%f,%f) WHERE `id`=%d",Pos[0],Pos[1],Pos[2],Pos[3],Health,ModeVehicles[vehicleid][vFuel],GetModePropertyInt(MODE_PROPERTY_VEHICLES_BID,vehicleid,0));
		samp_mysql_query(query);
	}
	Debug(DEBUG_END,"ModeVehicles_OnPlayerStateChang(reason: complete)");
}

ModeVehicles_OnPlayerUpdate(playerid)
{
	Debug(DEBUG_START,"ModeVehicles_OnPlayerUpdate(%d)",playerid);
	if(!IsPlayerInAnyVehicle(playerid)) {Debug(DEBUG_END,"ModeVehicles_OnPlayerUpdate(reason: complete)");return;}
	Debug(DEBUG_ACTION,"player in vehicle");
	new vehicleid = GetPlayerVehicleID(playerid),
		Float:tmp[4],
		data[3];
	Debug(DEBUG_ACTION,"get velocity");
	GetVehicleVelocity(vehicleid,tmp[0],tmp[1],tmp[2]);
	tmp[3] = floatsqroot(floatabs(floatpower(tmp[0] + tmp[1] + tmp[2],2)));
	Debug(DEBUG_ACTION,"write acceleration");
	data[0] = floatround(floatabs(tmp[3] - ModeVehicles_Player[playerid][pLastVelocity]));
	ModeVehicles_Player[playerid][pLastVelocity] = tmp[3];
	Debug(DEBUG_ACTION,"write speed");	
	data[1] = floatround(tmp[3] * 161.0);
	Debug(DEBUG_ACTION,"check null fuel");
	if((ModeVehicles[vehicleid][vFuel] <= 0.0) && (ModeVehicles[vehicleid][vEngineState] == true))
	{
		TogglePlayerControllableEx(playerid,false);
		ModeVehicles[vehicleid][vEngineState] = false;
	}
	else
	{
		Debug(DEBUG_ACTION,"get distance");
		GetVehiclePos(vehicleid,tmp[0],tmp[1],tmp[2]);
		tmp[3] = GetDistanceBetweenCoords(tmp[0],tmp[1],tmp[2],ModeVehicles_Player[playerid][pLastPos][0],ModeVehicles_Player[playerid][pLastPos][1],ModeVehicles_Player[playerid][pLastPos][2]);
		ModeVehicles_Player[playerid][pLastPos][0] = tmp[0];
		ModeVehicles_Player[playerid][pLastPos][1] = tmp[1];
		ModeVehicles_Player[playerid][pLastPos][2] = tmp[2];
		Debug(DEBUG_ACTION,"lost fuel");
		new model_ex = GetVehicleModel(vehicleid) - 400;
		ModeVehicles[vehicleid][vFuel] -= (Vehicles[model_ex][vExpense] * (tmp[3] / 100.0));
	}
	Debug(DEBUG_ACTION,"write fuel");
	data[2] = floatround(((Vehicles[model_ex][vMaxFuel] - ModeVehicles[vehicleid][vFuel]) / (Vehicles[model_ex][vMaxFuel] / 100.0)) / 10);
	Debug(DEBUG_ACTION,"show updated speedo");
	switch(ModeVehicles[vehicleid][vSpeedoType])
	{
		case SPEEDOMETER_ANALOG: SpeedometerAnalogUpdate(playerid,ModeVehicles[vehicleid][vSpeedoSubtype],ModeVehicles[vehicleid][vSpeedoId],data);
		case SPEEDOMETER_ELECTRO: SpeedometerElectroUpdate(playerid,ModeVehicles[vehicleid][vSpeedoSubtype],ModeVehicles[vehicleid][vSpeedoId],data);
	}
	Debug(DEBUG_END,"ModeVehicles_OnPlayerUpdate(reason: complete)");
}

ModeVehicles_OnPlayerKeySC(playerid,newkeys,oldkeys)
{
	Debug(DEBUG_START,"ModeVehicles_OnPlayerKeySC(%d,%d,%d)",playerid);
	if((IsPlayerInAnyVehicle(playerid) == 0) || (ModeVehicles[GetPlayerVehicleID(playerid)][vEngineState] == false)) {Debug(DEBUG_END,"ModeVehicles_OnPlayerUpdate(reason: complete)");return;}
	if(newkeys & KEY_EXIT_VEHICLE)
	{
		TogglePlayerControllableEx(playerid,true);
		RemovePlayerFromVehicle(playerid);
	}
	Debug(DEBUG_END,"ModeVehicles_OnPlayerKeySC(reason: complete)");
}