How would I assign an owner to an item? For example a holiday ticket can only be used by its owner or a new player ticket. I was looking at how the new player ticket was assigned and this is what I saw. In charactercreation.cs there is this line
which says the ticket owner is newChar
In the script below I am trying to make a prize ticket but how would you assign the "Player" that owns the ticket? I would like the owner to be the first player that double clicks the ticket. I was thinking I could set the owner in the "public override void OnDoubleClick( Mobile from )" Any thoughts on how I could do this?
I tried something similar to
but that doesn't work.
Here is the script I am working on:
Code:
if ( young )
{
NewPlayerTicket ticket = new NewPlayerTicket();
ticket.Owner = newChar;
newChar.BankBox.DropItem( ticket );
}
In the script below I am trying to make a prize ticket but how would you assign the "Player" that owns the ticket? I would like the owner to be the first player that double clicks the ticket. I was thinking I could set the owner in the "public override void OnDoubleClick( Mobile from )" Any thoughts on how I could do this?
I tried something similar to
Code:
else if ( ticket.Player = null )
{
ticket.Player = m_Player;
}
but that doesn't work.
Here is the script I am working on:
Code:
using Server.Mobiles;
using System;
using System.Collections.Generic;
namespace Server.Misc
{
class PrizeTicket : Item
{
private PlayerMobile m_Player;
[CommandProperty(AccessLevel.Administrator)]
public PlayerMobile Player
{
get
{
return m_Player;
}
set
{
m_Player = value;
}
}
[Constructable]
public PrizeTicket() : this(null)
{
}
[Constructable]
public PrizeTicket(PlayerMobile mobile) : base(0x14F0)
{
m_Player = mobile;
Name = "This is a prize ticket! This ticket will only work for YOU, so don't give it away!";
Weight = 1.0;
LootType = LootType.Newbied;
}
public override void OnDoubleClick( Mobile from )
{
PrizeTicket ticket = new PrizeTicket();
if ( from != m_Player )
{
from.SendLocalizedMessage( 501926 ); // This isn't your ticket! Shame on you! You have to use YOUR ticket.
}
else if ( !IsChildOf( from.Backpack ) )
{
from.SendLocalizedMessage( 1042001 ); // That must be in your pack for you to use it.
}
}
public PrizeTicket(Serial serial)
: base(serial)
{
}
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.Write((int)0); // version
writer.WriteMobile(m_Player);
}
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadInt();
m_Player = reader.ReadMobile() as PlayerMobile;
}
}
}
Last edited: