Plugin-Reload destroys mountable points for objects

Hi,
i am currently creating some NPC and they are allowed to sit.

When i reload the plugin, all the seats are invalid and you cannot mount on them again.
Maybe you can unmount before OnUnload() / Destroy()..?

If you try to /skin this invalid object, the message is "You can not skin this while a player is mounted". So it looks like the object(chair) is still marked as occupied.

I have found this in your code

public void Stand()
            {
                //if(CanSit() && sitting)
                if(sitting)
                {
#if DEBUG
                    Interface.Oxide.LogInfo($"HumanNPC {npc.player.displayName} trying to stand...");
#endif
//                    npc.Invoke("AllowMove",0);
                    var mounted = npc.player.GetMounted();
                    mounted.DismountPlayer(npc.player);
                    mounted.SetFlag(BaseEntity.Flags.Busy, false, false);
                    sitting = false;
                }
            }​

Maybe you can call this function in reload/unload/destroy cases?



Merged post

Hi,
the same happens if you edit a sitting NPC.

I am currently using this script to restore Busy.Flags on charis

[ChatCommand("ResetChairs")]
private void cmdOccupiedChairs(BasePlayer player, string command, string[] args)
{
    if (!player.IsAdmin) return;
    int i = 0;

	foreach (var Chair in BaseEntity.serverEntities.OfType<BaseChair>())
		if (Chair != null)
			foreach (string zone in (string[])ZoneManager.Call("GetEntityZoneIDs", Chair))
				if (Chair.GetMounted() == null && Chair.IsMounted()){
					Chair.SetFlag(BaseEntity.Flags.Busy, false, false);
					i++;
				}

    if (i > 0)
        Puts("Restored: " + i.ToString() + " chairs.");            
}​


Merged post

Since this post was merged automatically and i cannot edit the original post, i cannot edit it (╯°□°)╯︵ ┻━┻

You can delete the line in my script.
foreach (string zone in (string[])ZoneManager.Call("GetEntityZoneIDs", Chair))​

I am using it to only restore chairs in a specific zone (where NPCs are sitting around)

Has anyone come up with a solution for this? I built a giant stadium and put 100 NPCs all sitting in chairs, and all of the sudden I restarted and all 100+ NPCs are all standing glitched into the floors in places they never were (they were all sitting before) and now I cant use all these chairs and I cant remove them, its completely destroyed 50 hours of work building this thing and Im about to have to completely end my music video project due to every single chair I have being unusable now even though I did a complete reset on all NPCs, deleted everything and have no waypoints or anything at all.

 

So strange that it would override the game and my admin privileges and stop me from being able to remove an object from the game...

drummerjacob

Has anyone come up with a solution for this? I built a giant stadium and put 100 NPCs all sitting in chairs, and all of the sudden I restarted and all 100+ NPCs are all standing glitched into the floors in places they never were (they were all sitting before) and now I cant use all these chairs and I cant remove them, its completely destroyed 50 hours of work building this thing and Im about to have to completely end my music video project due to every single chair I have being unusable now even though I did a complete reset on all NPCs, deleted everything and have no waypoints or anything at all.

 

So strange that it would override the game and my admin privileges and stop me from being able to remove an object from the game...

I can give you a very small plugin with a simple command that will repair all mountables. But you will need a create Zone with Zone-Manager to cover the area and give it a name.

You can use the ingame command "/rc" or it will repair all chairs in the zone every 2hours

https://pastebin.com/7H4f9Zmu
(Download it and save it as "HumanNPCChairRepair.cs" in your plugins folder)


It will repair all chairs every 2hours (you can change this in line 23)

//in seconds
timer.Repeat(7200, 0, () =>
            {
                restoreChairs();
            });

It works for every zone with the name "stadium". You can change the zone name in the plugin in line 45

//name your zone with "/zone name stadium" or change the name in this line
string zoneID = GetZoneIDByName("stadium");

Thanks! That fixed it. I downloaded Zone Manager, made a zone and named it stadium and expanded it like 350 and it put everyone back in their chairs :)