/// <summary> /// Locks/Unlocks the most nearby vehicle if possible /// </summary> /// <param name="client"></param> public void LockVehicle(Client client) { RPVehicle nearest = VehicleManager.Instance().GetNearestVehicle(client.position); if (!PlayerManager.Instance().IsClientUsingCharacter(client)) { return; } if (nearest != null && client.position.DistanceTo(nearest.position) < doorLockDistance) { Character c = PlayerManager.Instance().GetPlayerByClient(client).activeCharacter; Boolean locked = false; if (c.factionID == nearest.factionID && c.onDuty) { locked = true; } else if (c.owner.id == nearest.ownerId) { locked = true; } // check if player has keys to the car if (locked) { nearest.ToggleDoorLock(); this.SendVehicleLockedMessage(client, locked); } } }
public void LockVehicleWithId(Client client, int id) { RPVehicle vehicle = GetVehicleWithId(id); if (vehicle != null && vehicle.spawned) { if (PlayerManager.Instance().IsClientUsingCharacter(client)) { Character character = PlayerManager.Instance().GetActiveCharacterForClient(client); if (vehicle.ownerId == character.ID) { if (vehicle.position.DistanceTo(character.position) < doorLockDistance) { vehicle.ToggleDoorLock(); this.SendVehicleLockedMessage(client, vehicle.locked); } else { API.shared.sendNotificationToPlayer(client, "You need to be closer to the vehicle"); } } } } else { API.shared.sendNotificationToPlayer(client, "Vehicle needs to be active!"); } }
public void LockVehicleWithId(Character character, int id) { RPVehicle vehicle = GetVehicleWithId(id); if (vehicle != null && vehicle.spawned) { if (vehicle.ownerId == character.ID) { if (vehicle.position.DistanceTo(character.position) < doorLockDistance) { vehicle.ToggleDoorLock(); this.SendVehicleLockedMessage(character.client, vehicle.locked); } else { character.SendNotification("You need to be closer to the vehicle"); } } } else { character.SendNotification("Vehicle needs to be active!"); } }