Fulqrum Publishing Home   |   Register   |   Today Posts   |   Members   |   UserCP   |   Calendar   |   Search   |   FAQ

Go Back   Official Fulqrum Publishing forum > Fulqrum Publishing > IL-2 Sturmovik: Cliffs of Dover > FMB, Mission & Campaign builder Discussions

Reply
 
Thread Tools Display Modes
  #21  
Old 02-27-2012, 08:17 PM
Smokeynz Smokeynz is offline
Approved Member
 
Join Date: Apr 2011
Posts: 106
Default

Method for mission listing within script

Method for Random selection of missions

Method for Triggered missions for Player

Method for Objective mission loading for Player

http://forum.1cpublishing.eu/showthread.php?t=30033
Reply With Quote
  #22  
Old 04-24-2012, 10:50 AM
Ataros Ataros is offline
Approved Member
 
Join Date: Jun 2010
Location: USSR
Posts: 2,439
Default

Radar script http://forum.1cpublishing.eu/showpos...4&postcount=83

Gunnery practice mission http://forum.1cpublishing.eu/showthread.php?t=31460

Last edited by Ataros; 04-25-2012 at 07:31 PM.
Reply With Quote
  #23  
Old 12-22-2013, 01:05 AM
_79_dev _79_dev is offline
Approved Member
 
Join Date: Sep 2010
Location: Dublin
Posts: 242
Default Chat <stas, <tl, ....Interface

I found very useful lately IPlayer interface with all its goodies....


Here is example script to execute chat info in good old style

check available commands:

<stats , <guns, <kills, <stats<all, <tl, <te...etc

That is just simple examples but You can convert lot of things from game to it....

If Any one is interested to give it a go on servers let me know if You experience any troubles with it... There is some delay on data read and some things are not working or are just not activated maybe

Enjoy...

Code:
//$reference parts/core/Strategy.dll
//$reference parts/core/MySql.Data.dll
//$reference parts/core/System.Data.dll

//$reference parts/core/gamePlay.dll


    #region timer


    long Tick_Mission_Time { get; set; }// Sets the Mission Clock for Time Remaining in Mission.

    Random random = new Random();//Function for Randomising events

    Stopwatch stopWatch = new Stopwatch();

    public string GetTimeElapsed()
    {
        string StringToReturn = "";
        StringToReturn = "";

        TimeSpan ts = stopWatch.Elapsed;

        // Format and display the TimeSpan value. 
        string elapsedTime = String.Format("{0:00}h:{1:00}m:{2:00}s", ts.Hours, ts.Minutes, ts.Seconds);


        StringToReturn = StringToReturn + elapsedTime;
        return StringToReturn;

    }



    #endregion



    #region Iplayer stats

    public string GetDictionary<T>(Dictionary<string, T> ds)
    {
        StringBuilder sb = new StringBuilder();
        foreach (string key in ds.Keys)
        {
            T d = ds[key];
            if (sb.Length != 0)
            {
                sb.Append(", ");
            }
            //sb.AppnedFormat("[{0}]={1}", key, d);
            sb.AppendFormat("[{0}]={1}", key, d);
        }
        return sb.ToString();
    }

    public string WritePlayerStatBase(Player player)
    {
        string Stats = "";

        if (player is IPlayer)
        {
            IPlayerStat st = (player as IPlayer).GetBattleStat();
            Stats = (String.Format("Take Offs: [{0}]; " + "Landings:  [{1}];  " + "Deaths:  [{2}]; " + "Bails:  [{3}]; ",
                                       st.takeoffs, st.landings, st.deaths, st.bails));



        }

        return Stats;
    }

    public string WritePlayerStatsGunnery(Player player)
    {
        string Stats = "";

        if (player is IPlayer)
        {
            IPlayerStat st = (player as IPlayer).GetBattleStat();



            if (st.bulletsFire != 0)
            {
                double accuracy = ((st.bulletsHit) / (st.bulletsFire)) * 100;

                Stats = (String.Format("Accuracy:  " + accuracy + " %;" + " Bullets Fired: [{0}]; " + "Bullets Hits: [{1}];  " + "Bullets Air Hits: [{2}];  ",
                                            st.bulletsFire, st.bulletsHit, st.bulletsHitAir));

            }

        }

        return Stats;
    }

    public string WritePlayerStatsKills(Player player)
    {
        string Stats = "";

        if (player is IPlayer)
        {
            IPlayerStat st = (player as IPlayer).GetBattleStat();


            Stats = (String.Format("Plane Kill Types: \"{0}\"; Planes Flown Types: \"{1}\";",
                            st.kills, GetDictionary(st.killsTypes), GetDictionary(st.tTotalTypes)));



        }

        return Stats;
    }

    public string WritePlayerStatsBombs(Player player)
    {
        string Stats = "";

        if (player is IPlayer)
        {
            IPlayerStat st = (player as IPlayer).GetBattleStat();


            Stats = (String.Format("Bombs Fired : [{0}]; " + "Bombs Hit : [{1}];  " + "Bombs Weight : [{2}]; " + "g kills: {3}; ",
                                    st.bombsFire, st.bombsHit, st.bombsWeight, st.gkills[0]));



        }

        return Stats;
    }

    #endregion

    #region Time Left

    public string WriteTime_Remaining(Player player)
    {
        string Time_Remaining = "";

        Tick_Mission_Time = ((32 * 60) * 240) - Time.tickCounter();
        var Mission_Time = Tick_Mission_Time / 2000;
        TimeSpan Convert_Ticks = TimeSpan.FromMinutes(Mission_Time);
        Time_Remaining = string.Format("{0:D2}h:{1:D2}m:{2:D2}s", Convert_Ticks.Hours, Convert_Ticks.Minutes, Convert_Ticks.Seconds);




        return Time_Remaining;
    }

    public string WriteTime_Elapsed(Player player)
    {
        string Time_Remaining = GetTimeElapsed();

        return Time_Remaining;
    }


    #endregion

    #region objectives

    public string WriteRedObjectives(Player player)
    {
        string Objectives = Objective_Total_Red; ;




        return Objectives;
    }

    public string WriteBlueObjectives(Player player)
    {
        string Objectives = Objective_Total_Blue;


        return Objectives;
    }

    #endregion


    #region chat


    public void Chat(string line, Player player)
    {
        if (GamePlay is GameDef)
        {
            (GamePlay as GameDef).gameInterface.CmdExec("chat " + line + " TO " + player.Name());
        }
    }


    void Mission_EventChat(IPlayer from, string msg)
    {



        if (msg.StartsWith("<obj"))
        {

            Chat("Red Triggers: " + WriteRedObjectives(from as Player), from);
            //GamePlay.gpHUDLogCenter(new Player[] { from as Player }, "Time Elapsed is " + WriteObjectives(from as Player));


            Chat("Blue Triggers: " + WriteBlueObjectives(from as Player), from);
            //GamePlay.gpHUDLogCenter(new Player[] { from as Player }, "Time Elapsed is " + WriteObjectives(from as Player));

        }
        if (msg.StartsWith("<te"))
        {

            //Chat(Time_Elapsed(from as Player), from);
            GamePlay.gpHUDLogCenter(new Player[] { from as Player }, "Time Elapsed is " + WriteTime_Elapsed(from as Player));

        }

        if (msg.StartsWith("<tl"))
        {

            GamePlay.gpHUDLogCenter(new Player[] { from as Player }, "Time Remaining is " + WriteTime_Remaining(from as Player));

        }
        if (msg.StartsWith("<timeleft"))
        {

            GamePlay.gpHUDLogCenter(new Player[] { from as Player }, "Time Remaining is " + WriteTime_Remaining(from as Player));

        }
        if (msg.StartsWith("<stats"))
        {

            GamePlay.gpHUDLogCenter(new Player[] { from as Player }, WritePlayerStatBase(from as Player));

        }
        if (msg.StartsWith("<guns"))
        {

            GamePlay.gpHUDLogCenter(new Player[] { from as Player }, WritePlayerStatsGunnery(from as Player));

        }

        if (msg.StartsWith("<kills"))
        {

            GamePlay.gpHUDLogCenter(new Player[] { from as Player }, WritePlayerStatsKills(from as Player));

        }

        if (msg.StartsWith("<bombs"))
        {

            GamePlay.gpHUDLogCenter(new Player[] { from as Player }, WritePlayerStatsBombs(from as Player));

        }

        if (msg.StartsWith("<stats<all"))
        {
            Timeout(1, () =>
            { GamePlay.gpHUDLogCenter(new Player[] { from as Player }, WritePlayerStatBase(from as Player)); }
       );
            Timeout(6, () =>
            { GamePlay.gpHUDLogCenter(new Player[] { from as Player }, WritePlayerStatsGunnery(from as Player)); }
        );
            Timeout(10, () =>
            { GamePlay.gpHUDLogCenter(new Player[] { from as Player }, WritePlayerStatsKills(from as Player)); }
       );
            Timeout(15, () =>
            { GamePlay.gpHUDLogCenter(new Player[] { from as Player }, WritePlayerStatsBombs(from as Player)); }
      );


        }
    }




    #endregion
__________________

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
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 03:43 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright © 2007 Fulqrum Publishing. All rights reserved.