PDA

Просмотр полной версии : Штрафбат для бросивших самолет в онлайне (скрипт)



-atas-
09.09.2011, 16:38
Запрещает вылет на новом самолете для тех кто бросил старый самолет в воздухе, выйдя в меню.
Автор FG28_Kodiak
http://forum.1cpublishing.eu/showpost.php?p=333766&postcount=7



using System;
using maddox.game;
using maddox.game.world;
using System.Collections.Generic;


public class Mission : AMission
{

const int TotalArrestTime = 30; // Time in seconds

public class prisonCell
{
public Player Prisoner { get; set; }
public DateTime JailTime { get; set; }
public bool Removable { get; set; }
}

public List<prisonCell> PrisonCamp = new List<prisonCell>();


public override void OnPlaceEnter(Player player, AiActor actor, int placeIndex)
{
base.OnPlaceEnter(player, actor, placeIndex);

if (PrisonCamp.Count != 0)
{
foreach (prisonCell pri in PrisonCamp)
{
if (pri.Prisoner == player)
{
TimeSpan ArrestTime = DateTime.Now.Subtract(pri.JailTime);

if (ArrestTime.TotalSeconds < TotalArrestTime)
{
GamePlay.gpLogServer(null, "Player: {0} is under Arrest\n", new object[] { player.Name() });
GamePlay.gpHUDLogCenter(new Player[] { player }, "{0} you are under Arrest!", new object[] { player.Name() });
(actor as AiAircraft).hitNamed(part.NamedDamageTypes.FuelPumpFailure);

}
else
{
pri.Removable = true;
}

}
}

PrisonCamp.RemoveAll(item => item.Removable == true);
}
}



public override void OnPlaceLeave(Player player, AiActor actor, int placeIndex)
{
base.OnPlaceLeave(player, actor, placeIndex);

if ((actor as AiAircraft).IsAirborne())
{

GamePlay.gpLogServer(null, "Player: {0} get a {1} sec. penalty for leaving Airplane in flight\n", new object[] { player.Name(), TotalArrestTime });

prisonCell NewPrisoner = new prisonCell();
NewPrisoner.Prisoner = player;
NewPrisoner.JailTime = DateTime.Now;

PrisonCamp.Add(NewPrisoner);
}
}

}

=FPS=Olega
09.09.2011, 17:34
Т.е. надо будет прыгать, а потом выходить? Просто во время полета может возникнуть срочное дело и нужно будет срочно отойти, - как быть? У меня такое часто бывает, например.:rolleyes:

-atas-
09.09.2011, 18:31
Т.е. надо будет прыгать, а потом выходить? Просто во время полета может возникнуть срочное дело и нужно будет срочно отойти, - как быть? У меня такое часто бывает, например.:rolleyes:

Например, можно прыгать или не выходить из самолета. Тот, кто по вам стреляет в этот момент ведь не виноват, что у вас дело.

Между сеансами игры штраф видимо сбрасывается.

-atas-
09.09.2011, 20:33
Исправлено с учетом парашютировавшихся

using System;
using maddox.game;
using maddox.game.world;
using System.Collections.Generic;


public class Mission : AMission
{

const int TotalArrestTime = 30; // Time in seconds

public class prisonCell
{
public Player Prisoner { get; set; }
public DateTime JailTime { get; set; }
public bool Removable { get; set; }
}

public List<prisonCell> PrisonCamp = new List<prisonCell>();


public override void OnPlaceEnter(Player player, AiActor actor, int placeIndex)
{
base.OnPlaceEnter(player, actor, placeIndex);

if (actor == null) // if player bailed out the actor is null so remove him from prison
{
if (PrisonCamp.Count != 0)
{
foreach (prisonCell pri in PrisonCamp)
{
if (pri.Prisoner == player)
{
pri.Removable = true;
}
}
PrisonCamp.RemoveAll(item => item.Removable == true);
}
}

if (PrisonCamp.Count != 0)
{
foreach (prisonCell pri in PrisonCamp)
{
if (pri.Prisoner == player)
{
TimeSpan ArrestTime = DateTime.Now.Subtract(pri.JailTime);

if (ArrestTime.TotalSeconds < TotalArrestTime)
{
GamePlay.gpLogServer(null, "Player: {0} get a {1} sec. penalty for leaving Airplane in flight\n", new object[] { player.Name(), TotalArrestTime });
GamePlay.gpHUDLogCenter(new Player[] { player }, "{0} you are under Arrest!", new object[] { player.Name() });
(actor as AiAircraft).hitNamed(part.NamedDamageTypes.FuelPumpFailure);

}
else
{
pri.Removable = true;
}

}
}

PrisonCamp.RemoveAll(item => item.Removable == true);
}
}

public override void OnPlaceLeave(Player player, AiActor actor, int placeIndex)
{
base.OnPlaceLeave(player, actor, placeIndex);

if ((actor as AiAircraft).IsAirborne())
{

prisonCell NewPrisoner = new prisonCell();
NewPrisoner.Prisoner = player;
NewPrisoner.JailTime = DateTime.Now;

PrisonCamp.Add(NewPrisoner);
}
}
}

Baur
09.09.2011, 20:52
Запрещает вылет на новом самолете для тех кто бросил старый самолет в воздухе, выйдя в меню.О, очень хорошая штука!!! Не раз такое наблюдал - не честно и обидно!

А это на сервере прописывают?

-atas-
09.09.2011, 21:15
А это на сервере прописывают?

Да.

MEHT
09.09.2011, 21:19
Прекрасный код. Пропишите еще им расстрел, что бы не козлили.

-atas-
10.09.2011, 22:55
Добавлено очередное обновление штрафбата, а также еще один новый скрипт, пишущий в чат, кого на самом деле сбили, а не "Сбит ИИ", как сейчас.

http://forum.1cpublishing.eu/showthread.php?t=25996&page=3

Vetochka
20.09.2011, 09:40
IsAirborne() в бете заработал как надо?

-atas-
20.09.2011, 10:19
Говорят, что да.