private void API_onPlayerDisconnected(Client player, string reason) { // Add our player to our connection cooldown. ConnectionManager.AddClient(player.address); if (!API.hasEntityData(player, "Instance")) { return; } Player instance = (Player)API.getEntityData(player, "Instance"); // Used for players in interiors. Logs them out outside the interior. if (player.hasData("LastPosition")) { player.position = player.getData("LastPosition"); } if (player.hasData("Anticheat")) { AnticheatInfo info = player.getData("Anticheat"); info.isOnline = false; info.LastPosition = player.position; } // Update player data just as they disconnect. instance.updatePlayerPosition(); instance.PlayerClothing.savePlayerClothes(); instance.PlayerInventory.saveInventory(); instance.removePlayerVehicles(); DiscordBot.sendMessageToServer(string.Format("{0} has logged out from the server.", player.name)); }
public void aCMD_Armor(Client player) { if (!Utility.isPlayerAdmin(player)) { return; } AnticheatInfo info = player.getData("Anticheat"); info.ArmorChangedRecently = true; player.armor = 100; }
public void aCMD_Health(Client player) { if (!Utility.isPlayerAdmin(player)) { return; } AnticheatInfo info = player.getData("Anticheat"); info.HealthChangedRecently = true; player.health = 100; }
public static void ExitDoor(Client player, params object[] arguments) { if (!player.hasData("LastPosition")) { return; } AnticheatInfo info = player.getData("Anticheat"); Vector3 lastPos = player.getData("LastPosition"); info.LastPosition = lastPos; player.position = lastPos; player.dimension = 0; player.resetData("LastPosition"); }
public static void EnterDoor(Client player, params object[] arguments) { if (arguments.Length <= 0) { return; } // Setup to find our target door. DoorInfo targetDoor = null; string doorID = arguments[0].ToString().Replace("Door-", string.Empty); // Find our target door. for (int i = 0; i < doors.Count; i++) { if (doors[i].Id.Replace("Door-", string.Empty) != doorID) { continue; } targetDoor = doors[i]; break; } // If our target door does not exist. Stop. if (targetDoor == null) { Console.WriteLine("[Door] Not a valid door. " + arguments[0].ToString()); return; } // If our target door is locked, don't let the player in. if (targetDoor.Locked) { API.shared.triggerClientEvent(player, "HeadNotification", "~r~This door is locked."); return; } // Load the IPL if it hasn't been loaded today, then teleport them into the interior. loadIPL(targetDoor.IPL); AnticheatInfo info = player.getData("Anticheat"); info.LastPosition = targetDoor.InteriorLocation; player.setData("LastPosition", player.position); player.position = targetDoor.InteriorLocation; player.dimension = targetDoor.CoreId; }