CreateDealership (Server Lagging) issue
#1

Hi,
When i tried to create a NEW dealership at my server. it makes my server lag even in creating/deleting car in the dealership like /createcdveh I think you guys experinced this issue too?. But others can fix it.

Is there any way to fix it ?

Here is my /createdealership code
Код:
CMD:createdealership(playerid, params[])
{
	if (PlayerInfo[playerid][pAdmin] < 1337)
	{
		SendClientMessageEx(playerid, COLOR_GREY, " You are not allowed to use this command.");
		return 1;
	}

	new string[128], price, radius, message[64];
	if(sscanf(params, "dds[64]", price, radius, message)) return SendClientMessageEx(playerid, COLOR_WHITE, "USAGE: /createdealership [price] [radius] [message]");

	new Float:X,Float:Y,Float:Z;
	GetPlayerPos(playerid,X,Y,Z);
	new dealershipid = CreateCarDealership(X, Y, Z, radius, price, message);
	if(dealershipid == -1)
	{
		SendClientMessageEx(playerid, COLOR_GREY, "ERROR: Car Dealerships limit reached.");
	}
	else
	{
		format(string, sizeof(string), " Car Dealership created with ID %d.", dealershipid);
		SendClientMessageEx(playerid, COLOR_GRAD1, string);
	}
	return 1;
}
Код:
CMD:destroydealership(playerid, params[])
{
	if (PlayerInfo[playerid][pAdmin] < 1337)
	{
		SendClientMessageEx(playerid, COLOR_GREY, " You are not allowed to use this command.");
		return 1;
	}

	new string[128], dealershipid;
	if(sscanf(params, "d", dealershipid)) return SendClientMessageEx(playerid, COLOR_WHITE, "USAGE: /destroydealership [dealershipid]");

	for(new d = 0 ; d < MAX_CARDEALERSHIPS; d++)
	{
		if(IsPlayerInRangeOfPoint(playerid, 3.0, CarDealershipInfo[d][cdEntranceX], CarDealershipInfo[d][cdEntranceY], CarDealershipInfo[d][cdEntranceZ]))
		{
			DestroyCarDealership(d);
			format(string, sizeof(string), " Car Dealership destroyed with ID %d.", d);
			SendClientMessageEx(playerid, COLOR_GRAD1, string);
			return 1;
		}
	}
	if(dealershipid > MAX_CARDEALERSHIPS) return 1;
	if(dealershipid < 0) return 1;
	DestroyCarDealership(dealershipid);
	format(string, sizeof(string), " Car Dealership destroyed with ID %d.", dealershipid);
	SendClientMessageEx(playerid, COLOR_GRAD1, string);
	return 1;
}
Код:
CMD:createcdveh(playerid, params[])
{
	if (PlayerInfo[playerid][pAdmin] < 1337)
	{
		SendClientMessageEx(playerid, COLOR_GREY, " You are not allowed to use this command.");
		return 1;
	}

	new string[128], price, dealershipid, modelid;
	if(sscanf(params, "ddd", price, dealershipid, modelid)) return SendClientMessageEx(playerid, COLOR_WHITE, "USAGE: /createcdveh [price] [dealership] [modelid]");

	new Float:X,Float:Y,Float:Z,Float:A;
	GetPlayerPos(playerid,X,Y,Z);
	GetPlayerFacingAngle(playerid, A);
	new cdvehicleid = CreateCarDealershipVehicle(dealershipid, modelid, X, Y, Z, A, price);
	if(cdvehicleid == -1)
	{
		SendClientMessageEx(playerid, COLOR_GREY, "ERROR: cdVehicles limit reached.");
	}
	else
	{
		format(string, sizeof(string), " Car Dealership Vehicle created with ID %d.", cdvehicleid);
		SendClientMessageEx(playerid, COLOR_GRAD1, string);
	}
	return 1;
}
Код:
CMD:destroycdveh(playerid, params[])
{
	if (PlayerInfo[playerid][pAdmin] < 1337)
	{
		SendClientMessageEx(playerid, COLOR_GREY, " You are not allowed to use this command.");
		return 1;
	}

	new string[128], vehid;
	if(sscanf(params, "d", vehid)) return SendClientMessageEx(playerid, COLOR_WHITE, "USAGE: /destroycdveh [vehicleid]");

	DestroyCarDealershipVehicle(GetCarDealershipId(vehid), GetCarDealershipVehicleId(vehid));
	SavecDealership(GetCarDealershipId(vehid));
	format(string, sizeof(string), " Car Dealership Vehicle destroyed with ID %d.", vehid);
	SendClientMessageEx(playerid, COLOR_GRAD1, string);
	return 1;
}
Reply
#2

Are you using Dini As saving system ? cause that might be the first place to start, it lags, and it is slow to read and write...
Reply
#3

Show us your stocks, please.
- CreateCarDealership();
- DestroyCarDealership();
- CreateCarDealershipVehicle();
- DestroyCarDealershipVehicle();
- SavecDealership();
Reply
#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
#5

Show us SaveCdDealership stock.
Reply
#6

Quote:
Originally Posted by Stanford
Посмотреть сообщение
Show us SaveCdDealership stock.
I dont have that saveCDDealership
Reply
#7

bump
Reply
#8

Quote:
Originally Posted by ChristianIvann09
Посмотреть сообщение
bump!
Your question isn't more important than anyone elses..

On topic, if you're running the server off a local machine it's probably having trouble creating files etc.. As you're obviously using a massive script.
Reply
#9

Quote:
Originally Posted by (*|Flake|*)
Посмотреть сообщение
Your question isn't more important than anyone elses..

On topic, if you're running the server off a local machine it's probably having trouble creating files etc.. As you're obviously using a massive script.
Quote:
Originally Posted by ChristianIvann09
Посмотреть сообщение
bump!
Quote:
Originally Posted by ChristianIvann09
Посмотреть сообщение
bump
In other words, what he's trying to say is;
stop being a pleb copying another script and claiming it for your own personal gain and learn to script by starting from scratch you plebian.
Reply
#10

Quote:
Originally Posted by [ED]Drix
Посмотреть сообщение
In other words, what he's trying to say is;
stop being a pleb copying another script and claiming it for your own personal gain and learn to script by starting from scratch you plebian.
Agh he gets me. Maybe ask the legit creators?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)