Page MenuHomeFeedback Tracker

Cannot prevent player to shoot with CharacterControllerComponent.SetDisableWeaponControls
Assigned, NormalPublic

Description

in the CharacterControllerComponent class there is a SetDisableWeaponControls method that as i understand should prevent players to use in anyway his weapons but it doesnt prevent anything, you can shoot, reload and ads

Details

Severity
Minor
Resolution
Open
Reproducibility
Always
Operating System
Windows 10 x64
Category
General
Steps To Reproduce

https://reforger.armaplatform.com/workshop/618F15199649CB6D-CantPreventPlayerShooting

in this mod you can go into mp_test world and see that it properly disable the view controls but not the weapon ones

Code is here -> CantPreventPlayerShooting\scripts\Game\CantShoot\CantShootExample.c

Additional Information

content of CantShootExample.c file

modded class SCR_BaseGameModeComponent
{
	override void OnPlayerSpawnFinalize_S(SCR_SpawnRequestComponent requestComponent, SCR_SpawnHandlerComponent handlerComponent, SCR_SpawnData data, IEntity entity)
	{
		GetGame().GetCallqueue().CallLater(CantShootHelper.BlockPlayerViewAndShoot, 3000, false, entity);
	}
}

modded class SCR_PlayerRestrictionZoneWarningComponent
{
	override void EOnInit(IEntity owner)
	{
		super.EOnInit(owner);
		GetGame().GetCallqueue().CallLater(CantShootHelper.BlockPlayerViewAndShoot, 3000, false, owner);
	}
}

class CantShootHelper
{
	static void BlockPlayerViewAndShoot(IEntity entity)
	{
		SCR_CharacterControllerComponent characterController = GetCharacterController(entity);
		if (!characterController)
			return;

		//characterController.SetFireWeaponWanted(false);
		//characterController.SetWeaponNoFireTime(1000);
		characterController.SetDisableWeaponControls(true);
		characterController.SetDisableViewControls(true);
		Print("----- CANTSHOOT: shooting should be disabled");
	}
	
	static SCR_CharacterControllerComponent GetCharacterController(IEntity from)
	{
		if (!from)
			return null;
		
		ChimeraCharacter character = ChimeraCharacter.Cast(from);
		if (!character)
			return SCR_CharacterControllerComponent.Cast(from.FindComponent(SCR_CharacterControllerComponent));
		
		return SCR_CharacterControllerComponent.Cast(character.GetCharacterController());
	}
}

Event Timeline

Sen created this task.Jun 7 2024, 7:42 PM
Sen edited Additional Information. (Show Details)
Sen edited Additional Information. (Show Details)
Geez changed the task status from New to Assigned.Jun 10 2024, 11:44 AM