Hey.
I'm making a plugin for an event and I need to check every second what players are in a zone between to points.
Say you have PointA at 100, 100, 100 and PointB at -100, 0, -100. I need to be able to check what players are in that region every second so I can award them points.
I've tried searching around but I can't find anything so I hope you can help.
Thanks, PsychoTea
Check if player is in region
Discussion in 'Rust Development' started by PsychoTea, Sep 1, 2015.
-
If the region can be a sphere you could use Zone manager.
-
Yes this plugin was made for exactly those situations ^^
If you need exemples on how to implement it you have all the plugins that require it: (Hotel, EventManager, etc)
And you can ask here i'll gladly help
[DOUBLEPOST=1441091137][/DOUBLEPOST]ZoneManager can be used just to detect players in zone, No need to set any options
-
use Vector3.Distance(pos1, pos2)
-
Ah ok, could you give me a few examples of how to use it please?
-
I can give you an example about Vector3.Distance ...
if(Vector3.Distance(player.transform.position, target.transform.position) < radius)
{
//Your stuff
} -
Ah I see. That's working around a center point. I will try that, thanks.
EDIT: although how would I check which players are in that zone every second? ZoneManager has an event for it... -
pain this is not the best way to do it ^^ especially if you have a lot of players
i'll make you something when i can -
Don't worry, I've got that, I just have 2 questions.
1) Here is my code:
For some reason, I get the error:Code:void Unload() { ZoneManager.Call("EraseZone", "hill1"); ZoneManager.Call("EraseZone", "hill2"); ZoneManager.Call("EraseZone", "hill3"); ZoneManager.Call("EraseZone", "hill4"); ZoneManager.Call("EraseZone", "hill5"); ZoneManager.Call("EraseZone", "KingSpawn"); }
Do you know how I could fix that?Code:[Error] Failed to call hook 'Unload' on plugin 'KingoftheHill v1.0.0' (NullReferenceException: Object reference not set to an instance of an object)
2) When specifying a zone via the commands of your plugin, it creates a red circle around the circunference of the zone. Is there a way I can use that in my plugin for when you're creating a zone? Eg a hook or even the source code to do it?
Thanks, PsychoTea (Ben) -
thats how Im using it in my Portals
