Restriction Zones

Approved Restriction Zones 1.3.1

No permission to download

MasterPeace

Retired Staff
Retired Staff
Feb 2, 2015
269
69
28
45
Poland
MasterPeace submitted a new resource:

Restriction Zones - Create zones in Fougerite Rust Legacy

Description

Requested long time ago Zone Creator plugin. You can use it to disable building in some places like Rads or Admin bases. You can disable PvP also.

Plugin is still in development.

Usage

/zone - Help
/zone set [name] [radius] [building:eek:n] [pvp:eek:n] - Create zone
eg. /zone set BeautifulZone 20 off on
/zone edit [name] [radius] - Edit zone
/zone check [name] - Check coordinates and...
Read more about this resource...
 

MasterPeace

Retired Staff
Retired Staff
Feb 2, 2015
269
69
28
45
Poland
Looks like I'm getting NullReferenceException after deleting entity and can do nothing about that.

Next update will be after I get answer from Snake how to use Timers in C# ;)

Then last thing to do will be PvP enable/disable but I'll leave it for later, because it will be tricky.
 

DreTaX

Probably knows the answer...
Administrator
Jun 29, 2014
4,095
4,815
113
At your house.
github.com
Looks like I'm getting NullReferenceException after deleting entity and can do nothing about that.

Next update will be after I get answer from Snake how to use Timers in C# ;)

Then last thing to do will be PvP enable/disable but I'll leave it for later, because it will be tricky.
About timers I can't explain a lot atm, but getting an instance is usually:

ClassName varname = new ClassName();

Most of the fougerite classes have something like this:

https://github.com/Notulp/Fougerite/blob/master/Fougerite/Fougerite/Server.cs#L75
 

MasterPeace

Retired Staff
Retired Staff
Feb 2, 2015
269
69
28
45
Poland
MasterPeace updated Restriction Zones with a new update entry:

Allow/Disallow admins + Distance check

PVP not going well as with Rust, Unity, all those crazy float shit (I mean variables), and it will be a little bit tricky... Well. Like Always. But:

- I added Allow / Disallow for Admins to build (config).
- Fixed Entity names - no NullReferenceError from now.
- I will not make Timer Warning as it will need to create list of players and we already know that it may cause some errors.
- New command: /zone distance [zonename].

With new command creating zone will be even easier, as you can just...
Read the rest of this update entry...
 

MasterPeace

Retired Staff
Retired Staff
Feb 2, 2015
269
69
28
45
Poland
What are your doubts :) If you want prove of work I can make video - but yes. I never tested it on online server. But what.. No reports of errors, so I guess its' working.
 

MasterPeace

Retired Staff
Retired Staff
Feb 2, 2015
269
69
28
45
Poland
I found a bug when I was recording clip (I didn't uploaded clip because I realized that I wasted too many time to record it and was mad, anyway, again)

I found some bugs:
1. Wrong entity name for shelter. I fixed it on my release, but didn't uploaded yet as it's too small update, not worth.
2. Wrong instruction in chat - I will not use IDs to delete/edit zones. Just names. I fixed it too.

Now I'm preparing myself to go back to Visual Studio and end PvP functionality. I still don't know how to do it best. Only way what was always working for me is to heal player after he get shot. But there was problem that Rust is not limiting your health and when I did something wrong I was getting like 189156 health after 5 minutes of staying on spikes.

Anyway.

Plugin will work in way:
a) Hurt player will receive 100% of damage back to health
or
b) Hurt player will receive 95-99% of damage back to health

It will work only on players vs players hurt. I will try to also heal entities, but you will never heal critical hit.

I think I will work on it tomorrow or on Tuesday and after that I will never go back to it.
 

DreTaX

Probably knows the answer...
Administrator
Jun 29, 2014
4,095
4,815
113
At your house.
github.com
I found a bug when I was recording clip (I didn't uploaded clip because I realized that I wasted too many time to record it and was mad, anyway, again)

I found some bugs:
1. Wrong entity name for shelter. I fixed it on my release, but didn't uploaded yet as it's too small update, not worth.
2. Wrong instruction in chat - I will not use IDs to delete/edit zones. Just names. I fixed it too.

Now I'm preparing myself to go back to Visual Studio and end PvP functionality. I still don't know how to do it best. Only way what was always working for me is to heal player after he get shot. But there was problem that Rust is not limiting your health and when I did something wrong I was getting like 189156 health after 5 minutes of staying on spikes.

Anyway.

Plugin will work in way:
a) Hurt player will receive 100% of damage back to health
or
b) Hurt player will receive 95-99% of damage back to health

It will work only on players vs players hurt. I will try to also heal entities, but you will never heal critical hit.

I think I will work on it tomorrow or on Tuesday and after that I will never go back to it.
How do you store the Zones? I might able to help you with that.

Btw, there is no need to heal.

HurtEvent.DamageAmount = 0
 
  • Agree
Reactions: hunternope3

MasterPeace

Retired Staff
Retired Staff
Feb 2, 2015
269
69
28
45
Poland
How do you store the Zones? I might able to help you with that.

Btw, there is no need to heal.

HurtEvent.DamageAmount = 0
I will try that DamageAmount again but I did that like 5 times in my life and it was never working. But I will check again to be sure and don't waste time.

About storing zones:
Code:
[Zones]
hangar=hangar

[Location]
hangar_X=6636.477
hangar_Y=350.2296
hangar_Z=-4332.621

[Radius]
hangar=45

[Building]
hangar=off

[PvP]
hangar=on
So first time I thought I will make new tab [ZonesIDs] and write there "zonename=id" - and then I realized that it's getting out of logic. So "id=zonename" would be good.

Code:
if (zonename is numeric) { find zone name of id and do something }
Well. Maybe I will do that if I will have time. But it will need some last id checker etc and I'm too lazy. I think PVP is more important.
 

DreTaX

Probably knows the answer...
Administrator
Jun 29, 2014
4,095
4,815
113
At your house.
github.com
I will try that DamageAmount again but I did that like 5 times in my life and it was never working. But I will check again to be sure and don't waste time.

About storing zones:
Code:
[Zones]
hangar=hangar

[Location]
hangar_X=6636.477
hangar_Y=350.2296
hangar_Z=-4332.621

[Radius]
hangar=45

[Building]
hangar=off

[PvP]
hangar=on
So first time I thought I will make new tab [ZonesIDs] and write there "zonename=id" - and then I realized that it's getting out of logic. So "id=zonename" would be good.

Code:
if (zonename is numeric) { find zone name of id and do something }
Well. Maybe I will do that if I will have time. But it will need some last id checker etc and I'm too lazy. I think PVP is more important.
If the damage amount wasn't working, I'm 100% sure that your code is wrong. I was just progressing with HungerGames today, and It worked. Next time send me the code that you were using.

-----

Zone logic:

1. Create a Dictionary.
2. Dictionary hould have a Vector2 type and an int
3.
Maybe It's because of night but I think u should use Vector2, since if we are using zones, we don't need to look at height.

Soo here comes a struggle, but I think there is a better way, i will look in it later.

blabla hurtevent:
C#:
Dictionary<Vector2, int> defaultpoints = new Dictionary<Vector2, int>();
//todo loop on plugininit and add all Vector from coords
//Should be Vector2 v = new Vector2(x, z);
Vector2 pos = HurtEvent.Attacker.PlayerClient.transform.position;
foreach (Vector2 x in defaultpoints.Keys)
{
    if (Vector2.Distance(x, pos) < defaultpoints[x])
    {
        // found player in zone
    }
}
 
  • Like
Reactions: MasterPeace

MasterPeace

Retired Staff
Retired Staff
Feb 2, 2015
269
69
28
45
Poland
Yea. I didn't thought about Vector2. If something is not needed (Y), delete it. I will change it.

About Dictionary - no. I don't remember but I'm just using array and checking zones in INI on every entity deploy. And also I want to keep myself away from Dictionaries, databases, and other datamanagers. Other thing if I would make my own game, but it's plugin for mod for game so I think it's best to keep it easiest as possible from developer and from pc side. Yea it would help for ID things, but it's unnecessary code what will just slow down plugin.

Most users will not even have more zones than 10, so keep it simply.

thanks for help
 

DreTaX

Probably knows the answer...
Administrator
Jun 29, 2014
4,095
4,815
113
At your house.
github.com
If you keep the data in a Dictionary that wont hurt. Its better than a DataStore. Using those will use memory. Using ini will use CPU. Its the same as the array but It also has the radius. If you use CPU that will make the server slow.

Sent from my Samsung Galaxy S4
 

MasterPeace

Retired Staff
Retired Staff
Feb 2, 2015
269
69
28
45
Poland
Yea but with files I had never problems. With Datastore / Dictionaries - yea.

We have radius. What would be zones without radius. I just said that I don't see reason why to add to that additional code to use dictionary (you need files anyway.. So load from file, then to dictionary, and when I decide to add, edit, delete zone I need to use files again and dictionary of course. yea maybe it will make performance a little bit higher.. But I saw on my example that until you have 3000 lines in INI it will not slow down gameplay)

I never had big server like 100 people online so it's hard to me to see how it's working. But hope it work ok.

--

What do you mean by entity hurt disable event? I'm trying to make with this small plugin as much possibilities as possible.
- If you want to add arena, admin base - you want to disable building there.
- If you want to add some town for players to meeat - you want to disable building and pvp
- If you want to make some sort of event and disable PvP in event area - yea.

So if you asking if with PvP off players can destroy entites - I will try to not let that. It's everything easy now I just don't have time to sit on that for this hour or something.

If you asking something other - I just didn't get that and you need to write more :p