Jump to content

[HELP] ColShape + Events or Timer + Table


Recommended Posts

I need to check is player in certain zone, which variant is more optimized?

1. Usage of ColShape: creating ColShapes as zones and using hit/leave events

2. Timer (500 ms) which checks if player position in boundaries (zone bounds will be defined in table)

It will be a lot of areas where player can be, so what way more efficient to not loose bandwidth?

Link to comment
  • Moderators
2 hours ago, Thomas_Nightfire said:

I need to check is player in certain zone, which variant is more optimized?

A combination.

- hit events is for starting the timer.

- The timer is used to check if everybody is inside of the colshape meets all the criteria. Like if everybody is still alive or inside of a vehicle.

 

2 hours ago, Thomas_Nightfire said:

to not loose bandwidth?

For a basic script, bandwidth is only used when a player hits or leaves a colshape. You do not have control over that, since it is always working even if you do not add eventHandlers.

But keep in mind that if you use that timer to synchronize the same information over and over, sure that can be bad.

 

 

  • Thanks 1
Link to comment
25 minutes ago, IIYAMA said:

A combination.

- hit events is for starting the timer.

- The timer is used to check if everybody is inside of the colshape meets all the criteria. Like if everybody is still alive or inside of a vehicle.

 

For a basic script, bandwidth is only used when a player hits or leaves a colshape. You do not have control over that, since it is always working even if you do not add eventHandlers.

But keep in mind that if you use that timer to synchronize the same information over and over, sure that can be bad.

 

 

I'm creating script that creates weather regions and when player enters one of them, weather will change. What your advice how to do it more optimized way (using less memory, creating less lags)?

I thought creating a lot of ColShapes and working with hit/leave events is a waste of memory, no?
 

Link to comment
  • Moderators
12 hours ago, Thomas_Nightfire said:

I thought creating a lot of ColShapes and working with hit/leave events is a waste of memory, no?

Should be fine. As long as you do not over do it.

Note: The position X and Y can also be used for the weather.

Edited by IIYAMA
Link to comment
  • 4 weeks later...
  • Moderators
58 minutes ago, Thomas_Nightfire said:

I need to create about 500 colshapes or more...

In that case you can better use the X and Y position.

For example working with chunks, like Minecraft does:

local chunkSize = 50


function convertPositionToChunk (x, y)
	x = x + 3000
	y = y + 3000
	if x > 0 and x <= 6000 and y > 0 and y <= 6000 then
		return math.ceil(x / chunkSize), math.ceil(y / chunkSize)        
	end
 	return false -- not in a chunk = out of the map
end



print(convertPositionToChunk (100, 200))

 

Or use this to make your 500 colshapes. If you really want to know if it is an issue, then just test with a potato laptop.

 

 

 

 

  • Like 1
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...