![]() |
|
|
|
#1
|
|||
|
|||
|
ok, if I use this code:
Code:
public override void OnAircraftTookOff(int missionNumber, string shortName, AiAircraft aircraft)
{
#region stats
base.OnAircraftTookOff(missionNumber, shortName, aircraft);
try
{
stats.aircraftTakeoff(shortName, aircraft);
}
catch (Exception ex)
{
System.Console.WriteLine("Stats.OnAircraftTookOff - Exception: " + ex);
}
#endregion
sendChatMessageTo(aircraft.Army(), " _79_dev has a problem", null);
//add your code here
}
System.Exception: c:\Users\John\Documents\1C SoftClub\il-2 sturmovik cliffs of dover\missions\Multi\Dogfight\Kanalkampf\kanalkamp f_spawns.cs(446,9): error CS0103: The name 'sendChatMessageTo' does not exist in the current context c:\Users\John\Documents\1C SoftClub\il-2 sturmovik cliffs of dover\missions\Multi\Dogfight\Kanalkampf\kanalkamp f_spawns.cs(446,27): error CS1501: No overload for method 'Army' takes 1 arguments at LB33FuQ4EXuxyJPZ68D.GrT31TQ99wLitevXpuS.ATy34ceFvF k(String , Boolean , Boolean ) at LB33FuQ4EXuxyJPZ68D.GrT31TQ99wLitevXpuS.3LP34ebVrC U(String ) at LB33FuQ4EXuxyJPZ68D.GrT31TQ99wLitevXpuS.gMaqT2fu7O VhvSHaMehN(Object ) at LB33FuQ4EXuxyJPZ68D.GrT31TQ99wLitevXpuS.Xi734IyswC Q(String , Int32 ) ================================================= ================================================= System.Exception: c:\Users\John\Documents\1C SoftClub\il-2 sturmovik cliffs of dover\missions\Multi\Dogfight\Kanalkampf\kanalkamp f_spawns.cs(446,9): error CS0103: The name 'sendChatMessageTo' does not exist in the current context c:\Users\John\Documents\1C SoftClub\il-2 sturmovik cliffs of dover\missions\Multi\Dogfight\Kanalkampf\kanalkamp f_spawns.cs(446,27): error CS1501: No overload for method 'Army' takes 1 arguments at LB33FuQ4EXuxyJPZ68D.GrT31TQ99wLitevXpuS.Xi734IyswC Q(String , Int32 ) at 4YQguDGg7WLABsU9pm3.T8Lw4SGw95gwTxUSs13.ySFG6YYvRQ bIruAHfae(Object , Int32 ) at 4YQguDGg7WLABsU9pm3.T8Lw4SGw95gwTxUSs13.sWbmrit6GT (dL3MgPdYLnmRhd1hBIK ) =================================================
__________________
![]() Asus P6T V2 Deluxe, I7 930, 3x2 GB RAM XMS3 Corsair1333 Mhz, Nvidia Leadtek GTX 470, Acer 1260p screen projector, Track IR 4 OS ver5, Saitek Pro Flight Rudder, Saitek X52, Win 7 x64 ultimate Last edited by _79_dev; 03-12-2012 at 08:13 AM. |
|
#2
|
|||
|
|||
|
ahh thats because it is actually...it isnt Chat..slap myself
sendScreenMessageTo |
|
#3
|
|||
|
|||
|
@_79_dev
Code:
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using maddox.game;
using maddox.game.world;
using maddox.GP;
public class Mission : AMission
{
private void sendChatMessage(string msg, params object[] args)
{
GamePlay.gpLogServer(null, msg, args);
}
private void sendChatMessage(Player player, string msg, params object[] args)
{
if (player != null)
GamePlay.gpLogServer(new Player[] { player }, msg, args);
}
private void sendChatMessage(int army, string msg, params object[] args)
{
List<Player> Consignees = new List<Player>();
if (GamePlay.gpPlayer() != null)
Consignees.Add(GamePlay.gpPlayer());
if (GamePlay.gpRemotePlayers() != null)
Consignees.AddRange(GamePlay.gpRemotePlayers());
if (army == -1)
GamePlay.gpLogServer(null, msg, args);
else if (Consignees.Exists(item => item.Army() == army))
GamePlay.gpLogServer(Consignees.FindAll(item => item.Army() == army).ToArray(), msg, args);
}
private void sendScreenMessage(string msg, params object[] args)
{
GamePlay.gpHUDLogCenter(null, msg, args);
}
private void sendScreenMessage(Player player, string msg, params object[] args)
{
if (player != null)
GamePlay.gpHUDLogCenter(new Player[] { player }, msg, args);
}
private void sendScreenMessage(int army, string msg, params object[] args)
{
List<Player> Consignees = new List<Player>();
if (GamePlay.gpPlayer() != null)
Consignees.Add(GamePlay.gpPlayer());
if (GamePlay.gpRemotePlayers() != null)
Consignees.AddRange(GamePlay.gpRemotePlayers());
if (army == -1)
GamePlay.gpHUDLogCenter(null, msg, args);
else if (Consignees.Exists(item => item.Army() == army))
GamePlay.gpHUDLogCenter(Consignees.FindAll(item => item.Army() == army).ToArray(), msg, args);
}
public override void OnAircraftTookOff(int missionNumber, string shortName, AiAircraft aircraft)
{
#region stats
base.OnAircraftTookOff(missionNumber, shortName, aircraft);
try
{
stats.aircraftTakeoff(shortName, aircraft);
}
catch (Exception ex)
{
System.Console.WriteLine("Stats.OnAircraftTookOff - Exception: " + ex);
}
#endregion
sendChatMessage(aircraft.Army(), " _79_dev has a problem");
//add your code here
}
}
|
|
#4
|
|||
|
|||
|
@ kodiak, been noticing that with lists they tend to grow ever larger, in this case Consigness grows larger every time a sendChatMessage is called. A player name is added many times, old players who have left stay in the list.
So added in "Consignees.Clear();" , do you think this effective addition, and in the right place? Code:
private void sendChatMessage(int army, string msg, params object[] args)
{
Consignees.Clear();
List<Player> Consignees = new List<Player>();
if (GamePlay.gpPlayer() != null)
Consignees.Add(GamePlay.gpPlayer());
if (GamePlay.gpRemotePlayers() != null)
Consignees.AddRange(GamePlay.gpRemotePlayers());
if (army == -1)
GamePlay.gpLogServer(null, msg, args);
else if (Consignees.Exists(item => item.Army() == army))
GamePlay.gpLogServer(Consignees.FindAll(item => item.Army() == army).ToArray(), msg, args);
}
|
|
#5
|
|||
|
|||
|
The List is not global nor unmanaged nor static, it's exist only in this method (local) and is deleted after the method is leaved (the destructor of the class is automaticaly called), so no Clear is needed.
And if Clear would needed it should be in this case on end of method. (In your parser-problem the List is global and only deleted after the mission is ended. Thats the difference Last edited by FG28_Kodiak; 03-12-2012 at 09:13 PM. |
|
#6
|
|||
|
|||
|
Thanks, good explination.
I have a relervant question, but will ask in new thread. |
|
#7
|
|||
|
|||
|
Thanks for help, got it sorted out now. Just had to call methods for sendChatMessage, that was missing in original code ...
__________________
![]() Asus P6T V2 Deluxe, I7 930, 3x2 GB RAM XMS3 Corsair1333 Mhz, Nvidia Leadtek GTX 470, Acer 1260p screen projector, Track IR 4 OS ver5, Saitek Pro Flight Rudder, Saitek X52, Win 7 x64 ultimate |
![]() |
| Thread Tools | |
| Display Modes | |
|
|