![]() |
|
#2
|
|||
|
|||
|
No it would not to many errors
![]() I ve corrected your script: Code:
using System;
using maddox.game;
using maddox.game.world;
using System.Collections.Generic;
public class Mission : AMission
{
public Player[] AllPlayers()
{
List<Player> players = new List<Player>();
if (!GamePlay.gpIsServerDedicated())
if (GamePlay.gpPlayer() != null)
players.Add(GamePlay.gpPlayer());
if (GamePlay.gpRemotePlayers() != null)
players.AddRange(GamePlay.gpRemotePlayers());
return players.ToArray();
}
public Player[] Red()
{
List<Player> players = new List<Player>();
if (AllPlayers() != null)
{
players.AddRange(AllPlayers());
return players.FindAll(item => item.Army() == 1).ToArray();
}
return null;
}
public Player[] Blue()
{
List<Player> players = new List<Player>();
if (AllPlayers() != null)
{
players.AddRange(AllPlayers());
return players.FindAll(item => item.Army() == 2).ToArray();
}
return null;
}
public void SendChatMessageTo(Player[] players, string msg, params object[] args)
{
if (players == null) return;
GamePlay.gpLogServer(players, msg, args);
}
public void SendScreenMessageTo(Player[] players, string msg, params object[] args)
{
if (players == null) return;
GamePlay.gpHUDLogCenter(players, msg, args);
}
public override void OnTrigger(int missionNumber, string shortName, bool active)
{
base.OnTrigger(missionNumber, shortName, active);
if ("Trigger2All".Equals(shortName) && active)
{
AiAction action = GamePlay.gpGetAction("Trigger2All");
if (action != null)
{
action.Do();
}
GamePlay.gpGetTrigger(shortName).Enable = false;
}
if ("ScoreBlue50".Equals(shortName) && active) //Trigger 1 Message
{
GamePlay.gpHUDLogCenter("The LW succeeded and inflicted heavy damage on Port of Dover");
GamePlay.gpGetTrigger(shortName).Enable = false;
}
if ("ScoreRed51".Equals(shortName) && active) //Trigger 1 Message
{
GamePlay.gpHUDLogCenter("The RAF inflicted heavy losses on the LW bombers");
GamePlay.gpGetTrigger(shortName).Enable = false;
}
if ("ScoreRed49".Equals(shortName) && active) //Trigger 2 Message
{
GamePlay.gpHUDLogCenter("The RAF inflicted heavy losses on the LW bombers");
GamePlay.gpGetTrigger(shortName).Enable = false;
}
if ("Trigger2ALL".Equals(shortName) && active) //Trigger 2 Message
{
SendScreenMessageTo(Red(), "German build-up over Calais plotted, heading N!");
GamePlay.gpGetTrigger(shortName).Enable = false;
}
}
public override void OnTickGame()
{
if (Time.tickCounter()%864000 == 63000) // 864000 = 8 hour repeat, 63000 = 35 min delay.
{
GamePlay.gpPostMissionLoad("missions/Multi/Dogfight/July1940_v10/Missionen/Mission2.mis");
SendScreenMessageTo(Red(), "RAF- Fly CAP between Calais and Dover");
SendChatMessageTo(Red(), "RAF- Fly CAP between Calais and Dover");
SendScreenMessageTo(Blue(), "LW- Meet a flight of HE111's 5000m over Calais. Escort them to Dover!");
SendChatMessageTo(Blue(), "LW- Meet a flight of HE111's 5000m over Calais. Escort them to Dover!");
}
}
//Section 4 : AI remove
public override void OnActorCreated(int missionNumber, string shortName, AiActor actor)
{
base.OnActorCreated(missionNumber, shortName, actor);
if (actor is AiGroundActor)
Timeout(3599, () =>
{
if (actor != null)
{
(actor as AiGroundActor).Destroy();
}
}
);
}
}
with AllPlayers() you get all players in the game. with Red() only the red players. with Blue() only the blue. if created two method public void SendChatMessageTo(Player[] players, string msg, params object[] args) and public void SendScreenMessageTo(Player[] players, string msg, params object[] args) the first sends the message to the chat window and the second to the screen, to use them use: to all players in game SendChatMessageTo(AllPlayers(), "Your Message"); to the red side SendChatMessageTo(Red(), "Your Message"); to the blue side: SendChatMessageTo(Blue(), "Your Message"); if you would like to show variables, points for example you can use: int redpoints = 50; SendChatMessageTo(Red(), "Red Side gets {0} points", redpoints); btw in the string {0} is a placeholder for the first variable, {1} for the second, {2} for the third and so on.. you should take care that the number of placeholders and the number of the variables are the same. For example this will work: SendChatMessageTo(Red(), "Red Side gets {0}/{1} points", redpoints, overallPoints); this will also work, but the value of the second variable is not shown SendChatMessageTo(Red(), "Red Side gets {0} points", redpoints, overallPoints); but this will get an error: SendChatMessageTo(Red(), "Red Side gets {0}/{1} points", redpoints); hope it helps Last edited by FG28_Kodiak; 06-28-2012 at 07:10 PM. |
|
|