void AuthToTurret(BasePlayer player, AutoTurret turret, Dictionary <ulong, string> authList) { bool isOnline = false; if (turret.IsOnline()) { turret.SetIsOnline(false); isOnline = true; } turret.authorizedPlayers.Clear(); foreach (var friend in authList) { turret.authorizedPlayers.Add(new ProtoBuf.PlayerNameID { userid = friend.Key, username = friend.Value }); } turret.SendNetworkUpdateImmediate(); player.SendNetworkUpdateImmediate(); if (isOnline) { turret.SetIsOnline(true); } SendReply(player, string.Format(msg("turretSuccess"), authList.Count)); return; }
public void FireTurretsGuns(BasePlayer player, AutoTurret turret) { if (turret.IsOnline() == true) { if (turret.GetAttachedWeapon().AmmoFraction() <= 0) { //nextShootTime = Time.time + turret.GetAttachedWeapon().GetReloadDuration(); turret.GetAttachedWeapon().TopUpAmmo(); //canGunShoot = false; } turret.FireAttachedGun(Vector3.zero, ConVar.PatrolHelicopter.bulletAccuracy); } }
public void ToggleTurret(AutoTurret turret, BasePlayer player = null) { if (turret == null) { return; } if (player != null && (!turret.IsAuthed(player) || turret.GetBuildingPrivilege()?.IsAuthed(player) == false)) { player.ChatMessage(_instance.Lang("NoPermThisTurret", player.UserIDString)); return; } if (turret.IsOnline()) { PowerTurretOff(turret); } else { PowerTurretOn(turret); } }
private void AuthToTurret(AutoTurret turret, Dictionary <ulong, string> authList, BasePlayer player = null) { bool isOnline = false; if (turret.IsOnline()) { turret.SetIsOnline(false); isOnline = true; } IEnumerable <ulong> currentAuth = turret.authorizedPlayers.Select(x => x.userid); foreach (var friend in authList) { if (currentAuth.Contains(friend.Key)) { continue; } turret.authorizedPlayers.Add(new ProtoBuf.PlayerNameID { userid = friend.Key, username = friend.Value }); } turret.SendNetworkUpdateImmediate(); if (isOnline) { turret.SetIsOnline(true); } if (player != null) { player.SendNetworkUpdateImmediate(); SendReply(player, string.Format(msg("turretSuccess"), authList.Count)); } }
public void ToggleTurret(AutoTurret turret, BasePlayer player = null) { if (turret == null) { return; } if (player != null) { if (!turret.IsAuthed(player)) { player.ChatMessage(Instance.Lang("NoPermThisTurret", player.UserIDString)); return; } } // Turn turret on if off, off if on, make sure data is right if (turret.IsOnline()) { PowerTurretOff(turret); } else { PowerTurretOn(turret); } }
public void TurretInput(InputState input, BasePlayer player) { if (input == null || player == null) { return; } BUTTON.TryParse(Button, out PowerButton); if (input.WasJustPressed(PowerButton)) { bool hasPermission = permission.UserHasPermission(player.UserIDString, perms); if (!hasPermission) { player.ChatMessage(msg("NoPermissions", player.UserIDString)); return; } RaycastHit hit; if (Physics.SphereCast(player.eyes.position, 0.5f, Quaternion.Euler(player.serverInput.current.aimAngles) * Vector3.forward, out hit)) { AutoTurret autoturret = hit.GetEntity()?.GetComponent <AutoTurret>(); SamSite samsite = hit.GetEntity()?.GetComponent <SamSite>(); if (autoturret != null) { if (hit.distance >= 1.5) { return; } if (!autoturret.IsAuthed(player)) { player.ChatMessage(msg("NotAuthed", player.UserIDString)); return; } if (!IsAuthed(player, autoturret)) { player.ChatMessage(msg("NoBuildPrivilege", player.UserIDString)); return; } if (autoturret.IsOnline()) { autoturret.SetIsOnline(false); PoweredTurrets.Remove(autoturret.net.ID); } else { autoturret.SetIsOnline(true); PoweredTurrets.Add(autoturret.net.ID); } autoturret.SendNetworkUpdateImmediate(); } if (samsite != null) { if (hit.distance >= 1.5) { return; } if (!IsAuthed(player, samsite)) { player.ChatMessage(msg("NoBuildPrivilege", player.UserIDString)); return; } if (samsite.IsPowered()) { samsite.UpdateHasPower(0, 1); PoweredSams.Remove(samsite.net.ID); } else { samsite.UpdateHasPower(25, 1); PoweredSams.Add(samsite.net.ID); } samsite.SendNetworkUpdateImmediate(); } } } }