Supported Games
Inspired by ZoneManager, ProtectedZone is a plugin that allows you to easily add as many zones as you want by simply standing in a location and typing /zone add. There are many features and more to come.
ToDo
Look into getting resources from salvage in a nodamage zone, and prefabs seem to give more resources.
Known Bugs
1. 2 zones overlapping causes enter/exit messages to not work properly, but otherwise work fine. The plugin does check if you're standing in a zone, and will not let you create another, but you can create one next to it and change the radius so it overlaps, so don't do that!
2. For some reason when using a treb, and a ballista is outside of the structure your attacking, it does 1500 damage to the structure(in a nodamage zone) if the blocks already have damage, none if the blocks are not damaged, I dont think this will not be an issue, but its weird.
3. Currently when "nodamage" is set to true the player cannot salvage a block, however they do get 1 resource on the first hit, after that none, there doesn't seem to be a fix for this.
Chat Commands
/zone help - Display the help menu
/zone add - Sets Zone where you stand
/zone list - Lists all zones
/zone remove - Removes zone
/zone info - Lists all Info and flags(must be in zone)
/zone edit - Edit zone values(must be in zone)
you can continue to enter after the first one, as many as you want. example:
/zone edit
Zone Flags/values:
**Can be changed with command /zone edit
radius : 20 is default, can be changed.
nopvp : true/false - no pvp damage
nobuild : true/false - cant place blocks or Crest
nodamage : true/false - nodamage to blocks
nodecay : true/false - only works on prefabs
nosleeperdamage : true/false
nocrestdamage : true/false
noroping : true/false
nopve : true/false - no animal/villager damage from or to player
noprefabdamage : true/false
noprefabplace : true/false
ejectplayer : true/false - ZoneCheckOn must be true
ejectsleeper : true/false - ejects a sleeper if they fall asleep in a zone(log)
messageon : true/false - a repeating message only in zone
entermessageon : true/false - on enter zone
exitmessageon : true/false - on exit zone
zonemessage : "message" - repeating message
entermessage : "message"
exitmessage : "message"
Additional Flags available if AntiLoot is Loaded:
nochestlooting: true/false
nostationlooting: true/false
nocampfirelooting: true/false
nofireplacelooting: true/false
notorchlooting: true/false
nofurniturelooting: true/false
novillagerlooting: true/false
Configuration
{
"AdminCanBuild": true,
"AdminCanKill": true,
"CrestCheckOn": false,
"MessageInterval": 100.0,
"MessagesOn": false,
"UseAntiLoot": false,
"ZoneCheckInterval": 1.0,
"ZoneCheckOn": false
}
ProtectedZone checks for admins and allows them to build and kill players in any zone, change the config setting to false if you dont want this
**"CrestCheckOn" **simply allows a player with a crest in a noBuildZone to build as normal, default is off(false).
MessagesOn and ZoneCheckOn need to both be set to true for the in zone messages to work, I used a timer to check if a player is in a zone, and I was worried it may cause lag on a busy server, but you can adjust the timers(above). Its all been working ok for me, but I have not tested on a busy server.
*Note: MessagesOn and ZoneCheckOn do not need to be true for the plugin to work, if they are not true the in zone messages will not work, but the plugin still checks player location through an event, like OnCubeplacement, so everything else will work as normal. *
Localization
API Usage
API:
(bool) NewZone(string[] args, Player player = null) //Create a Zone from an external plugin
// args[0] = "zone name"
// args[1] = "Vector3 or if player types "here""
// Returns true if the zone is saved, else returns false
(bool) RemoveZone(string ZoneId) //Erase a zone by ZoneID. // Returns true if the zone was removed or false if it doesn't exist.
(bool) IsPlayerInZone(Player player) //Returns true if the player is in a zone, otherwise returns false.
(bool) EditZone(string zoneId, string[] args) //allows editing of the zone flags/options of the specified zone.
(object) GetZoneName(string zoneId) //Returns the zone name (string), or null if the zone does not exist.
(object) GetZoneId(Player player) //Returns the zone ID (string) if it exists, or null if the zone does not exist.
(bool) HasFlag(string zoneId, string zoneFlag) //checks if the specified zone has the specified flag, returns true if zone has flag, otherwise false.
(void) AddFlag(string zoneId, string zoneFlag)//adds Flag(string) to a list in the specified zone
(void) RemoveFlag(string zoneId, string zoneFlag)//Removes Flag(string) from the list in the specified zone
Example code:
var zoneId = TryGetZoneId(player);
var zoneFlag = "nodamage";
if (isInZone(player))
{
if (hasFlag(zoneId.ToString(), zoneFlag))
SendReply(player, "Has nodamage flag!");
}
bool isInZone(Player player)
{
return (bool)ProtectedZone.Call("IsPlayerInZone", player);
}
bool hasFlag(string zoneId, string zoneFlag)
{
return (bool)ProtectedZone.Call("HasFlag", zoneId, zoneFlag);
}
object TryGetZoneId(Player player)
{
return ProtectedZone.Call("GetZoneId", player);
}
//AddFlag and RemoveFlag simply add a string to the list "Flags" in the zone specified so you can check that zone for that "Flag" later.
void AddFlag(string zoneId, string flagString)
{
ProtectedZone.Call("AddFlag", zoneId, flagString);
}
void RemoveFlag(string zoneId, string flagString)
{
ProtectedZone.Call("RemoveFlag", zoneId, flagString);
}
See AntiLoot for a good example of this.
Credits
Everyone on these forums really deserves credit, as I have scoured these forums and learned a lot. This plugin was developed by looking at the Assembly-CSharp.DLL, as well as some of the older plugins on here that use zones, as well as ZoneManager(Rust) and NoAttackZone.
The original author may request that this plugin be removed and there is a risk that the plugin may be unavailable in the future.
Note that the current maintainer may not have permission to assign a license to the plugin if they are not the original author, so explicit permission would need to be obtained from the original author in order for the plugin to remain openly available and guarantee that it will be around for all to enjoy going forward.

