RunUO Community

This is a sample guest message. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

int question!

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.

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();
        }
 
    }
}
 
It appears to me that your passing the wrong int when you double click the deed, instead of taking the deeds credits, your taking the xml doc Credits.

Try this :

Code:
                    XmlQuestPoints.TakeCredits(from, Credits);
                        from.SendMessage("You have receaved {0} credits.", Credits);
 

Nockar

Sorceror
Thanks for the info. Getting closer.

When I made that change it says "You have receaved 100 credits"

But No credits are actully added to the total. It remains the same. XmlQuestPoints > Credits > is unchanged were as before it was set to 0.
 
Try passing a negative int, just by reading the comment above it seems that the xml (Which I don't use) system is set up to add to the total when a neg int passed!
 

Nockar

Sorceror
from.SendMessage("You have receaved {0} credits.", + ( Credits - ( Credits*2 ));

Spits out the error
) expected
 

Nockar

Sorceror
Oh, i had a typo in there.

from.SendMessage("You have receaved {0} credits.", + ( Credits - ( Credits*2 )));

But it still shows as -100
 
Try this,

First let me explain what I'm thinking, You make the credits on the deed set to the value you want shown, then to populate the Xml Credits with the identical value but in a negative, so by using the following line of code you can set the p.Credit to the neg value of the positive value of Credits. This way you can pass the negative value to xml and have a positive value in the deed to show the user.

Code:
p.Credits = (Credits - (Credits*2));
 
Top