Full Version : guild attack between guild members
xmlspawner >>Scripting Support >>guild attack between guild members
<< Prev | Next >>
ArteGordon- 02-12-2006
you need to do 3 things.
1. increase the version number that is written out in the Serialize method

QUOTE
public override void Serialize( GenericWriter writer ) { if ( this.LastFealty+TimeSpan.FromDays( 1.0 ) < DateTime.Now ) this.CalculateGuildmaster(); writer.Write( (int) 4 );//version
writer.WriteGuildList( m_AllyDeclarations, true );
writer.WriteGuildList( m_AllyInvitations, true );

change the 4 to a 5 if that is what you have in your guild.cs
2. write out your new variable. It is CRITICAL that you write it out in the location indicated. It must come after the version, but before anything else is written. If you mess this up you may corrupt your save and be unable to load your shard again.
MAKE BACKUPS!
Make backups of any scripts that you change, and backup your saves.

QUOTE
public override void Serialize( GenericWriter writer ) { if ( this.LastFealty+TimeSpan.FromDays( 1.0 ) < DateTime.Now ) this.CalculateGuildmaster(); writer.Write( (int) 5 );//version
writer.Write( AllowGuildFighting );
writer.WriteGuildList( m_AllyDeclarations, true );
writer.WriteGuildList( m_AllyInvitations, true );

3. add a new case to the Deserialize method to handle reading in your new variable.

QUOTE
public override void Deserialize( GenericReader reader ) { int version = reader.ReadInt(); switch ( version ) {
case 5:
{
AllowGuildFighting = reader.ReadBool();
goto case 4;
}
case 4:
{
m_AllyDeclarations = reader.ReadGuildList();
m_AllyInvitations = reader.ReadGuildList();
goto case 3;
}

Finally, you should study and understand all of this. Just because it works does not mean that you can just forget about it. When RunUO 2.0 comes out, you may very well have to fiddle with this code again in order to upgrade, so it is best to understand it now.
darkwinters- 02-12-2006
ohh yeass it workss great!!!
thank you artegordon very much
my final question is how can i add a custom button for this?like "Guild Fighting"
when first clicked i want it to say "g.f is enabled" in the second click "g.c is disabled" and only yhe guildmaster can use this
ArteGordon- 02-12-2006
just look in the gump code. You will see many existing examples of buttons.
darkwinters- 02-12-2006
yes i know.i saw them but they are all locolized
for example

CODE
AddButton( 20, 360, 4005, 4007, 0, GumpButtonType.Reply, 0 ); AddHtmlLocalized( 55, 360, 470, 30, 1011441, false, false ); // EXIT

this is the exit button EXIT word is localized how can i use custom text.and i want this option to only shown to guildmasters.how will i use it like this?

CODE
if ( beholder.AccessLevel >= AccessLevel.GameMaster || beholder == leader ) { AddButton( 20, 310, 4005, 4007, 9, GumpButtonType.Reply, 0 ); AddHtmlLocalized( 55, 310, 470, 30, 1011094, false, false ); // Access guildmaster functions. }

and it have to send msg like its enabled or its disabled
ArteGordon- 02-12-2006
look for examples of AddLabel or AddHtml calls. You can add whatever strings you like.
darkwinters- 02-12-2006
can i add the button and case to the guildmastergump script?
because i want this option to only be use by guildmaster
ArteGordon- 02-12-2006
yes.
darkwinters- 02-12-2006
ok this looks very nice now
my final question is to send a message when its enabled or disabled.because the guildmaster cant understand whats going on when push to button.
can we add a message that says its enabled in and its disabled ?
ArteGordon- 02-13-2006
you can use the SendMessage call, like
from.SendMessage("whatever message you want");
where, 'from' is the player that you want to send the message to.
darkwinters- 02-13-2006
i know how to use this.i am not asking it.i need to place this to case so when the gm clicked the button it says enabled.but there is only one button.how will i make it to understand enabled and disable i am confused
ArteGordon- 02-13-2006
when you are constructing the gump you could either change the label based on the state of the AllowGuildFighting variable, or you could change the button gump art.
Just add a test for the AllowGuildFighting variable and add a different button and/or label based on its value.
You could add the SendMessage call to the OnResponse method case that handles that particular buttonid. Just have it report the value of the AllowGuildFighting variable.
darkwinters- 02-13-2006
hmmm
this is my buton

CODE
AddButton( 20, 340, 4005, 4007, 10, GumpButtonType.Reply, 0 ); AddHtml( 55, 340, 470, 30, ( "Guild Fight Modu" ), false, false );

and this is the case

CODE
case 10: // toggle fighting { m_Guild.AllowGuildFighting = !m_Guild.AllowGuildFighting; break; }

when clicked this button it firs enables it but with no msg
then in the second click it disables it but again no msg
i can change the case like this

CODE
case 10: // toggle fighting { m_Guild.AllowGuildFighting = !m_Guild.AllowGuildFighting; from.SendMessage("ohh master i dont know what you dou enable or disable?"); break;
}

this code explains everything i thing
ArteGordon- 02-13-2006
if you changed it to

CODE
case 10: // toggle fighting { m_Guild.AllowGuildFighting = !m_Guild.AllowGuildFighting; from.SendMessage("AllowGuildFighting is set to {0}", m_Guild.AllowGuildFighting); break;
}

or

CODE
case 10: // toggle fighting { m_Guild.AllowGuildFighting = !m_Guild.AllowGuildFighting; if(m_Guild.AllowGuildFighting) {
from.SendMessage("Guild Fighting is enabled");
} else
{
from.SendMessage("Guild Fighting is no longer allowed");
}
break;
}

darkwinters- 02-13-2006

CODE
- Error: Scripts\Gumps\Guilds\GuildmasterGump.cs: CS0246: (line 236, column 3) The type or namespace name 'from' could not be found (are you missing a using di rective or an assembly reference?) - Error: Scripts\Gumps\Guilds\GuildmasterGump.cs: CS0246: (line 239, column 3)
The type or namespace name 'from' could not be found (are you missing a using di
rective or an assembly reference?)

the line is from.sendmessage
i changed the from to m_Mobile and it works now
am i right?
ArteGordon- 02-13-2006
yes, 'from' was just there as an example. You need to substitute whatever variable actually points to the player that you want to send the message to.