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
Wait wait wait @DreTaX - My entity deployed hook stopped working. R6 and R7 of Fougerite are same about this.

Code:
public void EntityDeployed (Fougerite.Player Player, Fougerite.Entity Entity)
        {
            Player.Message("Entity deployed");
        }
I don't even receive this debug. EntityHurt is working. Didn't test PlayerHurt yet.
 

DreTaX

Probably knows the answer...
Administrator
Jun 29, 2014
4,093
4,784
113
At your house.
github.com
Wait wait wait @DreTaX - My entity deployed hook stopped working. R6 and R7 of Fougerite are same about this.

Code:
public void EntityDeployed (Fougerite.Player Player, Fougerite.Entity Entity)
        {
            Player.Message("Entity deployed");
        }
I don't even receive this debug. EntityHurt is working. Didn't test PlayerHurt yet.
Give me 10 mins and I will look at It too.
 
  • Like
Reactions: MasterPeace

DreTaX

Probably knows the answer...
Administrator
Jun 29, 2014
4,093
4,784
113
At your house.
github.com
Wait wait wait @DreTaX - My entity deployed hook stopped working. R6 and R7 of Fougerite are same about this.

Code:
public void EntityDeployed (Fougerite.Player Player, Fougerite.Entity Entity)
        {
            Player.Message("Entity deployed");
        }
I don't even receive this debug. EntityHurt is working. Didn't test PlayerHurt yet.


Did you add the hook?

Python:
__author__ = 'DreTaX'
__version__ = '1.0'
import clr

clr.AddReferenceByPartialName("Fougerite")
import Fougerite


class Test:

    def On_EntityDeployed(self, Player, Entity):
        Server.Broadcast("1")
        if Entity is not None and Player is not None:
            Server.Broadcast("Not null")
 

MasterPeace

Retired Staff
Retired Staff
Feb 2, 2015
269
69
28
45
Poland
Yes. I didn't change code at all. Just added other hooks for pvp and boom, after about hour of writing code and uploading to main server I realised that EntityDeployed is not reacting. Have you C# environment set? You could check C# too.

C:
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using Fougerite;
using Fougerite.Events;
using UnityEngine;

namespace Restriction_Zones
{
    public class Restriction_Zones_Class : Fougerite.Module
    {
// ------------------------------------------------
        // ABOUT

        public override string Name
        {
            get { return "Restriction Zones"; }
        }

        public override string Author
        {
            get { return "MasterPeace"; }
        }

        public override string Description
        {
            get { return "Creating zones for Fougerite Rust Legacy"; }
        }

        public override Version Version
        {
            get { return new Version("1.1.0"); }
        }

        // ------------------------------------------------
        // INITIALIZE

        public override void Initialize()
        {
            Hooks.OnEntityDeployed += EntityDeployed;
        }

        public override void DeInitialize()
        {
            Hooks.OnEntityDeployed -= EntityDeployed;
        }

       public void EntityDeployed (Fougerite.Player Player, Fougerite.Entity Entity)
        {
            Player.Message("Entity deployed");
        }
}
}
But only if you have environment set and have time.

Whole function is

C:
public void EntityDeployed (Fougerite.Player Player, Fougerite.Entity Entity)
        {
            ConfigINI = new IniParser("Save\\RestrictionZones\\Config.ini");
            bool AllowAdminsToBuild = Convert.ToBoolean(ConfigINI.GetSetting("Settings", "AllowAdminsToBuild"));
            bool MessageOn = Convert.ToBoolean(ConfigINI.GetSetting("Settings", "BuildingOffWarning"));
            string Message = ConfigINI.GetSetting("Settings", "BuildingOffMessage");

            Player.Message("Entity deployed");

            if (!Player.Admin)
            {
                DestroyEntity(Player, Entity, MessageOn, Message);
                Player.Message("Player is not admin");////////////////////////
            }
            else if (Player.Admin && !AllowAdminsToBuild) { DestroyEntity(Player, Entity, MessageOn, Message); Player.Message("Player is admin but not allowed"); }

        }
And whatever happens (no errors here) it should pass Player.Message("Entity deployed"); at least. Hm... I will check if older version is working. Or maybe? I will write if I will not find problem.
 

MasterPeace

Retired Staff
Retired Staff
Feb 2, 2015
269
69
28
45
Poland
Oh thanks god it's on my side. But I don't know where. I did that clear plugin like I wrote above without any functionality, just hook and it worked. Ok I will figure it out.

Thanks.
 

MasterPeace

Retired Staff
Retired Staff
Feb 2, 2015
269
69
28
45
Poland
Waaaaaaaaaaaaaaaaaaaw....

You can't keep strings that way in config waaaaaaaaaaaaaaaaaaw:
"Message=You cant build here"

waaaaaaaaaw. So many time wasted on so stupid error. Ok. So update will be soon.
 

MasterPeace

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

PvP, Entity Destroying, Entity names fixes

Restricition Zones 1.1.0:

- Added PVP on/off,
- Added Entity destroying on/off as DreTax wanted,
- /zone set name 100 off on on - please fix your zones by adding settings. Look at package for "New install" and open zones.ini to see what changed,
- Fixed entity names (shelter),
- More settings in config:
Code:
[Settings]
BuildingOffWarning=TRUE
PVPOffWarning=TRUE
DestroyingOffWarning=TRUE...
Read the rest of this update entry...
 

DreTaX

Probably knows the answer...
Administrator
Jun 29, 2014
4,093
4,784
113
At your house.
github.com
Waaaaaaaaaaaaaaaaaaaw....

You can't keep strings that way in config waaaaaaaaaaaaaaaaaaw:
"Message=You cant build here"

waaaaaaaaaw. So many time wasted on so stupid error. Ok. So update will be soon.
a y


Iniparser returns every value as a string by default. var is for holding some other objects.
 

DreTaX

Probably knows the answer...
Administrator
Jun 29, 2014
4,093
4,784
113
At your house.
github.com
[7/12/2015 12:58:45 AM] [Debug] Player HURT EXCEPTION: System.InvalidCastException: Cannot cast from source type to destination type.
at Restriction_Zones.Restriction_Zones_Class.PlayerHurt (Fougerite.Events.HurtEvent HE) [0x00000] in <filename unknown>:0
at (wrapper delegate-invoke) Fougerite.Hooks/HurtHandlerDelegate:invoke_void__this___HurtEvent (Fougerite.Events.HurtEvent)
at Fougerite.Hooks.PlayerHurt (.DamageEvent& e) [0x00000] in <filename unknown>:0
 

Martin

New Member
Member
Sep 7, 2014
23
2
3
[7/12/2015 12:58:45 AM] [Debug] Player HURT EXCEPTION: System.InvalidCastException: Cannot cast from source type to destination type.
at Restriction_Zones.Restriction_Zones_Class.PlayerHurt (Fougerite.Events.HurtEvent HE) [0x00000] in <filename unknown>:0
at (wrapper delegate-invoke) Fougerite.Hooks/HurtHandlerDelegate:invoke_void__this___HurtEvent (Fougerite.Events.HurtEvent)
at Fougerite.Hooks.PlayerHurt (.DamageEvent& e) [0x00000] in <filename unknown>:0
Is there any way to fix that?
 

Martin

New Member
Member
Sep 7, 2014
23
2
3
Hey can anyone ansswer me only, if there is no fix i wan't to delete plugin from my srv :)
 

MasterPeace

Retired Staff
Retired Staff
Feb 2, 2015
269
69
28
45
Poland
Hi.

I can't help as I don't have source anymore. You would need to decompile plugin for yourself first, I don't really have time now to do that, I'm working on other projects. I don't even have Rust anymore. Script was very easy.

1. On Player / Object Hurt -> Get positions of attacker and hurt object,
2. Get zone list from file (saved position, range)
3. Check distances of attacker / hurt to position
4. If distance is < or = range, do something (in zone), if not, do nothing.

You receive that error because probably Hurt Event has changed for player or objects. And looks like it was year ago.

Oh, and of course saving new zone:
1. Get player current position,
2. Get range from command
3. Save to file

Range is float, Unity default value of distance between two vector 3
 

DreTaX

Probably knows the answer...
Administrator
Jun 29, 2014
4,093
4,784
113
At your house.
github.com
A python version of this plugin would be very interesting.
Hi.

I can't help as I don't have source anymore. You would need to decompile plugin for yourself first, I don't really have time now to do that, I'm working on other projects. I don't even have Rust anymore. Script was very easy.

1. On Player / Object Hurt -> Get positions of attacker and hurt object,
2. Get zone list from file (saved position, range)
3. Check distances of attacker / hurt to position
4. If distance is < or = range, do something (in zone), if not, do nothing.

You receive that error because probably Hurt Event has changed for player or objects. And looks like it was year ago.

Oh, and of course saving new zone:
1. Get player current position,
2. Get range from command
3. Save to file

Range is float, Unity default value of distance between two vector 3
I know a Python one would be very interesting, though if you have more than 10 zones, It may lack the performance afterwards.

Anyway, with the permission of @MasterPeace I'm gonna decompile this, fix the problem and release It with the code.