public void OnTryRegister(SvManager svManager, ConnectionData connectionData) { if (ValidateUser(svManager, connectionData)) { if (svManager.TryGetUserData(connectionData.username, out User playerData)) { if (playerData.PasswordHash != connectionData.passwordHash) { svManager.RegisterFail(connectionData.connection, "Invalid credentials"); return; } } if (!connectionData.username.ValidCredential()) { svManager.RegisterFail(connectionData.connection, $"Name cannot be registered (min: {Util.minCredential}, max: {Util.maxCredential})"); return; } svManager.AddNewPlayer(connectionData, playerData?.Persistent); } }
private IEnumerator SalaryCoroutine(SvManager manager) { Debug.Log("Starting coroutine"); var time = Core.Instance.Settings.SecondsForPay / 3; while (true) { for (int i = 0; i < 3; i++) { var leftTime = Core.Instance.Settings.SecondsForPay - i * time; Debug.Log(i); ChatHandler.SendToAll(string.Format(Core.Instance.Settings.Announcement, leftTime)); yield return(new WaitForSeconds(time)); } foreach (var player in manager.connectedPlayers.Values) { player.TransferMoney(DeltaInv.AddToMe, player.GetSalary()); player.svPlayer.SendGameMessage($"Has ganado ${player.GetSalary()} por trabajar como {player.svPlayer.job.info.shared.jobName}"); } yield return(new WaitForSeconds(10f)); } }
public void OnUpdate(SvManager svManager) { foreach (var box in Instance.TriggerBoxes) { var center = (box.Value.Pos1 + box.Value.Pos2) * 0.5f; var scale = box.Value.Pos1 - box.Value.Pos2; var halfExtents = scale * 0.5f; var check = Physics.BoxCastAll(center, halfExtents, Vector3.up); if (check == null || !check.Any()) { continue; } // Debug.Log("check: "+check.Length); var players = check.Select(hit => hit.transform.gameObject.GetComponent <ShPlayer>()) .Where(player => player).ToArray(); //Debug.Log("players: "+players.Length); foreach (var player in players) { var ePlayer = Instance.PlayerHandler[player.ID].Boxes; if (ePlayer.Contains(box.Key)) { // Debug.Log("continueing: " + player.username); continue; } box.Value.OnEnter(player); ePlayer.Add(box.Key); } foreach (var ePlayer in Instance.PlayerHandler.Where(x => x.Value.Boxes.Contains(box.Key))) { if (players.All(x => x.ID != ePlayer.Key)) { ePlayer.Value.Boxes.Remove(box.Key); } } } }
public void OnSave(SvManager svManager) { var bountyData = new Data { ID = Hitman.bountiesKey }; foreach (var bounty in Hitman.bounties) { // Only save bounties targeting Humans if (!Hitman.aiTarget || Hitman.aiTarget.username != bounty.Key) { bountyData.CustomData[bounty.Key] = bounty.Value; } } svManager.database.Data.Upsert(bountyData); ChatHandler.SendToAll("Saving server status.."); foreach (var player in EntityCollections.Humans) { player.svPlayer.Save(); } svManager.database.WriteOut(); }
public void OnStart(SvManager svManager) { Core.Instance.SvManager = svManager; }
private IEnumerator EnterTheVoid(SvManager svManager) { voidRunning = true; var delay = new WaitForSecondsRealtime(0.1f); var duration = 4f; var startTime = Time.time; var originalTimeScale = Time.timeScale; var targetTimeScale = 0.25f; var defaultEnvironment = SceneManager.Instance.defaultEnvironment; var originalSky = SceneManager.Instance.skyColor; var originalCloud = SceneManager.Instance.cloudColor; var originalWater = SceneManager.Instance.waterColor; var targetSky = Color.red; var targetCloud = Color.black; var targetWater = Color.cyan; var normalizedClip = 0.25f; while (Time.time < startTime + duration) { yield return(delay); var normalizedTime = (Time.time - startTime) / duration; float lerp; if (normalizedTime < normalizedClip) { lerp = normalizedTime / normalizedClip; } else if (normalizedTime >= 1f - normalizedClip) { lerp = (1f - normalizedTime) / normalizedClip; } else { lerp = 1f; } svManager.SvSetTimeScale(Mathf.Lerp(originalTimeScale, targetTimeScale, lerp)); svManager.SvSetSkyColor(Color.LerpUnclamped(originalSky, targetSky, lerp)); svManager.SvSetCloudColor(Color.LerpUnclamped(originalCloud, targetCloud, lerp)); svManager.SvSetWaterColor(Color.LerpUnclamped(originalWater, targetWater, lerp)); } svManager.SvSetTimeScale(originalTimeScale); if (defaultEnvironment) { svManager.SvSetDefaultEnvironment(); } else { svManager.SvSetSkyColor(originalSky); svManager.SvSetCloudColor(originalCloud); svManager.SvSetWaterColor(originalWater); } voidRunning = false; }
public void OnEvent(SvManager svManager) { Core.Instance.joinWebhook.Send(string.Format(Core.Instance.Settings.Server.ServerStartMessage), embeds: Core.Instance.Settings.Server.ServerStartUseEmbed? Core.Instance.Settings.Server.ServerStartEmbed:null); }
public void OnStart(SvManager svManager) { svManager.StartCoroutine(Whatever()); }
public void OnManagerStart(SvManager manager) { manager.StartCoroutine(SalaryCoroutine(manager)); }
public void OnEvent(SvManager svManager) { Core.Instance.SvManager = svManager; Core.Instance.CooldownHandler.Load(); }
public void OnEvent(SvManager svManager) { Core.Instance.SvManager = svManager; Core.Instance.SvManager.StartCoroutine(Interval.Start(Core.Instance.Settings.General.SaveInterval * 60, new Commands.Save().Run)); }
public void OnEvent(SvManager svManager) { Core.Instance.SvManager = svManager; }