CreateDealership (Server Lagging) issue
#4

Quote:
Originally Posted by VerticalGaming
Посмотреть сообщение
Show us your stocks, please.
- CreateCarDealership();
- DestroyCarDealership();
- CreateCarDealershipVehicle();
- DestroyCarDealershipVehicle();
- SavecDealership();
Here:

Код:
stock CreateCarDealership(Float: enx, Float: eny, Float: enz, Float: radius, price, message[])
{
	new dealershipid = GetFreeCarDealership();
	if(dealershipid == -1) return -1;
	new text_info[128];
	CarDealershipInfo[dealershipid][cdEntranceX] = enx;
	CarDealershipInfo[dealershipid][cdEntranceY] = eny;
	CarDealershipInfo[dealershipid][cdEntranceZ] = enz;
	CarDealershipInfo[dealershipid][cdRadius] = radius;
	CarDealershipInfo[dealershipid][cdPrice] = price;
	strmid(CarDealershipInfo[dealershipid][cdMessage], message, 0, strlen(message), 255);
	CarDealershipInfo[dealershipid][cdPickupID] = CreateDynamicPickup(1239, 1, CarDealershipInfo[dealershipid][cdEntranceX], CarDealershipInfo[dealershipid][cdEntranceY], CarDealershipInfo[dealershipid][cdEntranceZ]);
	format(text_info, sizeof(text_info), "Car Dealership %s For Sale\nPrice: %d\nRadius: %.1f", CarDealershipInfo[dealershipid][cdMessage], CarDealershipInfo[dealershipid][cdPrice], CarDealershipInfo[dealershipid][cdRadius]);
	CarDealershipInfo[dealershipid][cdTextLabel] = CreateDynamic3DTextLabel(text_info,COLOR_RED,CarDealershipInfo[dealershipid][cdEntranceX], CarDealershipInfo[dealershipid][cdEntranceY], CarDealershipInfo[dealershipid][cdEntranceZ]+0.75,3.0,INVALID_PLAYER_ID,INVALID_VEHICLE_ID,1);
	SavecDealership(dealershipid);
	return dealershipid;
}
Код:
stock DestroyCarDealership(dealershipid)
{
	new string[30];
	CarDealershipInfo[dealershipid][cdEntranceX] = 0.0;
	CarDealershipInfo[dealershipid][cdEntranceY] = 0.0;
	CarDealershipInfo[dealershipid][cdEntranceZ] = 0.0;
	CarDealershipInfo[dealershipid][cdRadius] = 0.0;
	CarDealershipInfo[dealershipid][cdTill] = 0;
	CarDealershipInfo[dealershipid][cdOwned] = 0;
	CarDealershipInfo[dealershipid][cdPrice] = 0;
	format(string, sizeof(string), "None");
	strmid(CarDealershipInfo[dealershipid][cdOwner], string, 0, strlen(string), 255);
	format(string, sizeof(string), "None");
	strmid(CarDealershipInfo[dealershipid][cdMessage], string, 0, strlen(string), 255);
	DestroyDynamic3DTextLabel(CarDealershipInfo[dealershipid][cdTextLabel]);
	DestroyDynamicPickup(CarDealershipInfo[dealershipid][cdPickupID]);
	CarDealershipInfo[dealershipid][cdPickupID] = 0;
	CarDealershipInfo[dealershipid][cdTextLabel] = Text3D:INVALID_3DTEXT_ID;
	CarDealershipInfo[dealershipid][cdVehicleSpawn][0] = 0.0;
	CarDealershipInfo[dealershipid][cdVehicleSpawn][1] = 0.0;
	CarDealershipInfo[dealershipid][cdVehicleSpawn][2] = 0.0;
	CarDealershipInfo[dealershipid][cdVehicleSpawn][3] = 0.0;
	for(new v = 0; v < MAX_DEALERSHIPVEHICLES; v++)
	{
		if (CarDealershipInfo[dealershipid][cdVehicleModel][v] != 0)
		{
			DestroyCarDealershipVehicle(dealershipid, v);
		}
	}
	SavecDealership(dealershipid);
}
Код:
stock GetFreeCarDealership()
{
	new
	i = 0;
	while (i < MAX_CARDEALERSHIPS && CarDealershipInfo[i][cdEntranceX] != 0.0 && CarDealershipInfo[i][cdEntranceY] != 0.0)
	{
		i++;
	}
	if (i == MAX_CARDEALERSHIPS) return -1;
	return i;

}
Код:
stock SetPlayerOwnerOfCD(playerid, dealershipid)
{
	new owner[MAX_PLAYER_NAME];
	CarDealershipInfo[dealershipid][cdOwned] = 1;
	GetPlayerName(playerid, owner, sizeof(owner));
	strmid(CarDealershipInfo[dealershipid][cdOwner], owner, 0, strlen(owner), 255);
	new text_info[128];
	format(text_info, sizeof(text_info), "Car Dealership %s\nOwner: %s\nRadius: %.1f", CarDealershipInfo[dealershipid][cdMessage], CarDealershipInfo[dealershipid][cdOwner], CarDealershipInfo[dealershipid][cdRadius]);
	UpdateDynamic3DTextLabelText(CarDealershipInfo[dealershipid][cdTextLabel], COLOR_GREEN, text_info);
	SavecDealership(dealershipid);
}
Код:
stock SellCarDealership(dealershipid)
{
	CarDealershipInfo[dealershipid][cdOwned] = 0;
	CarDealershipInfo[dealershipid][cdVehicleSpawn][0] = 0.0;
	CarDealershipInfo[dealershipid][cdVehicleSpawn][1] = 0.0;
	CarDealershipInfo[dealershipid][cdVehicleSpawn][2] = 0.0;
	CarDealershipInfo[dealershipid][cdVehicleSpawn][3] = 0.0;
	strmid(CarDealershipInfo[dealershipid][cdOwner], "No-one", 0, MAX_PLAYER_NAME, 255);
	new text_info[128];
	format(text_info, sizeof(text_info), "Car Dealership %s For Sale\nPrice: %d\nRadius: %.1f", CarDealershipInfo[dealershipid][cdMessage], CarDealershipInfo[dealershipid][cdPrice], CarDealershipInfo[dealershipid][cdRadius]);
	UpdateDynamic3DTextLabelText(CarDealershipInfo[dealershipid][cdTextLabel], COLOR_RED, text_info);
	SavecDealership(dealershipid);
}
'

Код:
stock CreateCarDealershipVehicle(dealershipid, modelid, Float: x, Float: y, Float: z, Float: a, price)
{
	new cdvehicleid = GetFreeCarDealershipVehicleId(dealershipid);
	if(cdvehicleid == -1) return -1;
	new text_info[128];
	CarDealershipInfo[dealershipid][cdVehicleModel][cdvehicleid] = modelid;
	CarDealershipInfo[dealershipid][cdVehicleCost][cdvehicleid] = price;
	CarDealershipInfo[dealershipid][cdVehicleSpawnX][cdvehicleid] = x;
	CarDealershipInfo[dealershipid][cdVehicleSpawnY][cdvehicleid] = y;
	CarDealershipInfo[dealershipid][cdVehicleSpawnZ][cdvehicleid] = z;
	CarDealershipInfo[dealershipid][cdVehicleSpawnAngle][cdvehicleid] = a;
	new carcreated = CreateVehicle(modelid, x, y, z, a, 0, 0, 6);
	format(text_info, sizeof(text_info), "%s For Sale | Price: %d", GetVehicleName(carcreated), CarDealershipInfo[dealershipid][cdVehicleCost][cdvehicleid]);
	CarDealershipInfo[dealershipid][cdVehicleLabel][cdvehicleid] = CreateDynamic3DTextLabel(text_info,COLOR_LIGHTBLUE,0.0, 0.0, 0.0,5.0,INVALID_PLAYER_ID,carcreated,1);
	CarDealershipInfo[dealershipid][cdVehicleId][cdvehicleid] = carcreated;
	SavecDealership(cdvehicleid);
	return cdvehicleid;
}
'

Код:
stock DestroyCarDealershipVehicle(dealershipid, cdvehicleid)
{
	CarDealershipInfo[dealershipid][cdVehicleModel][cdvehicleid] = 0;
	CarDealershipInfo[dealershipid][cdVehicleCost][cdvehicleid] = 0;
	CarDealershipInfo[dealershipid][cdVehicleSpawnX][cdvehicleid] = 0.0;
	CarDealershipInfo[dealershipid][cdVehicleSpawnY][cdvehicleid] = 0.0;
	CarDealershipInfo[dealershipid][cdVehicleSpawnZ][cdvehicleid] = 0.0;
	CarDealershipInfo[dealershipid][cdVehicleSpawnAngle][cdvehicleid] = 0.0;
	DestroyDynamic3DTextLabel(CarDealershipInfo[dealershipid][cdVehicleLabel][cdvehicleid]);
	DestroyVehicle(CarDealershipInfo[dealershipid][cdVehicleId][cdvehicleid]);
	CarDealershipInfo[dealershipid][cdVehicleLabel][cdvehicleid] = Text3D:INVALID_3DTEXT_ID;
	CarDealershipInfo[dealershipid][cdVehicleId][cdvehicleid] = 0;
}
Код:
stock GetFreeCarDealershipVehicleId(dealershipid)
{
	new
	i = 0;
	while (i < MAX_DEALERSHIPVEHICLES && CarDealershipInfo[dealershipid][cdVehicleModel][i] != 0)
	{
		i++;
	}
	if (i == MAX_DEALERSHIPVEHICLES) return -1;
	return i;

}
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)