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());
}
}```