/// <summary> /// 玩家加入任务, 显示任务相关信息, 并与玩家进行关联 /// </summary> public async Task Join() { #region 从服务器获取任务剩余时间, 并开始倒计时 // 从服务器获取任务剩余时间 long remainTime = 0; BaseScript.TriggerServerEvent($"{CopClearGangzone.ResourceName}:ClientGetMissionRemainTime"); try { remainTime = await MissionRemainTimeAsyncer.GetFromServer(); } catch (TimeoutException e) { Notify.Error($"{e.Message}"); Debug.WriteLine($"[{CopClearGangzone.ResourceName}][ERROR]{e.Message}"); return; } // 任务倒计时 MissionTimer = new CustomTimer(remainTime); #endregion // 设置任务玩家组别及关系 Game.PlayerPed.SetAsFighter(); // 自定义玩家武器 Game.PlayerPed.Weapons.RemoveAll(); MissionInfo.PlayerWeapons.ForEach( w => Game.PlayerPed.Weapons.Give((WeaponHash)w.Hash, w.Ammo, false, true)); // 绑定事件 FatalDamageEvents.OnDeath += OnDeath; //FatalDamageEvents.OnPlayerKillPed += OnPlayerKillPed; // 界面/声音提醒 var info = MissionInfo.StartNotificationInfo; Notify.CustomImage("CHAR_CALL911", "CHAR_CALL911", info.Message, info.Sender, info.Subject, true, 2); AudioPlayer.Play(AudioName.Beep); Subtitle.Draw(MissionInfo.HintSubtitle, (int)remainTime); // 通知服务器 BaseScript.TriggerServerEvent($"{CopClearGangzone.ResourceName}:ClientJoinMission"); IsJoined = true; }