Tips23

Last-modified: 2011-08-29 (月) 15:23:03

AccountTag アカウントに情報を記録

  • カテゴリー: スクリプト
  • 重要性: 低
  • 投稿日: 2005-08-07 (日) 22:52:45

AccountTagを使用することでアカウントに情報を記録できます。長期報償等に使用されています。 Scripts\Accounting\Account.cs

public void SetTag( string name, string value )

タグの追加

public string GetTag( string name )

タグの情報を得る

public void RemoveTag( string name )

タグを削除

サンプル:アカウントに合計殺人数を記録

Scripts\Gumps\ReportMurderer.cs 殺人報告された回数をアカウントに記録します。アカウントに記録した場合キャラクターを削除しても残ります。この記録を参照することで使用しているキャラが青でもPKを行っていたアカウントを見分けること等が出来ます。

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

switch ( info.ButtonID )
{
case 1:
{
Mobile killer = (Mobile)m_Killers[m_Idx];
if ( killer != null && !killer.Deleted )
{
killer.Kills++;
killer.ShortTermMurders++;
//AccountTag
Server.Accounting.Account acct = killer.Account as Server.Accounting.Account; //殺人者のアカウント
if ( acct != null )
{
int total;
string tag = acct.GetTag( "TotalKills" );//タグ名TotalKillsの値(文字列)を入手

if ( tag == null || tag == "" )
total = 0;
else
total = Utility.ToInt32( tag ); //文字列をintに変換

acct.SetTag( "TotalKills", (total + 1).ToString() );//値を一つ増やして文字列に変換してからTotalKillsに記録
}

if ( killer is PlayerMobile )
((PlayerMobile)killer).ResetKillTime();

killer.SendLocalizedMessage( 1049067 );//You have been reported for murder!

if ( killer.Kills == 5 )
killer.SendLocalizedMessage( 502134 );//You are now known as a murderer!
else if ( SkillHandlers.Stealing.SuspendOnMurder && killer.Kills == 1 && killer is PlayerMobile && ((PlayerMobile)killer).NpcGuild == NpcGuild.ThievesGuild )
killer.SendLocalizedMessage( 501562 ); // You have been suspended by the Thieves Guild.
}
break;
}
case 2:
{
break;
}
}

m_Idx++;
if ( m_Idx < m_Killers.Count )
from.SendGump( new ReportMurdererGump( from, m_Killers, m_Idx ) );
}
Server.Accounting.Account acct = killer.Account as Server.Accounting.Account;

長ったらしく書いてるのは一番上にusing Server.Accounting;を追加するのがめんどかったからです。追加しておけば

Account acct = killer.Account as Account;

で済みました。

AccountTagに保存される情報は全て文字列ですので必要に応じて変換してください。

}}