ServUO Version
Publish Unknown
Ultima Expansion
None
Hello im using Xmlspawner, and Runuo, i know Xmlspawners can do many things

I got an item that gets deleted after a player does Doubleclick i would like to change something inside the Xmlspawner right before the item gets deleted

what i would like to do is to set the nextspawntime to 00:02:00 (2min)

can this be done via script? i dont want to check for items around since i got many spawners together
 
In the item code itself, you can override the Delete method (not usually recommended but fine if it's done safely):
C#:
public override void Delete()
{
    // is the current items' Spawner an XmlSpawner?
    if (Spawner is XmlSpawner xs)
    {
        // look through the spawner's entries
        foreach (var so in xs.SpawnObjects)
        {
            // does this entry contain the current item?
            if (so.SpawnedObjects.Contains(this))
            {
                // set the next spawn time
                so.NextSpawn = DateTime.UtcNow.AddMinutes(2.0);

                break;
            }
        }
    }

    base.Delete(); // always make sure this base call exists and executes
}

This should logically work, but there could be many other factors that override the spawn time; if it doesn't work, you can try setting the next spawn time using a zero-delay timer to ensure it ticks as soon as possible on the next core cycle and updates the spawner, which would overwrite any potential changes made after the item is actually deleted.

C#:
public override void Delete()
{
    // is the current items' Spawner an XmlSpawner?
    if (Spawner is XmlSpawner xs)
    {
        // look through the spawner's entries
        foreach (var so in xs.SpawnObjects)
        {
            // does this entry contain the current item?
            if (so.SpawnedObjects.Contains(this))
            {
                // set the next spawn time (on the next core cycle)
                Timer.DelayCall(() => so.NextSpawn = DateTime.UtcNow.AddMinutes(2.0));

                break;
            }
        }
    }

    base.Delete(); // always make sure this base call exists and executes
}
 
Back