Nockar
Sorceror
Hi there! This should be a easy one for some one out there. I
It compiles fine.
You can give it a number value.
It gets consumed on db click.
But, when you db click it does not up the credits to what ever number you told it to. It set the credits to 0 (zero). So it looks like its not actually getting that number that you set some how.
It says, “You have received 0 credits” and changes your credits to 0. So if you had 251 credits get set to 0 credits.
Any ideas??
Excerpt form xmlspawner text file.
my code
It compiles fine.
You can give it a number value.
It gets consumed on db click.
But, when you db click it does not up the credits to what ever number you told it to. It set the credits to 0 (zero). So it looks like its not actually getting that number that you set some how.
It says, “You have received 0 credits” and changes your credits to 0. So if you had 251 credits get set to 0 credits.
Any ideas??
Excerpt form xmlspawner text file.
Code:
- added the static methods int GetCredits(Mobile m), bool TakeCredits(Mobile m, int credits),
and bool HasCredits(Mobile m, int credits) which external scripts can use to interface with
the Credits system. Note, if a negative credits argument is passed to TakeCredits, it will
add to the players Credit total. HasCredits and TakeCredits return a bool depending on whether
player has sufficient credits.
my code
Code:
using System;
using Server;
using Server.Items;
using Server.Mobiles;
using Server.Prompts;
using Server.Network;
using System.Collections;
using Server.Gumps;
using Server.Commands;
using Server.Commands.Generic;
using Server.Engines.XmlSpawner2;
namespace Server.Items
{
public class XMLQuestCreditsDeed : Item
{
private int m_Credits;
[CommandProperty( AccessLevel.GameMaster )]
public int Credits { get{ return m_Credits; } set { m_Credits = value; } }
[Constructable]
public XMLQuestCreditsDeed(int Credits) : base(0x14EF)
{
m_Credits = Credits;
Name = "Quest Credits";
LootType = LootType.Blessed;
Weight = 1.0;
}
public XMLQuestCreditsDeed(Serial serial): base(serial)
{
}
public override void OnDoubleClick( Mobile from/*, int Credits*/ )
{
if ( !IsChildOf( from.Backpack ) )
{
from.SendLocalizedMessage( 1042001 ); // That must be in your pack for you to use it.
}
else
{
XmlQuestPoints p = (XmlQuestPoints)XmlAttach.FindAttachment(from, typeof(XmlQuestPoints));
if(p == null)
{
p = new XmlQuestPoints();
XmlAttach.AttachTo(from, p);
}
else
{
XmlQuestPoints.TakeCredits(from, p.Credits);
from.SendMessage("You have receaved {0} credits.", p.Credits);
}
this.Consume();
return;
}
}
public override void GetProperties( ObjectPropertyList list )
{
base.GetProperties( list );
list.Add(String.Format("Credits: {0}", m_Credits));
}
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.Write( (int) 0 ); // version
writer.Write(m_Credits);
}
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadInt();
m_Credits = reader.ReadInt();
}
}
}