i'm coding an PlaceRestriction plugin but for soem reason The SingleBed works but the Sleeping bag not
C#:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using Fougerite;
using Fougerite.Events;
using UnityEngine;
using RustPP.Social;
namespace PlaceRestriction
{
public class PlaceRestriction : Fougerite.Module
{
public bool UsingRustPP = false;
public string sys = "PlaceRestriction";
private string orange = "[color #FF8000]";
public override string Name { get { return "PlaceRestriction"; } }
public override string Author { get { return "ice cold"; } }
public override string Description { get { return "Blocks any placement on your ceiling/foundation from others unless they are in your friendslist with /addfriend"; } }
public override Version Version { get { return new Version("1.0"); } }
public override void Initialize()
{
Fougerite.Hooks.OnCommand += OnCommand;
Fougerite.Hooks.OnModulesLoaded += OnModulesLoaded;
Fougerite.Hooks.OnEntityDeployedWithPlacer += OnEntityDeployed;
}
public override void DeInitialize()
{
Fougerite.Hooks.OnCommand -= OnCommand;
Fougerite.Hooks.OnModulesLoaded -= OnModulesLoaded;
Fougerite.Hooks.OnEntityDeployedWithPlacer -= OnEntityDeployed;
}
public void OnModulesLoaded()
{
if (Fougerite.Server.GetServer().HasRustPP)
{
Logger.Log("Rust++ was founded now this plugin can be used");
UsingRustPP = true;
}
else
{
Logger.Log("Rust++ was not found now this plugin doesnt work");
UsingRustPP = false;
Fougerite.Hooks.OnEntityDeployedWithPlacer -= OnEntityDeployed;
}
}
public void OnCommand(Fougerite.Player pl, string cmd, string[] args)
{
if (cmd == "placerestriction")
{
pl.MessageFrom(sys, orange + "PlaceRestriction by ice cold");
pl.MessageFrom(sys, orange + "/pr - to get information about this plugin");
}
else if (cmd == "pr")
{
pl.MessageFrom(sys, orange + "This plugin blocks all placement on ceilings/foundation");
pl.MessageFrom(sys, orange + "if the player is not owner or in the friends list");
}
}
public void OnEntityDeployed(Fougerite.Player pl, Fougerite.Entity e, Fougerite.Player actualplacer)
{
if (UsingRustPP == true)
{
if (e.Name == "SleepingBag")
{
foreach (Fougerite.Entity xx in Util.GetUtil().FindEntitiesAround(e.Location, 5f))
{
if (xx.Name.ToLower().Contains("ceiling") || (xx.Name.ToLower().Contains("foundation")))
{
if (xx.OwnerID == actualplacer.SteamID)
{
pl.MessageFrom(sys, orange + "hee this is your base");
}
else
{
var friendc = Fougerite.Server.GetServer().GetRustPPAPI().GetFriendsCommand.GetFriendsLists();
if (friendc.ContainsKey(xx.UOwnerID))
{
var fs = (RustPP.Social.FriendList)friendc[xx.UOwnerID];
bool isfriend = fs.Cast<FriendList.Friend>().Any(friend => friend.GetUserID() == actualplacer.UID);
if (isfriend)
{
pl.MessageFrom(sys, orange + "This is an Friended base");
}
else
{
e.Destroy();
{
actualplacer.MessageFrom(sys, orange + "You cannot place near Structures [color green](/pr)");
}
}
}
}
}
}
}
else if (e.Name == "SingleBed")
{
foreach (Fougerite.Entity xx in Util.GetUtil().FindEntitiesAround(e.Location, 5f))
{
if (xx.Name.ToLower().Contains("ceiling") || (xx.Name.ToLower().Contains("foundation")))
{
if (xx.OwnerID == actualplacer.SteamID)
{
pl.MessageFrom(sys, orange + "hee this is your base");
}
else
{
var friendc = Fougerite.Server.GetServer().GetRustPPAPI().GetFriendsCommand.GetFriendsLists();
if (friendc.ContainsKey(xx.UOwnerID))
{
var fs = (RustPP.Social.FriendList)friendc[xx.UOwnerID];
bool isfriend = fs.Cast<FriendList.Friend>().Any(friend => friend.GetUserID() == actualplacer.UID);
if (isfriend)
{
pl.MessageFrom(sys, orange + "This is an Friended base");
}
else
{
e.Destroy();
actualplacer.MessageFrom(sys, orange + "You cannot place near Structures [color green](/pr)");
}
}
}
}
}
}
}
}
}
}