Dialog response problem,need some solution
#1

Dialog wont work when i try to purchase a vehicle. When i click "Yes" Nothing happens the box just dissapears.
Please take a look and give me some solution...Thank you.

Код:
#include <a_samp>
#include <SII>

#define color_white         0xFFFFFFFF
#define color_grey          0xAFAFAFFF
#define color_yellow        0xFFFF00FF
#define color_lightblue     0x33CCFFFF
#define color_orange        0xFF8300FF

#define MAX_DEALERSHIPS 	50 // Limit of dealerships. The higher the more lag
#define MAX_OWNABLE_CARS    3 // Limit of cars a player can own. The higher the more lag

#define dcmd(%1,%2,%3) if (!strcmp((%3)[1], #%1, true, (%2)) && ((((%3)[(%2) + 1] == '\0') && (dcmd_%1(playerid, ""))) || (((%3)[(%2) + 1] == ' ') && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1

enum dealership_enum
{
	dealership_name[32],
	dealership_owner[24],
	dealership_price,
	dealership_id,
	dealership_owned,
	Text3D:dealership_label,
	Float:dealership_x,
	Float:dealership_y,
	Float:dealership_z,
	Float:dealership_radius,
	dealership_earnings
};

enum vehicle_stats
{
	vehicle_dealership,
	vehicle_model,
	vehicle_price,
	Float:vehicle_position[5],
	Text3D:vehicle_label,
	vehicle_onsale
};

new VehicleStatistics[MAX_VEHICLES][vehicle_stats];
new DealershipStatistics[MAX_DEALERSHIPS][dealership_enum];
new bool:dealership_taken[MAX_DEALERSHIPS];
new bool:locked[MAX_VEHICLES];
new owner[MAX_VEHICLES][MAX_PLAYER_NAME];

new spoiler[20][0] = {1000, 1001, 1002, 1003, 1014, 1015, 1016, 1023, 1058, 1060, 1049, 1050, 1138, 1139, 1146, 1147, 1158, 1162, 1163, 1164};
new nitro[3][0] = {1008, 1009, 1010};
new front_bumper[23][0] = {1117, 1152, 1153, 1155, 1157, 1160, 1165, 1167, 1169, 1170, 1171, 1172, 1173, 1174, 1175, 1179, 1181, 1182, 1185, 1188, 1189, 1192, 1193};
new rear_bumper[22][0] = {1140, 1141, 1148, 1149, 1150, 1151, 1154, 1156, 1159, 1161, 1166, 1168, 1176, 1177, 1178, 1180, 1183, 1184, 1186, 1187, 1190, 1191};
new exhaust[28][0] = {1018, 1019, 1020, 1021, 1022, 1028, 1029, 1037, 1043, 1044, 1045, 1046, 1059, 1064, 1065, 1066, 1089, 1092, 1104, 1105, 1113, 1114, 1126, 1127, 1129, 1132, 1135, 1136};
new bventr[2][0] = {1042, 1044};
new bventl[2][0] = {1043, 1045};
new bscoop[4][0] = {1004, 1005, 1011, 1012};
new rscoop[13][0] = {1006, 1032, 1033, 1035, 1038, 1053, 1054, 1055, 1061, 1067, 1068, 1088, 1091};
new left_sideskirt[21][0] = {1007, 1026, 1031, 1036, 1039, 1042, 1047, 1048, 1056, 1057, 1069, 1070, 1090, 1093, 1106, 1108, 1118, 1119, 1133, 1122, 1134};
new right_sideskirt[21][0] = {1017, 1027, 1030, 1040, 1041, 1051, 1052, 1062, 1063, 1071, 1072, 1094, 1095, 1099, 1101, 1102, 1107, 1120, 1121, 1124, 1137};
new hydraulics[1][0] = {1087};
new bass[1][0] = {1086};
new rbbars[2][0] = {1109, 1110};
new fbbars[2][0] = {1115, 1116};
new wheels[17][0] = {1025, 1073, 1074, 1075, 1076, 1077, 1078, 1079, 1080, 1081, 1082, 1083, 1084, 1085, 1096, 1097, 1098};
new lights[2][0] = {1013, 1024};

forward LoadFilterscript();
forward CheckCarAmount();
forward OnCarStreamIn();

new vehName[][] =
{
    "Landstalker", "Bravura", "Buffalo", "Linerunner", "Perrenial", "Sentinel", "Dumper", "Firetruck", "Trashmaster",
    "Stretch", "Manana", "Infernus", "Voodoo", "Pony", "Mule", "Cheetah", "Ambulance", "Leviathan", "Moonbeam",
    "Esperanto", "Taxi", "Washington", "Bobcat", "Whoopee", "BF Injection", "Hunter", "Premier", "Enforcer",
    "Securicar", "Banshee", "Predator", "Bus", "Rhino", "Barracks", "Hotknife", "Trailer", "Previon", "Coach",
    "Cabbie", "Stallion", "Rumpo", "RC Bandit", "Romero", "Packer", "Monster", "Admiral", "Squalo", "Seasparrow",
    "Pizzaboy", "Tram", "Trailer", "Turismo", "Speeder", "Reefer", "Tropic", "Flatbed", "Yankee", "Caddy", "Solair",
    "Berkley's RC Van", "Skimmer", "PCJ-600", "Faggio", "Freeway", "RC Baron", "RC Raider", "Glendale", "Oceanic",
    "Sanchez", "Sparrow", "Patriot", "Quad", "Coastguard", "Dinghy", "Hermes", "Sabre", "Rustler", "ZR-350", "Walton",
    "Regina", "Comet", "BMX", "Burrito", "Camper", "Marquis", "Baggage", "Dozer", "Maverick", "News Chopper", "Rancher",
    "FBI Rancher", "Virgo", "Greenwood", "Jetmax", "Hotring", "Sandking", "Blista Compact", "Police Maverick",
    "Boxville", "Benson", "Mesa", "RC Goblin", "Hotring Racer A", "Hotring Racer B", "Bloodring Banger", "Rancher",
    "Super GT", "Elegant", "Journey", "Bike", "Mountain Bike", "Beagle", "Cropduster", "Stunt", "Tanker", "Roadtrain",
    "Nebula", "Majestic", "Buccaneer", "Shamal", "Hydra", "FCR-900", "NRG-500", "HPV1000", "Cement Truck", "Tow Truck",
    "Fortune", "Cadrona", "SWAT Truck", "Willard", "Forklift", "Tractor", "Combine", "Feltzer", "Remington", "Slamvan",
    "Blade", "Streak", "Freight", "Vortex", "Vincent", "Bullet", "Clover", "Sadler", "Firetruck", "Hustler", "Intruder",
    "Primo", "Cargobob", "Tampa", "Sunrise", "Merit", "Utility", "Nevada", "Yosemite", "Windsor", "Monster", "Monster",
    "Uranus", "Jester", "Sultan", "Stratium", "Elegy", "Raindance", "RC Tiger", "Flash", "Tahoma", "Savanna", "Bandito",
    "Freight Flat", "Streak Carriage", "Kart", "Mower", "Dune", "Sweeper", "Broadway", "Tornado", "AT-400", "DFT-30",
    "Huntley", "Stafford", "BF-400", "News Van", "Tug", "Trailer", "Emperor", "Wayfarer", "Euros", "Hotdog", "Club",
    "Freight Box", "Trailer", "Andromada", "Dodo", "RC Cam", "Launch", "LSPD Car", "SFPD Car", "LVPD Car",
    "Police Rancher", "Picador", "S.W.A.T", "Alpha", "Phoenix", "Glendale", "Sadler", "Luggage", "Luggage", "Stairs",
    "Boxville", "Tiller", "Utility Trailer"
};


public OnCarStreamIn()
{
	for(new forplayerid = 0; forplayerid < MAX_PLAYERS; forplayerid++)
	{
		if(IsPlayerConnected(forplayerid))
		{
		    for(new vehicleid = 0; vehicleid < MAX_VEHICLES; vehicleid++)
		    {
				if(vehicleid > 0)
				{
					if(IsPlayerNearVehicle(forplayerid, vehicleid, 30.0))
					{
						switch(locked[vehicleid])
						{
	   		 				case false: SetVehicleParamsForPlayer(vehicleid, forplayerid, 0, 0);
	    					case true: SetVehicleParamsForPlayer(vehicleid, forplayerid, 0, 1);
						}
					}
				}
			}
		}
	}
	return 0;
}

public CheckCarAmount()
{
	new
		cars,
		playername[24],
		var[32];

	for(new i = 0; i < MAX_PLAYERS; i++)
	{
	    if(IsPlayerConnected(i))
	    {
	        if(GetPVarInt(i, "AmountOfCars") < 0)
	        {
				GetPlayerName(i, playername, sizeof(playername));

				for(new s = 1; s <= MAX_OWNABLE_CARS; s++)
				{
				    format(var, sizeof(var), "Carkey_%d", s);
					if(GetPVarInt(i, var) > 0) { cars++; }
				}
				SetPVarInt(i, "AmountOfCars", cars);
			}
		}
	}
	return 1;
}

public LoadFilterscript()
{
    LoadDealerships();
	LoadDealershipCars();
	
	for(new i = 0; i < MAX_PLAYERS; i++) { if(IsPlayerConnected(i)) { LoadPlayerVehicleData(i); } }
	return 1;
}

stock frename(oldname[], newname[])
{
	if(!fexist(oldname)) return 0;
	new string[255], File:oldfile, File:newfile;
	oldfile = fopen(oldname, io_read);
	newfile = fopen(newname, io_write);
	while(fread(oldfile, string))
	{
		format(string,sizeof(string), "%s", string);
		fwrite(newfile, string);
	}
	fclose(oldfile);
	fclose(newfile);
	fremove(oldname);
	return 1;
}


stock CheckForFile(file[])
{
	if(!fexist(file)) return printf("WARNING: Missing %s in scriptfiles folder.\nYour server may NOT function properly without the file.\n", file);
	return 1;
}

public OnFilterScriptInit()
{
	CheckForFile("dealerships/vehicles/");
	CheckForFile("ownedcars/");
	SetTimer("LoadFilterscript", 2000, false);
	SetTimer("CheckCarAmount", 2000, true);
	SetTimer("OnCarStreamIn", 200, true);
	return 1;
}

public OnFilterScriptExit()
{
	for(new i = 1; i < MAX_DEALERSHIPS; i++)
	{
	    if(dealership_taken[i] == true)
	    {
	    	SaveDealership(i);
	    	for(new v = 1; v < MAX_VEHICLES; v++)
	    	{
	        	if(VehicleStatistics[v][vehicle_dealership] == i)
	        	{
	            	VehicleStatistics[v][vehicle_dealership] = 0;
					VehicleStatistics[v][vehicle_model] = 0;
					VehicleStatistics[v][vehicle_price] = 0;
					VehicleStatistics[v][vehicle_position][1] = 0.0;
					VehicleStatistics[v][vehicle_position][2] = 0.0;
					VehicleStatistics[v][vehicle_position][3] = 0.0;
					VehicleStatistics[v][vehicle_position][4] = 0.0;
					VehicleStatistics[v][vehicle_onsale] = 0;
					Delete3DTextLabel(VehicleStatistics[v][vehicle_label]);
					DestroyVehicle(v);
	        	}
			}
	    	strmid(DealershipStatistics[i][dealership_name], "None", 0, strlen("None"), 255);
			strmid(DealershipStatistics[i][dealership_owner], "No-one", 0, strlen("No-one"), 255);
			DealershipStatistics[i][dealership_price] = 0;
			DealershipStatistics[i][dealership_owned] = 0;
			DealershipStatistics[i][dealership_x] = 0.0;
			DealershipStatistics[i][dealership_y] = 0.0;
			DealershipStatistics[i][dealership_z] = 0.0;
			DealershipStatistics[i][dealership_radius] = 0.0;
			DealershipStatistics[i][dealership_earnings] = 0;
			dealership_taken[i] = false;
	   	 	Delete3DTextLabel(DealershipStatistics[i][dealership_label]);
	    	DestroyPickup(DealershipStatistics[i][dealership_id]);
		}
	}
	for(new i = 0; i < MAX_PLAYERS; i++)
	{
	    if(IsPlayerConnected(i))
 		{
		 	SavePlayerVehicleData(i);
		 	UnloadVehicles(i);
	 	}
	}
	return 1;
}

public OnPlayerSpawn(playerid)
{
	new
	    playername[24];
	    
	if(GetPVarInt(playerid, "CarsLoaded") == 0) LoadPlayerVehicleData(playerid);

	GetPlayerName(playerid, playername, sizeof(playername));

	if(strcmp(DealershipStatistics[GetPVarInt(playerid, "HasDealership")][dealership_owner], playername, true) == 0) { }
	else { SetPVarInt(playerid, "HasDealership", 0); }
	return 1;
}

public OnPlayerDisconnect(playerid)
{
	SavePlayerVehicleData(playerid);
	UnloadVehicles(playerid);
	return 1;
}

public OnVehicleMod(playerid, vehicleid, componentid)
{
	new
	    var[32],
		componentslot = InitComponents(componentid);

	format(var, sizeof(var), "Component%d_%d", componentslot, ReturnVehicleSlot(playerid));
	SetPVarInt(playerid, var, componentid);
	SavePlayerVehicleData(playerid);
	return 1;
}

public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
{
	new
	    var[32];
	    
	format(var, sizeof(var), "Paintjob_%d", ReturnVehicleSlot(playerid));
	SetPVarInt(playerid, var, paintjobid);
	SavePlayerVehicleData(playerid);
	return 1;
}

public OnVehicleRespray(playerid, vehicleid, color1, color2)
{
    new
	    var[32];

	format(var, sizeof(var), "Color1_%d", ReturnVehicleSlot(playerid));
	SetPVarInt(playerid, var, color1);
	
	format(var, sizeof(var), "Color2_%d", ReturnVehicleSlot(playerid));
	SetPVarInt(playerid, var, color2);
	SavePlayerVehicleData(playerid);
    return 1;
}

stock InitComponents(componentid)
{
	new
		i = 0;
		
	for(i = 0; i < 20; i ++) { if(spoiler[i][0] == componentid) { return 1; } }
	for(i = 0; i < 3; i ++) { if(nitro[i][0] == componentid) { return 2; } }
	for(i = 0; i < 23; i ++) { if(front_bumper[i][0] == componentid) { return 3; } }
	for(i = 0; i < 22; i ++) { if(rear_bumper[i][0] == componentid) { return 4; } }
	for(i = 0; i < 28; i ++) { if(exhaust[i][0] == componentid) { return 5; } }
	for(i = 0; i < 2; i ++) { if(bventr[i][0] == componentid) { return 6; } }
	for(i = 0; i < 2; i ++) { if(bventl[i][0] == componentid) { return 7; } }
	for(i = 0; i < 4; i ++) { if(bscoop[i][0] == componentid) { return 8; } }
	for(i = 0; i < 13; i ++) { if(rscoop[i][0] == componentid) { return 9; } }
	for(i = 0; i < 21; i ++) { if(left_sideskirt[i][0] == componentid) { return 10; } }
	for(i = 0; i < 21; i ++) { if(right_sideskirt[i][0] == componentid) { return 11; } }
	if(hydraulics[0][0] == componentid) { return 12; }
	if(bass[0][0] == componentid) { return 13; }
	for(i = 0; i < 2; i ++) { if(rbbars[i][0] == componentid) { return 14; } }
	for(i = 0; i < 2; i ++) { if(fbbars[i][0] == componentid) { return 15; } }
	for(i = 0; i < 17; i ++) { if(wheels[i][0] == componentid) { return 16; } }
	for(i = 0; i < 2; i ++) { if(lights[i][0] == componentid) { return 17; } }
	return 0;
}

stock LoadDealershipCars()
{
	new
		file[100],
		file2[100],
		string[128],
		vehicle;

	for(new i = 1; i < MAX_VEHICLES; i++)
	{
		format(file, sizeof(file), "dealerships/vehicles/%d.cfg", i);
		if(!fexist(file)) continue;
		if(fexist(file) && INI_Open(file))
		{
		    if(GetVehicleModel(i) > 399)
		    {
                for (new v = 1; v < MAX_VEHICLES; v ++)
				{
		            if (GetVehicleModel(v) == 0)
					{
		                i = v;
		                break;
					}
				}
				format(file2, sizeof(file2), "dealerships/vehicles/%d.cfg", i);
				frename(file, file2);
			}
		    
		    VehicleStatistics[i][vehicle_dealership] = INI_ReadInt("vehicle_dealership");
			VehicleStatistics[i][vehicle_model] = INI_ReadInt("vehicle_model");
			VehicleStatistics[i][vehicle_price] = INI_ReadInt("vehicle_price");
   			VehicleStatistics[i][vehicle_position][1] = INI_ReadFloat("vehicle_x");
		    VehicleStatistics[i][vehicle_position][2] = INI_ReadFloat("vehicle_y");
		    VehicleStatistics[i][vehicle_position][3] = INI_ReadFloat("vehicle_z");
			VehicleStatistics[i][vehicle_position][4] = INI_ReadFloat("vehicle_angle");
      		VehicleStatistics[i][vehicle_onsale] = INI_ReadInt("vehicle_onsale");
			vehicle = CreateVehicle(VehicleStatistics[i][vehicle_model], VehicleStatistics[i][vehicle_position][1], VehicleStatistics[i][vehicle_position][2], VehicleStatistics[i][vehicle_position][3], VehicleStatistics[i][vehicle_position][4], 0, 0, -1);
			format(string, sizeof(string), "%s For Sale - Price: $%d", GetVehicleName(vehicle), VehicleStatistics[i][vehicle_price]);
			VehicleStatistics[i][vehicle_label] = Create3DTextLabel(string, color_orange, VehicleStatistics[i][vehicle_position][1], VehicleStatistics[i][vehicle_position][2], VehicleStatistics[i][vehicle_position][3], 10.0, 0);
			INI_Close();
		}
	}
	return 1;
}

stock LoadDealerships()
{
	new file[100], string[256], name[32], ownr[24];
	for(new i = 1; i < MAX_DEALERSHIPS; i++)
	{
		format(file, sizeof(file), "dealerships/%d.cfg", i);
		if(fexist(file) && INI_Open(file))
		{
			INI_ReadString(name, "dealership_name");
			INI_ReadString(ownr, "dealership_owner");
			strmid(DealershipStatistics[i][dealership_name], name, 0, strlen(name), 255);
			strmid(DealershipStatistics[i][dealership_owner], ownr, 0, strlen(ownr), 255);
			DealershipStatistics[i][dealership_price] = INI_ReadInt("dealership_price");
			DealershipStatistics[i][dealership_owned] = INI_ReadInt("dealership_owned");
			DealershipStatistics[i][dealership_x] = INI_ReadFloat("dealership_x");
			DealershipStatistics[i][dealership_y] = INI_ReadFloat("dealership_y");
			DealershipStatistics[i][dealership_z] = INI_ReadFloat("dealership_z");
			DealershipStatistics[i][dealership_radius] = INI_ReadFloat("dealership_radius");
			DealershipStatistics[i][dealership_earnings] = INI_ReadInt("dealership_earnings");
			switch(DealershipStatistics[i][dealership_owned])
			{
			    case 0: { format(string, sizeof(string), "{FF6347}%s{FFFFFF} is for sale!\n\n{FF6347}Price:{FFFFFF} $%d\n\nTo purchase this dealership, type /buydealer.", DealershipStatistics[i][dealership_name], DealershipStatistics[i][dealership_price]); }
				case 1: { format(string, sizeof(string), "{FF6347}%s{FFFFFF}\n\n{FF6347}Owner:{FFFFFF} %s", DealershipStatistics[i][dealership_name], DealershipStatistics[i][dealership_owner]); }
			}
			DealershipStatistics[i][dealership_label] = Create3DTextLabel(string, color_white, DealershipStatistics[i][dealership_x], DealershipStatistics[i][dealership_y], DealershipStatistics[i][dealership_z], 10.0, 0);
			CreatePickup(1274, 23, DealershipStatistics[i][dealership_x], DealershipStatistics[i][dealership_y], DealershipStatistics[i][dealership_z]);
			dealership_taken[i] = true;
			INI_Close();
		}
	}
	return 1;
}

stock SaveDealership(dealershipid)
{
	new file[100];
	if(dealership_taken[dealershipid] == true)
 	{
		format(file, sizeof(file), "dealerships/%d.cfg", dealershipid);
		if(INI_Open(file))
		{
		   	INI_WriteString("dealership_name", DealershipStatistics[dealershipid][dealership_name]);
		   	INI_WriteString("dealership_owner", DealershipStatistics[dealershipid][dealership_owner]);
		   	INI_WriteInt("dealership_price", DealershipStatistics[dealershipid][dealership_price]);
		   	INI_WriteInt("dealership_owned", DealershipStatistics[dealershipid][dealership_owned]);
		   	INI_WriteFloat("dealership_x", DealershipStatistics[dealershipid][dealership_x]);
		   	INI_WriteFloat("dealership_y", DealershipStatistics[dealershipid][dealership_y]);
		   	INI_WriteFloat("dealership_z", DealershipStatistics[dealershipid][dealership_z]);
		   	INI_WriteFloat("dealership_radius", DealershipStatistics[dealershipid][dealership_radius]);
			INI_WriteInt("dealership_earnings", DealershipStatistics[dealershipid][dealership_earnings]);

			INI_Save();
			INI_Close();
		}
	}
	for(new i = 1; i < MAX_VEHICLES; i++)
	{
	    if(VehicleStatistics[i][vehicle_dealership] == dealershipid)
	    {
			format(file, sizeof(file), "dealerships/vehicles/%d.cfg", i);
			if(INI_Open(file))
			{
			    INI_WriteInt("vehicle_dealership", VehicleStatistics[i][vehicle_dealership]);
			    INI_WriteInt("vehicle_model", VehicleStatistics[i][vehicle_model]);
			    INI_WriteInt("vehicle_price", VehicleStatistics[i][vehicle_price]);
			    INI_WriteFloat("vehicle_x", VehicleStatistics[i][vehicle_position][1]);
			    INI_WriteFloat("vehicle_y", VehicleStatistics[i][vehicle_position][2]);
			    INI_WriteFloat("vehicle_z", VehicleStatistics[i][vehicle_position][3]);
			    INI_WriteFloat("vehicle_angle", VehicleStatistics[i][vehicle_position][4]);
	            INI_WriteInt("vehicle_onsale", VehicleStatistics[i][vehicle_onsale]);

				INI_Save();
				INI_Close();
			}
		}
	}
	return 1;
}

dcmd_createdealer(playerid, params[])
{
	new
	    price,
		dealername[32],
		Float:radius,
		dealershipid = -1,
		bool:assigned = false,
		string[256],
		Float:x,
		Float:y,
		Float:z;

	GetPlayerPos(playerid, x, y, z);
	if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, color_grey, "    You are not authorized to use this command !");

	if(sscanf(params, "dfs", price, radius, dealername))
		return SendClientMessage(playerid, color_white, "* [Usage]: /createdealer [price] [radius] [name of dealership]");

	for(new i = 1; i < MAX_DEALERSHIPS; i++)
	{
	    if(dealership_taken[i] == false)
	    {
	        dealershipid = i;
	        assigned = true;
	        break;
		}
	}
	if(assigned == false) return SendClientMessage(playerid, color_grey, "    Something went wrong while creating the dealership !");
	strmid(DealershipStatistics[dealershipid][dealership_name], dealername, 0, strlen(dealername), 255);
	strmid(DealershipStatistics[dealershipid][dealership_owner], "No-one", 0, strlen("No-one"), 255);
	DealershipStatistics[dealershipid][dealership_price] = price;
	DealershipStatistics[dealershipid][dealership_owned] = 0;
	DealershipStatistics[dealershipid][dealership_x] = x;
	DealershipStatistics[dealershipid][dealership_y] = y;
	DealershipStatistics[dealershipid][dealership_z] = z;
	DealershipStatistics[dealershipid][dealership_radius] = radius;
	DealershipStatistics[dealershipid][dealership_id] = CreatePickup(1274, 23, x, y, z);
	format(string, sizeof(string), "{FF6347}%s{FFFFFF} is for sale!\n\n{FF6347}Price:{FFFFFF} $%d\n\nTo purchase this dealership, type /buydealer.", dealername, price);
	DealershipStatistics[dealershipid][dealership_label] = Create3DTextLabel(string, color_white, x, y, z, 10.0, 0);
	format(string, sizeof(string), " Dealership %d created.", dealershipid);
	SendClientMessage(playerid, color_grey, string);
	dealership_taken[dealershipid] = true;
	SaveDealership(dealershipid);
	return 1;
}

dcmd_destroydealer(playerid, params[])
{
	new
		id,
		file[100];

    if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, color_grey, "    You are not authorized to use this command !");
	if(sscanf(params, "d", id))
	    return SendClientMessage(playerid, color_white, "* [Usage]: /destroydealer [dealershipid]");

	if(id < 1 || id > MAX_DEALERSHIPS) return SendClientMessage(playerid, color_grey, "    Invalid dealership ID !");
	if(dealership_taken[id] == true)
	{
	    format(file, sizeof(file), "dealerships/%d.cfg", id);
	    if(fexist(file)) { fremove(file); }
	    for(new i = 1; i < MAX_VEHICLES; i++)
	    {
	        if(VehicleStatistics[i][vehicle_dealership] == id)
	        {
	            format(file, sizeof(file), "dealerships/vehicles/%d.cfg", i);
	            if(fexist(file)) { fremove(file); }
	            VehicleStatistics[i][vehicle_dealership] = 0;
				VehicleStatistics[i][vehicle_model] = 0;
				VehicleStatistics[i][vehicle_price] = 0;
				VehicleStatistics[i][vehicle_position][1] = 0.0;
				VehicleStatistics[i][vehicle_position][2] = 0.0;
				VehicleStatistics[i][vehicle_position][3] = 0.0;
				VehicleStatistics[i][vehicle_position][4] = 0.0;
				VehicleStatistics[i][vehicle_onsale] = 0;
				Delete3DTextLabel(VehicleStatistics[i][vehicle_label]);
				DestroyVehicle(i);
	        }
		}
	    strmid(DealershipStatistics[id][dealership_name], "None", 0, strlen("None"), 255);
		strmid(DealershipStatistics[id][dealership_owner], "No-one", 0, strlen("No-one"), 255);
		DealershipStatistics[id][dealership_price] = 0;
		DealershipStatistics[id][dealership_owned] = 0;
		DealershipStatistics[id][dealership_x] = 0.0;
		DealershipStatistics[id][dealership_y] = 0.0;
		DealershipStatistics[id][dealership_z] = 0.0;
		DealershipStatistics[id][dealership_radius] = 0.0;
		DealershipStatistics[id][dealership_earnings] = 0;
		dealership_taken[id] = false;
	    Delete3DTextLabel(DealershipStatistics[id][dealership_label]);
	    DestroyPickup(DealershipStatistics[id][dealership_id]);
		return 1;
	}
	else { SendClientMessage(playerid, color_grey, "    Dealership ID not taken !"); }
	return 1;
}

dcmd_buydealer(playerid, params[])
{
	params[0] = 0;
	new
	    dealershipid = -1,
	    string[256],
	    playername[24],
	    bool:isnear = false;

	GetPlayerName(playerid, playername, sizeof(playername));
	if(GetPVarInt(playerid, "HasDealership") != 0) return SendClientMessage(playerid, color_grey, "    You already have a dealership !");
	for(new i = 1; i < MAX_DEALERSHIPS; i++)
	{
	    if(IsPlayerInRangeOfPoint(playerid, 2.0, DealershipStatistics[i][dealership_x], DealershipStatistics[i][dealership_y], DealershipStatistics[i][dealership_z]))
		{
		    dealershipid = i;
		    isnear = true;
		    break;
		}
	}
	if(isnear == false) return SendClientMessage(playerid, color_grey, "    You are not near a dealership!");
	if(DealershipStatistics[dealershipid][dealership_owned] == 0)
	{
	    if(GetPlayerMoney(playerid) >= DealershipStatistics[dealershipid][dealership_price])
	    {
			format(string, sizeof(string), "{FF6347}%s{FFFFFF}\n\n{FF6347}Owner:{FFFFFF} %s", DealershipStatistics[dealershipid][dealership_name], playername);
			Delete3DTextLabel(DealershipStatistics[dealershipid][dealership_label]);
			DealershipStatistics[dealershipid][dealership_label] = Create3DTextLabel(string, color_white, DealershipStatistics[dealershipid][dealership_x], DealershipStatistics[dealershipid][dealership_y], DealershipStatistics[dealershipid][dealership_z], 10.0, 0);
			DealershipStatistics[dealershipid][dealership_owned] = 1;
			strmid(DealershipStatistics[dealershipid][dealership_owner], playername, 0, strlen(playername), 255);
			GivePlayerMoney(playerid, -DealershipStatistics[dealershipid][dealership_price]);
			format(string, sizeof(string), "Congratulations, you've purchased %s for $%d.", DealershipStatistics[dealershipid][dealership_name], DealershipStatistics[dealershipid][dealership_price]);
			SendClientMessage(playerid, color_yellow, string);
			SetPVarInt(playerid, "HasDealership", dealershipid);
			SaveDealership(dealershipid);
			return 1;
		}
		else return SendClientMessage(playerid, color_grey, "   You can't afford this !");
	}
	else { SendClientMessage(playerid, color_grey, "    This dealership is already owned !"); }
	return 1;
}

dcmd_createcar(playerid, params[])
{
	new
		model,
		price,
		dealershipid = GetPVarInt(playerid, "HasDealership");

	if(GetPVarInt(playerid, "HasDealership") != 0)
	{
	    if(!IsPlayerInRangeOfPoint(playerid, DealershipStatistics[dealershipid][dealership_radius], DealershipStatistics[dealershipid][dealership_x], DealershipStatistics[dealershipid][dealership_y], DealershipStatistics[dealershipid][dealership_z]))
			return SendClientMessage(playerid, color_grey, "    You are not near your dealership !");

	    new Float:x, Float:y, Float:z, Float:angle;
	    GetPlayerPos(playerid, x, y, z); GetPlayerFacingAngle(playerid, angle);
	    if(sscanf(params, "dd", model, price)) return SendClientMessage(playerid, color_white, "* [Usage]: /createcar [model] [price]");
		CreateDealershipVehicle(playerid, model, price, x, y, z, angle);
		return 1;
	}
	else { SendClientMessage(playerid, color_grey, "    You don't own a dealership !"); }
	return 1;
}

dcmd_earnings(playerid, params[])
{
	params[0] = 0;

	new
	    dealershipid = GetPVarInt(playerid, "HasDealership"),
	    string[64];
	    
	if(GetPVarInt(playerid, "HasDealership") != 0)
	{
	    format(string, sizeof(string), "{FF8300}Earnings:{FFFFFF} $%d", DealershipStatistics[dealershipid][dealership_earnings]);
		SendClientMessage(playerid, color_white, string);
		return 1;
	}
    else { SendClientMessage(playerid, color_grey, "    You don't own a dealership !"); }
	return 1;
}

dcmd_collectearnings(playerid, params[])
{
	params[0] = 0;
	new
		string[128],
		dealershipid = GetPVarInt(playerid, "HasDealership");

	if(GetPVarInt(playerid, "HasDealership") != 0)
	{
	    if(!IsPlayerInRangeOfPoint(playerid, 2.0, DealershipStatistics[dealershipid][dealership_x], DealershipStatistics[dealershipid][dealership_y], DealershipStatistics[dealershipid][dealership_z]))
			return SendClientMessage(playerid, color_grey, "    You are not near your dealership !");

		if(!DealershipStatistics[dealershipid][dealership_earnings])
		    return SendClientMessage(playerid, color_grey, "    You have no earnings to collect !");

		format(string, sizeof(string), "* You've collected $%d from your dealership's earnings.", DealershipStatistics[dealershipid][dealership_earnings]);
		SendClientMessage(playerid, color_lightblue, string);

		GivePlayerMoney(playerid, DealershipStatistics[dealershipid][dealership_earnings]);
		DealershipStatistics[dealershipid][dealership_earnings] = 0;
		return 1;
	}
	else { SendClientMessage(playerid, color_grey, "    You don't own a dealership !"); }
	return 1;
}

dcmd_selldealership(playerid, params[])
{
	new
		dealershipid = GetPVarInt(playerid, "HasDealership"),
		string[128];

	if(GetPVarInt(playerid, "HasDealership") != 0)
	{
	    if(!IsPlayerInRangeOfPoint(playerid, 2.0, DealershipStatistics[dealershipid][dealership_x], DealershipStatistics[dealershipid][dealership_y], DealershipStatistics[dealershipid][dealership_z]))
			return SendClientMessage(playerid, color_grey, "    You are not near your dealership !");
			
		if(!params[0])
			return SendClientMessage(playerid, color_white, "* [Usage]: /selldealership [confirm] - Sell your dealership back for half price.");
		
		if(strcmp(params, "confirm", true) == 0)
		{
		    new
		        price = (DealershipStatistics[dealershipid][dealership_price] / 2);
		        
		    GivePlayerMoney(playerid, price);
            format(string, sizeof(string), "{FF6347}%s{FFFFFF} is for sale!\n\n{FF6347}Price:{FFFFFF} $%d\n\nTo purchase this dealership, type /buydealer.", DealershipStatistics[dealershipid][dealership_name], DealershipStatistics[dealershipid][dealership_price]);
			Delete3DTextLabel(DealershipStatistics[dealershipid][dealership_label]);
			DealershipStatistics[dealershipid][dealership_label] = Create3DTextLabel(string, color_white, DealershipStatistics[dealershipid][dealership_x], DealershipStatistics[dealershipid][dealership_y], DealershipStatistics[dealershipid][dealership_z], 10.0, 0);
			DealershipStatistics[dealershipid][dealership_owned] = 0;
			strmid(DealershipStatistics[dealershipid][dealership_owner], "No-one", 0, strlen("No-one"), 255);
			format(string, sizeof(string), "You've sold your dealership back to the market for $%d.", DealershipStatistics[dealershipid][dealership_price]);
			SendClientMessage(playerid, color_yellow, string);
			SetPVarInt(playerid, "HasDealership", 0);
			SaveDealership(dealershipid);
			return 1;
		}
	}
	else { SendClientMessage(playerid, color_grey, "    You don't own a dealership !"); }
	return 1;
}

dcmd_park(playerid, params[])
{
	params[0] = 0;
	if(IsPlayerInAnyVehicle(playerid))
	{
		if(DoesPlayerOwnThisVehicle(playerid))
			return ParkVehicle(playerid, ReturnVehicleSlot(playerid));

		else return SendClientMessage(playerid, color_grey, "    You don't own this vehicle !");
	}
	else { SendClientMessage(playerid, color_grey, "    You are not in a vehicle !"); }
	return 1;
}

dcmd_delete(playerid, params[])
{
	new
	    slot;

	if(GetPVarInt(playerid, "AmountOfCars") <= 0)
	    return SendClientMessage(playerid, color_grey, "    You don't own any vehicles !");

	if(sscanf(params, "d", slot))
	    return SendClientMessage(playerid, color_white, "* [Usage]: /delete [1/2]");

	DeleteVehicle(playerid, slot);
	return 1;
}

dcmd_lock(playerid, params[])
{
	new
	    vehicleid,
		status[15],
		Float:position[4],
		var[64];

	params[0] = 0;

	GetPlayerPos(playerid, position[1], position[2], position[3]);
	for(new s = 1; s <= MAX_OWNABLE_CARS; s++)
	{
	    format(var, sizeof(var), "Carkey_%d", s);
		if(IsPlayerNearVehicle(playerid, GetPVarInt(playerid, var), 3.5))
		{
			vehicleid = GetPVarInt(playerid, var);
			switch(locked[vehicleid])
			{
				case false:
				{
			    	for(new i = 0; i < MAX_PLAYERS; i++) { if(IsPlayerConnected(i)) { SetVehicleParamsForPlayer(vehicleid, i, 0, 1); } }
					locked[vehicleid] = true;
					status = "~r~locked";
					format(var, sizeof(var), "Locked_%d", s);
					SetPVarInt(playerid, var, 1);
				}
				case true:
				{
			    	for(new i = 0; i < MAX_PLAYERS; i++) { if(IsPlayerConnected(i)) { SetVehicleParamsForPlayer(vehicleid, i, 0, 0); } }
					locked[vehicleid] = false;
					status = "~g~unlocked";
					format(var, sizeof(var), "Locked_%d", s);
					SetPVarInt(playerid, var, 0);
				}
			}
			GameTextForPlayer(playerid, status, 2000, 6);
			PlaySoundAtPoint(1145, 3.0, position[1], position[2], position[3]);
			break;
		}
		else { SendClientMessage(playerid, color_grey, "    You are not near any of your vehicles !"); break; }
	}
	return 1;
}

stock PlaySoundAtPoint(soundid, Float:radius, Float:pos_x, Float:pos_y, Float:pos_z)
{
	for(new i = 0; i < MAX_PLAYERS; i++)
	{
	    if(IsPlayerConnected(i) && IsPlayerInRangeOfPoint(i, radius, pos_x, pos_y, pos_z))
	        return PlayerPlaySound(i, soundid, 0.0, 0.0, 0.0);
	}
	return 1;
}

stock IsPlayerNearVehicle(playerid, vehicleid, Float:radius)
{
	new
		Float:x,
		Float:y,
		Float:z;
		
	GetVehiclePos(vehicleid, x, y, z);
	
	if(IsPlayerInRangeOfPoint(playerid, radius, x, y, z)) return 1;
	return 0;
}

stock DoesPlayerOwnThisVehicle(playerid)
{
	new
	    vehicleid = GetPlayerVehicleID(playerid),
	    var[32];

	if(vehicleid > 0)
	{
	    for(new s = 1; s <= MAX_OWNABLE_CARS; s++)
	    {
	        format(var, sizeof(var), "Carkey_%d", s);
			if(GetPVarInt(playerid, var) == vehicleid) return 1;
		}
	}
	return 0;
}

stock CreateDealershipVehicle(creator, model, price, Float:carx, Float:cary, Float:carz, Float:carangle)
{
	new
	    vehicleid,
	    string[256];

	vehicleid = CreateVehicle(model, carx, cary, carz, carangle, 0, 0, -1);
	if(vehicleid == INVALID_VEHICLE_ID) return SendClientMessage(creator, color_grey, "    The car couldn't be created !");
	VehicleStatistics[vehicleid][vehicle_dealership] = GetPVarInt(creator, "HasDealership");
	VehicleStatistics[vehicleid][vehicle_model] = model;
	VehicleStatistics[vehicleid][vehicle_price] = price;
	VehicleStatistics[vehicleid][vehicle_position][1] = carx;
    VehicleStatistics[vehicleid][vehicle_position][2] = cary;
    VehicleStatistics[vehicleid][vehicle_position][3] = carz;
    VehicleStatistics[vehicleid][vehicle_position][4] = carangle;
    VehicleStatistics[vehicleid][vehicle_onsale] = 1;
	format(string, sizeof(string), "%s For Sale - Price: $%d", GetVehicleName(vehicleid), price);
	VehicleStatistics[vehicleid][vehicle_label] = Create3DTextLabel(string, color_orange, carx, cary, carz, 10.0, 0);
	SaveDealership(GetPVarInt(creator, "HasDealership"));
	return 1;
}

public OnPlayerStateChange(playerid, newstate, oldstate)
{
	if(newstate == PLAYER_STATE_DRIVER)
	{
	    new
	        vehicleid = GetPlayerVehicleID(playerid),
	        dialog_string[128];

		if(VehicleStatistics[vehicleid][vehicle_onsale] == 1)
		{
		    format(dialog_string, sizeof(dialog_string), "Would you like to buy this %s costing $%d?", GetVehicleName(vehicleid), VehicleStatistics[vehicleid][vehicle_price]);
		    ShowPlayerDialog(playerid, 1337, DIALOG_STYLE_MSGBOX, "Car Purchase", dialog_string, "Yes", "No");
			return 1;
		}
	}
	return 0;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
	if(dialogid == 1337)
	{
	    if(response)
	    {
	        new
	            vehicleid = GetPlayerVehicleID(playerid),
	            model = GetVehicleModel(vehicleid),
	            price = VehicleStatistics[vehicleid][vehicle_price],
				Float:position[5],
				string[128],
				dealershipid = -1,
				var[32],
				playername[24];

			GetPlayerName(playerid, playername, sizeof(playername));
			GetPlayerPos(playerid, position[1], position[2], position[3]);
			GetPlayerFacingAngle(playerid, position[4]);

	        if(GetPVarInt(playerid, "AmountOfCars") >= MAX_OWNABLE_CARS)
				return SendClientMessage(playerid, color_grey, "	You already own the maximum amount of vehicles !"), RemovePlayerFromVehicle(playerid);

			if(GetPlayerMoney(playerid) < price)
			    return SendClientMessage(playerid, color_grey, "	You can't afford that !"), RemovePlayerFromVehicle(playerid);

			for(new i = 1; i < MAX_DEALERSHIPS; i++)
			{
			    if(IsPlayerInRangeOfPoint(playerid, DealershipStatistics[i][dealership_radius], DealershipStatistics[i][dealership_x], DealershipStatistics[i][dealership_y], DealershipStatistics[i][dealership_z]))
				{
				    dealershipid = i;
					break;
				}
			}

			DealershipStatistics[dealershipid][dealership_earnings] += (price / 4);

			GivePlayerMoney(playerid, -price);

			RemovePlayerFromVehicle(playerid);
			vehicleid = CreateVehicle(model, (position[1] + (7.5 * floatsin(-position[4], degrees))), (position[2] + (7.5 * floatcos(position[4], degrees))), position[3], position[4], 0, 0, -1);
			format(string, sizeof(string), "Thank you for purchasing at %s, we hope to see you again!", DealershipStatistics[dealershipid][dealership_name]);
			SendClientMessage(playerid, color_white, string);
			SendClientMessage(playerid, color_white, "Your vehicle has been spawned in front of you.");

			SetPVarInt(playerid, "AmountOfCars", GetPVarInt(playerid, "AmountOfCars") + 1);

			format(var, sizeof(var), "Model_%d", GetPVarInt(playerid, "AmountOfCars"));
			SetPVarInt(playerid, var, model);

			format(var, sizeof(var), "X_%d", GetPVarInt(playerid, "AmountOfCars"));
			SetPVarFloat(playerid, var, (position[1] + (7.5 * floatsin(-position[4], degrees))));

			format(var, sizeof(var), "Y_%d", GetPVarInt(playerid, "AmountOfCars"));
			SetPVarFloat(playerid, var, (position[2] + (7.5 * floatcos(position[4], degrees))));

			format(var, sizeof(var), "Z_%d", GetPVarInt(playerid, "AmountOfCars"));
			SetPVarFloat(playerid, var, position[3]);

			format(var, sizeof(var), "Angle_%d", GetPVarInt(playerid, "AmountOfCars"));
			SetPVarFloat(playerid, var, position[4]);

			format(var, sizeof(var), "Carkey_%d", GetPVarInt(playerid, "AmountOfCars"));
			SetPVarInt(playerid, var, vehicleid);
			
			format(var, sizeof(var), "Paintjob_%d", GetPVarInt(playerid, "AmountOfCars"));
			SetPVarInt(playerid, var, -1);

			strmid(owner[vehicleid], playername, 0, strlen(playername), 255);
			SavePlayerVehicleData(playerid);
			return 1;
		}
		else return RemovePlayerFromVehicle(playerid);
	}
	return 1;
}

stock SavePlayerVehicleData(playerid)
{
	new file[100], playername[24], var[32];
	GetPlayerName(playerid, playername, sizeof(playername));
	format(file, sizeof(file), "ownedcars/%s.vehicle", playername);
	if(INI_Open(file))
	{
	    INI_WriteInt("AmountOfCars", GetPVarInt(playerid, "AmountOfCars"));
        INI_WriteInt("HasDealership", GetPVarInt(playerid, "HasDealership"));
		for(new s = 1; s <= MAX_OWNABLE_CARS; s++)
		{
		    format(var, sizeof(var), "Model_%d", s);
			INI_WriteInt(var, GetPVarInt(playerid, var));
			
			format(var, sizeof(var), "X_%d", s);
	    	INI_WriteFloat(var, GetPVarFloat(playerid, var));
	    	
	    	format(var, sizeof(var), "Y_%d", s);
	    	INI_WriteFloat(var, GetPVarFloat(playerid, var));
	    	
	    	format(var, sizeof(var), "Z_%d", s);
	    	INI_WriteFloat(var, GetPVarFloat(playerid, var));
	    	
	    	format(var, sizeof(var), "Angle_%d", s);
	    	INI_WriteFloat(var, GetPVarFloat(playerid, var));
	    	
			format(var, sizeof(var), "Paintjob_%d", s);
	    	INI_WriteInt(var, GetPVarInt(playerid, var));
	    	
	    	for(new i = 1; i <= 17; i++)
	    	{
	    	    format(var, sizeof(var), "Component%d_%d", i, s);
				INI_WriteInt(var, GetPVarInt(playerid, var));
	    	}
	    	
            format(var, sizeof(var), "Color1_%d", s);
			INI_WriteInt(var, GetPVarInt(playerid, var));
			
			format(var, sizeof(var), "Color2_%d", s);
			INI_WriteInt(var, GetPVarInt(playerid, var));
			
			format(var, sizeof(var), "Locked_%d", s);
			INI_WriteInt(var, GetPVarInt(playerid, var));
		}
		INI_Save();
		INI_Close();
	}
	return 1;
}

stock LoadPlayerVehicleData(playerid)
{
	new file[100], playername[24], var[32];
	GetPlayerName(playerid, playername, sizeof(playername));
	format(file, sizeof(file), "ownedcars/%s.vehicle", playername);
	if(fexist(file) && INI_Open(file))
	{
	    SetPVarInt(playerid, "AmountOfCars", INI_ReadInt("AmountOfCars"));
        SetPVarInt(playerid, "HasDealership", INI_ReadInt("HasDealership"));
        
	    for(new s = 1; s <= MAX_OWNABLE_CARS; s++)
		{
		    format(var, sizeof(var), "Model_%d", s);
			SetPVarInt(playerid, var, INI_ReadInt(var));

			format(var, sizeof(var), "X_%d", s);
	    	SetPVarFloat(playerid, var, INI_ReadFloat(var));

	    	format(var, sizeof(var), "Y_%d", s);
	    	SetPVarFloat(playerid, var, INI_ReadFloat(var));

	    	format(var, sizeof(var), "Z_%d", s);
	    	SetPVarFloat(playerid, var, INI_ReadFloat(var));

	    	format(var, sizeof(var), "Angle_%d", s);
	    	SetPVarFloat(playerid, var, INI_ReadFloat(var));

			format(var, sizeof(var), "Paintjob_%d", s);
	    	SetPVarInt(playerid, var, INI_ReadInt(var));

	    	for(new i = 1; i <= 17; i++)
	    	{
	    	    format(var, sizeof(var), "Component%d_%d", i, s);
				SetPVarInt(playerid, var, INI_ReadInt(var));
	    	}

            format(var, sizeof(var), "Color1_%d", s);
			SetPVarInt(playerid, var, INI_ReadInt(var));

			format(var, sizeof(var), "Color2_%d", s);
			SetPVarInt(playerid, var, INI_ReadInt(var));

			format(var, sizeof(var), "Locked_%d", s);
			SetPVarInt(playerid, var, INI_ReadInt(var));
		}
		
		INI_Close();
	}
	for(new s = 1; s <= MAX_OWNABLE_CARS; s++)
	{
	    new model, Float:Floats[5], carid;
		format(var, sizeof(var), "Model_%d", s);
		model = GetPVarInt(playerid, var);
		
		format(var, sizeof(var), "X_%d", s);
		Floats[1] = GetPVarFloat(playerid, var);
		
	    format(var, sizeof(var), "Y_%d", s);
		Floats[2] = GetPVarFloat(playerid, var);
		
		format(var, sizeof(var), "Z_%d", s);
		Floats[3] = GetPVarFloat(playerid, var);
		
		format(var, sizeof(var), "Angle_%d", s);
		Floats[4] = GetPVarFloat(playerid, var);
		
		carid = CreateVehicle(model, Floats[1], Floats[2], Floats[3], Floats[4], 0, 0, -1);
		if(carid != INVALID_VEHICLE_ID)
		{
		    format(var, sizeof(var), "Carkey_%d", s);
		    SetPVarInt(playerid, var, carid);
		}
		
		format(var, sizeof(var), "Locked_%d", s);
		switch(GetPVarInt(playerid, var))
		{
			case false: { locked[carid] = false; }
			case true: { locked[carid] = true; }
		}
		strmid(owner[carid], playername, 0, strlen(playername), 255);
	}
	SetPVarInt(playerid, "CarsLoaded", 1);
	ModifyVehicles(playerid);
	return 1;
}

stock ParkVehicle(playerid, slot)
{
	new
	    var[32],
	    Float:v_hp,
	    string[64],
	    vehicleid,
	    Float:v_pos[4],
	    Float:v_rot,
	    tmp_model,
	    Float:tmp_pos[4],
	    Float:tmp_rot,
	    playername[24],
	    Float:ply_pos[4],
	    islocked;

	GetPlayerName(playerid, playername, sizeof(playername));
	    
	format(var, sizeof(var), "Carkey_%d", slot);
	vehicleid = GetPVarInt(playerid, var);

	if(vehicleid > 0)
	{
		locked[vehicleid] = false;

		GetVehicleHealth(vehicleid, v_hp);
		GetVehiclePos(vehicleid, v_pos[1], v_pos[2], v_pos[3]);
		GetVehicleZAngle(vehicleid, v_rot);
		
		format(var, sizeof(var), "X_%d", slot);
		SetPVarFloat(playerid, var, v_pos[1]);
		
		format(var, sizeof(var), "Y_%d", slot);
		SetPVarFloat(playerid, var, v_pos[2]);
		
		format(var, sizeof(var), "Z_%d", slot);
		SetPVarFloat(playerid, var, v_pos[3]);
		
		format(var, sizeof(var), "Angle_%d", slot);
		SetPVarFloat(playerid, var, v_rot);
		
		DestroyVehicle(vehicleid);
		
		format(var, sizeof(var), "Model_%d", slot);
		tmp_model = GetPVarInt(playerid, var);
		
		format(var, sizeof(var), "X_%d", slot);
		tmp_pos[1] = GetPVarFloat(playerid, var);
		
		format(var, sizeof(var), "Y_%d", slot);
		tmp_pos[2] = GetPVarFloat(playerid, var);
		
		format(var, sizeof(var), "Z_%d", slot);
		tmp_pos[3] = GetPVarFloat(playerid, var);
		
		format(var, sizeof(var), "Angle_%d", slot);
		tmp_rot = GetPVarFloat(playerid, var);

		format(var, sizeof(var), "Locked_%d", slot);
		islocked = GetPVarInt(playerid, var);
		
		vehicleid = CreateVehicle(tmp_model, tmp_pos[1], tmp_pos[2], tmp_pos[3], tmp_rot, 1, 1, -1);
		ModifyVehicles(playerid);

		SetVehicleHealth(vehicleid, v_hp);
		
		format(string, sizeof(string), "%s has parked their vehicle.", playername);

		GetPlayerPos(playerid, ply_pos[1], ply_pos[2], ply_pos[3]);

		for(new i = 0; i < MAX_PLAYERS; i++)
		{
		    if(IsPlayerConnected(i) && IsPlayerInRangeOfPoint(i, 20.0, ply_pos[1], ply_pos[2], ply_pos[3]))
		    {
		        SendClientMessage(i, 0xC2A2DAAA, string);
		    }
		}
		switch(islocked)
		{
		    case false: { locked[vehicleid] = false; }
			case true: { locked[vehicleid] = true; }
		}
		strmid(owner[vehicleid], playername, 0, strlen(playername), 255);
		PutPlayerInVehicle(playerid, vehicleid, 0);
		SavePlayerVehicleData(playerid);
		return 1;
	}
	return 1;
}

stock ReturnVehicleSlot(playerid)
{
	if(IsPlayerInAnyVehicle(playerid))
	{
		new
		    vehicleid = GetPlayerVehicleID(playerid),
		    var[32];
		    
		for(new s = 1; s <= MAX_OWNABLE_CARS; s++)
		{
			format(var, sizeof(var), "Carkey_%d", s);
	    	if(vehicleid == GetPVarInt(playerid, var)) return s;
		}
	}
	return 0;
}

stock ModifyVehicles(playerid)
{
	new vehicleid, var[32], colors[3];
	for(new s = 1; s <= MAX_OWNABLE_CARS; s++)
	{
	    format(var, sizeof(var), "Carkey_%d", s);
		vehicleid = GetPVarInt(playerid, var);
		if(vehicleid > 0)
		{
      		format(var, sizeof(var), "Paintjob_%d", s);
			if(GetPVarInt(playerid, var) != -1)
				ChangeVehiclePaintjob(vehicleid, GetPVarInt(playerid, var));

			format(var, sizeof(var), "Component1_%d", s);
			if(GetPVarInt(playerid, var) != 0)
				AddVehicleComponent(vehicleid, GetPVarInt(playerid, var));
			
			format(var, sizeof(var), "Component2_%d", s);
			if(GetPVarInt(playerid, var) != 0)
				ChangeVehiclePaintjob(vehicleid, GetPVarInt(playerid, var));

			format(var, sizeof(var), "Component3_%d", s);
			if(GetPVarInt(playerid, var) != 0)
				ChangeVehiclePaintjob(vehicleid, GetPVarInt(playerid, var));
			
			format(var, sizeof(var), "Component4_%d", s);
			if(GetPVarInt(playerid, var) != 0)
				AddVehicleComponent(vehicleid, GetPVarInt(playerid, var));

			format(var, sizeof(var), "Component5_%d", s);
			if(GetPVarInt(playerid, var) != 0)
				ChangeVehiclePaintjob(vehicleid, GetPVarInt(playerid, var));

			format(var, sizeof(var), "Component6_%d", s);
			if(GetPVarInt(playerid, var) != 0)
				ChangeVehiclePaintjob(vehicleid, GetPVarInt(playerid, var));

			format(var, sizeof(var), "Component7_%d", s);
			if(GetPVarInt(playerid, var) != 0)
				AddVehicleComponent(vehicleid, GetPVarInt(playerid, var));

			format(var, sizeof(var), "Component8_%d", s);
			if(GetPVarInt(playerid, var) != 0)
				ChangeVehiclePaintjob(vehicleid, GetPVarInt(playerid, var));

			format(var, sizeof(var), "Component9_%d", s);
			if(GetPVarInt(playerid, var) != 0)
				ChangeVehiclePaintjob(vehicleid, GetPVarInt(playerid, var));

			format(var, sizeof(var), "Component10_%d", s);
			if(GetPVarInt(playerid, var) != 0)
				AddVehicleComponent(vehicleid, GetPVarInt(playerid, var));

			format(var, sizeof(var), "Component11_%d", s);
			if(GetPVarInt(playerid, var) != 0)
				ChangeVehiclePaintjob(vehicleid, GetPVarInt(playerid, var));

			format(var, sizeof(var), "Component12_%d", s);
			if(GetPVarInt(playerid, var) != 0)
				ChangeVehiclePaintjob(vehicleid, GetPVarInt(playerid, var));

			format(var, sizeof(var), "Component13_%d", s);
			if(GetPVarInt(playerid, var) != 0)
				AddVehicleComponent(vehicleid, GetPVarInt(playerid, var));

			format(var, sizeof(var), "Component14_%d", s);
			if(GetPVarInt(playerid, var) != 0)
				ChangeVehiclePaintjob(vehicleid, GetPVarInt(playerid, var));

			format(var, sizeof(var), "Component15_%d", s);
			if(GetPVarInt(playerid, var) != 0)
				ChangeVehiclePaintjob(vehicleid, GetPVarInt(playerid, var));

			format(var, sizeof(var), "Component16_%d", s);
			if(GetPVarInt(playerid, var) != 0)
				AddVehicleComponent(vehicleid, GetPVarInt(playerid, var));

			format(var, sizeof(var), "Component17_%d", s);
			if(GetPVarInt(playerid, var) != 0)
				ChangeVehiclePaintjob(vehicleid, GetPVarInt(playerid, var));

			format(var, sizeof(var), "Color1_%d", s);
			colors[1] = GetPVarInt(playerid, var);
			
			format(var, sizeof(var), "Color2_%d", s);
			colors[2] = GetPVarInt(playerid, var);
			
			ChangeVehicleColor(vehicleid, colors[1], colors[2]);
		}
	}
	return 1;
}

stock UnloadVehicles(playerid)
{
	new
	    playername[24],
	    var[32];
	    
	GetPlayerName(playerid, playername, sizeof(playername));
	for(new i = 1; i < MAX_VEHICLES; i++)
	{
	    if(strcmp(owner[i], playername, true) == 0)
	    {
	        for(new s = 1; s <= MAX_OWNABLE_CARS; s++)
	        {
	            format(var, sizeof(var), "Carkey_%d", s);
	            if(GetPVarInt(playerid, var) == i)
	            {
	                DestroyVehicle(i);
				}
			}
		}
	}
	return 1;
}

stock DeleteVehicle(playerid, slot)
{
	new
	    var[32],
	    string[64],
	    slotstring[10],
	    vehicleid;
	    
	format(var, sizeof(var), "Carkey_%d", slot);
	vehicleid = GetPVarInt(playerid, var);

	format(var, sizeof(var), "Model_%d", slot);
	SetPVarInt(playerid, var, 0);
	
	format(var, sizeof(var), "X_%d", slot);
	SetPVarFloat(playerid, var, 0.0);

    format(var, sizeof(var), "Y_%d", slot);
	SetPVarFloat(playerid, var, 0.0);
	
	format(var, sizeof(var), "Z_%d", slot);
	SetPVarFloat(playerid, var, 0.0);
	
	format(var, sizeof(var), "Angle_%d", slot);
	SetPVarFloat(playerid, var, 0.0);

	format(var, sizeof(var), "Paintjob_%d", slot);
	SetPVarInt(playerid, var, 0);
	
	for(new i = 1; i <= 17; i++)
	{
		format(var, sizeof(var), "Component%d_%d", i, slot);
		SetPVarInt(playerid, var, 0);
	}

	format(var, sizeof(var), "Color1_%d", slot);
	SetPVarInt(playerid, var, 0);
	
	format(var, sizeof(var), "Color2_%d", slot);
	SetPVarInt(playerid, var, 0);
	
	SetPVarInt(playerid, var, 0);
	
	switch(slot)
	{
	    case 1: slotstring = "one";
	    case 2: slotstring = "two";
	}
	format(string, sizeof(string), "You have deleted your vehicle in slot %s.", slotstring);
	SendClientMessage(playerid, color_white, string);

	if(vehicleid > 0) { SetPVarInt(playerid, "AmountOfCars", GetPVarInt(playerid, "AmountOfCars") - 1); }

	DestroyVehicle(vehicleid);

	SavePlayerVehicleData(playerid);
	return 1;
}

GetVehicleName(vehicleid)
{
	new
		vehiclename[64] = "None";
		
	if(!vehicleid) return vehiclename;
 	format(vehiclename, sizeof(vehiclename), "%s", vehName[( GetVehicleModel(vehicleid) - 400 )]);
    return vehiclename;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
	dcmd(createdealer, 12, cmdtext);
	dcmd(destroydealer, 13, cmdtext);

	dcmd(buydealer, 9, cmdtext);
	dcmd(createcar, 9, cmdtext);
	dcmd(earnings, 8, cmdtext);
	dcmd(collectearnings, 15, cmdtext);
	dcmd(selldealership, 14, cmdtext);

	dcmd(park, 4, cmdtext);
	dcmd(delete, 6, cmdtext);
	dcmd(lock, 4, cmdtext);
	return 0;
}

stock sscanf(string[], format[], {Float,_}:...)
{
	#if defined isnull
		if (isnull(string))
	#else
		if (string[0] == 0 || (string[0] == 1 && string[1] == 0))
	#endif
		{
			return format[0];
		}
	#pragma tabsize 4
	new
		formatPos = 0,
		stringPos = 0,
		paramPos = 2,
		paramCount = numargs(),
		delim = ' ';
	while (string[stringPos] && string[stringPos] <= ' ')
	{
		stringPos++;
	}
	while (paramPos < paramCount && string[stringPos])
	{
		switch (format[formatPos++])
		{
			case '\0':
			{
				return 0;
			}
			case 'i', 'd':
			{
				new
					neg = 1,
					num = 0,
					ch = string[stringPos];
				if (ch == '-')
				{
					neg = -1;
					ch = string[++stringPos];
				}
				do
				{
					stringPos++;
					if ('0' <= ch <= '9')
					{
						num = (num * 10) + (ch - '0');
					}
					else
					{
						return -1;
					}
				}
				while ((ch = string[stringPos]) > ' ' && ch != delim);
				setarg(paramPos, 0, num * neg);
			}
			case 'h', 'x':
			{
				new
					num = 0,
					ch = string[stringPos];
				do
				{
					stringPos++;
					switch (ch)
					{
						case 'x', 'X':
						{
							num = 0;
							continue;
						}
						case '0' .. '9':
						{
							num = (num << 4) | (ch - '0');
						}
						case 'a' .. 'f':
						{
							num = (num << 4) | (ch - ('a' - 10));
						}
						case 'A' .. 'F':
						{
							num = (num << 4) | (ch - ('A' - 10));
						}
						default:
						{
							return -1;
						}
					}
				}
				while ((ch = string[stringPos]) > ' ' && ch != delim);
				setarg(paramPos, 0, num);
			}
			case 'c':
			{
				setarg(paramPos, 0, string[stringPos++]);
			}
			case 'f':
			{

				new changestr[16], changepos = 0, strpos = stringPos;
				while(changepos < 16 && string[strpos] && string[strpos] != delim)
				{
					changestr[changepos++] = string[strpos++];
    				}
				changestr[changepos] = '\0';
				setarg(paramPos,0,_:floatstr(changestr));
			}
			case 'p':
			{
				delim = format[formatPos++];
				continue;
			}
			case '\'':
			{
				new
					end = formatPos - 1,
					ch;
				while ((ch = format[++end]) && ch != '\'') {}
				if (!ch)
				{
					return -1;
				}
				format[end] = '\0';
				if ((ch = strfind(string, format[formatPos], false, stringPos)) == -1)
				{
					if (format[end + 1])
					{
						return -1;
					}
					return 0;
				}
				format[end] = '\'';
				stringPos = ch + (end - formatPos);
				formatPos = end + 1;
			}
			case 'u':
			{
				new
					end = stringPos - 1,
					id = 0,
					bool:num = true,
					ch;
				while ((ch = string[++end]) && ch != delim)
				{
					if (num)
					{
						if ('0' <= ch <= '9')
						{
							id = (id * 10) + (ch - '0');
						}
						else
						{
							num = false;
						}
					}
				}
				if (num && IsPlayerConnected(id))
				{
					setarg(paramPos, 0, id);
				}
				else
				{
					#if !defined foreach
						#define foreach(%1,%2) for (new %2 = 0; %2 < MAX_PLAYERS; %2++) if (IsPlayerConnected(%2))
						#define __SSCANF_FOREACH__
					#endif
					string[end] = '\0';
					num = false;
					new
						name[MAX_PLAYER_NAME];
					id = end - stringPos;
					foreach (Player, playerid)
					{
						GetPlayerName(playerid, name, sizeof (name));
						if (!strcmp(name, string[stringPos], true, id))
						{
							setarg(paramPos, 0, playerid);
							num = true;
							break;
						}
					}
					if (!num)
					{
						setarg(paramPos, 0, INVALID_PLAYER_ID);
					}
					string[end] = ch;
					#if defined __SSCANF_FOREACH__
						#undef foreach
						#undef __SSCANF_FOREACH__
					#endif
				}
				stringPos = end;
			}
			case 's', 'z':
			{
				new
					i = 0,
					ch;
				if (format[formatPos])
				{
					while ((ch = string[stringPos++]) && ch != delim)
					{
						setarg(paramPos, i++, ch);
					}
					if (!i)
					{
						return -1;
					}
				}
				else
				{
					while ((ch = string[stringPos++]))
					{
						setarg(paramPos, i++, ch);
					}
				}
				stringPos--;
				setarg(paramPos, i, '\0');
			}
			default:
			{
				continue;
			}
		}
		while (string[stringPos] && string[stringPos] != delim && string[stringPos] > ' ')
		{
			stringPos++;
		}
		while (string[stringPos] && (string[stringPos] == delim || string[stringPos] <= ' '))
		{
			stringPos++;
		}
		paramPos++;
	}
	do
	{
		if ((delim = format[formatPos++]) > ' ')
		{
			if (delim == '\'')
			{
				while ((delim = format[formatPos++]) && delim != '\'') {}
			}
			else if (delim != 'z')
			{
				return delim;
			}
		}
	}
	while (delim > ' ');
	return 0;
}
Reply
#2

@OnDialogResponse change:
pawn Код:
return 1;
->
pawn Код:
return 0;
Change that in all filterscripts to.
Reply
#3

I changed @OnDialogResponse
Код:
return 1;
to
Код:
return 0;
and still the same...the box dissapears.
Reply
#4

Do you changed it in all u filterscripts?
Reply
#5

How do you meen...should i change all return 1; to return 0; in this FS? or..
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)