Does this timer will cause lag of the entire server?
#1

Hi, I just coded this for my Furnace System.

here is the code I use y_timer
Код:
task FurnaceTimer[1000]()
{
	for(new x = 0; x < MAX_BASES; x++)
	{
		if(BaseData[x][baseCreated])
		{
			if(BaseData[x][baseTotalFurnace] != 0)
			{
				for(new y = 0; y < MAX_BASEOBJECTS; y++)
				{
					if(BaseObjectData[x][y][oID] != INVALID_OBJECT_ID && BaseObjectData[x][y][oFurnace] && BaseObjectData[x][y][oFurnaceStatus])
					{
						if(BaseFurnaceData[x][y][furnaceMainItem] != -1 && BaseFurnaceData[x][y][furnaceSecondItem] != -1 || BaseFurnaceData[x][y][furnaceSecondItem] != -1)
						{
							if(BaseFurnaceData[x][y][furnaceSItemQuantity] < 2) return 1;
							if(++BaseObjectData[x][y][oFurnaceTimer] >= 120)
							{
								if(BaseFurnaceData[x][y][furnaceMainItem] != -1 && BaseFurnaceData[x][y][furnaceSecondItem] != -1)
								{
									BaseFurnaceData[x][y][furnaceMItemQuantity]--;
									switch(BaseFurnaceData[x][y][furnaceMainItem])
									{
										case ITEM_IRON:
										{
											if(BaseFurnaceData[x][y][furnaceFinalItem] != ITEM_IRON) return 1;
											BaseFurnaceData[x][y][furnaceFinalItem] = ITEM_IRONBAR;
											BaseFurnaceData[x][y][furnaceFItemQuantity]++;
										}
										case ITEM_BLUEIRON:
										{
											if(BaseFurnaceData[x][y][furnaceFinalItem] != ITEM_BLUEIRON) return 1;
											BaseFurnaceData[x][y][furnaceFinalItem] = ITEM_BLUEIRONBAR;
											BaseFurnaceData[x][y][furnaceFItemQuantity]++;

										}
										case ITEM_REDIRON:
										{
											if(BaseFurnaceData[x][y][furnaceFinalItem] != ITEM_REDIRON) return 1;
											BaseFurnaceData[x][y][furnaceFinalItem] = ITEM_REDIRONBAR;
											BaseFurnaceData[x][y][furnaceFItemQuantity]++;

										}
									}
								}
								BaseFurnaceData[x][y][furnaceSItemQuantity] -= 2;
								BaseObjectData[x][y][oFurnaceTimer] = 0;
							}
						}
						else BaseObjectData[x][y][oFurnaceStatus] = 0;
					}
				}
				
			}
		}
	}
        return 1;
}
will this code cause lags? if there are hundred of bases and hundred of base furnace objects? if Yes how I can optimize this?
Reply
#2

Oh the styling of code ...
What is the purpose of this could you tell us so maybe we can give you a better code?
Reply
#3

Quote:
Originally Posted by whadez
Посмотреть сообщение
Oh the styling of code ...
What is the purpose of this could you tell us so maybe we can give you a better code?
every 2mins it will produce a new material. hmm not being rude here xD

The code there stated what i wanted to be. I'm not quite sure if this code or way of coding will cause lag.
Uhm how do I explain this lol. As you can see the code there every two minutes will produce new material.

Also It loops through all Bases created in the server and Furnaces In the server.

So meaning if there are hunred of bases this code will loop it all same goes to furnace
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)