ServUO Version
Publish 57
Ultima Expansion
Age Of Shadows
Hello, Ive made this script that is almost finished (this night i will start to setting rewards and then will be finished) and runs perfectly (I attach the item and the experience script that can be added in loot)..

This is a taliisman that can be charged with experience from mobs. Clicking on talisman while it''s weared activate/deactivate talismn improving life rege and mana cost consuming some experience. (this need some mods if someone is interested i can post it). When you use the talisman from your backpack it open a reward gump where you can spend eperience.

This talisman gives also stat bonus of experience / 100 until max value of 15 points.

the question is... i need to add the same bonus mod (exp\100) to all resistance, but when i add it in the method of on equip, the method on remove can't read mod[]. I've tryied to set a private mod method, but I am still not enought skillfull to understand why it does''t work. Someone can help me?
Thank you

the file is talismanoslayer.
Code:
using System;
using Server.Mobiles;
using Server.Gumps;
using Server.Network;

namespace Server.Items
{
    public class TalismanoSlayer : Item
    {
        private int talismano_exp;
        private int incremento;
        public bool TalisAttivo;
      
      /*   private ResistanceMod[] mods = new ResistanceMod[5] here i've tryed to do private method
                       {

                         new ResistanceMod( ResistanceType.Fire, 5 ),
                         new ResistanceMod( ResistanceType.Poison, 5 ),
                         new ResistanceMod( ResistanceType.Energy, 5 ),
                         new ResistanceMod( ResistanceType.Cold, 5 ),
                         new ResistanceMod( ResistanceType.Physical, 5)
                       };*/

        [CommandProperty(AccessLevel.GameMaster)]
        public int TalismanExperience { get { return talismano_exp; } set { talismano_exp = value; } }


        [Constructable]
        public TalismanoSlayer(): base(0x2F58)
        {
        Name = "a slayer talisman";
		Hue = 1287;
            Layer = Layer.Talisman;
            TalisAttivo = false;
        }
        public TalismanoSlayer(Serial serial): base(serial)
        {
        }
        public override void OnDoubleClick(Mobile from)
        {
            Item talism = from.FindItemOnLayer(Layer.Talisman);
            if (IsChildOf(from.Backpack))
            {
                if ((from.FindItemOnLayer(Layer.Talisman) == null) && (from.Map == Map.Trammel))
                {
                    from.AddItem(this);
                    from.SendGump(new TaliGump(from));                
                }
                else
                    from.SendMessage("your talisman slot must be free and you can use it only in trammel"); 
                return;
            }
            if (talism == this)
            {
                
                if (TalisAttivo)
                {
                    TalisAttivo = false;
                    Hue = 1287;
                    from.SendMessage(" you turn OFF the power of the talisman. ");
                        return;
                }
                else
                {
                TalisAttivo = true;
                Hue = 1288;
                    from.SendMessage(" you turn ON the power of the talisman. ");
                    return;
                }
            }
            return;
        }
        public override bool OnEquip(Mobile from)
        {
            incremento = talismano_exp / 100;
            if (incremento < 0) incremento = 0;
            if (incremento > 15) incremento = 15;
            if (talismano_exp > 1500) talismano_exp = 1500;

            if (from.Map != Map.Trammel)
            {
                from.SendMessage("You can wear it only in Trammel ");
                return false;
            }
            else
                from.AddStatMod(new StatMod(StatType.All, incremento + "All", incremento, TimeSpan.Zero));
                if(talismano_exp >= 100) from.PlaySound(0x1EA);
            // from.AddResistanceMod(new ResistanceMod(ResistanceType.Physical, incremento);
            //   from.AddResistanceMod(mods[5]);
// if i puth resistance mod here it works, but no works on remove
            from.SendMessage("this item is only for PVM ");
            base.OnEquip(from);
            return true;
        }
        public override void OnRemoved(object o)
        {
            if (o is Mobile)
            {
                ((Mobile)o).RemoveStatMod(incremento + "All");

                //    ((Mobile)o).RemoveResistanceMod(mods[5]); // here i've tryed to get off stats, but for sure i am missing something
                ((Mobile)o).SendMessage("talisman's avaiable experience is {0} ", talismano_exp);

                if (TalisAttivo)
                {
                    TalisAttivo = false;
                    Hue = 1287;
                }
            }
            base.OnRemoved(o);
        }
        public override void Serialize(GenericWriter writer)
        {
            base.Serialize(writer);

            writer.Write((int)0); // version
            writer.Write((int)talismano_exp);
            writer.Write((int)incremento);
           // writer.Write((bool)TalisAttivo);
        }

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

            int version = reader.ReadInt();

            switch (version)
            {
                case 0:
                   talismano_exp = reader.ReadInt();
                    incremento = reader.ReadInt();
                    TalisAttivo = false; /* reader.ReadBool();  */  

                    break;
            }
        }
         
        public class TaliGump : Gump
        {           
            public TaliGump(Mobile from)            
            : base(285, 0) 
            {
                Closable = true;
                Disposable = true;
                Dragable = true; 
                Resizable = false;

                AddPage(0);

                AddBackground(17, 69, 498, 313, 9250);
                AddLabel(224, 84, 16, "Rewards");

                AddRadio(30, 120, 208, 209, false, 1);
                AddRadio(30, 140, 208, 209, false, 2);
                AddRadio(30, 160, 208, 209, false, 3);
                AddRadio(30, 180, 208, 209, false, 4);
                AddRadio(30, 200, 208, 209, false, 5);
                AddRadio(30, 220, 208, 209, false, 6);
                AddRadio(30, 240, 208, 209, false, 7);
                AddRadio(30, 260, 208, 209, false, 8);
                AddRadio(30, 280, 208, 209, false, 9);
                AddRadio(30, 300, 208, 209, false, 10);

                AddRadio(287, 120, 208, 209, false, 11);
                AddRadio(287, 140, 208, 209, false, 12);
                AddRadio(287, 160, 208, 209, false, 13);
                AddRadio(287, 180, 208, 209, false, 14);
                AddRadio(287, 200, 208, 209, false, 15);
                AddRadio(287, 220, 208, 209, false, 16);
                AddRadio(287, 240, 208, 209, false, 17);

                AddLabel(55, 119, 1153, "a white horse(20) ");
                AddLabel(55, 139, 1153, "Reagents bag(15) ");
                AddLabel(55, 159, 1153, "Bag of potions(20) ");
                AddLabel(55, 179, 1153, "10000 Gold(25) ");
                AddLabel(55, 199, 1153, "Scroll of Trascendence(30) ");
                AddLabel(55, 219, 1153, "Slayer equip ticket(40) ");
                AddLabel(55, 239, 1153, "Horned studded armor(70) ");
                AddLabel(55, 259, 1153, "Agapite plate armor(80) ");
                AddLabel(55, 279, 1153, "10 Kudos(100) ");
                AddLabel(55, 299, 1153, "5 Trascendence Scrolls(120) ");
             
                AddLabel(310, 119, 1153, "5 Slayer equip ticket(180) ");
                AddLabel(310, 139, 1153, "Repair Slayer Weapon deed(280) ");
                AddLabel(310, 159, 1153, "Repair Slayer Armor deed(300) ");
                AddLabel(310, 179, 1153, "Weapon Refinement contract(400) ");
                AddLabel(310, 199, 1153, "Verite Ointment(700) ");
                AddLabel(310, 219, 1153, "Valorite Ointment(1300) ");
                AddLabel(310, 239, 1153, "Destroy your talisman ");
                AddLabel(310, 254, 1153, "and get slayer blessing water ");

                AddButton(214, 344, 247, 248, 30, GumpButtonType.Reply, 0);

                from.SendMessage("You open the reward page");
                
            }

            public override void OnResponse(NetState state, RelayInfo info)
            {
                Mobile from = state.Mobile;

                if (info.ButtonID == 30)
                {
                    string toSay = "";
                    for (int i = 0; i < info.Switches.Length; i++)
                    {
                        int m = info.Switches[i];
                        switch (m)
                        {
                            case 1: // 1 whitehorse 20

                                 if ((from.FindItemOnLayer(Layer.Talisman) is TalismanoSlayer))
                                    {
                                    Item talismano = from.FindItemOnLayer(Layer.Talisman);

                                    if ((((TalismanoSlayer)talismano).TalismanExperience >= 20) && (from.Hits > 1))
                                        {
                                            toSay += "you have obtained a white horse ";
                                            ((TalismanoSlayer)talismano).TalismanExperience -= 20;

                                        HorseSpawn cavallo = new HorseSpawn();
                                        cavallo.Body = 0xC8;
                                        cavallo.Hue = 1150;
                                        cavallo.Name = "a white horse";
                                        cavallo.ControlSlots = 0;
                                        cavallo.Controlled = true;
                                        cavallo.ControlMaster = from;
                                        Point3D loc = from.Location;
                                        Map map = from.Map;
                                        cavallo.MoveToWorld(loc, map);
                                    }
                                     else
                                        {
                                            toSay += "you haven't got enought experience";
                                        }
                                    }

                                 else 
                                    {
                                     toSay += "you must equip your talisman";
                                    }

                                     break;
                                    
// this it will be my workwork for this night. Completing it :P
                            case 2: // bag all reags 15
                                toSay += "Radio 2 : "; break;
                            case 3: //bag potion 20
                                toSay += "Radio 3 : "; break;
                            case 4: // 10k gold 25
                                toSay += "Radio 4 : "; break;
                            case 5: // scroll trasce 30
                                toSay += "Check 5, "; break;
                            case 6: // ticket slayer 40
                                toSay += "Check 6, "; break;
                            case 7: // horned studa 70
                                toSay += "Check 7, "; break;
                            case 8: // aga plate 80
                                toSay += "Check 8, "; break;
                            case 9: // 10 Kudos 100
                                toSay += "Check 9, "; break;
                            case 10: //5 scroll trasce 120
                                toSay += "Check 10, "; break;
                            case 11: // 5 ticket slayer 180
                                toSay += "Radio 11 : "; break;
                            case 12: // deed ripara weapon 280
                                toSay += "Radio 12 : "; break;
                            case 13: // deed ripara arm 300
                                toSay += "Radio 13 : "; break;
                            case 14: // except refinement 400
                                toSay += "Radio 14 : "; break;
                            case 15:// verite oint 500
                                toSay += "Check 51, "; break;
                            case 16: //valorite oint 1300
                                toSay += "Check 16, "; break;
                            case 17: // destroy talisman for belssing water servono 1500 exp
                                toSay += " tasto inattivo"; break;
                        }
                    }
                    from.SendMessage(toSay);
                }
            }



        }

    }
}
if you like it take it. no reference needed. it's all done by me and I am happy when peaple likes my creations
 

Attachments

  • TalismanoExp.cs
    1.5 KB · Views: 5
  • TalismanoSlayer.cs
    11.8 KB · Views: 3
mods[5] = null, coz you have array from 6 elements, from 0 to 5;
You have added resist mod not from array list:
C#:
from.AddResistanceMod(new ResistanceMod(ResistanceType.Physical, incremento);
but you're trying to remove it from array (mod[5]), which element = null;

So just try to change to mod[4].

But ideally, I would advise you to extend the Resistance Mod by StatMod type, adding a name identifier by which you can manage and track the added mods, and don't create arrays per each items.
 
Last edited:
thank you very much for the answer but maybe my lack is somwhere else. I haven't explained my problem well and i try to do it as good as i can-
As I've done for Stat mod, i need to check and record the int value of talisman_experience /100 applly it as buff on elementals and phisycal resist on equip and get back to normal resistances on remove.
To do this if i do an array like this inside the method of on equip:

Code:
// int incremento is defined as private inside the main

incremento = talismano_exp / 100;
            if (incremento < 0) incremento = 0;
            if (incremento > 15) incremento = 15;
            if (talismano_exp > 1500) talismano_exp = 1500;


ResistanceMod[] mods = new ResistanceMod[5]
                      {

                         new ResistanceMod( ResistanceType.Fire, +incremento ),
                         new ResistanceMod( ResistanceType.Poison, +incremento ),
                         new ResistanceMod( ResistanceType.Energy, +incremento),
                         new ResistanceMod( ResistanceType.Cold, +incremento ),
                         new ResistanceMod( ResistanceType.Physical, +incremento)
                      };*/
           // from.AddResistanceMod(mods[5]);

i can get what i need, but i can't read "the array mods" when in on remove I try to add ((Mobile)o).RemoveResistanceMod(mods[5]);

i tried to do a private array like this, but i can't read incremento because is not a static value and I am going crazy :D
Code:
 private ResistanceMod[] mods = new ResistanceMod[5]
                         {

                            new ResistanceMod( ResistanceType.Fire, +incremento ),
                            new ResistanceMod( ResistanceType.Poison, +incremento ),
                            new ResistanceMod( ResistanceType.Energy, +incremento),
                            new ResistanceMod( ResistanceType.Cold, +incremento ),
                            new ResistanceMod( ResistanceType.Physical, +incremento)
                         };
it works well if i do something like this, but it's not what i need because modres is static and i cannot chnge the value
Code:
  static int modres = 5;

        ResistanceMod ene= new ResistanceMod(ResistanceType.Energy, +modres);
        ResistanceMod fir = new ResistanceMod(ResistanceType.Fire, +modres);
        ResistanceMod poi = new ResistanceMod(ResistanceType.Poison, +modres);
        ResistanceMod co = new ResistanceMod(ResistanceType.Cold, +modres);
        ResistanceMod fis = new ResistanceMod(ResistanceType.Physical, +modres);

        public override void OnRemoved(object o)
        {
            if (o is Mobile)
            {
                ((Mobile)o).RemoveStatMod(incremento + "All");

                ((Mobile)o).RemoveResistanceMod(fir);
                ((Mobile)o).RemoveResistanceMod(fis);
                ((Mobile)o).RemoveResistanceMod(poi);
                ((Mobile)o).RemoveResistanceMod(ene);
                ((Mobile)o).RemoveResistanceMod(co);
 
Last edited:
Just a quick look and it seems to me that you need to store your player,

//new field
Code:
private PlayerMobile pm;

in OnEquip
Code:
if (from is PlayerMobile)
 pm = from as PlayerMobile;

Then use pm in your OnRemove instead of trying to use the object.

I haven't tested this nor do I know for sure how the modding works in ServUO, I could be missing something here but if the playermobile is logging the mod, then you'll want a ref to it for removing it as well!
 
sry, I am still not very expert in some things :p
how I have to write in on remove?
if i write it like this
pm.RemoveResistanceMod(ResistanceType.Energy);
I've got an error and same way if I try to remove "incremento" that is stored in the on equip method.

Anyway you give me a good idea and maybe we have found the solution.
I'll try to set a new private int called resist
and get resist from incremento in the on equip
then i can add resist to mobile +resist
and on equip maybe workd if i add the mobile resistance with -resist.
If it works he is stupid and i am stupid with it.

five minutes and i say f it works. Thank you
::D it works, but it get some problems when i activate the talisman gump.
I will try to fix it or maybe i'll run the last version.


ok. that's it. It works propely, but it has got a problem. If i restart the server with the talisman equipped, on the next start talisman gives only stats mod and not resist mod. Maybe a wrong write/deserialization? Any ideas?

Code:
using System;
using Server.Mobiles;
using Server.Gumps;
using Server.Network;

namespace Server.Items
{
    public class TalismanoSlayer : Item
    {
        private int talismano_exp;
        private int incremento;
        public bool TalisAttivo;
        private int resistance;
        private bool resistito = false;

        [CommandProperty(AccessLevel.GameMaster)]
        public int TalismanExperience { get { return talismano_exp; } set { talismano_exp = value; } }


        [Constructable]
        public TalismanoSlayer(): base(0x2F58)
        {
        Name = "a slayer talisman";
		Hue = 1287;
            Layer = Layer.Talisman;
            TalisAttivo = false;
        }
        public TalismanoSlayer(Serial serial): base(serial)
        {
        }
        public override void OnDoubleClick(Mobile from)
        {
            Item talism = from.FindItemOnLayer(Layer.Talisman);
            if (IsChildOf(from.Backpack))
            {
                if ((from.FindItemOnLayer(Layer.Talisman) == null) && (from.Map == Map.Trammel))
                {
                    from.AddItem(this);
                    from.SendGump(new TaliGump(from));                
                }
                else
                    from.SendMessage("your talisman slot must be free and you can use it only in trammel"); 
                return;
            }
            if (talism == this)
            {
                
                if (TalisAttivo)
                {
                    TalisAttivo = false;
                    Hue = 1287;
                    from.SendMessage(" you turn OFF the power of the talisman. ");
                        return;
                }
                else
                {
                TalisAttivo = true;
                Hue = 1288;
                    from.SendMessage(" you turn ON the power of the talisman. ");
                    return;
                }
            }
            return;
        }
        public override bool OnEquip(Mobile from)
        {
            incremento = talismano_exp / 100;
            if (incremento < 0) incremento = 0;
            if (incremento > 15) incremento = 15;
            if (talismano_exp > 1500) talismano_exp = 1500;
            


            if (from.Map != Map.Trammel)
            {
                from.SendMessage("You can wear it only in Trammel ");
                return false;
            }
            else
                from.AddStatMod(new StatMod(StatType.All, incremento + "All", incremento, TimeSpan.Zero));
                if(talismano_exp >= 100) from.PlaySound(0x1EA);

if (resistito == false)
            {
                resistance = incremento;
                from.AddResistanceMod(new ResistanceMod(ResistanceType.Energy, +resistance));
            from.AddResistanceMod(new ResistanceMod(ResistanceType.Fire, +resistance));
            from.AddResistanceMod(new ResistanceMod(ResistanceType.Poison, +resistance));
            from.AddResistanceMod(new ResistanceMod(ResistanceType.Cold, +resistance));
            from.AddResistanceMod(new ResistanceMod(ResistanceType.Physical, +resistance));
                resistito = true;
            }
            from.SendMessage("this item is only for PVM ");
            base.OnEquip(from);
            return true;
        }


        public override void OnRemoved(object o)
        {
            if (o is Mobile)
            {
                ((Mobile)o).RemoveStatMod(incremento + "All");
                if(resistito)
                {
                 ((Mobile)o).AddResistanceMod(new ResistanceMod(ResistanceType.Energy, -resistance));
                ((Mobile)o).AddResistanceMod(new ResistanceMod(ResistanceType.Fire, -resistance));
                ((Mobile)o).AddResistanceMod(new ResistanceMod(ResistanceType.Poison, -resistance));
                ((Mobile)o).AddResistanceMod(new ResistanceMod(ResistanceType.Cold, -resistance));
                ((Mobile)o).AddResistanceMod(new ResistanceMod(ResistanceType.Physical, -resistance));
                    resistito = false;
                }

                ((Mobile)o).SendMessage("talisman's avaiable experience is {0} ", talismano_exp);

                if (TalisAttivo)
                {
                    TalisAttivo = false;
                    Hue = 1287;
                }
            }
            base.OnRemoved(o);
        }
        public override void Serialize(GenericWriter writer)
        {
            base.Serialize(writer);

            writer.Write((int)0); // version
            writer.Write((int)talismano_exp);
            writer.Write((int)incremento);
            writer.Write((int)resistance);
            writer.Write((bool)resistito);
            // writer.Write((bool)TalisAttivo);
        }

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

            int version = reader.ReadInt();

            switch (version)
            {
                case 0:
                   talismano_exp = reader.ReadInt();
                    incremento = reader.ReadInt();
                    resistance = reader.ReadInt();
                    resistito = reader.ReadBool();
                    TalisAttivo = false; /* reader.ReadBool();  */  

                    break;
            }
        }
 
Last edited:
Not tested, just copied your first posted code and added the suggestion I gave so it is easier to understand what I was referring to!

Code:
using System;
using Server.Mobiles;
using Server.Gumps;
using Server.Network;

namespace Server.Items
{
    public class TalismanoSlayer : Item
    {
        private int talismano_exp;
        private int incremento;
        public bool TalisAttivo;
     
      /*   private ResistanceMod[] mods = new ResistanceMod[5] here i've tryed to do private method
                       {

                         new ResistanceMod( ResistanceType.Fire, 5 ),
                         new ResistanceMod( ResistanceType.Poison, 5 ),
                         new ResistanceMod( ResistanceType.Energy, 5 ),
                         new ResistanceMod( ResistanceType.Cold, 5 ),
                         new ResistanceMod( ResistanceType.Physical, 5)
                       };*/

        [CommandProperty(AccessLevel.GameMaster)]
        public int TalismanExperience { get { return talismano_exp; } set { talismano_exp = value; } }


        [Constructable]
        public TalismanoSlayer(): base(0x2F58)
        {
        Name = "a slayer talisman";
        Hue = 1287;
            Layer = Layer.Talisman;
            TalisAttivo = false;
        }
        public TalismanoSlayer(Serial serial): base(serial)
        {
        }
        public override void OnDoubleClick(Mobile from)
        {
            Item talism = from.FindItemOnLayer(Layer.Talisman);
            if (IsChildOf(from.Backpack))
            {
                if ((from.FindItemOnLayer(Layer.Talisman) == null) && (from.Map == Map.Trammel))
                {
                    from.AddItem(this);
                    from.SendGump(new TaliGump(from));               
                }
                else
                    from.SendMessage("your talisman slot must be free and you can use it only in trammel");
                return;
            }
            if (talism == this)
            {
               
                if (TalisAttivo)
                {
                    TalisAttivo = false;
                    Hue = 1287;
                    from.SendMessage(" you turn OFF the power of the talisman. ");
                        return;
                }
                else
                {
                TalisAttivo = true;
                Hue = 1288;
                    from.SendMessage(" you turn ON the power of the talisman. ");
                    return;
                }
            }
            return;
        }

PlayerMobile pm; //added field to hold player

        public override bool OnEquip(Mobile from)
        {

if (from is PlayerMobile) //check for player and fill field here, then use pm below in the method
pm = from;
else
return false;

            incremento = talismano_exp / 100;
            if (incremento < 0) incremento = 0;
            if (incremento > 15) incremento = 15;
            if (talismano_exp > 1500) talismano_exp = 1500;

            if (pm.Map != pm.Trammel)
            {
                pm.SendMessage("You can wear it only in Trammel ");
                return false;
            }
            else
                pm.AddStatMod(new StatMod(StatType.All, incremento + "All", incremento, TimeSpan.Zero));
                if(talismano_exp >= 100) from.PlaySound(0x1EA);
            //pm.AddResistanceMod(new ResistanceMod(ResistanceType.Physical, incremento);
            //pm.AddResistanceMod(mods[5]);
// if i put resistance mod here it works, but no works on remove
            pm.SendMessage("this item is only for PVM ");
            base.OnEquip(from);
            return true;
        }
        public override void OnRemoved(object o)
        {
            if (pm != null) //check for field to hold player, then use pm below in your method
            {
                (pm.RemoveStatMod(incremento + "All");

                //    (pm.RemoveResistanceMod(mods[5]); // here i've tryed to get off stats, but for sure i am missing something
                (pm.SendMessage("talisman's available experience is {0} ", talismano_exp);

                if (TalisAttivo)
                {
                    TalisAttivo = false;
                    Hue = 1287;
                }
            }

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

            writer.Write((int)0); // version
            writer.Write((int)talismano_exp);
            writer.Write((int)incremento);
           // writer.Write((bool)TalisAttivo);
        }

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

            int version = reader.ReadInt();

            switch (version)
            {
                case 0:
                   talismano_exp = reader.ReadInt();
                    incremento = reader.ReadInt();
                    TalisAttivo = false; /* reader.ReadBool();  */ 

                    break;
            }
        }
        
        public class TaliGump : Gump
        {          
            public TaliGump(Mobile from)           
            : base(285, 0)
            {
                Closable = true;
                Disposable = true;
                Dragable = true;
                Resizable = false;

                AddPage(0);

                AddBackground(17, 69, 498, 313, 9250);
                AddLabel(224, 84, 16, "Rewards");

                AddRadio(30, 120, 208, 209, false, 1);
                AddRadio(30, 140, 208, 209, false, 2);
                AddRadio(30, 160, 208, 209, false, 3);
                AddRadio(30, 180, 208, 209, false, 4);
                AddRadio(30, 200, 208, 209, false, 5);
                AddRadio(30, 220, 208, 209, false, 6);
                AddRadio(30, 240, 208, 209, false, 7);
                AddRadio(30, 260, 208, 209, false, 8);
                AddRadio(30, 280, 208, 209, false, 9);
                AddRadio(30, 300, 208, 209, false, 10);

                AddRadio(287, 120, 208, 209, false, 11);
                AddRadio(287, 140, 208, 209, false, 12);
                AddRadio(287, 160, 208, 209, false, 13);
                AddRadio(287, 180, 208, 209, false, 14);
                AddRadio(287, 200, 208, 209, false, 15);
                AddRadio(287, 220, 208, 209, false, 16);
                AddRadio(287, 240, 208, 209, false, 17);

                AddLabel(55, 119, 1153, "a white horse(20) ");
                AddLabel(55, 139, 1153, "Reagents bag(15) ");
                AddLabel(55, 159, 1153, "Bag of potions(20) ");
                AddLabel(55, 179, 1153, "10000 Gold(25) ");
                AddLabel(55, 199, 1153, "Scroll of Trascendence(30) ");
                AddLabel(55, 219, 1153, "Slayer equip ticket(40) ");
                AddLabel(55, 239, 1153, "Horned studded armor(70) ");
                AddLabel(55, 259, 1153, "Agapite plate armor(80) ");
                AddLabel(55, 279, 1153, "10 Kudos(100) ");
                AddLabel(55, 299, 1153, "5 Trascendence Scrolls(120) ");
            
                AddLabel(310, 119, 1153, "5 Slayer equip ticket(180) ");
                AddLabel(310, 139, 1153, "Repair Slayer Weapon deed(280) ");
                AddLabel(310, 159, 1153, "Repair Slayer Armor deed(300) ");
                AddLabel(310, 179, 1153, "Weapon Refinement contract(400) ");
                AddLabel(310, 199, 1153, "Verite Ointment(700) ");
                AddLabel(310, 219, 1153, "Valorite Ointment(1300) ");
                AddLabel(310, 239, 1153, "Destroy your talisman ");
                AddLabel(310, 254, 1153, "and get slayer blessing water ");

                AddButton(214, 344, 247, 248, 30, GumpButtonType.Reply, 0);

                from.SendMessage("You open the reward page");
               
            }

            public override void OnResponse(NetState state, RelayInfo info)
            {
                Mobile from = state.Mobile;

                if (info.ButtonID == 30)
                {
                    string toSay = "";
                    for (int i = 0; i < info.Switches.Length; i++)
                    {
                        int m = info.Switches[i];
                        switch (m)
                        {
                            case 1: // 1 whitehorse 20

                                 if ((from.FindItemOnLayer(Layer.Talisman) is TalismanoSlayer))
                                    {
                                    Item talismano = from.FindItemOnLayer(Layer.Talisman);

                                    if ((((TalismanoSlayer)talismano).TalismanExperience >= 20) && (from.Hits > 1))
                                        {
                                            toSay += "you have obtained a white horse ";
                                            ((TalismanoSlayer)talismano).TalismanExperience -= 20;

                                        HorseSpawn cavallo = new HorseSpawn();
                                        cavallo.Body = 0xC8;
                                        cavallo.Hue = 1150;
                                        cavallo.Name = "a white horse";
                                        cavallo.ControlSlots = 0;
                                        cavallo.Controlled = true;
                                        cavallo.ControlMaster = from;
                                        Point3D loc = from.Location;
                                        Map map = from.Map;
                                        cavallo.MoveToWorld(loc, map);
                                    }
                                     else
                                        {
                                            toSay += "you haven't got enought experience";
                                        }
                                    }

                                 else
                                    {
                                     toSay += "you must equip your talisman";
                                    }

                                     break;
                                   
// this it will be my workwork for this night. Completing it :P
                            case 2: // bag all reags 15
                                toSay += "Radio 2 : "; break;
                            case 3: //bag potion 20
                                toSay += "Radio 3 : "; break;
                            case 4: // 10k gold 25
                                toSay += "Radio 4 : "; break;
                            case 5: // scroll trasce 30
                                toSay += "Check 5, "; break;
                            case 6: // ticket slayer 40
                                toSay += "Check 6, "; break;
                            case 7: // horned studa 70
                                toSay += "Check 7, "; break;
                            case 8: // aga plate 80
                                toSay += "Check 8, "; break;
                            case 9: // 10 Kudos 100
                                toSay += "Check 9, "; break;
                            case 10: //5 scroll trasce 120
                                toSay += "Check 10, "; break;
                            case 11: // 5 ticket slayer 180
                                toSay += "Radio 11 : "; break;
                            case 12: // deed ripara weapon 280
                                toSay += "Radio 12 : "; break;
                            case 13: // deed ripara arm 300
                                toSay += "Radio 13 : "; break;
                            case 14: // except refinement 400
                                toSay += "Radio 14 : "; break;
                            case 15:// verite oint 500
                                toSay += "Check 51, "; break;
                            case 16: //valorite oint 1300
                                toSay += "Check 16, "; break;
                            case 17: // destroy talisman for belssing water servono 1500 exp
                                toSay += " tasto inattivo"; break;
                        }
                    }
                    from.SendMessage(toSay);
                }
            }



        }

    }
}
 
ok, I've understand, but in this way if i set in the rpivate array mod the int incremento, IDE says me that incremento is not a static int and i get mad.
I've modified with +resist (the same of incremento) and -resist. it works, but on server restart the add resistance doesn't work anymore. If i log in and log out it hell works
 
Like I said I haven't played with mods and not sure what your trying to change, all player stats and such should be a instanced value for that player, statics are a field that has one copy, like a read only or constant field. So if your messing with a static, understand it is the singularity in what ever your working with! Usually a system will use statics to control fields that there should only be one value used among all the objects that are using it.

So with this knowledge, what you need to do is use the instanced fields, ie: the player is a copy of PlayerMobile, it has its own values in fields for that copy whereas another player has there copy and there fields are filled with different values. so this is why you need to have references to instances in order to use and know what field your dealing with! I hope that makes sense, I'm no professional coder but the principle behind static vs non static is pretty easy to understand once you understand what the main difference is!
 
ok. Solved!!!
Now works propely. I had to deserialize the last bool as false because on server restart, keeping true by writebool, he doesn't give +resist buff but it detract -resist and it bugs resist.
NOW finally works and I am very proud of this simple script.
This is the final ver.
Thank you for the explanations and for the brain storming :D
 

Attachments

  • TalismanoSlayer.cs
    30.6 KB · Views: 8
Back