2020-09-30, 10:12 PM
(This post was last modified: 2020-09-30, 10:15 PM by JaKe Elite.)
Hi!?
It's my first time posting here but I would like to know is there any possibilities that I can optimize this code? It causes a huge lag spike in the server when used in a live server. It occurs when this loop is called when removing a furniture/land object or removing the entire furniture/land object.?(This also happens when the script has to reload the furniture/land object)
The lag can also be noticed?when deleting a house (which removes all the furniture in the process)
Things to know; My server has 16,000 objects so it is no surprise that the loop will check each single objects in the server.
I will be showing the functions (codes) that calls the loop:
I will be editing this thread if more codes are needed.
It's my first time posting here but I would like to know is there any possibilities that I can optimize this code? It causes a huge lag spike in the server when used in a live server. It occurs when this loop is called when removing a furniture/land object or removing the entire furniture/land object.?(This also happens when the script has to reload the furniture/land object)
The lag can also be noticed?when deleting a house (which removes all the furniture in the process)
Things to know; My server has 16,000 objects so it is no surprise that the loop will check each single objects in the server.
I will be showing the functions (codes) that calls the loop:
PHP Code:
RemoveFurniture(objectid)
{
? ? if(IsValidDynamicObject(objectid) && Streamer_GetExtraInt(objectid, E_OBJECT_TYPE) == E_OBJECT_FURNITURE)
{
new
? ? ? ? id = Streamer_GetExtraInt(objectid, E_OBJECT_INDEX_ID);
? ? DeleteFurnitureObject(objectid);
? ? mysql_format(mysql_connection, queryBuffer, sizeof(queryBuffer), "DELETE FROM furniture WHERE id = %i", id);
? ? mysql_tquery(mysql_connection, queryBuffer);
}
}
DeleteFurnitureObject(objectid)
{
if(IsValidDynamicObject(objectid) && Streamer_GetExtraInt(objectid, E_OBJECT_TYPE) == E_OBJECT_FURNITURE)
{
? ? new Text3D:textid = Text3D:Streamer_GetExtraInt(objectid, E_OBJECT_3DTEXT_ID);
? ? ? ? if(IsValidDynamic3DTextLabel(textid))
? ? ? ? {
? ? ? ? ? ? DestroyDynamic3DTextLabel(textid);
? ? ? ? }
? ? ? ? DestroyDynamicObject(objectid);
}
}
RemoveAllFurniture(houseid)
{
? ? if(HouseInfo[houseid][hID] > 0)
{
? ? for(new i = 0; i <= Streamer_GetUpperBound(STREAMER_TYPE_OBJECT); i )
? ? {
? ? ? ? if(IsValidDynamicObject(i) && Streamer_GetExtraInt(i, E_OBJECT_TYPE) == E_OBJECT_FURNITURE && Streamer_GetExtraInt(i, E_OBJECT_EXTRA_ID) == HouseInfo[houseid][hID])
? ? ? ? {
? ? ? ? ? ? DeleteFurnitureObject(i);
}
}
mysql_format(mysql_connection, queryBuffer, sizeof(queryBuffer), "DELETE FROM furniture WHERE houseid = %i", HouseInfo[houseid][hID]);
mysql_tquery(mysql_connection, queryBuffer);
}
}
ReloadFurniture(objectid, labels)
{
if(IsValidDynamicObject(objectid) && Streamer_GetExtraInt(objectid, E_OBJECT_TYPE) == E_OBJECT_FURNITURE)
{
? ? new
? ? ? ? id = Streamer_GetExtraInt(objectid, E_OBJECT_INDEX_ID);
? ? DeleteFurnitureObject(objectid);
? ? mysql_format(mysql_connection, queryBuffer, sizeof(queryBuffer), "SELECT * FROM furniture WHERE id = %i", id);
? ? mysql_tquery(mysql_connection, queryBuffer, "SQL_LoadFurnitures", "i", labels);
}
}
ReloadAllFurniture(houseid)
{
? ? if(HouseInfo[houseid][hID] > 0)
{
? ? for(new i = 0; i <= Streamer_GetUpperBound(STREAMER_TYPE_OBJECT); i )
? ? {
? ? ? ? if(IsValidDynamicObject(i) && Streamer_GetExtraInt(i, E_OBJECT_TYPE) == E_OBJECT_FURNITURE && Streamer_GetExtraInt(i, E_OBJECT_EXTRA_ID) == HouseInfo[houseid][hID])
? ? ? ? {
? ? ? ? ? ? DeleteFurnitureObject(i);
}
}
mysql_format(mysql_connection, queryBuffer, sizeof(queryBuffer), "SELECT * FROM furniture WHERE houseid = %i", HouseInfo[houseid][hID]);
mysql_tquery(mysql_connection, queryBuffer, "SQL_LoadFurnitures", "i", HouseInfo[houseid][hLabels]);
}
}
I will be editing this thread if more codes are needed.