::FirstPlayer <- 0;
::_Timer <- 0;
::last_set <- 0;
::_GetSaferoomLocation <- 0.0;
::GetSaferoomNum <- 0;
::_TimerMax <- 15; //设置多少秒后处死未进入安全屋的幸存者
::GetFirstPlayerName <- [];
function VSLib::EasyLogic::Update::Run()
{
local P_Distance = 0;
local P_D = 0;
foreach (P in Players.All())
{
if(P.GetTeam() == SURVIVORS && PlayerIsAlive(P) == 1)
{
if(Time() >= last_set + 1 && GetSaferoomNum < 5)
{
GetSaferoomNum++;
last_set = Time();
_GetSaferoomLocation = Utils.CalculateDistance(Utils.GetSaferoomLoca tion(), Entity(P).GetLocation());
}
P_Distance = Utils.CalculateDistance(Utils.GetSaferoomLoca tion(), Entity(P).GetLocation())
P_D = _GetSaferoomLocation - P_Distance;
local NewSafeDistance = P_D / _GetSaferoomLocation * 100;
if(NewSafeDistance.tointeger() >= 90)
{
if(FirstPlayer == 0)
{
FirstPlayer = 1;
GetFirstPlayerName = Player(P).GetName();
}
}
}
}
if(FirstPlayer == 1)
{
if(Time() > 0)
{
Timers.AddTimer( 1.0, false, Time_KillPlayer );
}
}
}
::Time_KillPlayer <- function(params)
{
local SafeDoor = null;
local P_Distance = 0;
local P_D = 0;
_Timer++;
if(_Timer >= _TimerMax)
{
foreach (P in Players.All())
{
if(P.GetTeam() == SURVIVORS && PlayerIsAlive(P) == 1)
{
P_Distance = Utils.CalculateDistance(Utils.GetSaferoomLoca tion(), Entity(P).GetLocation())
P_D = _GetSaferoomLocation - P_Distance;
local SafeDistance = P_D / _GetSaferoomLocation * 100;
if(SafeDistance.tointeger() < 90)
{
Player(P).Kill();
FirstPlayer = 0;
}
}
}
}
else
{
local Num = _TimerMax-_Timer;
SafeDoor = HUD.Item("{info01}\n{info02}");
SafeDoor.SetValue("info01", GetFirstPlayerName+"은신처에 도착");
SafeDoor.SetValue("info02", "남은 시간-"+Num+"도착하지 않은 사람 처벌");
SafeDoor.AttachTo(HUD_LEFT_BOT); //HUD位置参数,可使用预设参数,如HUD_MID_BOT,也可使用数值(0-14),如0, 0, 0, 0(x坐标, y坐标, 宽, 高)
SafeDoor.ChangeHUDNative(300, 120, 1024, 80, 1024, 76
; // HUD坐标(xy)1024(长)768(宽)是屏幕最大值
SafeDoor.SetTextPosition(TextAlign.Left); //,Left=,Center=,Right=
SafeDoor.AddFlag(g_ModeScript.HUD_FLAG_NOBG); //HUD
Timers.AddTimer( 1.0, false, CloseHud, SafeDoor ); //HUD
foreach (p in Players.All())
{
if(!Entity(p).IsBot() && PlayerIsAlive(p) == 1 && Player(p).GetTeam() == SURVIVORS)
{
Player(p).PlaySound("Buttons.snd11");
}
}
}
}
function OnGameEvent_player_team(params)
{
local Userid = null;
local User = null;
local Team = null;
if(params.rawin("userid") && params.rawin("team"))
{
Userid = params["userid"];
User = GetPlayerFromUserID(Userid);
Team = params["team"];
if(User.GetClassname() == "player" && !IsPlayerABot(User))
{
if(Team > 0)
{
if(Team == 2)
{
Timers.AddTimer( 1.0, true, Time_DetectInfo, User );
}
}
}
}
}
::Time_DetectInfo <- function(client)
{
if(Entity(client).GetTeam() == SURVIVORS && PlayerIsAlive(client) == 1 && !IsPlayerABot(client))
{
if(FirstPlayer == 1)
{
local P_Distance = Utils.CalculateDistance(Utils.GetSaferoomLoca tion(), Entity(client).GetLocation())
local P_D = _GetSaferoomLocation - P_Distance;
local NewSafeDistance = P_D / _GetSaferoomLocation * 100;
local Num = _TimerMax-_Timer;
if(Num > 0)
{
if(NewSafeDistance.tointeger() >= 90)
{
Player(client).ShowHint("은신처 지점으로 서둘러!!", 1.0, "icon_medkit", "", HUD_RandomColor());
}
else
{
Player(client).ShowHint("은신처 지점으로 서둘러!!", 1.0, "icon_skull", "", HUD_RandomColor());
}
}
}
}
else
{
Timers.RemoveTimer(Time_DetectInfo);
}
}
::HUD_RandomColor<-function()
{
local Color = {};
local C = RandomInt(1, 5);
if(C == 1) Color = "255 128 0";
if(C == 2) Color = "255 255 128";
if(C == 3) Color = "255 255 255";
if(C == 4) Color = "255 255 0";
if(C == 5) Color = "0 255 0";
return Color;
}
::CloseHud <- function(hud)
{
hud.Detach();
}
:
layerIsAlive<-function(P)
{
if (Player(P).IsAlive())
{
return 1;
}
return 0;
}
When the survivor reaches the destination
After a certain time, survivors who are not at the destination will die.
Please make it a plugin ..