Michele

Member
Hy guys, for our rp shard we need a script like this.


When a player dies in remote areas of a map, like an island, he has no way to get back to land where there are cities and curators.
We need to create a portal (the staff will add one to many points on the map) that can be seen and used only if the player is dead (ghost). When the player crosses the portal he returns to a point X established by us.

Example: I die on the island of the titans (we have custom map) , I do not know how to return, I search on the island for the portal of dead, I enter it and it brings me to point X, y, z where I will find the city and a curator. Can you make such a system? if so?

Ty all and sorry for bad eng
 
Try something like this
Code:
using Server.Mobiles;

namespace Server.Items
{
    public class PortalOfDeaths : Item
    {
        [Constructable]
        public PortalOfDeaths()
            : base(0xF6C)
        {
            Name = "Portal of Deaths";
            Movable = false;
            Visible = false;
            Active = true;
            DestinationPoint = Point3D.Zero;
            DestinationMap = Map.Trammel;
            TeleportPets = true;
        }

        public PortalOfDeaths(Serial serial)
            : base(serial)
        { }

        [CommandProperty(AccessLevel.GameMaster)]
        public bool Active { get; set; }

        [CommandProperty(AccessLevel.GameMaster)]
        public Point3D DestinationPoint { get; set; }

        [CommandProperty(AccessLevel.GameMaster)]
        public Map DestinationMap { get; set; }

        [CommandProperty(AccessLevel.GameMaster)]
        public bool TeleportPets { get; set; }

        public override bool OnMoveOver(Mobile mobile)
        {
            if (!Active || !mobile.Player || (mobile.Alive && mobile.IsPlayer()))
                return base.OnMoveOver(mobile);

            if (TeleportPets)
                BaseCreature.TeleportPets(mobile, DestinationPoint, DestinationMap);

            mobile.MoveToWorld(DestinationPoint, DestinationMap);
            return false;
        }

        public override void Serialize(GenericWriter writer)
        {
            base.Serialize(writer);

            writer.Write(0); // version
            writer.Write(Active);
            writer.Write(DestinationPoint);
            writer.Write(DestinationMap);
            writer.Write(TeleportPets);
        }

        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);

            int version = reader.ReadInt();

            switch (version)
            {
                case 0:
                {
                    Active = reader.ReadBool();
                    DestinationPoint = reader.ReadPoint3D();
                    DestinationMap = reader.ReadMap();
                    TeleportPets = reader.ReadBool();
                    break;
                }
            }
        }
    }
}

To only allow ghost to see these portals search for this code in PlayerMobile.cs
Code:
        public override bool CanSee(Item item)
        {
            if (m_DesignContext != null && m_DesignContext.Foundation.IsHiddenToCustomizer(item))
            {
                return false;
            }

            return base.CanSee(item);
        }
Change it to this
Code:
        public override bool CanSee(Item item)
        {
            if (m_DesignContext != null && m_DesignContext.Foundation.IsHiddenToCustomizer(item))
            {
                return false;
            }

            if (!Alive && item is PortalOfDeaths) // Add this check and line below
                return true;

            return base.CanSee(item);
        }

Now just [props the PortalOfDeaths and setup options. Staff members will be able to use portal while alive to help with testing locations. Hope this helps.
 
Mate very thank you the portal works great but with a little issue, the gost cant see it..

When a gm add it, the gm see it and work if gm wolk on

When a player (in life) walk trhoug it nothing appened <------- its ok!

When a player death (ghost) walk throug it, the portal move it in a seleceted locatino <---- Its ok but death player cant see it, just walk throug
 
Yes mate, Line 4847

public override bool CanSee(Item item)
{
if (m_DesignContext != null && m_DesignContext.Foundation.IsHiddenToCustomizer(item))
{
return false;
}
if (!Alive && item is PortalOfDeaths)
return true;
return base.CanSee(item);
}
 
Try this to PortalOfDeaths.cs and see if it fixes the issue
Code:
using System.Linq;
using Server.Mobiles;

namespace Server.Items
{
    public class PortalOfDeaths : Item
    {
        public static void Initialize()
        {
            EventSink.PlayerDeath += e =>
            {
                Mobile mobile = e.Mobile;

                if (mobile == null || mobile.NetState == null || !mobile.GetItemsInRange(mobile.NetState.UpdateRange).Any(item => item is PortalOfDeaths))
                    return;

                mobile.ClearScreen();
                mobile.SendEverything();
            };
        }

        [Constructable]
        public PortalOfDeaths()
            : base(0xF6C)
        {
            Name = "Portal of Deaths";
            Movable = false;
            Visible = false;
            Active = true;
            DestinationPoint = Point3D.Zero;
            DestinationMap = Map.Trammel;
            TeleportPets = true;
        }

        public PortalOfDeaths(Serial serial)
            : base(serial)
        { }

        [CommandProperty(AccessLevel.GameMaster)]
        public bool Active { get; set; }

        [CommandProperty(AccessLevel.GameMaster)]
        public Point3D DestinationPoint { get; set; }

        [CommandProperty(AccessLevel.GameMaster)]
        public Map DestinationMap { get; set; }

        [CommandProperty(AccessLevel.GameMaster)]
        public bool TeleportPets { get; set; }

        public override bool OnMoveOver(Mobile mobile)
        {
            if (!Active || !mobile.Player || (mobile.Alive && mobile.IsPlayer()))
                return base.OnMoveOver(mobile);

            if (TeleportPets)
                BaseCreature.TeleportPets(mobile, DestinationPoint, DestinationMap);

            mobile.MoveToWorld(DestinationPoint, DestinationMap);
            return false;
        }

        public override void Serialize(GenericWriter writer)
        {
            base.Serialize(writer);

            writer.Write(0); // version
            writer.Write(Active);
            writer.Write(DestinationPoint);
            writer.Write(DestinationMap);
            writer.Write(TeleportPets);
        }

        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);

            int version = reader.ReadInt();

            switch (version)
            {
                case 0:
                {
                    Active = reader.ReadBool();
                    DestinationPoint = reader.ReadPoint3D();
                    DestinationMap = reader.ReadMap();
                    TeleportPets = reader.ReadBool();
                    break;
                }
            }
        }
    }
}
 

Active Shards

Donations

Total amount
$0.00
Goal
$1,000.00
Back