Here comes the example:
- Code: Select all
using System;
using MCDzienny.InfectionSystem;
namespace MCDzienny
{
public class CmdOnInfectionRoundEnds : Command
{
// Don't change the following statements.
public override string name { get { return ""; } }
public override string shortcut { get { return ""; } }
public override string type { get { return ""; } }
public override bool museumUsable { get { return false; } }
public override LevelPermission defaultRank { get { return LevelPermission.Banned; } }
// Init is executed once when the code is loaded.
public override void Init()
{
// Hook up InectionRoundEnded(object, EventArgs) method
// to the event that is triggered when the infection round ends.
InfectionSystem.AnnounceWinners += InfectionRoundEnded;
}
private void InfectionRoundEnded(object sender, InfectionSystem.AnnounceWinnersEventArgs e)
{
// In this place write the code that is to be executed when the round ends.
}
// Don't change the following statements.
public override void Help(Player p) { }
public override void Use(Player p, string message) { }
}
}
Also, the structure of AnnounceWinnersEventArgs:
- Code: Select all
using System;
using System.Collections.Generic;
namespace MCDzienny.InfectionSystem
{
public class AnnounceWinnersEventArgs : EventArgs
{
public List<Player> NotInfected { get; set; }
public List<Player> Infected { get; set; }
public Level CurrentInfectionLevel { get; set; }
}
}
So, you can for example use e.CurrentInfectionLevel to send a message that will be only visible on the current infection level etc.
- Code: Select all
Player.GlobalMessageLevel(e.CurrentInfectionLevel, "This message is only displayed on the current infection level.");
Alternatively you can use:
- Code: Select all
using System;
using MCDzienny.InfectionSystem;
namespace MCDzienny
{
public class CmdOnInfectionRoundEnds : Command
{
// Don't change the following statements.
public override string name { get { return ""; } }
public override string shortcut { get { return ""; } }
public override string type { get { return ""; } }
public override bool museumUsable { get { return false; } }
public override LevelPermission defaultRank { get { return LevelPermission.Banned; } }
// Init is executed once when the code is loaded.
public override void Init()
{
// Hook up InectionRoundEnded(object, EventArgs) method
// to the event that is triggered when the infection round ends.
InfectionSystem.PayReward += InfectionRoundEnded;
}
private void InfectionRoundEnded(object sender, InfectionSystem.PayRewardEventArgs e)
{
// In this place write the code that is to be executed when the round ends.
}
// Don't change the following statements.
public override void Help(Player p) { }
public override void Use(Player p, string message) { }
}
}
You can view PayRewardEventArgs member using Visual C# intelisense.
Also, it's possible to remove the default algorithms for paying the reward to winners and announcing the winners.
In order to remove default behaviour:
- Code: Select all
InfectionSystem.PayReward -= InfectionSystem.PayRewardDefault;
InfectionSystem.AnnounceWinners -= InfectionSystem.AnnounceWinnersDefault;