本文整理汇总了C#中Server.Mobiles.PlayerMobile.AddItem方法的典型用法代码示例。如果您正苦于以下问题:C# PlayerMobile.AddItem方法的具体用法?C# PlayerMobile.AddItem怎么用?C# PlayerMobile.AddItem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Server.Mobiles.PlayerMobile
的用法示例。
在下文中一共展示了PlayerMobile.AddItem方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Convert_OnCommand
public static void Convert_OnCommand( CommandEventArgs e )
{
e.Mobile.SendMessage( "Converting all players to PlayerMobile. You will be disconnected. Please Restart the server after the world has finished saving." );
List<Mobile> mobs = new List<Mobile>( World.Mobiles.Values );
int count = 0;
foreach ( Mobile m in mobs )
{
if ( m.Player && !(m is PlayerMobile ) )
{
count++;
if ( m.NetState != null )
m.NetState.Dispose();
PlayerMobile pm = new PlayerMobile( m.Serial );
pm.DefaultMobileInit();
List<Item> copy = new List<Item>( m.Items );
for (int i=0;i<copy.Count;i++)
pm.AddItem( copy[i] );
CopyProps( pm, m );
for (int i=0;i<m.Skills.Length;i++)
{
pm.Skills[i].Base = m.Skills[i].Base;
pm.Skills[i].SetLockNoRelay( m.Skills[i].Lock );
}
World.Mobiles[m.Serial] = pm;
}
}
if ( count > 0 )
{
NetState.ProcessDisposedQueue();
World.Save();
Console.WriteLine( "{0} players have been converted to PlayerMobile. {1}.", count, Core.Service ? "The server is now restarting" : "Press any key to restart the server" );
if ( !Core.Service )
Console.ReadKey( true );
Core.Kill( true );
}
else
{
e.Mobile.SendMessage( "Couldn't find any Players to convert." );
}
}
示例2: Convert_OnCommand
public static void Convert_OnCommand( CommandEventArgs e )
{
e.Mobile.SendMessage( "Converting all players to PlayerMobile. You will be disconnected. Please Restart the server after the world has finished saving." );
ArrayList mobs = new ArrayList( World.Mobiles.Values );
int count = 0;
foreach ( Mobile m in mobs )
{
if ( m.Player && !(m is PlayerMobile ) )
{
count++;
if ( m.NetState != null )
m.NetState.Dispose();
PlayerMobile pm = new PlayerMobile( m.Serial );
pm.DefaultMobileInit();
ArrayList copy = new ArrayList( m.Items );
for (int i=0;i<copy.Count;i++)
pm.AddItem( (Item)copy[i] );
CopyProps( pm, m );
for (int i=0;i<m.Skills.Length;i++)
{
pm.Skills[i].Base = m.Skills[i].Base;
pm.Skills[i].SetLockNoRelay( m.Skills[i].Lock );
}
World.Mobiles[m.Serial] = pm;
}
}
if ( count > 0 )
{
NetState.ProcessDisposedQueue();
World.Save();
log.InfoFormat("{0} players have been converted to PlayerMobile. Restarting the server.",
count);
Core.Shutdown(true);
}
else
{
log.Info( "Couldn't find any Players to convert." );
}
}
示例3: RestoreState
public static void RestoreState(
PlayerMobile m,
bool moveExisting,
bool logging,
out int created,
out int deleted,
out int ignored,
out int moved)
{
var pack = m.Backpack;
if (pack == null || pack.Deleted)
{
m.AddItem(
pack = new Backpack
{
Movable = false
});
}
var bank = m.BankBox;
if (bank == null || bank.Deleted)
{
m.AddItem(
bank = new BankBox(m)
{
Movable = false
});
}
var root = VitaNexCore.DataDirectory + "/PlayerBackup/" + m.Account.Username + "/" + m.Serial;
var idxFile = IOUtility.EnsureFile(root + ".idx");
var binFile = IOUtility.EnsureFile(root + ".bin");
var logFile = logging ? IOUtility.EnsureFile(root + ".log") : null;
var log = logging ? new StringBuilder() : null;
if (log != null)
{
log.AppendLine();
log.AppendLine(new String('*', 10));
log.AppendLine();
log.AppendLine("RESTORE:\tDate[{0}]\tMobile[{1}]", DateTime.UtcNow, m);
log.AppendLine();
}
int idxCreated = 0, idxDeleted = 0, idxIgnored = 0, idxMoved = 0;
idxFile.Deserialize(
idx =>
{
idx.GetVersion();
var ser = idx.ReadInt();
if (ser != m.Serial)
{
if (log != null)
{
log.AppendLine("INVALID:\tSerial[{0}]", ser);
}
return;
}
long idxLength;
int idxCount;
ReadLength(idx, false, out idxLength, out idxCount);
if (log != null)
{
log.AppendLine("INDEX:\tCount[{0}]\tLength[{1}]", idxCount, idxLength);
}
var items = new Tuple<Item, Serial, long, long, string>[idxCount];
binFile.Deserialize(
bin =>
{
bin.GetVersion();
var restored = new Dictionary<Item, Serial>();
Backpack oldPack = null;
BankBox oldBank = null;
for (var i = 0; i < idxCount; i++)
{
Type type;
Serial serial, parent;
long binIndex, binLength;
ReadIndex(idx, out type, out serial, out parent, out binIndex, out binLength);
var valid = serial.IsValid && serial.IsItem;
var exists = World.Items.ContainsKey(serial);
//.........这里部分代码省略.........
示例4: JailThem
public static void JailThem( PlayerMobile player, JailOption option )
{
if ( null == player || player.AccessLevel >= JailConfig.JailImmuneLevel )
return;
if ( JailOption.Squelch == option )
player.Squelched = true;
foreach ( Item item in player.Items )
{
if ( item is JailHammer ) // Jailed while jailed gets them another load of rock to mine
{
if ( 0 > ( ((JailHammer)item).UsesRemaining += JailConfig.UsesRemaining ) ) // handle integer overflow
((JailHammer)item).UsesRemaining *= -1;
Banker.Withdraw( player, JailConfig.FineAmount );
player.SendMessage( "Your remaining sentence has been increased!" );
player.SendMessage( "You have been fined {0} gold and are being kicked!", JailConfig.FineAmount );
// This gives a nice little delay for the message to be read
s_KickProcessingQueue.Enqueue( player );
player.Squelched = true;
Server.Timer.DelayCall( TimeSpan.FromSeconds( kSecondsTillKick ), new Server.TimerCallback( KickPlayerInQueue ) );
return;
}
}
// If mounted, dismount them and stable mount
if ( player.Mounted )
{
if ( player.Mount is EtherealMount )
{
EtherealMount pet = player.Mount as EtherealMount;
pet.Internalize();
pet.Rider = null;
}
else if ( player.Mount is BaseMount )
{
BaseMount pet = player.Mount as BaseMount;
pet.Rider = null;
Jail.StablePet( player, pet );
}
}
// Stable all other pets
foreach ( Mobile mobile in World.Mobiles.Values )
{
if ( mobile is BaseCreature )
{
BaseCreature bc = mobile as BaseCreature;
if ( null != bc && (bc.Controlled && bc.ControlMaster == player) || (bc.Summoned && bc.SummonMaster == player) )
Jail.StablePet( player, bc );
}
}
// Move all items to a bag and move that to the bank
Container backpack = player.Backpack;
Backpack bag = new Backpack(); bag.Hue = JailConfig.RobeHue;
ArrayList equipedItems = new ArrayList( player.Items );
foreach ( Item item in equipedItems )
{
if ( item.Layer == Layer.Bank || item.Layer == Layer.Backpack || item.Layer == Layer.Hair || item.Layer == Layer.FacialHair || item is DeathShroud )
continue;
bag.DropItem( item );
}
ArrayList backpackItems = new ArrayList( backpack.Items );
foreach ( Item item in backpackItems )
{
if ( item is JailRock )
item.Delete();
else if ( item.Movable ) // Non movable pack items must remain (i.e. skill balls)
bag.DropItem( item );
}
// Remember their access level and make them a player
JailHammer hammer = new JailHammer();
hammer.PlayerAccessLevel = player.AccessLevel;
player.AccessLevel = AccessLevel.Player;
// Bank the bag of belongings, give them a hammer and welcome them
player.BankBox.DropItem( bag );
player.AddItem( hammer );
// Explosively move player to jail
player.BoltEffect( 0 );
player.FixedParticles( 0x36BD, 20, 10, 5044, EffectLayer.Waist );
player.PlaySound( 0x307 );
player.FixedParticles( 0x3709, 10, 30, 5052, EffectLayer.LeftFoot );
player.PlaySound( 0x225 );
// This gives a nice little delay for the effect to complete
s_JailProcessingQueue.Enqueue( player );
Server.Timer.DelayCall( TimeSpan.FromSeconds( kSecondsTillJail ), new Server.TimerCallback( JailPlayerInQueue ) );
}
示例5: EventSink_AccountLogin
public static void EventSink_AccountLogin(AccountLoginEventArgs e)
{
try
{
IAccount a = Accounts.GetAccount(e.Username);
if (a == null) return; // si pas de compte (bug xD) on sort
Account acc = a as Account;
if (a == null || a.Count > 0) return; // Si cast en compte est null ou s'il y a déjà des joueurs pour ce compte, on n'importe pas les joueurs de la save sphere
else if (acc != null && acc.Comments != null && acc.Comments.Count > 0) return; // pareil s'il y a déjà un commentaire sur le compte
//else if (acc != null && acc.TotalGameTime > TimeSpan.FromMinutes(15)) return;
// Vérifions que les fichiers nécessaires existent bien
if (!SphereFiles.checkDataFiles()) return;
// Commencons par récupérer les SERIAL des personnages associés au compte
List<string> charUIDs = new List<string>();
int totalTime = 0; // on récupère le temps en sec joué par le joueurs sur sphere
bool found = false;
string username = e.Username.ToLower();
foreach (string line in File.ReadAllLines(SphereFiles.accountFile))
{
// On cherche d'abord à retrouver l'utilisateur
if (line.ToLower() == "[" + username + "]")
{
found = true;
continue;
}
// Ensuite une fois qu'on l'a trouvé on ajout les SERIAL de ses personnages
// jusqu'à tombé sur un autre compte (ou la fin du fichier)
if (found)
{
if (line.StartsWith("[")) break;
if (line.StartsWith("TOTALCONNECTTIME="))
totalTime = Int32.Parse(line.Split('=')[1]);
if (line.StartsWith("CHARUID"))
charUIDs.Add(line.Split('=')[1]);
}
}
// On traite chacun des SERIAL des personnages des joueurs
foreach (string c in charUIDs)
{
Mobile pm = null; // Le mobile qui sera créé
found = false; // on remet found à false car on ne l'a pas encore trouvé
bool woman = false; // dans le cas on on serait sur une femme il faut s'en souvenir
bool hasHouse = false;
// On parcourt toutes les lignes du fichier contenant les personnages
foreach (string line in File.ReadAllLines(SphereFiles.playerFile))
{
// Si l'on recontre une femme on s'en souvient pour lui mettre des seins !
if (line.StartsWith("[WORLDCHAR"))
woman = line.Contains("woman");
// Si l'on tombe sur le SERIAL du joueur que l'on cherche on peut passer au traitement
if (line.StartsWith("SERIAL="))
{
if (line.Split('=')[1] == c)
{
found = true;
continue;
}
}
// On est sur le bon joueur, il faut en extraire les informations
if (found)
{
// Si le Mobile est encore null on l'instancie et on l'initialise
if (pm == null)
{
pm = new PlayerMobile();
pm.Player = true; // !!! nécessaire pour lire le paperdoll
pm.AccessLevel = AccessLevel.Player;
pm.Map = Map.Internal; // pour que le joueur soit déconnecté
pm.LogoutLocation = new Point3D(3503, 2574, 14); // endroit de départ des joueurs
pm.LogoutMap = Map.Trammel; // map de départ des joueurs
pm.BodyValue = (woman ? 401 : 400);
pm.Female = woman;
pm.SkillsCap = 7000; // skill cap de 700
pm.StatCap = 225; // stat cap de 225
// Ajoutons un backpack au joueur pour qu'il puisse y ranger ses affaires
Container pack = pm.Backpack;
if (pack == null)
{
pack = new Backpack();
pack.Movable = false;
pm.AddItem(pack);
}
// Une cape pour les vétérans !
pm.Backpack.DropItem(new VeteranCloak());
}
// Si l'on arrive sur un autre joueur on ajoute l'actuel et on continue de chercher
// les éventuels autres joueurs du compte
//.........这里部分代码省略.........