• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Lua How to check which scripts chewing server preformence?

Printer

if Printer then print("LUA") end
Senator
Premium User
Joined
Dec 27, 2009
Messages
5,780
Solutions
31
Reaction score
2,299
Location
Sweden?
Yo,

as the title says. I always wonder how to check it?
 
I will use this thread if it is okay. I wonder if checking an area each 10 second is considered to be chewing server performance? I am using it as a part for a last-man-standing event (credits to teckman for the loops)
The area is not wide (total of 2240 tiles)

Here is the part of the script that checks:

LUA:
	cfg = {
		[1] = {x = 32109, y = 32552, z = 11},
		[2] = {x = 32164, y = 32591, z = 11}
	}
	
	player = {}
	
	for x = cfg.area[1].x, cfg.area[2].x do
		for y = cfg.area[1].y, cfg.area[2].y do
			for z = cfg.area[1].z, cfg.area[2].z do
				if(isPlayer(getTopCreature({x=x, y=y, z=z}).uid) == 1) then
					table.insert(player, getTopCreature({x=x, y=y, z=z}).uid)
				end
			end
		end
	end

LUA:
config = {
	centerPos = {x = , y = , z = },
	rangeX = ,
	rangeY = ,
}

players = {}
for _, cid in pairs(getSpectators(config.centerPos, config.rangeX, config.rangeY)) do
	if(isPlayer(cid)) then
		table.insert(players, cid)
	end
end

IMO more efficient.
 
LUA:
config = {
	centerPos = {x = , y = , z = },
	rangeX = ,
	rangeY = ,
}

players = {}
for _, cid in pairs(getSpectators(config.centerPos, config.rangeX, config.rangeY)) do
	if(isPlayer(cid)) then
		table.insert(players, cid)
	end
end

IMO more efficient.


I believe you but I am just wondering what makes this more efficient, thinking of converting all of my scripts to this format
 
Back
Top