Which Entity? Foundation, It can be anything?I get NullReferenceException: Object reference not set to an instance of an object when I do Entity.Destroy()
Would post logs but its not showing up in the logs
- Destroying Pillar/FoundationsWhich Entity? Foundation, It can be anything?
Also, which Event?
def On_EntityDeployed(self, Player, Entity):
if Entity.Name == "WoodPillar":
for foundation in Entity.GetLinkedStructs():
if foundation.Name == "WoodFoundation":
if round(DataStore.Get("BuildingRestriction", "Max Height"), 0) < Entity.Y - foundation.Y:
Entity.Destroy()
Player.Inventory.AddItem("Wood Pillar")
Player.InventoryNotice("1 x Wood Pillar")
Player.Message("You are not allowed to build more than [ " + str(round(DataStore.Get("BuildingRestriction", "Max Height"), 0) / 4) + " ] pillars high")
break
elif Entity.Name == "WoodFoundation":
count = 0
for foundation in Entity.GetLinkedStructs():
if foundation.Name == "WoodFoundation":
count += 1
if count == DataStore.Get("BuildingRestriction", "Max Foundations"):
Entity.Destroy()
Player.Inventory.AddItem("Wood Foundation")
Player.InventoryNotice("1 x Wood Foundation")
Player.Message("You are not allowed to place more than [ " + str(DataStore.Get("BuildingRestriction", "Max Foundations")) + " ] foundations")
break
continue
continue
If you would put a debug msg after the if round statement would that appear?- Destroying Pillar/Foundations
- On_EntityDeployed
Python:def On_EntityDeployed(self, Player, Entity): if Entity.Name == "WoodPillar": for foundation in Entity.GetLinkedStructs(): if foundation.Name == "WoodFoundation": if round(DataStore.Get("BuildingRestriction", "Max Height"), 0) < Entity.Y - foundation.Y: Entity.Destroy() Player.Inventory.AddItem("Wood Pillar") Player.InventoryNotice("1 x Wood Pillar") Player.Message("You are not allowed to build more than [ " + str(round(DataStore.Get("BuildingRestriction", "Max Height"), 0) / 4) + " ] pillars high") break elif Entity.Name == "WoodFoundation": count = 0 for foundation in Entity.GetLinkedStructs(): if foundation.Name == "WoodFoundation": count += 1 if count == DataStore.Get("BuildingRestriction", "Max Foundations"): Entity.Destroy() Player.Inventory.AddItem("Wood Foundation") Player.InventoryNotice("1 x Wood Foundation") Player.Message("You are not allowed to place more than [ " + str(DataStore.Get("BuildingRestriction", "Max Foundations")) + " ] foundations") break continue continue
Can you try this?- Destroying Pillar/Foundations
- On_EntityDeployed
Python:def On_EntityDeployed(self, Player, Entity): if Entity.Name == "WoodPillar": for foundation in Entity.GetLinkedStructs(): if foundation.Name == "WoodFoundation": if round(DataStore.Get("BuildingRestriction", "Max Height"), 0) < Entity.Y - foundation.Y: Entity.Destroy() Player.Inventory.AddItem("Wood Pillar") Player.InventoryNotice("1 x Wood Pillar") Player.Message("You are not allowed to build more than [ " + str(round(DataStore.Get("BuildingRestriction", "Max Height"), 0) / 4) + " ] pillars high") break elif Entity.Name == "WoodFoundation": count = 0 for foundation in Entity.GetLinkedStructs(): if foundation.Name == "WoodFoundation": count += 1 if count == DataStore.Get("BuildingRestriction", "Max Foundations"): Entity.Destroy() Player.Inventory.AddItem("Wood Foundation") Player.InventoryNotice("1 x Wood Foundation") Player.Message("You are not allowed to place more than [ " + str(DataStore.Get("BuildingRestriction", "Max Foundations")) + " ] foundations") break continue continue
try:
Entity.Destroy()
except:
Server.Broadcast("Something is wrong with: " + str(Entity))
return
With Entity.Destroy() commented out is it fine. With it in it will still destroy the object but just give the error. It doesn't seem to effect anything, Its just annoying.Can you try this?
Python:try: Entity.Destroy() except: Server.Broadcast("Something is wrong with: " + str(Entity)) return
If It happens with Try, then It is not the destroy function.With Entity.Destroy() commented out is it fine. With it in it will still destroy the object but just give the error. It doesn't seem to effect anything, Its just annoying.
Also doing the try: except: still gives the error
def On_EntityDeployed(self, Player, Entity):
if Entity.Name == "WoodPillar":
#Entity locations are in float, this is just a case stuff.
height = round(float(DataStore.Get("BuildingRestriction", "Max Height")), 0)
for foundation in Entity.GetLinkedStructs():
if foundation.Name != "WoodFoundation":
continue
if height < Entity.Y - foundation.Y:
try:
Entity.Destroy()
except:
Server.Broadcast("Failed to destroy the entity.")
Player.Inventory.AddItem("Wood Pillar")
Player.InventoryNotice("1 x Wood Pillar")
Player.Message("You are not allowed to build more than [ " + str(round(DataStore.Get("BuildingRestriction", "Max Height"), 0) / 4) + " ] pillars high")
break
elif Entity.Name == "WoodFoundation":
count = 0
max = int(DataStore.Get("BuildingRestriction", "Max Foundations"))
for foundation in Entity.GetLinkedStructs():
if foundation.Name != "WoodFoundation":
continue
count += 1
if count == max:
try:
Entity.Destroy()
except:
Server.Broadcast("Failed to destroy the entity.")
Player.Inventory.AddItem("Wood Foundation")
Player.InventoryNotice("1 x Wood Foundation")
Player.Message("You are not allowed to place more than [ " + str(DataStore.Get("BuildingRestriction", "Max Foundations")) + " ] foundations")
break
Still gets the same error, at the moment its just annoyingIf It happens with Try, then It is not the destroy function.
I removed some unnecessary coding stuffs, and changed the structure of the code to help you understand what's continue.
Give it a try.
Python:def On_EntityDeployed(self, Player, Entity): if Entity.Name == "WoodPillar": #Entity locations are in float, this is just a case stuff. height = round(float(DataStore.Get("BuildingRestriction", "Max Height")), 0) for foundation in Entity.GetLinkedStructs(): if foundation.Name != "WoodFoundation": continue if height < Entity.Y - foundation.Y: try: Entity.Destroy() except: Server.Broadcast("Failed to destroy the entity.") Player.Inventory.AddItem("Wood Pillar") Player.InventoryNotice("1 x Wood Pillar") Player.Message("You are not allowed to build more than [ " + str(round(DataStore.Get("BuildingRestriction", "Max Height"), 0) / 4) + " ] pillars high") break elif Entity.Name == "WoodFoundation": count = 0 max = int(DataStore.Get("BuildingRestriction", "Max Foundations")) for foundation in Entity.GetLinkedStructs(): if foundation.Name != "WoodFoundation": continue count += 1 if count == max: try: Entity.Destroy() except: Server.Broadcast("Failed to destroy the entity.") Player.Inventory.AddItem("Wood Foundation") Player.InventoryNotice("1 x Wood Foundation") Player.Message("You are not allowed to place more than [ " + str(DataStore.Get("BuildingRestriction", "Max Foundations")) + " ] foundations") break
If you see it on the console, the rest of it is in the rust server log in rust_server_Data, not the Fougerite logs in the plugin area.I get NullReferenceException: Object reference not set to an instance of an object when I do Entity.Destroy()
Would post logs but its not showing up in the logs
Output.logIf you see it on the console, the rest of it is in the rust server log in rust_server_Data, not the Fougerite logs in the plugin area.
NullReferenceException: Object reference not set to an instance of an object
at Facepunch.MeshBatch.Runtime.MeshBatchPhysicalOutput.ActivateImmediatelyUnchecked () [0x00000] in <filename unknown>:0
at Facepunch.MeshBatch.Runtime.MeshBatchPhysicalOutput.OnQueue () [0x00000] in <filename unknown>:0
at Facepunch.MeshBatch.Runtime.Sealed.MeshBatchPhysicalIntegration.IntegrateOne () [0x00000] in <filename unknown>:0
at Facepunch.MeshBatch.Runtime.Sealed.MeshBatchPhysicalIntegration.FixedUpdate () [0x00000] in <filename unknown>:0
What's It then?Doesn't appear to be related to any Fougerite code.