Best way to conquer a zone
#1

Hello all.

I try made a conquer script. But i have question. What is the best way to conquer a zone?

First: Use a SetTimer like ZoneUpdate and make a loop for all zones and check the time of players inside in zone and conquer area.

PHP код:
public ZoneUpdate()
{
Loop all zones
Check 
if zone have player inside
Check 
if Player inside
Check 
if player is in mode 'conquer zone'
Check the time of player inside with a var++
Check if time inside is the neccessary
conquer the zone

Second: Use OnPlayerUpdate for playerid and check if player is still in zone when time inside

PHP код:
public OnPlayerUpdate(playerid)
{
Check if player is in mode 'conquer zone'
Check if player is insde a zone with a variable
Check the time with gettime of player inside
Check 
if time inside is the neccessary
Conquer the zone

What is the best way and why the other no?
What are the pros and cons of both in this case?
Reply
#2

How is this "conquer mode" triggered? Is it activated upon entering the zone? It seems silly to run continues timer when the actual action only starts when a player is in "conquer mode". In any case I recommend using the Streamer plugin's dynamic areas. Those callbacks make it very easy to track when someone enters and leaves a zone. Perhaps there's also a function to count the number of players in a zone, but I'm not sure about that.
Reply
#3

If you refrain from using Streamer make a timer that's clicking every second for the first method, because that's way better for your hardware than using OnPlayerUpdate.
Reply
#4

Yes. For the zones i use streamer's area for controlling the in the area players and use OnPlayerEnterArea for the 'conquer mode' like PlayerInArea[playerid] = areaid and PlayerInConquer[playerid] = true

Then, is best for hardware and speed use one timer instead OnPlayerUpdate
Reply
#5

I would use a global timer with a foreach loop, but it's just my opinion
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)