local blockedtab = {} function ulx.blockattacks( calling_ply, target_plys, duration, should_enable ) if not should_enable then for i=1, #target_plys do for k, v in pairs( target_plys[ i ]:GetWeapons() ) do v:SetNextPrimaryFire( CurTime() + 9999999 ) v:SetNextSecondaryFire( CurTime() + 9999999 ) end blockedtab[ target_plys[ i ]:UniqueID() ] = true timer.Create( target_plys[ i ]:UniqueID(), duration, 1, function() for k, v in pairs( target_plys[ i ]:GetWeapons() ) do v:SetNextPrimaryFire( CurTime() + 0 ) v:SetNextSecondaryFire( CurTime() + 0 ) end blockedtab[ target_plys[ i ]:UniqueID() ] = false Ulib.tsay( nil, target_plys[ i ]:Nick() .. " is now able to attack again" ) end ) end ulx.fancyLogAdmin( calling_ply, "#A blocked #T from attacking for #i seconds", target_plys, duration ) else for i=1, #target_plys do if blockedtab[ target_plys[ i ]:UniqueID() ] then for k, v in pairs( target_plys[ i ]:GetWeapons() ) do v:SetNextPrimaryFire( CurTime() + 0 ) v:SetNextSecondaryFire( CurTime() + 0 ) end blockedtab[ target_plys[ i ]:UniqueID() ] = false end end ulx.fancyLogAdmin( calling_ply, "#A allowed #T to attack again", target_plys ) end end local blockattacks = ulx.command( "Fun", "ulx blockattacks", ulx.blockattacks, "!blockattacks" ) blockattacks:addParam{ type=ULib.cmds.PlayersArg } blockattacks:addParam{ type=ULib.cmds.NumArg, min=1, hint="seconds" } blockattacks:defaultAccess( ULib.ACCESS_ADMIN ) blockattacks:help( "Block a player from attacking and picking up weapons for a duration of time" ) blockattacks:setOpposite( "ulx unblockattacks", { _, _, _, true }, "!unblockattacks" ) hook.Add( "PlayerCanPickupWeapon", "blockplayers", function( ply ) if blockedtab[ ply:UniqueID() ] then return false end end )