Intro
Sometimes you want to add a custom flag to the players, so you can control something, for example if they did or not a quest and if they will be able to do it again or not.
Of course you don´t want to delete players and restart the shard etc.
Description
Go to
\Scripts\Mobiles and open
PlayerMobile.cs
Now, look for
private int m_Profession;
just below it, place your flag/variable, as example:
private bool m_test;
Now, to keep this organized, lets add just below this declaration
Code:
//test flag for quest of the tutorial
[CommandProperty( AccessLevel.GameMaster )]
public bool test
{
get{ return m_test; }
set{ m_test = value; }
}
Now we must search for
switch ( version ). This step is very important, and forgeting this will cause some doom
Code:
switch ( version )
{
case 19:
{
m_test = reader.ReadBool();
goto case 18;
}
case 18:
{
m_SolenFriendship = (SolenFriendship)...
Now, look for
Code:
writer.Write( (int) 18 ); // version
and change
18 for the newer version,
19
And finally, add below this last line,
Code:
writer.Write( m_test );
Presto!
Conclusion
Adding custom flags can be a powerfull tool when designing a quest, and as this tutorial shows, its easy to implement, and can be easily accessed from other classes.
Also note, the method above can use others variables too, with few changes.
This tutorial was based in FSGov script by Ronin.