Best way to conquer a zone - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Best way to conquer a zone (
/showthread.php?tid=626244)
Best way to conquer a zone -
TheMasterNico - 12.01.2017
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?
Re: Best way to conquer a zone -
Vince - 12.01.2017
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.
Re: Best way to conquer a zone -
Awide - 12.01.2017
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.
Respuesta: Best way to conquer a zone -
TheMasterNico - 12.01.2017
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
Re: Best way to conquer a zone -
darkdrago - 12.01.2017
I would use a global timer with a foreach loop, but it's just my opinion