is there a way to prevent the guild attack between guild members?like the guildmaster of the guild can switch off the guild attack or switch on it from the guildstone ?
no. you have to modify notoriety.cs if you want to do this.
in Mobile_AllowHarmful
CODE |
if ( fromGuild != null && targetGuild != null && (fromGuild == targetGuild || fromGuild.IsAlly( targetGuild ) || fromGuild.IsEnemy( targetGuild )) ) return true; // Guild allies or enemies can be harmful
|
You would have to change this to test for your custom guild property.
thanks arte but i know how to switch it off from the script but i want to make a option for enable and disable this from the guild menu but i dont know how to work.for examle if i disable this from the notoriety than this will work for all the guilds.but if i can make a enable and disable option for this than this is up to guild that who wants this or not.
you would have to add your own custom property to the Guild class that would keep track of this status and could be toggled.
Then modify the guildstone gumps to allow you to toggle that property.
Then modify the notoriety check to look for that property.
Because the property would be guild-specific, the notoriety modification would reflect the individual guild settings.
like
QUOTE |
if ( fromGuild != null && targetGuild != null && ((fromGuild == targetGuild && fromGuild.AllowGuildFighting) || fromGuild.IsAlly( targetGuild ) || fromGuild.IsEnemy( targetGuild )) ) return true; // Guild allies or enemies can be harmful
|
where you have added the custom AllowGuildFighting property to the Guild class.
can you show me the custom property for the guild class and gump.i never do anythink like this befor (enable and disabling something from a button)or mayme you can recomment me some engine in the core that looks familiar to this.
just go into the Guild class and add
CODE |
public bool AllowGuildFighting = true;
|
Then go into the GuildGump.cs. You will see many examples of buttons.
Just add a button case in the OnResponse method that toggles that property, like
CODE |
case 10: // toggle fighting { m_Guild.AllowGuildFighting = !m_Guild.AllowGuildFighting;
break; }
|
you will need to add the code to add and display the button with buttonid 10, but there are many examples of buttons already in the gump. You just need to fiddle with it.
If you plan on having that property saved across server restarts, then you are going to have to Serialize and Deserialize it.
ok but whats going to be AllowGuildFighting
hasnt got it any checks etc?
and can i use xmlspawner data engine to serialize and deserialize?
sorry, I dont understand your question.
to make this system
firs i ll make the modify to notoriety.cs
than add the class to guild.cs
and then add the button and case for guild gump
this all right?
and for the serialize and deserialize
xmlspawner has a feature that i saw in a topic that makes it easier i think.
yes, you need to go through those steps.
As for the serialization/deserialization. You should just modify that in the Guild class directly.
CODE |
private string m_AllowGuildFighting;
[CommandProperty(AccessLevel.GameMaster)] public string AllowGuildFighting { get { if (m_AllowGuildFighting == null) { // find the value on the XmlData attachment XmlData a = (XmlData)XmlAttach.FindAttachment(this, typeof(XmlData), "AllowGuildFighting"); if (a != null) { m_AllowGuildFighting = a.Data; } } return m_AllowGuildFighting; } set { m_AllowGuildFighting = value; // find the value on the XmlData attachment XmlData a = (XmlData)XmlAttach.FindAttachment(this, typeof(XmlData), "AllowGuildFighting"); if (a == null) { // if none exist, then add one a = new XmlData("AllowGuildFighting", m_AllowGuildFighting); XmlAttach.AttachTo(this, a); } // store the new title in the Data property if (a != null) { a.Data = m_AllowGuildFighting; } InvalidateProperties(); } }
|
can i use serialize and deserialize like that?
the attachments are only designed to work with Items and Mobiles.
are there any links that shows how to serialize and deserialize?
CODE |
public class MyClass { private string m_Field1; private int m_Field2; ... public void Serialize( GenericWriter w ) { w.Write( m_Field1 ); w.Write( m_Field2 ); }
public MyClass( GenericReader r ) { m_Field1 = r.ReadString(); m_Field2 = r.ReadInt(); } }
....
public class MyMobile : Mobile { private MyClass m_Class; ... public override void Serialize( GenericWriter w ) { ... m_Class.Serialize( w ); }
public override void Deserialize( GenericReader r ) { ... m_Class = new MyClass( r ); } }
|
i think this is all but i dont know what to write to the field1 and field2 sections